From 270b7dd1d62c9fce3d64ad339913d8ec6311574b Mon Sep 17 00:00:00 2001 From: Victor Kislichenko Date: Mon, 1 Jun 2020 22:35:17 +0300 Subject: [PATCH] added ShopifyPayment Dispute resource --- README.md | 2 ++ lib/Dispute.php | 30 ++++++++++++++++++++++++++++++ lib/ShopifyPayment.php | 35 +++++++++++++++++++++++++++++++++++ lib/ShopifyResource.php | 2 +- lib/ShopifySDK.php | 2 ++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 lib/Dispute.php create mode 100644 lib/ShopifyPayment.php diff --git a/README.md b/README.md index a507d8a..a48fd44 100644 --- a/README.md +++ b/README.md @@ -359,6 +359,8 @@ Some resources are available directly, some resources are only available through - [Shop](https://help.shopify.com/api/reference/shop) _(read only)_ - [SmartCollection](https://help.shopify.com/api/reference/smartcollection) - SmartCollection -> [Event](https://help.shopify.com/api/reference/event/) +- [ShopifyPayment](https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/) +- ShopifyPayment -> [Dispute](https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/dispute/) _(read only)_ - [Theme](https://help.shopify.com/api/reference/theme) - Theme -> [Asset](https://help.shopify.com/api/reference/asset/) - [User](https://help.shopify.com/api/reference/user) _(read only, Shopify Plus Only)_ diff --git a/lib/Dispute.php b/lib/Dispute.php new file mode 100644 index 0000000..e769872 --- /dev/null +++ b/lib/Dispute.php @@ -0,0 +1,30 @@ + + * Created at 01/06/2020 16:45 AM UTC+03:00 + * + * @see https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/dispute Shopify API Reference for Dispute + */ + +namespace PHPShopify; + + +/** + * -------------------------------------------------------------------------- + * ShopifyPayment -> Child Resources + * -------------------------------------------------------------------------- + * @property-read ShopifyResource $DiscountCode + * + * @method ShopifyResource DiscountCode(integer $id = null) + * + */ +class Dispute extends ShopifyResource +{ + /** + * @inheritDoc + */ + public $resourceKey = 'dispute'; + + +} \ No newline at end of file diff --git a/lib/ShopifyPayment.php b/lib/ShopifyPayment.php new file mode 100644 index 0000000..a6da406 --- /dev/null +++ b/lib/ShopifyPayment.php @@ -0,0 +1,35 @@ + + * Created at 01/06/2020 16:45 AM UTC+03:00 + * + * @see https://shopify.dev/docs/admin-api/rest/reference/shopify_payments Shopify API Reference for ShopifyPayment + */ + +namespace PHPShopify; + + +/** + * -------------------------------------------------------------------------- + * ShopifyPayment -> Child Resources + * -------------------------------------------------------------------------- + * @property-read ShopifyResource $Dispute + * + * @method ShopifyResource Dispute(integer $id = null) + * + */ +class ShopifyPayment extends ShopifyResource +{ + /** + * @inheritDoc + */ + public $resourceKey = 'shopify_payment'; + + /** + * @inheritDoc + */ + protected $childResource = array( + 'Dispute' + ); +} \ No newline at end of file diff --git a/lib/ShopifyResource.php b/lib/ShopifyResource.php index 66ce2b7..5e4ca00 100644 --- a/lib/ShopifyResource.php +++ b/lib/ShopifyResource.php @@ -530,7 +530,7 @@ public function processResponse($responseArray, $dataKey = null) $httpCode = CurlRequest::$lastHttpCode; if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated && $httpCode != $httpDeleted) { - throw new Exception\CurlException("Request failed with HTTP Code $httpCode."); + throw new Exception\CurlException("Request failed with HTTP Code $httpCode.", $httpCode); } } diff --git a/lib/ShopifySDK.php b/lib/ShopifySDK.php index 1d9276d..94dbe81 100644 --- a/lib/ShopifySDK.php +++ b/lib/ShopifySDK.php @@ -104,6 +104,7 @@ * @property-read ShippingZone $ShippingZone * @property-read Shop $Shop * @property-read SmartCollection $SmartCollection + * @property-read ShopifyPayment $ShopifyPayment * @property-read Theme $Theme * @property-read User $User * @property-read Webhook $Webhook @@ -196,6 +197,7 @@ class ShopifySDK 'ShippingZone', 'Shop', 'SmartCollection', + 'ShopifyPayment', 'Theme', 'User', 'Webhook',