Skip to content

Commit a1e87dc

Browse files
committed
Merge remote-tracking branch 'origin/access' into laravel52
2 parents a6c5a27 + 3f63377 commit a1e87dc

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Api.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use GuzzleHttp\Client;
1212
use GuzzleHttp\Exception\ConnectException;
1313
use GuzzleHttp\Exception\RequestException;
14+
use GuzzleHttp\Psr7\Response;
1415
use League\CLImate\CLImate;
1516
use League\CLImate\Util\Writer\File;
1617
use League\CLImate\Util\Writer\WriterInterface;
@@ -20,6 +21,7 @@ class Api {
2021

2122
protected $config;
2223
protected $http;
24+
protected $lastResponse;
2325

2426
/**
2527
* @param $config array|string|\Fulfillment\Api\Contracts\ApiConfiguration|null
@@ -155,9 +157,12 @@ public function config()
155157

156158
protected function tryRequest($method, $url, $payload = null, $queryString = null, $firstTry = true)
157159
{
160+
$this->lastResponse = null;
158161
try
159162
{
160-
return $this->http->makeRequest($method, $url, $payload, $queryString);
163+
$resultArr = $this->http->makeRequest($method, $url, $payload, $queryString);
164+
$this->lastResponse = $resultArr['response'];
165+
return $resultArr['result'];
161166
}
162167
catch (ConnectException $c)
163168
{
@@ -274,4 +279,14 @@ public function delete($url, $queryString = null)
274279
{
275280
return $this->tryRequest('delete', $url, null, $queryString);
276281
}
282+
283+
/**
284+
* Get the Response object from the last successful request
285+
*
286+
* @return Response|null
287+
*/
288+
public function getLastResponse()
289+
{
290+
return $this->lastResponse;
291+
}
277292
}

src/Http/Request.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ function makeRequest($method, $url, $apiRequest = null, $queryString = null)
168168
}
169169
}
170170

171-
return $result;
172-
171+
// can't use tuple here because might be using php 5 or 7
172+
// and list expansion is reversed depending on which is used
173+
return ['result' => $result, 'response' => $response];
173174
}
174175
catch (ConnectException $c)
175176
{

0 commit comments

Comments
 (0)