Skip to content

Commit

Permalink
adds inventory endpoints (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Jun 26, 2015
1 parent d2ebfe9 commit 31381e2
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/GW2Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use GW2Treasures\GW2Api\V2\Endpoint\File\FileEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint\Item\ItemEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint\Map\MapEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint\Material\MaterialEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint\Quaggan\QuagganEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint\Recipe\RecipeEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint\Skin\SkinEndpoint;
Expand Down Expand Up @@ -113,6 +114,10 @@ public function maps() {
return new MapEndpoint( $this );
}

public function materials() {
return new MaterialEndpoint( $this );
}

public function quaggans() {
return new QuagganEndpoint( $this );
}
Expand Down
18 changes: 18 additions & 0 deletions src/V2/Endpoint/Account/AccountEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,22 @@ protected function url() {
public function info() {
return $this->request()->json();
}

/**
* Get the account bank.
*
* @return BankEndpoint
*/
public function bank() {
return new BankEndpoint( $this->api, $this->apiKey );
}

/**
* Get the account material storage.
*
* @return MaterialEndpoint
*/
public function materials() {
return new MaterialEndpoint( $this->api, $this->apiKey );
}
}
29 changes: 29 additions & 0 deletions src/V2/Endpoint/Account/BankEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\Account;

use GW2Treasures\GW2Api\GW2Api;
use GW2Treasures\GW2Api\V2\Authentication\AuthenticatedEndpoint;
use GW2Treasures\GW2Api\V2\Authentication\IAuthenticatedEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;

class BankEndpoint extends Endpoint implements IAuthenticatedEndpoint {
use AuthenticatedEndpoint;

public function __construct( GW2Api $api, $apiKey ) {
parent::__construct( $api );

$this->apiKey = $apiKey;
}

/**
* {@inheritdoc}
*/
protected function url() {
return 'v2/account/bank';
}

public function get() {
return $this->request()->json();
}
}
29 changes: 29 additions & 0 deletions src/V2/Endpoint/Account/MaterialEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\Account;

use GW2Treasures\GW2Api\GW2Api;
use GW2Treasures\GW2Api\V2\Authentication\AuthenticatedEndpoint;
use GW2Treasures\GW2Api\V2\Authentication\IAuthenticatedEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;

class MaterialEndpoint extends Endpoint implements IAuthenticatedEndpoint {
use AuthenticatedEndpoint;

public function __construct( GW2Api $api, $apiKey ) {
parent::__construct( $api );

$this->apiKey = $apiKey;
}

/**
* {@inheritdoc}
*/
protected function url() {
return 'v2/account/materials';
}

public function get() {
return $this->request()->json();
}
}
20 changes: 20 additions & 0 deletions src/V2/Endpoint/Character/CharacterEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,24 @@ public function __construct( GW2Api $api, $apiKey ) {
protected function url() {
return 'v2/characters';
}

/**
* Get the equipment of a character.
*
* @param string $character
* @return EquipmentEndpoint
*/
public function equipment( $character ) {
return new EquipmentEndpoint( $this->api, $this->apiKey, $character );
}

/**
* Get the inventory of a character.
*
* @param string $character
* @return InventoryEndpoint
*/
public function inventory( $character ) {
return new InventoryEndpoint( $this->api, $this->apiKey, $character );
}
}
35 changes: 35 additions & 0 deletions src/V2/Endpoint/Character/EquipmentEndpoint.php
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 EquipmentEndpoint 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}
*/
protected function url() {
return 'v2/characters/' . urlencode( $this->character ) . '/equipment';
}

/**
* @return array
*/
public function get() {
return $this->request()->json()->equipment;
}
}
35 changes: 35 additions & 0 deletions src/V2/Endpoint/Character/InventoryEndpoint.php
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 InventoryEndpoint 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}
*/
protected function url() {
return 'v2/characters/' . urlencode( $this->character ) . '/inventory';
}

/**
* @return array
*/
public function get() {
return $this->request()->json()->bags;
}
}
20 changes: 20 additions & 0 deletions src/V2/Endpoint/Material/MaterialEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\Material;

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

/**
* {@inheritdoc}
*/
protected function url() {
return 'v2/materials';
}
}

0 comments on commit 31381e2

Please sign in to comment.