Skip to content

Commit 0d1023d

Browse files
authored
Add getMetapropertyOptionsById function (#46)
* Fix getMetapropertyOptions according to use a propertyID parameter * Add new function for getMetapropertyOptionsById * Add testGetMetapropertyOptionsById * Fix testGetMetapropertyOptionsById
1 parent 9b05a0b commit 0d1023d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/Bynder/Api/Impl/AssetBankManager.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@ public function getMetapropertyOptions($query)
131131
);
132132
}
133133

134+
/**
135+
* Gets a list of metaproperty options.
136+
*
137+
* @param string $propertyId Metaproperty id
138+
* @param array $query Associative array of parameters to filter the results.
139+
* @return \GuzzleHttp\Promise\Promise
140+
* @throws \GuzzleHttp\Exception\RequestException
141+
*/
142+
public function getMetapropertyOptionsById($propertyId, $query)
143+
{
144+
return $this->requestHandler->sendRequestAsync('GET', 'api/v4/metaproperties/' . $propertyId . '/options/',
145+
['query' => $query]
146+
);
147+
}
148+
134149
/**
135150
* Gets a list of all meta property option dependencies (globally).
136151
*

tests/AssetBank/AssetBankManagerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,35 @@ public function testGetMetapropertyOptions()
463463
self::assertEquals($result, ['query']);
464464
}
465465

466+
/**
467+
* Test if we call getMetapropertyOptionsById it will use the correct params for the request and returns successfully.
468+
*
469+
* @covers \Bynder\Api\Impl\AssetBankManager::getMetapropertyOptionsById()
470+
* @throws \Exception
471+
*/
472+
public function testGetMetapropertyOptionsById()
473+
{
474+
$stub = $this->getMockBuilder('Bynder\Api\Impl\OAuth2\RequestHandler')
475+
->disableOriginalConstructor()
476+
->getMock();
477+
478+
$propertyId = '00000000-0000-0000-0000000000000000';
479+
$optionId = '00000000-0000-0000-0000000000000001';
480+
$query = ['ids' => $optionId];
481+
482+
$stub->method('sendRequestAsync')
483+
->with('GET', 'api/v4/metaproperties/' . $propertyId . '/options/', [
484+
'query' => $query
485+
])
486+
->willReturn(['query']);
487+
488+
$assetBankManager = new AssetBankManager($stub);
489+
$result = $assetBankManager->getMetapropertyOptionsById($propertyId, $query);
490+
491+
self::assertNotNull($result);
492+
self::assertEquals($result, ['query']);
493+
}
494+
466495
/**
467496
* Test if we call getMetapropetryGlobalOptionDependencies it will use the correct params for the request and
468497
* returns successfully.

0 commit comments

Comments
 (0)