diff --git a/lib/GraphQL.php b/lib/GraphQL.php index 7d49d25..185593b 100644 --- a/lib/GraphQL.php +++ b/lib/GraphQL.php @@ -11,6 +11,8 @@ namespace PHPShopify; +use PHPShopify\Exception\ApiException; +use PHPShopify\Exception\CurlException; use PHPShopify\Exception\SdkException; class GraphQL extends ShopifyResource @@ -33,6 +35,8 @@ protected function getResourcePath() * @param array|null $variables * * @uses HttpRequestGraphQL::post() to send the HTTP request + * @throws ApiException if the response has an error specified + * @throws CurlException if response received with unexpected HTTP code. * * @return array */ @@ -47,6 +51,7 @@ public function post($graphQL, $url = null, $wrapData = false, $variables = null /** * @inheritdoc + * @throws SdkException */ public function get($urlParams = array(), $url = null, $dataKey = null) { @@ -55,6 +60,7 @@ public function get($urlParams = array(), $url = null, $dataKey = null) /** * @inheritdoc + * @throws SdkException */ public function put($dataArray, $url = null, $wrapData = true) { @@ -63,6 +69,7 @@ public function put($dataArray, $url = null, $wrapData = true) /** * @inheritdoc + * @throws SdkException */ public function delete($urlParams = array(), $url = null) { diff --git a/lib/HttpRequestJson.php b/lib/HttpRequestJson.php index ee8372a..ceab78f 100644 --- a/lib/HttpRequestJson.php +++ b/lib/HttpRequestJson.php @@ -62,7 +62,7 @@ protected static function prepareRequest($httpHeaders = array(), $dataArray = ar * @param string $url * @param array $httpHeaders * - * @return string + * @return array */ public static function get($url, $httpHeaders = array()) { @@ -80,7 +80,7 @@ public static function get($url, $httpHeaders = array()) * @param array $dataArray * @param array $httpHeaders * - * @return string + * @return array */ public static function post($url, $dataArray, $httpHeaders = array()) { @@ -98,7 +98,7 @@ public static function post($url, $dataArray, $httpHeaders = array()) * @param array $dataArray * @param array $httpHeaders * - * @return string + * @return array */ public static function put($url, $dataArray, $httpHeaders = array()) { @@ -115,7 +115,7 @@ public static function put($url, $dataArray, $httpHeaders = array()) * @param string $url * @param array $httpHeaders * - * @return string + * @return array */ public static function delete($url, $httpHeaders = array()) { diff --git a/lib/ShopifyResource.php b/lib/ShopifyResource.php index e8f6542..8d7be10 100644 --- a/lib/ShopifyResource.php +++ b/lib/ShopifyResource.php @@ -302,6 +302,9 @@ public function generateUrl($urlParams = array(), $customAction = null) * * @uses HttpRequestJson::get() to send the HTTP request * + * @throws ApiException if the response has an error specified + * @throws CurlException if response received with unexpected HTTP code. + * * @return array */ public function get($urlParams = array(), $url = null, $dataKey = null) @@ -321,6 +324,10 @@ public function get($urlParams = array(), $url = null, $dataKey = null) * * @param array $urlParams Check Shopify API reference of the specific resource for the list of URL parameters * + * @throws SdkException + * @throws ApiException if the response has an error specified + * @throws CurlException if response received with unexpected HTTP code. + * * @return integer */ public function count($urlParams = array()) @@ -340,6 +347,8 @@ public function count($urlParams = array()) * @param mixed $query * * @throws SdkException if search is not enabled for the resouce + * @throws ApiException if the response has an error specified + * @throws CurlException if response received with unexpected HTTP code. * * @return array */ @@ -365,6 +374,9 @@ public function search($query) * * @uses HttpRequestJson::post() to send the HTTP request * + * @throws ApiException if the response has an error specified + * @throws CurlException if response received with unexpected HTTP code. + * * @return array */ public function post($dataArray, $url = null, $wrapData = true) @@ -387,6 +399,9 @@ public function post($dataArray, $url = null, $wrapData = true) * * @uses HttpRequestJson::put() to send the HTTP request * + * @throws ApiException if the response has an error specified + * @throws CurlException if response received with unexpected HTTP code. + * * @return array */ public function put($dataArray, $url = null, $wrapData = true) @@ -409,6 +424,9 @@ public function put($dataArray, $url = null, $wrapData = true) * * @uses HttpRequestJson::delete() to send the HTTP request * + * @throws ApiException if the response has an error specified + * @throws CurlException if response received with unexpected HTTP code. + * * @return array an empty array will be returned if the request is successfully completed */ public function delete($urlParams = array(), $url = null) @@ -493,7 +511,7 @@ public function processResponse($responseArray, $dataKey = null) if (isset($responseArray['errors'])) { $message = $this->castString($responseArray['errors']); - throw new ApiException($message); + throw new ApiException($message, CurlRequest::$lastHttpCode); } if ($dataKey && isset($responseArray[$dataKey])) {