Skip to content

Commit

Permalink
Merge pull request #52 from fixeditforyou/api-urlencode-code
Browse files Browse the repository at this point in the history
API: Encode product code URL parameters
  • Loading branch information
mmenozzi authored Mar 10, 2021
2 parents 650382d + c492821 commit d847f12
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function authenticatedRequest(string $uri, string $method, array $headers
*/
public function findProductModel(string $code): ?array
{
return $this->getResourceOrNull(sprintf('/api/rest/v1/product-models/%s', $code));
return $this->getResourceOrNull(sprintf('/api/rest/v1/product-models/%s', urlencode($code)));
}

/**
Expand Down Expand Up @@ -144,7 +144,7 @@ public function findAttribute(string $code): ?array
*/
public function downloadFile(string $code): \SplFileInfo
{
$endpoint = sprintf('/api/rest/v1/media-files/%s/download', $code);
$endpoint = sprintf('/api/rest/v1/media-files/%s/download', urlencode($code));
Assert::string($this->accessToken);
$headers = ['Authorization' => sprintf('Bearer %s', $this->accessToken)];
$request = new Request('GET', $this->baseUrl . $endpoint, $headers);
Expand All @@ -168,7 +168,7 @@ public function downloadFile(string $code): \SplFileInfo
*/
public function findProduct(string $code): ?array
{
return $this->getResourceOrNull(sprintf('/api/rest/v1/products/%s', $code));
return $this->getResourceOrNull(sprintf('/api/rest/v1/products/%s', urlencode($code)));
}

/**
Expand Down

0 comments on commit d847f12

Please sign in to comment.