1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helix\Shopify; |
4
|
|
|
|
5
|
|
|
use Helix\Shopify\Base\AbstractEntity; |
6
|
|
|
use Helix\Shopify\Base\AbstractEntity\ImmutableInterface; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* A location. |
10
|
|
|
* |
11
|
|
|
* @immutable Cannot be modified via the API. |
12
|
|
|
* |
13
|
|
|
* @see https://shopify.dev/docs/admin-api/rest/reference/inventory/location |
14
|
|
|
* |
15
|
|
|
* @method bool isActive () |
16
|
|
|
* @method string getAddress1 () |
17
|
|
|
* @method string getAddress2 () |
18
|
|
|
* @method string getCity () |
19
|
|
|
* @method string getCountryCode () |
20
|
|
|
* @method string getCreatedAt () |
21
|
|
|
* @method bool isLegacy () |
22
|
|
|
* @method string getLocalizedCountryName () |
23
|
|
|
* @method string getLocalizedProvinceName () |
24
|
|
|
* @method string getName () |
25
|
|
|
* @method string getPhone () |
26
|
|
|
* @method string getProvince () |
27
|
|
|
* @method string getProvinceCode () |
28
|
|
|
* @method string getUpdatedAt () |
29
|
|
|
* @method string getZip () |
30
|
|
|
* |
31
|
|
|
* @method InventoryLevel[] selectInventoryLevels (callable $filter) `fn( InventoryLevel $level ): bool` |
32
|
|
|
*/ |
33
|
|
|
class Location extends AbstractEntity implements ImmutableInterface |
34
|
|
|
{ |
35
|
|
|
|
36
|
|
|
const TYPE = 'location'; |
37
|
|
|
const DIR = 'locations'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return InventoryLevel[] |
41
|
|
|
*/ |
42
|
|
|
public function getInventoryLevels() |
43
|
|
|
{ |
44
|
|
|
$remote = $this->api->get("{$this}/inventory_levels")['inventory_levels'] ?? []; |
45
|
|
|
return $this->api->factoryAll($this, InventoryLevel::class, $remote); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Factory. |
50
|
|
|
* |
51
|
|
|
* @param InventoryItem $item |
52
|
|
|
* @return InventoryLevel |
53
|
|
|
*/ |
54
|
|
|
public function newInventoryLevel(InventoryItem $item) |
55
|
|
|
{ |
56
|
|
|
return $this->api->factory($this, InventoryLevel::class, [ |
57
|
|
|
'location_id' => $this->getId(), |
58
|
|
|
'inventory_item_id' => $item->getId() |
59
|
|
|
]); |
60
|
|
|
} |
61
|
|
|
} |