Implemented Reset Skin endpoint

This commit is contained in:
ErickSkrauch 2019-04-11 01:33:10 +03:00
parent 46c0215add
commit 7ba4472ec1
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
3 changed files with 27 additions and 0 deletions

View File

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [UUID to Name history](https://wiki.vg/Mojang_API#UUID_-.3E_Name_history) endpoint.
- [Playernames -> UUIDs](https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs) endpoint.
- [Change Skin](https://wiki.vg/Mojang_API#Change_Skin) endpoint.
- [Reset Skin](https://wiki.vg/Mojang_API#Reset_Skin) endpoint.
### Changed
- The constructor no longer has arguments.

View File

@ -229,6 +229,23 @@ class Api {
]);
}
/**
* @param string $accessToken
* @param string $accountUuid
*
* @throws \Ely\Mojang\Exception\MojangApiException
* @throws GuzzleException
*
* @url https://wiki.vg/Mojang_API#Reset_Skin
*/
public function resetSkin(string $accessToken, string $accountUuid): void {
$this->getClient()->request('DELETE', "https://api.mojang.com/user/profile/{$accountUuid}/skin", [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
],
]);
}
/**
* @param string $login
* @param string $password

View File

@ -290,6 +290,15 @@ class ApiTest extends TestCase {
$this->assertStringContainsString('slim', $request->getBody()->getContents());
}
public function testResetSkin() {
$this->mockHandler->append(new Response(200));
$this->api->resetSkin('mocked access token', '86f6e3695b764412a29820cac1d4d0d6');
/** @var \Psr\Http\Message\RequestInterface $request */
$request = $this->history[0]['request'];
$this->assertSame('https://api.mojang.com/user/profile/86f6e3695b764412a29820cac1d4d0d6/skin', (string)$request->getUri());
$this->assertSame('Bearer mocked access token', $request->getHeaderLine('Authorization'));
}
public function testPlayernamesToUuidsInvalidArgumentException() {
$names = [];
for ($i = 0; $i < 101; $i++) {