From e12905e60cdaf2f1522ed20a013cb07a5de82daf Mon Sep 17 00:00:00 2001 From: Steve Barbera Date: Tue, 27 Jun 2023 13:21:17 -0600 Subject: [PATCH 1/3] Added the Gift Card Adjustment Resource --- README.md | 1 + lib/GiftCard.php | 9 ++++++++- lib/GiftCardAdjustment.php | 20 ++++++++++++++++++++ lib/ShopifySDK.php | 3 +++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 lib/GiftCardAdjustment.php diff --git a/README.md b/README.md index e823a6c..bc11ba7 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,7 @@ Some resources are available directly, some resources are only available through - FulfillmentOrder -> [FulfillmentRequest](https://shopify.dev/api/admin-rest/2023-01/resources/fulfillmentrequest) - FulfillmentOrder -> [Fulfillment](https://shopify.dev/api/admin-rest/2023-01/resources/fulfillment) - [GiftCard](https://help.shopify.com/api/reference/gift_card) _(Shopify Plus Only)_ +- [GiftCardAdjustment](https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment) _(Shopify Plus Only)_ - [InventoryItem](https://help.shopify.com/api/reference/inventoryitem) - [InventoryLevel](https://help.shopify.com/api/reference/inventorylevel) - [Location](https://help.shopify.com/api/reference/location/) _(read only)_ diff --git a/lib/GiftCard.php b/lib/GiftCard.php index 2391064..07d5428 100644 --- a/lib/GiftCard.php +++ b/lib/GiftCard.php @@ -45,4 +45,11 @@ public function disable() return $this->post($dataArray, $url); } -} \ No newline at end of file + + /** + * @inheritDoc + */ + protected $childResource = array( + 'GiftCardAdjustment' => 'Adjustment' + ); +} diff --git a/lib/GiftCardAdjustment.php b/lib/GiftCardAdjustment.php new file mode 100644 index 0000000..066642d --- /dev/null +++ b/lib/GiftCardAdjustment.php @@ -0,0 +1,20 @@ + + * Created at: 8/21/16 8:39 AM UTC+06:00 + * + * @see https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment Shopify API Reference for Gift Card Adjustment + * @note - requires gift_card_adjustments access scope enabled by Shopify Support + */ + +namespace PHPShopify; + + +class GiftCardAdjustment extends ShopifyResource +{ + /** + * @inheritDoc + */ + protected $resourceKey = 'adjustment'; +} diff --git a/lib/ShopifySDK.php b/lib/ShopifySDK.php index f10caea..36af40b 100644 --- a/lib/ShopifySDK.php +++ b/lib/ShopifySDK.php @@ -90,6 +90,7 @@ * @property-read Fulfillment $Fulfillment * @property-read FulfillmentService $FulfillmentService * @property-read GiftCard $GiftCard + * @property-read GiftCardAdjustment $GiftCardAdjustment * @property-read InventoryItem $InventoryItem * @property-read InventoryLevel $InventoryLevel * @property-read Location $Location @@ -140,6 +141,7 @@ * @method FulfillmentService FulfillmentService(integer $id = null) * @method FulfillmentOrder FulfillmentOrder(integer $id = null) * @method GiftCard GiftCard(integer $id = null) + * @method GiftCardAdjustment GiftCardAdjustment(integer $id = null) * @method InventoryItem InventoryItem(integer $id = null) * @method InventoryLevel InventoryLevel(integer $id = null) * @method Location Location(integer $id = null) @@ -261,6 +263,7 @@ class ShopifySDK 'Dispute' => 'ShopifyPayment', 'Fulfillment' => 'Order', 'FulfillmentEvent' => 'Fulfillment', + 'GiftCardAdjustment'=> 'GiftCard', 'OrderRisk' => 'Order', 'Payouts' => 'ShopifyPayment', 'ProductImage' => 'Product', From 7a52f6af5f381785b028f774131466531539d4b1 Mon Sep 17 00:00:00 2001 From: Steve Barbera Date: Tue, 27 Jun 2023 13:37:48 -0600 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc11ba7..8459ff7 100644 --- a/README.md +++ b/README.md @@ -357,7 +357,7 @@ Some resources are available directly, some resources are only available through - FulfillmentOrder -> [FulfillmentRequest](https://shopify.dev/api/admin-rest/2023-01/resources/fulfillmentrequest) - FulfillmentOrder -> [Fulfillment](https://shopify.dev/api/admin-rest/2023-01/resources/fulfillment) - [GiftCard](https://help.shopify.com/api/reference/gift_card) _(Shopify Plus Only)_ -- [GiftCardAdjustment](https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment) _(Shopify Plus Only)_ +- GiftCard -> [Adjustment](https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment) _(Shopify Plus Only)_ - [InventoryItem](https://help.shopify.com/api/reference/inventoryitem) - [InventoryLevel](https://help.shopify.com/api/reference/inventorylevel) - [Location](https://help.shopify.com/api/reference/location/) _(read only)_ From 589ebb808bd363a54dd6016f7e76edf62231940a Mon Sep 17 00:00:00 2001 From: Steve Barbera Date: Tue, 27 Jun 2023 13:49:43 -0600 Subject: [PATCH 3/3] added usage to the GiftCardAdjustment class --- lib/GiftCardAdjustment.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/GiftCardAdjustment.php b/lib/GiftCardAdjustment.php index 066642d..933f54b 100644 --- a/lib/GiftCardAdjustment.php +++ b/lib/GiftCardAdjustment.php @@ -6,6 +6,26 @@ * * @see https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment Shopify API Reference for Gift Card Adjustment * @note - requires gift_card_adjustments access scope enabled by Shopify Support + * + * @usage: + * + $shopify = \PHPShopify\ShopifySDK::config($config); + + $gift_card_id = 88888888888; + + $gift_card_adjustment_id = 999999999999; + + // Get all gift card adjustments + $shopify->GiftCard($gift_card_id)->Adjustment()->get(); + + // Get a single gift card adjustment + $shopify->GiftCard($gift_card_id)->Adjustment($gift_card_adjustment_id)->get(); + + // Create a gift card adjustment + $shopify->GiftCard($gift_card_id)->Adjustment()->post([ + 'amount' => 5, + 'note' => 'Add $5 to gift card' + ]); */ namespace PHPShopify;