-
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 #111 from GW2Treasures/endpoints/home
Add /v2/home endpoints
- Loading branch information
Showing
6 changed files
with
130 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
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 | ||
|
||
namespace GW2Treasures\GW2Api\V2\Endpoint\Home; | ||
|
||
use GW2Treasures\GW2Api\V2\Bulk\BulkEndpoint; | ||
use GW2Treasures\GW2Api\V2\Bulk\IBulkEndpoint; | ||
use GW2Treasures\GW2Api\V2\Endpoint; | ||
|
||
class CatEndpoint extends Endpoint implements IBulkEndpoint { | ||
use BulkEndpoint; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function url() { | ||
return 'v2/home/cats'; | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace GW2Treasures\GW2Api\V2\Endpoint\Home; | ||
|
||
use GW2Treasures\GW2Api\V2\Endpoint; | ||
|
||
class HomeEndpoint extends Endpoint { | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function url() { | ||
return 'v2/home'; | ||
} | ||
|
||
public function cats() { | ||
return new CatEndpoint( $this->api ); | ||
} | ||
|
||
public function nodes() { | ||
return new NodeEndpoint( $this->api ); | ||
} | ||
} |
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 | ||
|
||
namespace GW2Treasures\GW2Api\V2\Endpoint\Home; | ||
|
||
use GW2Treasures\GW2Api\V2\Bulk\BulkEndpoint; | ||
use GW2Treasures\GW2Api\V2\Bulk\IBulkEndpoint; | ||
use GW2Treasures\GW2Api\V2\Endpoint; | ||
|
||
class NodeEndpoint extends Endpoint implements IBulkEndpoint { | ||
use BulkEndpoint; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function url() { | ||
return 'v2/home/nodes'; | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
class HomeEndpointTest extends TestCase { | ||
public function testMounts() { | ||
$endpoint = $this->api()->home(); | ||
|
||
$this->assertEndpointUrl( 'v2/home', $endpoint ); | ||
} | ||
|
||
public function testHomeCats() { | ||
$endpoint = $this->api()->home()->cats(); | ||
|
||
$this->assertEndpointIsBulk( $endpoint ); | ||
$this->assertEndpointUrl( 'v2/home/cats', $endpoint ); | ||
|
||
$this->mockResponse('{"hint":"chicken","id":1}'); | ||
$this->assertEquals('chicken', $endpoint->get(1)->hint); | ||
} | ||
|
||
public function testHomeNodes() { | ||
$endpoint = $this->api()->home()->nodes(); | ||
|
||
$this->assertEndpointIsBulk( $endpoint ); | ||
$this->assertEndpointUrl( 'v2/home/nodes', $endpoint ); | ||
|
||
$this->mockResponse('{"id":"advanced_cloth_rack"}'); | ||
$this->assertEquals('advanced_cloth_rack', $endpoint->get('advanced_cloth_rack')->id); | ||
} | ||
} |