Skip to content

Commit

Permalink
Merge eb1d35c into b545f0c
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hepner committed Feb 16, 2018
2 parents b545f0c + eb1d35c commit 0ab3ace
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/DesignsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,18 @@ public function resubmitDesign($id, $resubmissionData)
return json_decode($res->getBody()->getContents(), true);
}

public function getCategories()
/**
* Returns a list of product categories
*
* Supports passing additional filter params, i.e., "'licensed' => 1"
* @see http://apidocs.affinitygateway.com/#operation/listCategories
* @param array $params key/value pairs of additional params
* @return array Product categories listing
*/
public function getCategories(array $params = [])
{
$path = '/product_categories';
$res = $this->client->request('GET', $path);
$res = $this->client->request('GET', $path, ['query' => $params]);

if ($res->getStatusCode() !== 200) {
$this->throwInvalidResponseException($res);
Expand Down
10 changes: 10 additions & 0 deletions tests/Affinity/ListCategoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ public function request_has_appropriate_headers()
$this->assertEquals('test-api-key', $requestHeaders['X-Api-Key'][0]);
}

/** @test */
public function request_includes_parameters()
{
$this->designs->getCategories(['is_available' => true]);

$request = $this->historyContainer[0]['request'];

$this->assertEquals('is_available=1', $request->getUri()->getQuery());
}

/** @test */
public function throws_exception_on_non_200_response()
{
Expand Down

0 comments on commit 0ab3ace

Please sign in to comment.