diff --git a/src/GW2Api.php b/src/GW2Api.php index 6150914..197fd4d 100644 --- a/src/GW2Api.php +++ b/src/GW2Api.php @@ -16,6 +16,7 @@ use GW2Treasures\GW2Api\V2\Endpoint\Commerce\CommerceEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Continent\ContinentEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Currency\CurrencyEndpoint; +use GW2Treasures\GW2Api\V2\Endpoint\Dungeon\DungeonEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Emblem\EmblemEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\File\FileEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Finisher\FinisherEndpoint; @@ -33,6 +34,8 @@ use GW2Treasures\GW2Api\V2\Endpoint\Profession\ProfessionEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Pvp\PvpEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Quaggan\QuagganEndpoint; +use GW2Treasures\GW2Api\V2\Endpoint\Race\RaceEndpoint; +use GW2Treasures\GW2Api\V2\Endpoint\Raid\RaidEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Recipe\RecipeEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Skill\SkillEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Skin\SkinEndpoint; @@ -184,6 +187,10 @@ public function currencies() { return new CurrencyEndpoint( $this ); } + public function dungeons() { + return new DungeonEndpoint( $this ); + } + public function emblem() { return new EmblemEndpoint( $this ); } @@ -248,6 +255,14 @@ public function quaggans() { return new QuagganEndpoint( $this ); } + public function races() { + return new RaceEndpoint( $this ); + } + + public function raids() { + return new RaidEndpoint( $this ); + } + public function recipes() { return new RecipeEndpoint( $this ); } diff --git a/src/V2/Endpoint/Account/AccountEndpoint.php b/src/V2/Endpoint/Account/AccountEndpoint.php index 021b9c9..bb76750 100644 --- a/src/V2/Endpoint/Account/AccountEndpoint.php +++ b/src/V2/Endpoint/Account/AccountEndpoint.php @@ -6,6 +6,7 @@ use GW2Treasures\GW2Api\V2\Authentication\AuthenticatedEndpoint; use GW2Treasures\GW2Api\V2\Authentication\IAuthenticatedEndpoint; use GW2Treasures\GW2Api\V2\Endpoint; +use GW2Treasures\GW2Api\V2\Endpoint\Account\Home\HomeEndpoint; class AccountEndpoint extends Endpoint implements IAuthenticatedEndpoint { use AuthenticatedEndpoint; @@ -50,6 +51,15 @@ public function bank() { return new BankEndpoint( $this->api, $this->apiKey ); } + /** + * Get daily dungeon completions. + * + * @return DungeonEndpoint + */ + public function dungeons() { + return new DungeonEndpoint( $this->api, $this->apiKey ); + } + /** * Get a list of all unlocked dyes (ids). * @@ -68,6 +78,15 @@ public function finishers() { return new FinisherEndpoint( $this->api, $this->apiKey ); } + /** + * Get info about the home instance. + * + * @return HomeEndpoint + */ + public function home() { + return new HomeEndpoint($this->api, $this->apiKey); + } + /** * Get a list of item stacks representing the account's shared inventory slots. * @@ -107,12 +126,21 @@ public function minis() { /** * Get unlocked outfits. * - * @return MiniEndpoint + * @return OutfitEndpoint */ public function outfits() { return new OutfitEndpoint( $this->api, $this->apiKey ); } + /** + * Get weekly raid completion. + * + * @return RaidEndpoint + */ + public function raids() { + return new RaidEndpoint( $this->api, $this->apiKey ); + } + /** * Get unlocked recipes. * diff --git a/src/V2/Endpoint/Account/DungeonEndpoint.php b/src/V2/Endpoint/Account/DungeonEndpoint.php new file mode 100644 index 0000000..9d68217 --- /dev/null +++ b/src/V2/Endpoint/Account/DungeonEndpoint.php @@ -0,0 +1,29 @@ +apiKey = $apiKey; + } + + /** + * {@inheritdoc} + */ + public function url() { + return 'v2/account/dungeons'; + } + + public function get() { + return $this->request()->json(); + } +} diff --git a/src/V2/Endpoint/Account/Home/CatEndpoint.php b/src/V2/Endpoint/Account/Home/CatEndpoint.php new file mode 100644 index 0000000..42a99b5 --- /dev/null +++ b/src/V2/Endpoint/Account/Home/CatEndpoint.php @@ -0,0 +1,29 @@ +apiKey = $apiKey; + } + + /** + * {@inheritdoc} + */ + public function url() { + return 'v2/account/home/cats'; + } + + public function get() { + return $this->request()->json(); + } +} diff --git a/src/V2/Endpoint/Account/Home/HomeEndpoint.php b/src/V2/Endpoint/Account/Home/HomeEndpoint.php new file mode 100644 index 0000000..f070b02 --- /dev/null +++ b/src/V2/Endpoint/Account/Home/HomeEndpoint.php @@ -0,0 +1,34 @@ +apiKey = $apiKey; + } + + /** + * The url of this endpoint. + * + * @return string + */ + public function url() { + return 'v2/account/home'; + } + + public function cats() { + return new CatEndpoint($this->api, $this->apiKey); + } + public function nodes() { + return new NodeEndpoint($this->api, $this->apiKey); + } +} diff --git a/src/V2/Endpoint/Account/Home/NodeEndpoint.php b/src/V2/Endpoint/Account/Home/NodeEndpoint.php new file mode 100644 index 0000000..bd8fa1b --- /dev/null +++ b/src/V2/Endpoint/Account/Home/NodeEndpoint.php @@ -0,0 +1,29 @@ +apiKey = $apiKey; + } + + /** + * {@inheritdoc} + */ + public function url() { + return 'v2/account/home/nodes'; + } + + public function get() { + return $this->request()->json(); + } +} diff --git a/src/V2/Endpoint/Account/RaidEndpoint.php b/src/V2/Endpoint/Account/RaidEndpoint.php new file mode 100644 index 0000000..fb841ca --- /dev/null +++ b/src/V2/Endpoint/Account/RaidEndpoint.php @@ -0,0 +1,29 @@ +apiKey = $apiKey; + } + + /** + * {@inheritdoc} + */ + public function url() { + return 'v2/account/raids'; + } + + public function get() { + return $this->request()->json(); + } +} diff --git a/src/V2/Endpoint/Dungeon/DungeonEndpoint.php b/src/V2/Endpoint/Dungeon/DungeonEndpoint.php new file mode 100644 index 0000000..85a302b --- /dev/null +++ b/src/V2/Endpoint/Dungeon/DungeonEndpoint.php @@ -0,0 +1,25 @@ +api ); } + + public function upgrades() { + return new UpgradeEndpoint( $this->api ); + } } diff --git a/tests/V2/AccountEndpointTest.php b/tests/V2/AccountEndpointTest.php index 7c06912..1376343 100644 --- a/tests/V2/AccountEndpointTest.php +++ b/tests/V2/AccountEndpointTest.php @@ -40,6 +40,16 @@ public function testBank() { $this->assertEquals(24675, $endpoint->get()[1]->upgrades[0]); } + public function testDungeon() { + $endpoint = $this->api()->account('test')->dungeons(); + + $this->assertEndpointIsAuthenticated( $endpoint ); + $this->assertEndpointUrl( 'v2/account/dungeons', $endpoint ); + + $this->mockResponse('[]'); + $this->assertEquals([], $endpoint->get()); + } + public function testDyes() { $endpoint = $this->api()->account('test')->dyes(); @@ -60,6 +70,33 @@ public function testFinishers() { $this->assertEquals(true, $endpoint->get()[0]->permanent); } + public function testHome() { + $endpoint = $this->api()->account('test')->home(); + + $this->assertEndpointIsAuthenticated( $endpoint ); + $this->assertEndpointUrl( 'v2/account/home', $endpoint ); + } + + public function testHomeCat() { + $endpoint = $this->api()->account('test')->home()->cats(); + + $this->assertEndpointIsAuthenticated( $endpoint ); + $this->assertEndpointUrl( 'v2/account/home/cats', $endpoint ); + + $this->mockResponse('[{"id": 1,"hint": "chicken"}]'); + $this->assertEquals('chicken', $endpoint->get()[0]->hint); + } + + public function testHomeNodes() { + $endpoint = $this->api()->account('test')->home()->nodes(); + + $this->assertEndpointIsAuthenticated( $endpoint ); + $this->assertEndpointUrl( 'v2/account/home/nodes', $endpoint ); + + $this->mockResponse('["quartz_node","sprocket_generator"]'); + $this->assertEquals(["quartz_node","sprocket_generator"], $endpoint->get()); + } + public function testInventory() { $endpoint = $this->api()->account('test')->inventory(); @@ -110,6 +147,16 @@ public function testOutfits() { $this->assertEquals([1,2,3], $endpoint->get()); } + public function testRaids() { + $endpoint = $this->api()->account('test')->raids(); + + $this->assertEndpointIsAuthenticated( $endpoint ); + $this->assertEndpointUrl( 'v2/account/raids', $endpoint ); + + $this->mockResponse('[]'); + $this->assertEquals([], $endpoint->get()); + } + public function testRecipes() { $endpoint = $this->api()->account('test')->recipes(); diff --git a/tests/V2/DungeonEndpointTest.php b/tests/V2/DungeonEndpointTest.php new file mode 100644 index 0000000..46013ea --- /dev/null +++ b/tests/V2/DungeonEndpointTest.php @@ -0,0 +1,14 @@ +api()->dungeons(); + + $this->assertEndpointIsBulk( $endpoint ); + $this->assertEndpointIsLocalized( $endpoint ); + $this->assertEndpointUrl( 'v2/dungeons', $endpoint ); + + $this->mockResponse('{"id":"ascalonian_catacombs","paths":[{"id":"hodgins"},{"id":"detha"},{"id":"tzark"}]}'); + $this->assertCount(3, $endpoint->get('ascalonian_catacombs')->paths); + } +} diff --git a/tests/V2/RaceEndpointTest.php b/tests/V2/RaceEndpointTest.php new file mode 100644 index 0000000..5184c34 --- /dev/null +++ b/tests/V2/RaceEndpointTest.php @@ -0,0 +1,14 @@ +api()->races(); + + $this->assertEndpointIsBulk( $endpoint ); + $this->assertEndpointIsLocalized( $endpoint ); + $this->assertEndpointUrl( 'v2/races', $endpoint ); + + $this->mockResponse('["Human","Asura","Sylvari","Charr","Norn"]'); + $this->assertEquals( ["Human","Asura","Sylvari","Charr","Norn"], $endpoint->ids() ); + } +} diff --git a/tests/V2/RaidEndpointTest.php b/tests/V2/RaidEndpointTest.php new file mode 100644 index 0000000..0bbc657 --- /dev/null +++ b/tests/V2/RaidEndpointTest.php @@ -0,0 +1,14 @@ +api()->raids(); + + $this->assertEndpointIsBulk( $endpoint ); + $this->assertEndpointIsLocalized( $endpoint ); + $this->assertEndpointUrl( 'v2/raids', $endpoint ); + + $this->mockResponse('["forsaken_thicket"]'); + $this->assertEquals( ["forsaken_thicket"], $endpoint->ids() ); + } +} diff --git a/tests/V2/WvWEndpointTest.php b/tests/V2/WvWEndpointTest.php index beba789..f75ed15 100644 --- a/tests/V2/WvWEndpointTest.php +++ b/tests/V2/WvWEndpointTest.php @@ -83,4 +83,15 @@ public function testRankEndpoint() { $this->mockResponse('{"id":1,"title":"Invader","min_rank":1}'); $this->assertEquals('Invader', $endpoint->get(1)->title); } + + public function testUpgradeEndpoint() { + $endpoint = $this->api()->wvw()->upgrades(); + + $this->assertEndpointUrl('v2/wvw/upgrades', $endpoint); + $this->assertEndpointIsBulk($endpoint); + $this->assertEndpointIsLocalized($endpoint); + + $this->mockResponse('[3,4,7,8,9]'); + $this->assertEquals([3,4,7,8,9], $endpoint->ids()); + } }