Skip to content

Commit e495a2f

Browse files
committed
Support InventoryItem and InventoryLevel
1 parent a2590eb commit e495a2f

File tree

5 files changed

+59
-3
lines changed

5 files changed

+59
-3
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ Some resources are available directly, some resources are only available through
254254
- [Event](https://help.shopify.com/api/reference/event/)
255255
- [FulfillmentService](https://help.shopify.com/api/reference/fulfillmentservice)
256256
- [GiftCard](https://help.shopify.com/api/reference/gift_card) _(Shopify Plus Only)_
257+
- [InventoryItem](https://help.shopify.com/api/reference/inventoryitem)
258+
- [InventoryLevel](https://help.shopify.com/api/reference/inventorylevel)
257259
- [Location](https://help.shopify.com/api/reference/location/) _(read only)_
258260
- [Metafield](https://help.shopify.com/api/reference/metafield)
259261
- [Multipass](https://help.shopify.com/api/reference/multipass) _(Shopify Plus Only, API not available yet)_
@@ -358,6 +360,14 @@ The custom methods are specific to some resources which may not be available for
358360
- [search()](https://help.shopify.com/api/reference/gift_card#search)
359361
Search for gift cards matching supplied query
360362

363+
- InventoryLevel ->
364+
- [adjust($data)](https://help.shopify.com/api/reference/inventorylevel#adjust)
365+
Adjust inventory level.
366+
- [connect($data)](https://help.shopify.com/api/reference/inventorylevel#connect)
367+
Connect an inventory item to a location.
368+
- [set($data)](https://help.shopify.com/api/reference/inventorylevel#set)
369+
Set an inventory level for a single inventory item within a location.
370+
361371
- Order ->
362372
- [close()](https://help.shopify.com/api/reference/order#close)
363373
Close an Order

lib/InventoryItem.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* @author Arsenii Lozytskyi <[email protected]>
4+
* Created at 04/15/18 02:25 PM UTC+03:00
5+
*
6+
* @see https://help.shopify.com/api/reference/inventoryitem
7+
*/
8+
9+
namespace PHPShopify;
10+
11+
class InventoryItem extends ShopifyResource
12+
{
13+
/** @inheritDoc */
14+
protected $resourceKey = 'inventory_item';
15+
}

lib/InventoryLevel.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* @author Arsenii Lozytskyi <[email protected]>
4+
* Created at 04/15/18 02:31 PM UTC+03:00
5+
*
6+
* @see https://help.shopify.com/api/reference/inventorylevel
7+
*/
8+
9+
namespace PHPShopify;
10+
11+
/**
12+
* Class InventoryLevel
13+
*
14+
* @method array adjust($data) Adjust inventory level.
15+
* @method array connect($data) Connect an inventory item to a location.
16+
* @method array set($data) Sets an inventory level for a single inventory item within a location.
17+
*/
18+
class InventoryLevel extends ShopifyResource
19+
{
20+
/** @inheritDoc */
21+
protected $resourceKey = 'inventory_level';
22+
23+
/** @inheritDoc */
24+
protected $customPostActions = [
25+
'adjust',
26+
'connect',
27+
'set',
28+
];
29+
}

lib/ShopifyResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract class ShopifyResource
4848

4949
/**
5050
* List of child Resource names / classes
51-
*
51+
*
5252
* If any array item has an associative key => value pair, value will be considered as the resource name
5353
* (by which it will be called) and key will be the associated class name.
5454
*
@@ -498,4 +498,4 @@ public function processResponse($responseArray, $dataKey = null)
498498
return $responseArray;
499499
}
500500
}
501-
}
501+
}

lib/ShopifySDK.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class ShopifySDK
102102
'Event',
103103
'FulfillmentService',
104104
'GiftCard',
105+
'InventoryItem',
106+
'InventoryLevel',
105107
'Location',
106108
'Metafield',
107109
'Multipass',
@@ -296,4 +298,4 @@ public static function checkApiCallLimit($firstCallWait = false)
296298

297299
static::$microtimeOfLastApiCall = microtime(true);
298300
}
299-
}
301+
}

0 commit comments

Comments
 (0)