-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from GW2Treasures/endpoints/character-speciali…
…zations Add /v2/characters/:id/specializations endpoint
- Loading branch information
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace GW2Treasures\GW2Api\V2\Endpoint\Character; | ||
|
||
use GW2Treasures\GW2Api\GW2Api; | ||
use GW2Treasures\GW2Api\V2\Authentication\AuthenticatedEndpoint; | ||
use GW2Treasures\GW2Api\V2\Authentication\IAuthenticatedEndpoint; | ||
use GW2Treasures\GW2Api\V2\Endpoint; | ||
|
||
class SpecializationEndpoint extends Endpoint implements IAuthenticatedEndpoint { | ||
use AuthenticatedEndpoint; | ||
|
||
protected $character; | ||
|
||
public function __construct( GW2Api $api, $apiKey, $character ) { | ||
parent::__construct( $api ); | ||
|
||
$this->apiKey = $apiKey; | ||
$this->character = $character; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function url() { | ||
return 'v2/characters/' . rawurlencode( $this->character ) . '/specializations'; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function get() { | ||
return $this->request()->json()->specializations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace V2; | ||
|
||
use TestCase; | ||
|
||
class SpecializationEquipmentEndpointTest extends TestCase { | ||
public function test() { | ||
$endpoint = $this->api()->characters('test')->specializations('char'); | ||
|
||
$this->assertEndpointIsAuthenticated( $endpoint ); | ||
$this->assertEndpointUrl( 'v2/characters/char/specializations', $endpoint ); | ||
|
||
$this->mockResponse('{"specializations":{"pve":[{"id":41,"traits":[232,214,226]}]}}'); | ||
$this->assertEquals(41, $endpoint->get()->pve[0]->id); | ||
} | ||
|
||
public function testCharacterNameEncoding() { | ||
$endpoint = $this->api()->characters('test')->equipment('Character Namè'); | ||
|
||
$this->assertEndpointUrl( 'v2/characters/Character%20Nam%C3%A8/equipment', $endpoint ); | ||
} | ||
} |