Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gift Card Adjustment Resource #299

Merged
merged 3 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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