-
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.
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace GW2Treasures\GW2Api\V2\Endpoint\Tokeninfo; | ||
|
||
use GW2Treasures\GW2Api\GW2Api; | ||
use GW2Treasures\GW2Api\V2\Endpoint; | ||
use GW2Treasures\GW2Api\V2\Authentication\AuthenticatedEndpoint; | ||
use GW2Treasures\GW2Api\V2\Authentication\IAuthenticatedEndpoint; | ||
|
||
class TokeninfoEndpoint extends Endpoint implements IAuthenticatedEndpoint { | ||
use AuthenticatedEndpoint; | ||
|
||
public function __construct( GW2Api $api, $apiKey ) { | ||
parent::__construct( $api ); | ||
|
||
$this->apiKey = $apiKey; | ||
} | ||
|
||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function url() { | ||
return 'v2/tokeninfo'; | ||
} | ||
|
||
/** | ||
* Get info about the used api key. | ||
* | ||
* @return mixed | ||
*/ | ||
public function get() { | ||
return $this->request()->json(); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
class TokeninfoEndpointTest extends TestCase { | ||
public function test() { | ||
$this->mockResponse('{ | ||
"id": "017A2B0C-A6C5-CC4D-A055-680F427CE8FD", | ||
"name": "public key", | ||
"permissions": [ | ||
"account", | ||
"characters" | ||
] | ||
}'); | ||
|
||
$tokeninfo = $this->api()->tokeninfo('api_key')->get(); | ||
$this->assertEquals( 'public key', $tokeninfo->name ); | ||
$this->assertContains( 'characters', $tokeninfo->permissions ); | ||
} | ||
} |