Skip to content

Commit

Permalink
use guzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Mar 23, 2015
1 parent 6538811 commit 9bd68ef
Show file tree
Hide file tree
Showing 18 changed files with 260 additions and 383 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require": {
"php": ">=5.4.0",
"chuyskywalker/rolling-curl": "~3.1"
"guzzlehttp/guzzle": "~5.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5"
Expand Down
218 changes: 151 additions & 67 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 6 additions & 12 deletions src/Endpoint/AuthenticatedEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@

namespace GW2Treasures\GW2Api\Endpoint;

use GW2Treasures\GW2Api\Request\RequestManager;
use GuzzleHttp\Client;

abstract class AuthenticatedEndpoint extends Endpoint {
protected $_token;

public function __construct( RequestManager $requestManager, $token ) {
parent::__construct( $requestManager );
public function __construct( Client $client, $token, array $options = [] ) {
parent::__construct( $client, $options );
$this->_token = $token;
}

/**
* {@inheritdoc}
*/
protected function request( array $query = [] ) {
return $this->requestManager->request( $this->url(), $query, ['Authorization' => 'Bearer ' . $this->_token ]);
}

/**
* {@inheritdoc}
*/
protected function requestMany( array $queries ) {
return $this->requestManager->request( $this->url(), $queries, ['Authorization' => 'Bearer ' . $this->_token ]);
protected function createRequest( array $query = [], $url = null, $method = 'GET', $options = [] ) {
$options = [ 'headers' => [ 'Authorization' => 'Bearer ' . $this->_token ]] + $options;
return parent::createRequest( $query, $url, $method, $options );
}
}
Loading

0 comments on commit 9bd68ef

Please sign in to comment.