Skip to content

Commit

Permalink
Fix for Team app credentials listings sorted in ascending order (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
kedarkhaire authored Feb 13, 2024
1 parent 9f2fc0a commit 80d40b8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Api/Management/Entity/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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[] */
Expand Down Expand Up @@ -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;
}

Expand All @@ -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
*/
Expand Down Expand Up @@ -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.');
}
}
}

0 comments on commit 80d40b8

Please sign in to comment.