Skip to content

Commit

Permalink
Add Client::useSandbox().
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed May 23, 2019
1 parent e95323b commit 8da0e9e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "0.2-dev"
}
},
"config": {
Expand Down
12 changes: 11 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,24 @@ public static function fromAccessToken(string $accessToken)
return static::make(null, null)->setAccessToken($accessToken);
}

/**
* Use sandbox environment.
*
* @return $this
*/
final public function useSandbox(): self
{
return $this->useCustomApiEndpoint('https://api.insure-staging.katsanalabs.com');
}

/**
* Authenticate helper using OAuth2.
*
* @param string $scope
*
* @return \Laravie\Codex\Contracts\Response
*/
public function authenticate(string $scope = '*'): ResponseContract
final public function authenticate(string $scope = '*'): ResponseContract
{
return $this->via(new ClientCredentialsGrant())->authenticate();
}
Expand Down
9 changes: 9 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

class ClientTest extends TestCase
{
/** @test */
public function it_can_set_endpoint_to_sandbox()
{
$client = $this->makeClient(Faker::create());
$client->useSandbox();

$this->assertSame('https://api.insure-staging.katsanalabs.com', $client->getApiEndpoint());
}

/** @test */
public function it_can_authenticate_using_passport()
{
Expand Down

0 comments on commit 8da0e9e

Please sign in to comment.