Skip to content

Commit

Permalink
Merge pull request #32 from GW2Treasures/endpoints/traits
Browse files Browse the repository at this point in the history
Add /v2/traits endpoint
  • Loading branch information
darthmaim committed Sep 4, 2015
2 parents 3c999a0 + 6a12054 commit d4e2dc0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ For all examples it is assumed that you have a variable `$api = new GW2Api()`.
/v2/skins | [Skin\SkinEndpoint][SkinEndpoint] <br>`GW2Api::skins()` | 📦🌏
/v2/specializations | [Specialization\SpecializationEndpoint][SpecializationEndpoint] <br>`GW2Api::specializations()` | 📦🌏
/v2/tokeninfo | [Tokeninfo\TokeninfoEndpoint][TokeninfoEndpoint] <br>`GW2Api::tokeninfo()` | 🔒
~~/v2/traits~~ | *disabled* | 🚫
/v2/traits | [Traits\TraitEndpoint][TraitEndpoint] <br>`GW2Api::traits()` | 📦🌏
/v2/worlds | [World\WorldEndpoint][WorldEndpoint] <br>`GW2Api::worlds()` | 📦🌏
~~/v2/wvw/matches~~ | *disabled* | 🚫
~~/v2/wvw/objectives~~ | *disabled* | 🚫🌏
Expand Down Expand Up @@ -901,6 +901,25 @@ $api->tokeninfo('API_KEY')->get();
```


#### /v2/traits
[TraitEndpoint]: #v2traits

`\GW2Treasures\GW2Api\V2\Endpoint\Traits\TraitEndpoint`
([source](src/V2/Endpoint/Traits/TraitEndpoint.php))

Implements [📦BulkEndpoint][BulkEndpoint] and [🌏LocalizedEndpoint][LocalizedEndpoint].

##### Methods
- Inherited methods from [📦BulkEndpoint][BulkEndpoint]
- Inherited methods from [🌏LocalizedEndpoint][LocalizedEndpoint]

##### Example
```php
$api->traits()->get(214);
// => { id: 214, tier:2, name: "Aeromancer's Training", … }
```


#### /v2/worlds
[WorldEndpoint]: #v2worlds

Expand Down
5 changes: 5 additions & 0 deletions src/GW2Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use GW2Treasures\GW2Api\V2\Endpoint\Skin\SkinEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint\Specialization\SpecializationEndpoint;
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\IEndpoint;

Expand Down Expand Up @@ -181,6 +182,10 @@ public function tokeninfo( $apiKey ) {
return new TokeninfoEndpoint( $this, $apiKey );
}

public function traits() {
return new TraitEndpoint( $this );
}

public function worlds() {
return new WorldEndpoint( $this );
}
Expand Down
20 changes: 20 additions & 0 deletions src/V2/Endpoint/Traits/TraitEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\Traits;

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 TraitEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/**
* {@inheritdoc}
*/
public function url() {
return 'v2/traits';
}
}
14 changes: 14 additions & 0 deletions tests/V2/TraitEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

class TraitEndpointTest extends TestCase {
public function test() {
$endpoint = $this->api()->traits();

$this->assertEndpointIsBulk( $endpoint );
$this->assertEndpointIsLocalized( $endpoint );
$this->assertEndpointUrl( 'v2/traits', $endpoint );

$this->mockResponse('[214,221,222,223]');
$this->assertEquals( [214,221,222,223], $endpoint->ids() );
}
}

0 comments on commit d4e2dc0

Please sign in to comment.