Skip to content

Commit

Permalink
Add esception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jan 28, 2017
1 parent 212ae70 commit d45b467
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/MoneywaveApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Moneywave;


use GuzzleHttp\Exception\RequestException;

abstract class MoneywaveApiClient {

protected $moneywave;
Expand Down Expand Up @@ -41,13 +43,19 @@ public function __set($key, $value)

public function dispatch($method = "POST")
{
try {
$result = $this->moneywave->request($method, $this->url, array(
"form_params" => $this->data,
"headers" => ["Authorization" => $this->moneywave->getToken()]
));
$this->response = json_decode($result->getBody(), true);
$this->responseCode = $result->getStatusCode();
$this->status = $this->response["status"];
$this->response = json_decode($result->getBody(), true);
$this->responseCode = $result->getStatusCode();
$this->status = $this->response["status"];
} catch (RequestException $e) {
$this->responseCode = $e->getCode();
$this->response = $e->getMessage();
$this->status = $e->getMessage();
}
}

public function getResponse()
Expand Down

0 comments on commit d45b467

Please sign in to comment.