From 84168c60b2e015aeb11f344ea8f42c44d5df6c23 Mon Sep 17 00:00:00 2001 From: darthmaim Date: Sun, 22 Jan 2017 01:01:51 +0100 Subject: [PATCH 1/6] add /v2/account/outfits --- src/V2/Endpoint/Account/AccountEndpoint.php | 9 +++++++ src/V2/Endpoint/Account/OutfitEndpoint.php | 29 +++++++++++++++++++++ tests/V2/AccountEndpointTest.php | 10 +++++++ 3 files changed, 48 insertions(+) create mode 100644 src/V2/Endpoint/Account/OutfitEndpoint.php diff --git a/src/V2/Endpoint/Account/AccountEndpoint.php b/src/V2/Endpoint/Account/AccountEndpoint.php index 7887eb8..021b9c9 100644 --- a/src/V2/Endpoint/Account/AccountEndpoint.php +++ b/src/V2/Endpoint/Account/AccountEndpoint.php @@ -104,6 +104,15 @@ public function minis() { return new MiniEndpoint( $this->api, $this->apiKey ); } + /** + * Get unlocked outfits. + * + * @return MiniEndpoint + */ + public function outfits() { + return new OutfitEndpoint( $this->api, $this->apiKey ); + } + /** * Get unlocked recipes. * diff --git a/src/V2/Endpoint/Account/OutfitEndpoint.php b/src/V2/Endpoint/Account/OutfitEndpoint.php new file mode 100644 index 0000000..c86a1b9 --- /dev/null +++ b/src/V2/Endpoint/Account/OutfitEndpoint.php @@ -0,0 +1,29 @@ +apiKey = $apiKey; + } + + /** + * {@inheritdoc} + */ + public function url() { + return 'v2/account/outfits'; + } + + public function get() { + return $this->request()->json(); + } +} diff --git a/tests/V2/AccountEndpointTest.php b/tests/V2/AccountEndpointTest.php index 1197e91..7c06912 100644 --- a/tests/V2/AccountEndpointTest.php +++ b/tests/V2/AccountEndpointTest.php @@ -100,6 +100,16 @@ public function testMinis() { $this->assertEquals([1,2,3,4,5,6], $endpoint->get()); } + public function testOutfits() { + $endpoint = $this->api()->account('test')->outfits(); + + $this->assertEndpointIsAuthenticated( $endpoint ); + $this->assertEndpointUrl( 'v2/account/outfits', $endpoint ); + + $this->mockResponse('[1,2,3]'); + $this->assertEquals([1,2,3], $endpoint->get()); + } + public function testRecipes() { $endpoint = $this->api()->account('test')->recipes(); From 796f8c148a83ef2bd30b50f92957dad6f59fbb9b Mon Sep 17 00:00:00 2001 From: darthmaim Date: Sun, 22 Jan 2017 01:12:12 +0100 Subject: [PATCH 2/6] add /v2/guild/search --- src/V2/Endpoint/Guild/GuildEndpoint.php | 9 +++++++++ src/V2/Endpoint/Guild/SearchEndpoint.php | 23 +++++++++++++++++++++++ tests/V2/GuildEndpointTest.php | 11 +++++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/V2/Endpoint/Guild/SearchEndpoint.php diff --git a/src/V2/Endpoint/Guild/GuildEndpoint.php b/src/V2/Endpoint/Guild/GuildEndpoint.php index 05aef35..c39ddeb 100644 --- a/src/V2/Endpoint/Guild/GuildEndpoint.php +++ b/src/V2/Endpoint/Guild/GuildEndpoint.php @@ -74,6 +74,15 @@ public function ranksOf($apiKey, $guildId) { return new RankEndpoint($this->api, $apiKey, $guildId); } + /** + * Search for a guild. + * + * @return SearchEndpoint + */ + public function search() { + return new SearchEndpoint($this->api); + } + /** * Get stash of a guild. * diff --git a/src/V2/Endpoint/Guild/SearchEndpoint.php b/src/V2/Endpoint/Guild/SearchEndpoint.php new file mode 100644 index 0000000..d1bc7e3 --- /dev/null +++ b/src/V2/Endpoint/Guild/SearchEndpoint.php @@ -0,0 +1,23 @@ +request([ 'name' => $name ])->json(); + } +} diff --git a/tests/V2/GuildEndpointTest.php b/tests/V2/GuildEndpointTest.php index 95ae7db..ef9139c 100644 --- a/tests/V2/GuildEndpointTest.php +++ b/tests/V2/GuildEndpointTest.php @@ -80,6 +80,17 @@ public function testRanks() { $this->assertEquals('Leader', $endpoint->get()[0]->id); } + public function testSearch() { + $endpoint = $this->api()->guild()->search(); + + $this->assertEndpointUrl('v2/guild/search', $endpoint); + + $this->mockResponse('["335C4BB3-5CA3-E511-80D3-E4115BD7186D"]'); + $this->assertEquals('335C4BB3-5CA3-E511-80D3-E4115BD7186D', $endpoint->name("API Test")[0]); + + $this->assertEquals('name=API%20Test', $this->getLastRequest()->getUri()->getQuery()); + } + public function testStash() { $endpoint = $this->api()->guild()->stashOf('API_KEY', 'GUILD_ID'); From 6985912e349efe95b2b68541e5cbf8fb6c9db622 Mon Sep 17 00:00:00 2001 From: darthmaim Date: Sun, 22 Jan 2017 01:16:23 +0100 Subject: [PATCH 3/6] add /v2/pvp/ranks --- src/V2/Endpoint/Pvp/PvpEndpoint.php | 7 +++++++ src/V2/Endpoint/Pvp/RankEndpoint.php | 20 ++++++++++++++++++++ tests/V2/PvpEndpointTest.php | 11 +++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/V2/Endpoint/Pvp/RankEndpoint.php diff --git a/src/V2/Endpoint/Pvp/PvpEndpoint.php b/src/V2/Endpoint/Pvp/PvpEndpoint.php index 2901861..709c16c 100644 --- a/src/V2/Endpoint/Pvp/PvpEndpoint.php +++ b/src/V2/Endpoint/Pvp/PvpEndpoint.php @@ -32,6 +32,13 @@ public function games($apiKey) { return new GameEndpoint($this->api, $apiKey); } + /** + * @return RankEndpoint + */ + public function ranks() { + return new RankEndpoint($this->api); + } + /** * @return SeasonEndpoint */ diff --git a/src/V2/Endpoint/Pvp/RankEndpoint.php b/src/V2/Endpoint/Pvp/RankEndpoint.php new file mode 100644 index 0000000..b8b3772 --- /dev/null +++ b/src/V2/Endpoint/Pvp/RankEndpoint.php @@ -0,0 +1,20 @@ +assertContains('4FDC931F-677F-4369-B20A-9FBB6A63B2B4', $endpoint->ids()); } + public function testRanks() { + $endpoint = $this->api()->pvp()->ranks(); + + $this->assertEndpointUrl('v2/pvp/ranks', $endpoint); + $this->assertEndpointIsBulk($endpoint); + $this->assertEndpointIsLocalized($endpoint); + + $this->mockResponse('[1,2,3,4,5,6,7,8,9]'); + $this->assertEquals([1,2,3,4,5,6,7,8,9], $endpoint->ids()); + } + public function testSeasons() { $endpoint = $this->api()->pvp()->seasons(); From 446749be60c1fccff86a3b6291ad8367ef579466 Mon Sep 17 00:00:00 2001 From: darthmaim Date: Sun, 22 Jan 2017 01:20:24 +0100 Subject: [PATCH 4/6] add /v2/wvw/ranks --- src/V2/Endpoint/WvW/RankEndpoint.php | 20 ++++++++++++++++++++ src/V2/Endpoint/WvW/WvWEndpoint.php | 4 ++++ tests/V2/WvWEndpointTest.php | 11 +++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/V2/Endpoint/WvW/RankEndpoint.php diff --git a/src/V2/Endpoint/WvW/RankEndpoint.php b/src/V2/Endpoint/WvW/RankEndpoint.php new file mode 100644 index 0000000..86a6785 --- /dev/null +++ b/src/V2/Endpoint/WvW/RankEndpoint.php @@ -0,0 +1,20 @@ +api ); } + + public function ranks() { + return new RankEndpoint( $this->api ); + } } diff --git a/tests/V2/WvWEndpointTest.php b/tests/V2/WvWEndpointTest.php index 1f2dc51..9c834a1 100644 --- a/tests/V2/WvWEndpointTest.php +++ b/tests/V2/WvWEndpointTest.php @@ -38,4 +38,15 @@ public function testMatchEndpoint() { $this->mockResponse('{"id":"2-6","scores":{"red":169331,"blue":246780,"green":216241}}'); $this->assertEquals(169331, $endpoint->world('id')->scores->red); } + + public function testRankEndpoint() { + $endpoint = $this->api()->wvw()->ranks(); + + $this->assertEndpointUrl('v2/wvw/ranks', $endpoint); + $this->assertEndpointIsBulk($endpoint); + $this->assertEndpointIsLocalized($endpoint); + + $this->mockResponse('{"id":1,"title":"Invader","min_rank":1}'); + $this->assertEquals('Invader', $endpoint->get(1)->title); + } } From 7bdbd9bf9730c86411e3073a28fefd9580fce1c3 Mon Sep 17 00:00:00 2001 From: darthmaim Date: Sun, 22 Jan 2017 02:07:25 +0100 Subject: [PATCH 5/6] add /v2/wvw/matches/{overview,scores,stats} --- src/V2/Endpoint/WvW/MatchEndpoint.php | 12 ++++++++++ src/V2/Endpoint/WvW/OverviewEndpoint.php | 28 ++++++++++++++++++++++ src/V2/Endpoint/WvW/ScoreEndpoint.php | 28 ++++++++++++++++++++++ src/V2/Endpoint/WvW/StatEndpoint.php | 28 ++++++++++++++++++++++ tests/V2/WvWEndpointTest.php | 30 ++++++++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 src/V2/Endpoint/WvW/OverviewEndpoint.php create mode 100644 src/V2/Endpoint/WvW/ScoreEndpoint.php create mode 100644 src/V2/Endpoint/WvW/StatEndpoint.php diff --git a/src/V2/Endpoint/WvW/MatchEndpoint.php b/src/V2/Endpoint/WvW/MatchEndpoint.php index 2ecb41d..99c9c1e 100644 --- a/src/V2/Endpoint/WvW/MatchEndpoint.php +++ b/src/V2/Endpoint/WvW/MatchEndpoint.php @@ -25,4 +25,16 @@ public function url() { public function world($id) { return $this->request(['world' => $id])->json(); } + + public function overview() { + return new OverviewEndpoint($this->api); + } + + public function scores() { + return new ScoreEndpoint($this->api); + } + + public function stats() { + return new StatEndpoint($this->api); + } } diff --git a/src/V2/Endpoint/WvW/OverviewEndpoint.php b/src/V2/Endpoint/WvW/OverviewEndpoint.php new file mode 100644 index 0000000..64af79d --- /dev/null +++ b/src/V2/Endpoint/WvW/OverviewEndpoint.php @@ -0,0 +1,28 @@ +request(['world' => $id])->json(); + } +} diff --git a/src/V2/Endpoint/WvW/ScoreEndpoint.php b/src/V2/Endpoint/WvW/ScoreEndpoint.php new file mode 100644 index 0000000..e01d6e0 --- /dev/null +++ b/src/V2/Endpoint/WvW/ScoreEndpoint.php @@ -0,0 +1,28 @@ +request(['world' => $id])->json(); + } +} diff --git a/src/V2/Endpoint/WvW/StatEndpoint.php b/src/V2/Endpoint/WvW/StatEndpoint.php new file mode 100644 index 0000000..980651e --- /dev/null +++ b/src/V2/Endpoint/WvW/StatEndpoint.php @@ -0,0 +1,28 @@ +request(['world' => $id])->json(); + } +} diff --git a/tests/V2/WvWEndpointTest.php b/tests/V2/WvWEndpointTest.php index 9c834a1..e545944 100644 --- a/tests/V2/WvWEndpointTest.php +++ b/tests/V2/WvWEndpointTest.php @@ -39,6 +39,36 @@ public function testMatchEndpoint() { $this->assertEquals(169331, $endpoint->world('id')->scores->red); } + public function testMatchOverviewEndpoint() { + $endpoint = $this->api()->wvw()->matches()->overview(); + + $this->assertEndpointUrl('v2/wvw/matches/overview', $endpoint); + $this->assertEndpointIsBulk($endpoint); + + $this->mockResponse('{"id":"1-1","worlds":{"red":1008,"blue":1019,"green":1005}}'); + $this->assertEquals(1008, $endpoint->world(1008)->worlds->red); + } + + public function testMatchScoreEndpoint() { + $endpoint = $this->api()->wvw()->matches()->scores(); + + $this->assertEndpointUrl('v2/wvw/matches/scores', $endpoint); + $this->assertEndpointIsBulk($endpoint); + + $this->mockResponse('{"id":"1-1","scores":{"red":169331,"blue":246780,"green":216241}}'); + $this->assertEquals(169331, $endpoint->world(1008)->scores->red); + } + + public function testMatchStatEndpoint() { + $endpoint = $this->api()->wvw()->matches()->stats(); + + $this->assertEndpointUrl('v2/wvw/matches/stats', $endpoint); + $this->assertEndpointIsBulk($endpoint); + + $this->mockResponse('{"id":"1-1","deaths":{"red":7276,"blue":5922,"green":5767}}'); + $this->assertEquals(7276, $endpoint->world(1008)->deaths->red); + } + public function testRankEndpoint() { $endpoint = $this->api()->wvw()->ranks(); From 7c9ec001a03a59b02e288a8e0690efe35fa9ebbb Mon Sep 17 00:00:00 2001 From: darthmaim Date: Sun, 22 Jan 2017 02:32:15 +0100 Subject: [PATCH 6/6] add /v2/pvp/seasons/:id/leaderboards/:board/:region --- src/V2/Endpoint/Pvp/LeaderboardEndpoint.php | 42 +++++++++++++++++ .../Pvp/LeaderboardRegionEndpoint.php | 45 +++++++++++++++++++ src/V2/Endpoint/Pvp/SeasonEndpoint.php | 4 ++ tests/V2/PvpEndpointTest.php | 20 +++++++++ 4 files changed, 111 insertions(+) create mode 100644 src/V2/Endpoint/Pvp/LeaderboardEndpoint.php create mode 100644 src/V2/Endpoint/Pvp/LeaderboardRegionEndpoint.php diff --git a/src/V2/Endpoint/Pvp/LeaderboardEndpoint.php b/src/V2/Endpoint/Pvp/LeaderboardEndpoint.php new file mode 100644 index 0000000..f50ac3f --- /dev/null +++ b/src/V2/Endpoint/Pvp/LeaderboardEndpoint.php @@ -0,0 +1,42 @@ +season = $season; + } + + /** + * The url of this endpoint. + * + * @return string + */ + public function url() { + return 'v2/pvp/seasons/'.$this->season.'/leaderboards'; + } + + /** + * Get a list of available leaderboards. + * + * @return string[] + */ + public function ids() { + return $this->request()->json(); + } + + public function get($leaderboard, $region) { + return new LeaderboardRegionEndpoint($this->api, $this->season, $leaderboard, $region); + } +} diff --git a/src/V2/Endpoint/Pvp/LeaderboardRegionEndpoint.php b/src/V2/Endpoint/Pvp/LeaderboardRegionEndpoint.php new file mode 100644 index 0000000..3f1441d --- /dev/null +++ b/src/V2/Endpoint/Pvp/LeaderboardRegionEndpoint.php @@ -0,0 +1,45 @@ +season = $season; + $this->leaderboard = $leaderboard; + $this->region = $region; + } + + + /** + * The url of this endpoint. + * + * @return string + */ + public function url() { + return 'v2/pvp/seasons/'.$this->season.'/leaderboards/'.$this->leaderboard.'/'.$this->region; + } +} diff --git a/src/V2/Endpoint/Pvp/SeasonEndpoint.php b/src/V2/Endpoint/Pvp/SeasonEndpoint.php index ef44210..dbccf9f 100644 --- a/src/V2/Endpoint/Pvp/SeasonEndpoint.php +++ b/src/V2/Endpoint/Pvp/SeasonEndpoint.php @@ -17,4 +17,8 @@ class SeasonEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoi public function url() { return 'v2/pvp/seasons'; } + + public function leaderboardsOf($season) { + return new LeaderboardEndpoint($this->api, $season); + } } diff --git a/tests/V2/PvpEndpointTest.php b/tests/V2/PvpEndpointTest.php index f2d91cc..590a950 100644 --- a/tests/V2/PvpEndpointTest.php +++ b/tests/V2/PvpEndpointTest.php @@ -64,6 +64,26 @@ public function testSeasons() { $this->assertEquals('PvP League Season One', $endpoint->get("44B85826-B5ED-4890-8C77-82DDF9F2CF2B")->name); } + public function testSeasonLeaderboardsList() { + $endpoint = $this->api()->pvp()->seasons()->leaderboardsOf('44B85826-B5ED-4890-8C77-82DDF9F2CF2B'); + + $this->assertEndpointUrl('v2/pvp/seasons/44B85826-B5ED-4890-8C77-82DDF9F2CF2B/leaderboards', $endpoint); + + $this->mockResponse('["legendary","guild"]'); + $this->assertEquals('legendary', $endpoint->ids()[0]); + } + + public function testSeasonLeaderboardsGet() { + $endpoint = $this->api()->pvp()->seasons()->leaderboardsOf('44B85826-B5ED-4890-8C77-82DDF9F2CF2B') + ->get('legendary', 'na'); + + $this->assertEndpointUrl('v2/pvp/seasons/44B85826-B5ED-4890-8C77-82DDF9F2CF2B/leaderboards/legendary/na', $endpoint); + $this->assertEndpointIsPaginated($endpoint); + + $this->mockResponse('[{"name":"darthmaim.6017", "rank":1}]'); + $this->assertEquals('darthmaim.6017', $endpoint->page(0, 1)[0]->name); + } + public function testStanding() { $endpoint = $this->api()->pvp()->standings('API_KEY');