-
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
75 additions
and
32 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,53 @@ | ||
<?php | ||
|
||
namespace GW2Treasures\GW2Api\V2\Endpoint\Commerce\Transaction; | ||
|
||
use GuzzleHttp\Client; | ||
use GW2Treasures\GW2Api\V2\AuthenticatedEndpoint; | ||
use InvalidArgumentException; | ||
|
||
class TypeEndpoint extends AuthenticatedEndpoint { | ||
|
||
protected static $types = [ 'current', 'history' ]; | ||
|
||
/** @var string $type */ | ||
protected $type; | ||
|
||
public function __construct( Client $client, $apiKey, $type, array $options = [ ] ) { | ||
if( !in_array( $type, self::$types )) { | ||
throw new InvalidArgumentException( | ||
'Invalid $type ("' . $type . '""), has to be one of: ' . implode(', ', self::$types) | ||
); | ||
} | ||
|
||
$this->type = $type; | ||
|
||
parent::__construct( $client, $apiKey, $options ); | ||
} | ||
|
||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function url() { | ||
return 'v2/commerce/transactions/' . $this->type; | ||
} | ||
|
||
/** | ||
* Get pending/completed buy transactions. | ||
* | ||
* @return ListEndpoint | ||
*/ | ||
public function buys() { | ||
return new ListEndpoint( $this->getClient(), $this->apiKey, $this->type, 'buys' ); | ||
} | ||
|
||
/** | ||
* Get pending/completed sell transactions. | ||
* | ||
* @return ListEndpoint | ||
*/ | ||
public function sells() { | ||
return new ListEndpoint( $this->getClient(), $this->apiKey, $this->type, 'sells' ); | ||
} | ||
} |