From 4e7750a3c7e40adb0bdb831df5113b3d97ac2bd2 Mon Sep 17 00:00:00 2001 From: Dorian Boulc'h Date: Thu, 16 May 2024 14:48:12 +0200 Subject: [PATCH 1/2] feat: add rotate project access token endpoint --- src/Api/Projects.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Api/Projects.php b/src/Api/Projects.php index 3f5d1962..1173c337 100644 --- a/src/Api/Projects.php +++ b/src/Api/Projects.php @@ -1704,6 +1704,30 @@ public function createProjectAccessToken($project_id, array $parameters = []) return $this->post($this->getProjectPath($project_id, 'access_tokens'), $resolver->resolve($parameters)); } + /** + * @param int|string $project_id + * @param int $token_id + * @param array $parameters { + * @var \DateTimeInterface $expires_at the token expires at midnight UTC on that date + * } + * + * @return mixed + */ + public function rotateProjectAccessToken($project_id, int $token_id, array $parameters = []) + { + $resolver = $this->createOptionsResolver(); + $datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value): string { + return $value->format('Y-m-d'); + }; + + $resolver->setDefined('expires_at') + ->setAllowedTypes('expires_at', \DateTimeInterface::class) + ->setNormalizer('expires_at', $datetimeNormalizer) + ; + + return $this->post($this->getProjectPath($project_id, 'access_tokens/'.$token_id.'/rotate'), $resolver->resolve($parameters)); + } + /** * @param int|string $project_id * @param int|string $token_id From a7f87c63af6009cf1242c33ee9326b5a84c8d944 Mon Sep 17 00:00:00 2001 From: Dorian Boulc'h Date: Thu, 16 May 2024 14:52:47 +0200 Subject: [PATCH 2/2] fix: typo in phpdoc --- src/Api/Projects.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Api/Projects.php b/src/Api/Projects.php index 1173c337..8421343b 100644 --- a/src/Api/Projects.php +++ b/src/Api/Projects.php @@ -1708,6 +1708,7 @@ public function createProjectAccessToken($project_id, array $parameters = []) * @param int|string $project_id * @param int $token_id * @param array $parameters { + * * @var \DateTimeInterface $expires_at the token expires at midnight UTC on that date * } *