diff --git a/README.md b/README.md index 9c94df0..a615013 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ For all examples it is assumed that you have a variable `$api = new GW2Api()`. /v2/skins | [Skin\SkinEndpoint][SkinEndpoint]
`GW2Api::skins()` | 📦🌏 /v2/specializations | [Specialization\SpecializationEndpoint][SpecializationEndpoint]
`GW2Api::specializations()` | 📦🌏 /v2/tokeninfo | [Tokeninfo\TokeninfoEndpoint][TokeninfoEndpoint]
`GW2Api::tokeninfo()` | 🔒 - ~~/v2/traits~~ | *disabled* | 🚫 + /v2/traits | [Traits\TraitEndpoint][TraitEndpoint]
`GW2Api::traits()` | 📦🌏 /v2/worlds | [World\WorldEndpoint][WorldEndpoint]
`GW2Api::worlds()` | 📦🌏 ~~/v2/wvw/matches~~ | *disabled* | 🚫 ~~/v2/wvw/objectives~~ | *disabled* | 🚫🌏 @@ -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 diff --git a/src/GW2Api.php b/src/GW2Api.php index 36546e4..27b5e8b 100644 --- a/src/GW2Api.php +++ b/src/GW2Api.php @@ -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; @@ -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 ); } diff --git a/src/V2/Endpoint/Traits/TraitEndpoint.php b/src/V2/Endpoint/Traits/TraitEndpoint.php new file mode 100644 index 0000000..7cdf54e --- /dev/null +++ b/src/V2/Endpoint/Traits/TraitEndpoint.php @@ -0,0 +1,20 @@ +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() ); + } +}