Skip to content

Commit

Permalink
fix: query params to generate the query
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcollin committed Apr 17, 2024
1 parent a1577ae commit 209cca4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Clients/GenericClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ protected function setRoute($route)
{
$this->route = $route;
if ($this->getQueryParameters()) {
$this->route .= $this->getQueryParameters();
$this->route .= '?' . http_build_query($this->getQueryParameters());
}

return $this;
Expand Down Expand Up @@ -249,14 +249,13 @@ protected function setApiVersion($apiVersion)
*/
protected function setQueryParams(array $params)
{
$this->queryParameters = [];
$notAllowedParameters = array_diff_key($params, array_flip($this->possibleQueryParameters));
if (!empty($notAllowedParameters)) {
throw new QueryParamsException($notAllowedParameters, $this->possibleQueryParameters);
}

$filteredParams = array_intersect_key($params, array_flip($this->possibleQueryParameters));
$this->queryParameters = '?' . http_build_query(array_merge($this->queryParameters, $filteredParams));
$this->queryParameters = array_merge($this->queryParameters, $filteredParams);

return $this;
}
Expand Down

0 comments on commit 209cca4

Please sign in to comment.