Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 05a7a48

Browse files
committed
Added delete-tokens endpoint
1 parent 6b29d4c commit 05a7a48

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

App/AppRepository.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ public function deleteToken(TokenUUID $tokenUUID);
4545
* @return Token[]
4646
*/
4747
public function getTokens(): array;
48+
49+
/**
50+
* Purge tokens.
51+
*/
52+
public function deleteTokens();
4853
}

App/AppRepositoryBucket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ public function findRepository(string $appName): ? AppRepository
7373
}
7474

7575
/**
76-
* Get configuration
76+
* Get configuration.
7777
*
7878
* @return array
7979
*/
80-
public function getConfiguration() : array
80+
public function getConfiguration(): array
8181
{
8282
return $this->configuration;
8383
}

App/HttpAppRepository.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getTokens(): array
7878
$response = $this
7979
->httpClient
8080
->get(
81-
'/token',
81+
'/tokens',
8282
'get',
8383
Http::getQueryValues($this)
8484
);
@@ -89,4 +89,20 @@ public function getTokens(): array
8989
return Token::createFromArray($token);
9090
}, $response['body']);
9191
}
92+
93+
/**
94+
* Delete all tokens.
95+
*/
96+
public function deleteTokens()
97+
{
98+
$response = $this
99+
->httpClient
100+
->get(
101+
'/tokens',
102+
'delete',
103+
Http::getQueryValues($this)
104+
);
105+
106+
$this->throwTransportableExceptionIfNeeded($response);
107+
}
92108
}

App/InMemoryAppRepository.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private function getIndexKey(): string
4242
{
4343
return $this
4444
->getRepositoryReference()
45-
->compose();
45+
->getAppId();
4646
}
4747

4848
/**
@@ -72,4 +72,30 @@ public function deleteToken(TokenUUID $tokenUUID)
7272

7373
unset($this->tokens[$this->getIndexKey()][$tokenUUID->composeUUID()]);
7474
}
75+
76+
/**
77+
* Get tokens.
78+
*
79+
* @return Token[]
80+
*/
81+
public function getTokens(): array
82+
{
83+
if (!array_key_exists($this->getIndexKey(), $this->tokens)) {
84+
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
85+
}
86+
87+
return $this->tokens[$this->getIndexKey()];
88+
}
89+
90+
/**
91+
* Delete all tokens.
92+
*/
93+
public function deleteTokens()
94+
{
95+
if (!array_key_exists($this->getIndexKey(), $this->tokens)) {
96+
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
97+
}
98+
99+
$this->tokens[$this->getIndexKey()] = [];
100+
}
75101
}

0 commit comments

Comments
 (0)