Skip to content

Commit

Permalink
feat: add query method
Browse files Browse the repository at this point in the history
  • Loading branch information
rem42 committed Oct 30, 2024
1 parent c74a8b9 commit 8ab54e5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Request/PrestashopRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class PrestashopRequest extends ScraperRequest implements RequestAuthBa
private string $host;

private string $key;
private bool $useKeyInQuery = false;
private array $query = [];

Check failure on line 21 in src/Request/PrestashopRequest.php

View workflow job for this annotation

GitHub Actions / PHP 8.1

Property Scraper\ScraperPrestashop\Request\PrestashopRequest::$query type has no value type specified in iterable type array.

Check failure on line 21 in src/Request/PrestashopRequest.php

View workflow job for this annotation

GitHub Actions / PHP 8.1

Property Scraper\ScraperPrestashop\Request\PrestashopRequest::$query type has no value type specified in iterable type array.

public function __construct(string $host, string $key, string $resource)
{
Expand All @@ -44,12 +44,14 @@ public function getAuthBasic(): string

public function getQuery(): array
{
if (true === $this->useKeyInQuery) {
return [
'ws_key' => $this->key,
];
}
return [];
return $this->query;
}

public function addQuery(string $key, string $value): self
{
$this->query[$key] = $value;

return $this;
}

public function getHeaders(): array
Expand Down Expand Up @@ -79,7 +81,7 @@ public function setId(?int $id): self

public function useKeyInQuery(): self
{
$this->useKeyInQuery = true;
$this->query['ws_key'] = $this->key;

return $this;
}
Expand Down

0 comments on commit 8ab54e5

Please sign in to comment.