diff --git a/CHANGELOG.md b/CHANGELOG.md index ec4d2da..9b234b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/Api.php b/src/Api.php index 228b533..28189a7 100644 --- a/src/Api.php +++ b/src/Api.php @@ -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 diff --git a/tests/ApiTest.php b/tests/ApiTest.php index cf00956..b562a7a 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -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++) {