Skip to content

Commit 979fb54

Browse files
authored
Merge pull request #112 from apisearch-io/feature/add-token-to-put-token
Changed the action from addToken to putToken
2 parents e7cb423 + 32d23de commit 979fb54

6 files changed

+13
-13
lines changed

App/AppRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ interface AppRepository extends WithRepositoryReference
3434
*
3535
* @param Token $token
3636
*/
37-
public function addToken(Token $token);
37+
public function putToken(Token $token);
3838

3939
/**
4040
* Delete token.

App/DiskAppRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ public function configureIndex(
140140
*
141141
* @param Token $token
142142
*/
143-
public function addToken(Token $token)
143+
public function putToken(Token $token)
144144
{
145145
$this->load();
146-
parent::addToken($token);
146+
parent::putToken($token);
147147
$this->save();
148148
}
149149

App/HttpAppRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ class HttpAppRepository extends HttpRepositoryWithCredentials implements AppRepo
3535
*
3636
* @param Token $token
3737
*/
38-
public function addToken(Token $token)
38+
public function putToken(Token $token)
3939
{
4040
$response = $this
4141
->httpClient
4242
->get(
43-
sprintf('/%s/tokens', $this->getAppUUID()->getId()),
43+
sprintf('/%s/tokens/%s', $this->getAppUUID()->getId(), $token->getTokenUUID()->composeUUID()),
4444
'put',
4545
[],
4646
$token->toArray(),

App/InMemoryAppRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function configureIndex(
160160
*
161161
* @param Token $token
162162
*/
163-
public function addToken(Token $token)
163+
public function putToken(Token $token)
164164
{
165165
$this->tokens[$this->getAppKey()][$token->getTokenUUID()->composeUUID()] = $token;
166166
}

App/MockAppRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MockAppRepository extends HttpRepositoryWithCredentials implements AppRepo
3535
*
3636
* @param Token $token
3737
*/
38-
public function addToken(Token $token)
38+
public function putToken(Token $token)
3939
{
4040
$this->throwMockException();
4141
}

Tests/App/AppRepositoryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ public function testAddToken()
154154
$inMemoryAppRepository = $this->getRepository();
155155
$inMemoryAppRepository->setRepositoryReference(RepositoryReference::create(AppUUID::createById('xxx')));
156156
$token = new Token(TokenUUID::createById('lll'), AppUUID::createById('xxx'));
157-
$inMemoryAppRepository->addToken($token);
158-
$inMemoryAppRepository->addToken($token);
157+
$inMemoryAppRepository->putToken($token);
158+
$inMemoryAppRepository->putToken($token);
159159
$this->assertCount(1, $inMemoryAppRepository->getTokens());
160160
$token2 = new Token(TokenUUID::createById('uuu'), AppUUID::createById('xxx'));
161-
$inMemoryAppRepository->addToken($token2);
161+
$inMemoryAppRepository->putToken($token2);
162162
$this->assertCount(2, $inMemoryAppRepository->getTokens());
163163
}
164164

@@ -171,7 +171,7 @@ public function testDeleteToken()
171171
$inMemoryAppRepository->setRepositoryReference(RepositoryReference::create(AppUUID::createById('xxx')));
172172
$inMemoryAppRepository->createIndex(IndexUUID::createById('yyy'), new Config());
173173
$token = new Token(TokenUUID::createById('lll'), AppUUID::createById('xxx'));
174-
$inMemoryAppRepository->addToken($token);
174+
$inMemoryAppRepository->putToken($token);
175175
$this->assertCount(1, $inMemoryAppRepository->getTokens());
176176
$inMemoryAppRepository->deleteToken(TokenUUID::createById('nono'));
177177
$this->assertCount(1, $inMemoryAppRepository->getTokens());
@@ -188,9 +188,9 @@ public function testDeleteTokens()
188188
$inMemoryAppRepository->setRepositoryReference(RepositoryReference::create(AppUUID::createById('xxx')));
189189
$inMemoryAppRepository->createIndex(IndexUUID::createById('yyy'), new Config());
190190
$token = new Token(TokenUUID::createById('lll'), AppUUID::createById('xxx'));
191-
$inMemoryAppRepository->addToken($token);
191+
$inMemoryAppRepository->putToken($token);
192192
$token2 = new Token(TokenUUID::createById('uuu'), AppUUID::createById('xxx'));
193-
$inMemoryAppRepository->addToken($token2);
193+
$inMemoryAppRepository->putToken($token2);
194194
$this->assertCount(2, $inMemoryAppRepository->getTokens());
195195
$inMemoryAppRepository->deleteTokens();
196196
$this->assertCount(0, $inMemoryAppRepository->getTokens());

0 commit comments

Comments
 (0)