diff --git a/composer.json b/composer.json index 4114e898..8c4ec25d 100644 --- a/composer.json +++ b/composer.json @@ -71,6 +71,9 @@ "preferred-install": { "symfony/property-access": "source", "*": "dist" + }, + "allow-plugins": { + "php-http/discovery": true } }, "minimum-stability": "dev", diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 8ab74f4f..0b030015 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -58,6 +58,9 @@ abstract class App extends Entity implements AppInterface /** @var \Apigee\Edge\Api\Management\Entity\AppCredential[] */ protected $credentials = []; + /** @var string[] */ + protected $initialApiProducts = []; + /** * App constructor. * @@ -216,4 +219,33 @@ public function setScopes(string ...$scopes): void { $this->privateSetScopes(...$scopes); } + + /** + * Get Initial API Products only during app creation. + * + * @return array $initialApiProducts + * + * @internal + */ + final public function getApiProducts(): array + { + return $this->initialApiProducts; + } + + /** + * Set Initial API Products only during app creation. + * The method is not supported to update existing App. + * + * @param array $initialApiProducts + * + * @throws \LogicException If used to update existing App. + */ + final public function setInitialApiProducts(array $initialApiProducts): void + { + if (!$this->appId) { + $this->initialApiProducts = $initialApiProducts; + } else { + throw new \LogicException('This method is only supported for creating a new app.'); + } + } } diff --git a/tests/Api/Management/Controller/AppControllerTestBase.php b/tests/Api/Management/Controller/AppControllerTestBase.php index 355abc14..ee212f23 100644 --- a/tests/Api/Management/Controller/AppControllerTestBase.php +++ b/tests/Api/Management/Controller/AppControllerTestBase.php @@ -107,6 +107,7 @@ protected function alterArraysBeforeCompareSentAndReceivedPayloadsInCreate(array { // This is not returned in the POST/PUT API call responses only in GET. unset($sentEntityAsArray['appFamily']); + unset($sentEntityAsArray['apiProducts']); } /** @@ -116,6 +117,8 @@ protected function alterObjectsBeforeCompareResponseAndCreatedEntity(\stdClass & { /* @var \Apigee\Edge\Api\Management\Entity\DeveloperAppInterface $created */ $responseObject->appFamily = $created->getAppFamily(); + + $responseObject->apiProducts = $created->getApiProducts(); } /**