Skip to content

Commit

Permalink
Merge pull request #299 from whobutsb/feature/giftcard-adjustments
Browse files Browse the repository at this point in the history
Gift Card Adjustment Resource
  • Loading branch information
tareqtms authored Jun 28, 2023
2 parents eb26e68 + 589ebb8 commit c0103f9
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)_
- 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)_
Expand Down
9 changes: 8 additions & 1 deletion lib/GiftCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ public function disable()

return $this->post($dataArray, $url);
}
}

/**
* @inheritDoc
*/
protected $childResource = array(
'GiftCardAdjustment' => 'Adjustment'
);
}
40 changes: 40 additions & 0 deletions lib/GiftCardAdjustment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Created by PhpStorm.
* @author Tareq Mahmood <[email protected]>
* 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
*
* @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;


class GiftCardAdjustment extends ShopifyResource
{
/**
* @inheritDoc
*/
protected $resourceKey = 'adjustment';
}
3 changes: 3 additions & 0 deletions lib/ShopifySDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -261,6 +263,7 @@ class ShopifySDK
'Dispute' => 'ShopifyPayment',
'Fulfillment' => 'Order',
'FulfillmentEvent' => 'Fulfillment',
'GiftCardAdjustment'=> 'GiftCard',
'OrderRisk' => 'Order',
'Payouts' => 'ShopifyPayment',
'ProductImage' => 'Product',
Expand Down

0 comments on commit c0103f9

Please sign in to comment.