Skip to content

Commit

Permalink
Merge pull request #35 from GW2Treasures/endpoints/wvw-objectives
Browse files Browse the repository at this point in the history
Add /v2/wvw/objectives endpoint
  • Loading branch information
darthmaim committed Sep 25, 2015
2 parents c410b90 + 67825f1 commit 20ecbd9
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ For all examples it is assumed that you have a variable `$api = new GW2Api()`.
/v2/traits | [Traits\TraitEndpoint][TraitEndpoint] <br>`GW2Api::traits()` | 📦🌏
/v2/worlds | [World\WorldEndpoint][WorldEndpoint] <br>`GW2Api::worlds()` | 📦🌏
~~/v2/wvw/matches~~ | *disabled* | 🚫
~~/v2/wvw/objectives~~ | *disabled* | 🚫🌏
/v2/wvw/objectives | [WvW\ObjectiveEndpoint][WvW\ObjectiveEndpoint] <br>`GW2Api::wvw()->objectives()` | 📦🌏

† Not FQN, all endpoints are in the namespace `\GW2Treasures\GW2Api\V2\Endpoint`
‡ Flags:
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/GW2Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 )) {
Expand Down
20 changes: 20 additions & 0 deletions src/V2/Endpoint/WvW/ObjectiveEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\WvW;

use GW2Treasures\GW2Api\V2\Bulk\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Bulk\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Localization\ILocalizedEndpoint;
use GW2Treasures\GW2Api\V2\Localization\LocalizedEndpoint;

class ObjectiveEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/**
* {@inheritdoc}
*/
public function url() {
return 'v2/wvw/objectives';
}
}
18 changes: 18 additions & 0 deletions src/V2/Endpoint/WvW/WvWEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\WvW;

use GW2Treasures\GW2Api\V2\Endpoint;

class WvWEndpoint extends Endpoint {
/**
* {@inheritdoc}
*/
public function url() {
return 'v2/wvw';
}

public function objectives() {
return new ObjectiveEndpoint( $this->api );
}
}
20 changes: 20 additions & 0 deletions tests/V2/WvWEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class WvWEndpointTest extends TestCase {
public function test() {
$endpoint = $this->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 );
}
}

0 comments on commit 20ecbd9

Please sign in to comment.