Skip to content

Commit

Permalink
add Interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed May 17, 2015
1 parent e42c028 commit de57eab
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/V2/AuthenticatedEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use GuzzleHttp\Message\ResponseInterface;
use GW2Treasures\GW2Api\V2\Exception\AuthenticationException;
use GW2Treasures\GW2Api\V2\Exception\InvalidPermissionsException;
use GW2Treasures\GW2Api\V2\Interfaces\IAuthenticatedEndpoint;

abstract class AuthenticatedEndpoint extends Endpoint {
abstract class AuthenticatedEndpoint extends Endpoint implements IAuthenticatedEndpoint {
protected $apiKey;

public function __construct( Client $client, $apiKey, array $options = [] ) {
Expand Down
12 changes: 1 addition & 11 deletions src/V2/BulkEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@
use GuzzleHttp\Pool;

trait BulkEndpoint {

/**
* Max page size of this endpoint.
*
* If the base class has the $maxPageSize property it will be used, otherwise defaults to 200.
*
* @return int
*/
protected function maxPageSize() {
return isset( $this->maxPageSize ) ? $this->maxPageSize : 200;
}
use PaginatedEndpoint;


/**
Expand Down
3 changes: 2 additions & 1 deletion src/V2/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use GuzzleHttp\Message\RequestInterface;
use GuzzleHttp\Message\ResponseInterface;
use GW2Treasures\GW2Api\Exception\ApiException;
use GW2Treasures\GW2Api\V2\Interfaces\IEndpoint;

abstract class Endpoint {
abstract class Endpoint implements IEndpoint {
/** @var Client $client */
protected $client;

Expand Down
4 changes: 3 additions & 1 deletion src/V2/Endpoint/Color/ColorEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\ILocalizedEndpoint;
use GW2Treasures\GW2Api\V2\LocalizedEndpoint;

class ColorEndpoint extends Endpoint {
class ColorEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/V2/Endpoint/Commerce/ListingEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;

class ListingEndpoint extends Endpoint {
class ListingEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

protected $supportsIdsAll = false;
Expand Down
3 changes: 2 additions & 1 deletion src/V2/Endpoint/Commerce/PriceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;

class PriceEndpoint extends Endpoint {
class PriceEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

/** @var bool $supportsIdsAll */
Expand Down
4 changes: 3 additions & 1 deletion src/V2/Endpoint/Continent/ContinentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\ILocalizedEndpoint;
use GW2Treasures\GW2Api\V2\LocalizedEndpoint;

class ContinentEndpoint extends Endpoint {
class ContinentEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/V2/Endpoint/File/FileEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;

class FileEndpoint extends Endpoint {
class FileEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/V2/Endpoint/Item/ItemEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\ILocalizedEndpoint;
use GW2Treasures\GW2Api\V2\LocalizedEndpoint;

class ItemEndpoint extends Endpoint {
class ItemEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/** @var bool $supportsIdsAll */
Expand Down
4 changes: 3 additions & 1 deletion src/V2/Endpoint/Map/MapEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\ILocalizedEndpoint;
use GW2Treasures\GW2Api\V2\LocalizedEndpoint;

class MapEndpoint extends Endpoint {
class MapEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/** @var bool $supportsIdsAll */
Expand Down
3 changes: 2 additions & 1 deletion src/V2/Endpoint/Quaggan/QuagganEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;

class QuagganEndpoint extends Endpoint {
class QuagganEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/V2/Endpoint/Recipe/RecipeEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;

class RecipeEndpoint extends Endpoint {
class RecipeEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

/** @var bool $supportsIdsAll */
Expand Down
4 changes: 3 additions & 1 deletion src/V2/Endpoint/Skin/SkinEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\ILocalizedEndpoint;
use GW2Treasures\GW2Api\V2\LocalizedEndpoint;

class SkinEndpoint extends Endpoint {
class SkinEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/** @var bool $supportsIdsAll */
Expand Down
4 changes: 3 additions & 1 deletion src/V2/Endpoint/World/WorldEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use GW2Treasures\GW2Api\V2\Endpoint;
use GW2Treasures\GW2Api\V2\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Interfaces\ILocalizedEndpoint;
use GW2Treasures\GW2Api\V2\LocalizedEndpoint;

class WorldEndpoint extends Endpoint {
class WorldEndpoint extends Endpoint implements IBulkEndpoint, ILocalizedEndpoint {
use BulkEndpoint, LocalizedEndpoint;

/**
Expand Down
5 changes: 5 additions & 0 deletions src/V2/Interfaces/IAuthenticatedEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace GW2Treasures\GW2Api\V2\Interfaces;

interface IAuthenticatedEndpoint extends IEndpoint { }
28 changes: 28 additions & 0 deletions src/V2/Interfaces/IBulkEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace GW2Treasures\GW2Api\V2\Interfaces;

interface IBulkEndpoint extends IPaginatedEndpoint {
/**
* All ids.
*
* @return string[]|int[]
*/
public function ids();

/**
* Single entry by id.
*
* @param $id
* @return mixed
*/
public function get( $id );

/**
* Multiple entries by ids.
*
* @param string[]|int[] $ids
* @return array
*/
public function many( array $ids );
}
5 changes: 5 additions & 0 deletions src/V2/Interfaces/IEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace GW2Treasures\GW2Api\V2\Interfaces;

interface IEndpoint { }
11 changes: 11 additions & 0 deletions src/V2/Interfaces/ILocalizedEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace GW2Treasures\GW2Api\V2\Interfaces;

interface ILocalizedEndpoint {
/**
* @param string $language
* @return $this
*/
function lang( $language );
}
19 changes: 19 additions & 0 deletions src/V2/Interfaces/IPaginatedEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace GW2Treasures\GW2Api\V2\Interfaces;

interface IPaginatedEndpoint extends IEndpoint {
/**
* Max page size of this endpoint.
*
* @return int
*/
function maxPageSize();

/**
* All entries.
*
* @return array
*/
public function all();
}
25 changes: 25 additions & 0 deletions src/V2/PaginatedEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace GW2Treasures\GW2Api\V2;

trait PaginatedEndpoint {
/**
* Max page size of this endpoint.
*
* If the base class has the $maxPageSize property it will be used, otherwise defaults to 200.
*
* @return int
*/
protected function maxPageSize() {
return isset( $this->maxPageSize ) ? $this->maxPageSize : 200;
}

/**
* All entries.
*
* @return array
*/
public function all() {
// TODO: implement
}
}

0 comments on commit de57eab

Please sign in to comment.