Skip to content

Commit

Permalink
Add getMetapropertyOptionsById function (#46)
Browse files Browse the repository at this point in the history
* Fix getMetapropertyOptions according to use a propertyID parameter

* Add new function for getMetapropertyOptionsById

* Add testGetMetapropertyOptionsById

* Fix testGetMetapropertyOptionsById
  • Loading branch information
nyroDev authored Feb 11, 2025
1 parent 9b05a0b commit 0d1023d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Bynder/Api/Impl/AssetBankManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ public function getMetapropertyOptions($query)
);
}

/**
* Gets a list of metaproperty options.
*
* @param string $propertyId Metaproperty id
* @param array $query Associative array of parameters to filter the results.
* @return \GuzzleHttp\Promise\Promise
* @throws \GuzzleHttp\Exception\RequestException
*/
public function getMetapropertyOptionsById($propertyId, $query)
{
return $this->requestHandler->sendRequestAsync('GET', 'api/v4/metaproperties/' . $propertyId . '/options/',
['query' => $query]
);
}

/**
* Gets a list of all meta property option dependencies (globally).
*
Expand Down
29 changes: 29 additions & 0 deletions tests/AssetBank/AssetBankManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,35 @@ public function testGetMetapropertyOptions()
self::assertEquals($result, ['query']);
}

/**
* Test if we call getMetapropertyOptionsById it will use the correct params for the request and returns successfully.
*
* @covers \Bynder\Api\Impl\AssetBankManager::getMetapropertyOptionsById()
* @throws \Exception
*/
public function testGetMetapropertyOptionsById()
{
$stub = $this->getMockBuilder('Bynder\Api\Impl\OAuth2\RequestHandler')
->disableOriginalConstructor()
->getMock();

$propertyId = '00000000-0000-0000-0000000000000000';
$optionId = '00000000-0000-0000-0000000000000001';
$query = ['ids' => $optionId];

$stub->method('sendRequestAsync')
->with('GET', 'api/v4/metaproperties/' . $propertyId . '/options/', [
'query' => $query
])
->willReturn(['query']);

$assetBankManager = new AssetBankManager($stub);
$result = $assetBankManager->getMetapropertyOptionsById($propertyId, $query);

self::assertNotNull($result);
self::assertEquals($result, ['query']);
}

/**
* Test if we call getMetapropetryGlobalOptionDependencies it will use the correct params for the request and
* returns successfully.
Expand Down

0 comments on commit 0d1023d

Please sign in to comment.