From e996e266afdaad2c100bacae351e203419143d1e Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Thu, 11 Jan 2024 14:09:17 +0530 Subject: [PATCH 1/2] Fix for Team app credentials listings sorted in ascending order --- src/Api/Management/Entity/App.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 0b030015..697c3728 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,7 @@ 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 +197,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 +240,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.'); } } } From 0d6b003dacc36ae13dd48fbf8b36ccf2532988c5 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 13 Feb 2024 16:02:31 +0530 Subject: [PATCH 2/2] PHPCS errors --- src/Api/Management/Entity/App.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 697c3728..b089189d 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -189,6 +189,7 @@ 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; }