Skip to content

Commit

Permalink
Merge pull request #18 from jcroll/apiChange
Browse files Browse the repository at this point in the history
[RFC] Change method addToken() to setToken()
  • Loading branch information
jcroll authored Sep 7, 2016
2 parents e4d22aa + e7b0c8f commit de82465
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $client = FoursquareClient::factory([
'mode' => 'foursquare', // optional (one of 'foursquare' or 'swarm')
]);

$client->addToken($oauthToken); // optionally pass in for user specific requests
$client->setToken($oauthToken); // optionally pass in for user specific requests

$client->setMode('swarm'); // switch from mode 'foursquare' to 'swarm'

Expand Down
14 changes: 13 additions & 1 deletion src/Client/FoursquareClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,25 @@ public static function factory($config = [])
*
* @return $this
*/
public function addToken($token)
public function setToken($token)
{
$this->getHttpClient()->setDefaultOption('query/oauth_token', $token);

return $this;
}

/**
* @param string $token
*
* @return $this
*
* @deprecated since version 2.1. Use setToken() instead.
*/
public function addToken($token)
{
return $this->setToken($token);
}

/**
* @param string $mode
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Client/FoursquareClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testAddToken($clientId, $clientSecret)
$token = 'secretToken';

$client = FoursquareClient::factory($config);
$client->addToken($token);
$client->setToken($token);

$defaultOptions = $client->getHttpClient()->getDefaultOption('query');

Expand Down

0 comments on commit de82465

Please sign in to comment.