Skip to content

Commit

Permalink
Complete OAuth 2
Browse files Browse the repository at this point in the history
  • Loading branch information
calcinai committed Feb 6, 2020
1 parent 1d938de commit 9ef292b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@
$org = $application->load(\XeroPHP\Models\Accounting\Organisation::class)->execute();
print_r($org);


//$provider->disconnect($token, $tenants[0]->id);
17 changes: 13 additions & 4 deletions src/XeroPHP/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ public function getConfig($key)
/**
* @param string $config
* @param mixed $option
* @param mixed $value
*
* @throws Exception
*
* @return mixed
* @throws Exception
*/
public function getConfigOption($config, $option)
{
Expand Down Expand Up @@ -122,11 +119,23 @@ public function setConfigOption($config, $option, $value)
return $this->config;
}

/**
* @return ClientInterface
*/
public function getTransport()
{
return $this->transport;
}

/**
* @param ClientInterface $client
* @return ClientInterface
*/
public function setTransport(ClientInterface $client)
{
return $this->transport = $client;
}

/**
* Validates and expands the provided model class to a full PHP class.
*
Expand Down
7 changes: 5 additions & 2 deletions src/XeroPHP/Remote/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,18 @@ public function __construct(Application $app, URL $url, $method = self::METHOD_G
* @throws Exception\RateLimitExceededException
* @throws Exception\ReportPermissionMissingException
* @throws Exception\UnauthorizedException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function send()
{
$uri = Uri::withQueryValues(new Uri($this->getUrl()->getFullURL()), $this->getParameters());

$request = new PsrRequest($this->getMethod(), $uri, $this->getHeaders(), $this->body);

$guzzleResponse = $this->app->getTransport()->send($request);
try {
$guzzleResponse = $this->app->getTransport()->send($request);
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
throw new Exception($e->getMessage(), $e->getCode());
}

$this->response = new Response($this,
$guzzleResponse->getBody()->getContents(),
Expand Down

0 comments on commit 9ef292b

Please sign in to comment.