From 80d40b86f2933da2e4f1b47e253f35e6ebaffc89 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 13 Feb 2024 18:12:43 +0530 Subject: [PATCH] Fix for Team app credentials listings sorted in ascending order (#346) --- src/Api/Management/Entity/App.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 0b030015..b089189d 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -25,6 +25,7 @@ use Apigee\Edge\Entity\Property\ScopesPropertyAwareTrait; use Apigee\Edge\Entity\Property\StatusPropertyAwareTrait; use Apigee\Edge\Structure\AttributesProperty; +use LogicException; /** * Class App. @@ -55,7 +56,7 @@ abstract class App extends Entity implements AppInterface /** @var string Url, used for "three-legged" OAuth grant type flows. */ protected $callbackUrl; - /** @var \Apigee\Edge\Api\Management\Entity\AppCredential[] */ + /** @var AppCredential[] */ protected $credentials = []; /** @var string[] */ @@ -187,6 +188,8 @@ public function setCallbackUrl(string $callbackUrl): void */ public function getCredentials(): array { + usort($this->credentials, static fn (AppCredentialInterface $a, AppCredentialInterface $b) => $b->getIssuedAt() <=> $a->getIssuedAt()); + return $this->credentials; } @@ -195,7 +198,7 @@ public function getCredentials(): array * * Credentials, included in app, can not be changed by modifying them on the entity level. * - * @param \Apigee\Edge\Api\Management\Entity\AppCredentialInterface ...$credentials + * @param AppCredentialInterface ...$credentials * * @internal */ @@ -238,14 +241,14 @@ final public function getApiProducts(): array * * @param array $initialApiProducts * - * @throws \LogicException If used to update existing App. + * @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.'); + throw new LogicException('This method is only supported for creating a new app.'); } } }