diff --git a/demo/errorResponse.php b/demo/errorResponse.php new file mode 100644 index 00000000..b290b684 --- /dev/null +++ b/demo/errorResponse.php @@ -0,0 +1,64 @@ +platform(); + $platform->login(["jwt" => $credentials['RC_JWT']]); + + $r = $platform->get("/restapi/v1.0/account/23/extension/{$extensionId}/call-log", $queryParams); + + echo $r->text(); + + echo "\n"; +} +function successfulResponse() +{ + $credentials = require (__DIR__ . '/_credentials.php'); + $accountId = '~'; + $extensionId = '~'; + $queryParams = array( + ); + $rcsdk = new SDK($credentials['clientId'], $credentials['clientSecret'], $credentials['server'], 'Demo', '1.0.0'); + + $platform = $rcsdk->platform(); + $platform->login(["jwt" => $credentials['RC_JWT']]); + + $r = $platform->get("/restapi/v1.0/account/{$accountId}/extension/{$extensionId}/call-log", $queryParams); + + echo $r->text(); + + echo "\n"; +} +/* +function errorResponseDeleteMethod() +{ + $credentials = require (__DIR__ . '/_credentials.php'); + $accountId = '~'; + $extensionId = '~'; + $queryParams = array( + 'dateTo' => 'sss' + ); + $rcsdk = new SDK($credentials['clientId'], $credentials['clientSecret'], $credentials['server'], 'Demo', '1.0.0'); + + $platform = $rcsdk->platform(); + $platform->login(["jwt" => $credentials['RC_JWT']]); + + $r = $platform->delete("/restapi/v1.0/account/{$accountId}/extension/{$extensionId}/call-log", $queryParams); + + echo $r->text(); + + echo "\n"; +}*/ +successfulResponse(); +errorResponse(); \ No newline at end of file diff --git a/src/Http/Client.php b/src/Http/Client.php index e3b335a7..9418f4cd 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -71,7 +71,7 @@ protected function loadResponse(RequestInterface $request) $request->getBody()->rewind(); } - $response = $this->_guzzle->send($request, ['exceptions' => false]); + $response = $this->_guzzle->send($request, ['http_errors' => false, 'exceptions' => false]); return new ApiResponse($request, $response); @@ -127,16 +127,16 @@ protected function parseProperties($method, $url, $queryParams = [], $body = nul $query = ""; if (!empty($queryParams) && is_array($queryParams)) { foreach ($queryParams as $key => $value) { - if (is_array($value)){ - foreach ($value as $val) { - $query .= $key."=".urlencode($val)."&"; + if (is_array($value)) { + foreach ($value as $val) { + $query .= $key . "=" . urlencode($val) . "&"; + } + } else { + $query .= $key . "=" . urlencode($value) . "&"; } - }else{ - $query .= $key."=".urlencode($value)."&"; - } } } - $query = rtrim($query,'&'); + $query = rtrim($query, '&'); if ($query != "") { $url = $url . (stristr($url, '?') ? '&' : '?') . $query; } @@ -188,10 +188,10 @@ protected function parseProperties($method, $url, $queryParams = [], $body = nul // Create request return [ - 'method' => $method, - 'url' => $url, + 'method' => $method, + 'url' => $url, 'headers' => $headers, - 'body' => $body, + 'body' => $body, ]; }