diff --git a/README.md b/README.md index 7072316..8a3cfcc 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ For all examples it is assumed that you have a variable `$api = new GW2Api()`. /v2/traits | [Traits\TraitEndpoint][TraitEndpoint]
`GW2Api::traits()` | 📦🌏 /v2/worlds | [World\WorldEndpoint][WorldEndpoint]
`GW2Api::worlds()` | 📦🌏 ~~/v2/wvw/matches~~ | *disabled* | 🚫 - ~~/v2/wvw/objectives~~ | *disabled* | 🚫🌏 + /v2/wvw/objectives | [WvW\ObjectiveEndpoint][WvW\ObjectiveEndpoint]
`GW2Api::wvw()->objectives()` | 📦🌏 † Not FQN, all endpoints are in the namespace `\GW2Treasures\GW2Api\V2\Endpoint` ‡ Flags: @@ -993,6 +993,26 @@ $api->worlds()->all(); ``` +#### /v2/wvw/objectives +[WvW\ObjectiveEndpoint]: #v2wvwobjectives + +`\GW2Treasures\GW2Api\V2\Endpoint\WvW\ObjectiveEndpoint` +([source](src/V2/Endpoint/WvW/ObjectiveEndpoint.php)) + +Implements [📦BulkEndpoint][BulkEndpoint] and [🌏LocalizedEndpoint][LocalizedEndpoint]. + +##### Methods + - Inherited methods from [📦BulkEndpoint][BulkEndpoint] + - Inherited methods from [🌏LocalizedEndpoint][LocalizedEndpoint] + +##### Example +```php +$api->wvw()->objectives()->get('968-98'); + +// => { id: "968-98", name: "Wurm Tunnel", … } +``` + + ## License [MIT](LICENSE) © 2015 gw2treasures.com diff --git a/src/GW2Api.php b/src/GW2Api.php index 573dfc4..a4a46c1 100644 --- a/src/GW2Api.php +++ b/src/GW2Api.php @@ -22,6 +22,7 @@ use GW2Treasures\GW2Api\V2\Endpoint\Tokeninfo\TokeninfoEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\Traits\TraitEndpoint; use GW2Treasures\GW2Api\V2\Endpoint\World\WorldEndpoint; +use GW2Treasures\GW2Api\V2\Endpoint\WvW\WvWEndpoint; use GW2Treasures\GW2Api\V2\IEndpoint; class GW2Api { @@ -195,6 +196,10 @@ public function worlds() { return new WorldEndpoint( $this ); } + public function wvw() { + return new WvWEndpoint( $this ); + } + public function attachRegisteredHandlers( IEndpoint $endpoint ) { foreach( $this->handlers as $handler => $handles ) { if( is_a( $endpoint, $handles )) { diff --git a/src/V2/Endpoint/WvW/ObjectiveEndpoint.php b/src/V2/Endpoint/WvW/ObjectiveEndpoint.php new file mode 100644 index 0000000..a62da2d --- /dev/null +++ b/src/V2/Endpoint/WvW/ObjectiveEndpoint.php @@ -0,0 +1,20 @@ +api ); + } +} diff --git a/tests/V2/WvWEndpointTest.php b/tests/V2/WvWEndpointTest.php new file mode 100644 index 0000000..077935e --- /dev/null +++ b/tests/V2/WvWEndpointTest.php @@ -0,0 +1,20 @@ +api()->wvw(); + + $this->assertEndpointUrl( 'v2/wvw', $endpoint ); + } + + public function testObjectiveEndpoint() { + $endpoint = $this->api()->wvw()->objectives(); + + $this->assertEndpointIsBulk( $endpoint ); + $this->assertEndpointIsLocalized( $endpoint ); + $this->assertEndpointUrl( 'v2/wvw/objectives', $endpoint ); + + $this->mockResponse('{"id": "968-98","name": "Wurm Tunnel"}'); + $this->assertEquals( 'Wurm Tunnel', $endpoint->get('968-98')->name ); + } +}