@@ -55,15 +55,15 @@ |
||
55 | 55 | 'payment_details' => [Payment::class, 'toData'] |
56 | 56 | ]; |
57 | 57 | |
58 | - final protected static function getType (): string { |
|
58 | + final protected static function getType(): string { |
|
59 | 59 | return 'transaction'; |
60 | 60 | } |
61 | 61 | |
62 | - final public function __toString (): string { |
|
62 | + final public function __toString(): string { |
|
63 | 63 | return "{$this->getDir()}/{$this->getId()}"; |
64 | 64 | } |
65 | 65 | |
66 | - final protected function getDir (): string { |
|
66 | + final protected function getDir(): string { |
|
67 | 67 | return "orders/{$this->getOrderId()}/transactions"; |
68 | 68 | } |
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -56,7 +56,7 @@ |
||
56 | 56 | /** |
57 | 57 | * @return Tax |
58 | 58 | */ |
59 | - public function newTax () { |
|
59 | + public function newTax() { |
|
60 | 60 | return $this->data['tax_lines']->add(Tax::toData($this, [])); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | \ No newline at end of file |
@@ -88,30 +88,30 @@ discard block |
||
88 | 88 | 'prerequisite_to_entitlement_quantity_ratio' => ['toData', Ratio::class] |
89 | 89 | ]; |
90 | 90 | |
91 | - final protected static function getSearchPath (): string { |
|
91 | + final protected static function getSearchPath(): string { |
|
92 | 92 | return 'price_rule'; |
93 | 93 | } |
94 | 94 | |
95 | - final protected static function getSearchType (): string { |
|
95 | + final protected static function getSearchType(): string { |
|
96 | 96 | return 'price_rules'; |
97 | 97 | } |
98 | 98 | |
99 | - final protected static function getType (): string { |
|
99 | + final protected static function getType(): string { |
|
100 | 100 | return 'price_rule'; |
101 | 101 | } |
102 | 102 | |
103 | - final public function __toString (): string { |
|
103 | + final public function __toString(): string { |
|
104 | 104 | return "price_rules/{$this->getId()}"; |
105 | 105 | } |
106 | 106 | |
107 | - final protected function getDir (): string { |
|
107 | + final protected function getDir(): string { |
|
108 | 108 | return 'price_rules'; |
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @return DiscountCode[] |
113 | 113 | */ |
114 | - public function getDiscountCodes () { |
|
114 | + public function getDiscountCodes() { |
|
115 | 115 | assert($this->hasId()); |
116 | 116 | if (!$this->discountCodes) { |
117 | 117 | $remote = $this->api->get("{$this}/discount_codes"); |
@@ -126,28 +126,28 @@ discard block |
||
126 | 126 | /** |
127 | 127 | * @return null|number |
128 | 128 | */ |
129 | - public function getMaxShipping () { |
|
129 | + public function getMaxShipping() { |
|
130 | 130 | return $this->data['prerequisite_shipping_price_range']['less_than_or_equal_to'] ?? null; |
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @return null|int |
135 | 135 | */ |
136 | - public function getMinQuantity () { |
|
136 | + public function getMinQuantity() { |
|
137 | 137 | return $this->data['prerequisite_quantity_range']['greater_than_or_equal_to'] ?? null; |
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * @return null|number |
142 | 142 | */ |
143 | - public function getMinSubtotal () { |
|
143 | + public function getMinSubtotal() { |
|
144 | 144 | return $this->data['prerequisite_subtotal_range']['greater_than_or_equal_to'] ?? null; |
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
148 | 148 | * @return DiscountCode |
149 | 149 | */ |
150 | - public function newDiscountCode () { |
|
150 | + public function newDiscountCode() { |
|
151 | 151 | $this->getDiscountCodes(); |
152 | 152 | return $this->discountCodes->add(new DiscountCode($this->api, ['price_rule_id' => $this->getId()])); |
153 | 153 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param null|number $max |
157 | 157 | * @return $this |
158 | 158 | */ |
159 | - public function setMaxShipping ($max) { |
|
159 | + public function setMaxShipping($max) { |
|
160 | 160 | return $this->set('prerequisite_shipping_price_range', isset($max) ? ['less_than_or_equal_to' => $max] : null); |
161 | 161 | } |
162 | 162 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param null|int $min |
165 | 165 | * @return $this |
166 | 166 | */ |
167 | - public function setMinQuantity (?int $min) { |
|
167 | + public function setMinQuantity(?int $min) { |
|
168 | 168 | return $this->set('prerequisite_quantity_range', isset($min) ? ['greater_than_or_equal_to' => $min] : null); |
169 | 169 | } |
170 | 170 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param null|number $min |
173 | 173 | * @return $this |
174 | 174 | */ |
175 | - public function setMinSubtotal ($min) { |
|
175 | + public function setMinSubtotal($min) { |
|
176 | 176 | return $this->set('prerequisite_subtotal_range', isset($min) ? ['greater_than_or_equal_to' => $min] : null); |
177 | 177 | } |
178 | 178 | } |
179 | 179 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class DiscountCode extends AbstractEntity { |
21 | 21 | |
22 | - final protected static function getType (): string { |
|
22 | + final protected static function getType(): string { |
|
23 | 23 | return 'discount_code'; |
24 | 24 | } |
25 | 25 | |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | * @param string $code |
29 | 29 | * @return null|static |
30 | 30 | */ |
31 | - public static function loadByCode (Api $api, string $code) { |
|
31 | + public static function loadByCode(Api $api, string $code) { |
|
32 | 32 | $remote = $api->get('discount_codes/lookup', ['code' => $code]); |
33 | 33 | return $remote ? new static($api, $remote['discount_code']) : null; |
34 | 34 | } |
35 | 35 | |
36 | - final public function __toString (): string { |
|
36 | + final public function __toString(): string { |
|
37 | 37 | return "{$this->getDir()}/{$this->getId()}"; |
38 | 38 | } |
39 | 39 | |
40 | - final protected function getDir (): string { |
|
40 | + final protected function getDir(): string { |
|
41 | 41 | return "price_rules/{$this->getPriceRuleId()}/discount_codes"; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -142,23 +142,23 @@ discard block |
||
142 | 142 | 'tax_lines' => [Tax::class, 'toDataSet'] |
143 | 143 | ]; |
144 | 144 | |
145 | - final protected static function getMetafieldType (): string { |
|
145 | + final protected static function getMetafieldType(): string { |
|
146 | 146 | return 'order'; |
147 | 147 | } |
148 | 148 | |
149 | - final protected static function getSearchPath (): string { |
|
149 | + final protected static function getSearchPath(): string { |
|
150 | 150 | return 'orders'; |
151 | 151 | } |
152 | 152 | |
153 | - final protected static function getSearchType (): string { |
|
153 | + final protected static function getSearchType(): string { |
|
154 | 154 | return 'orders'; |
155 | 155 | } |
156 | 156 | |
157 | - final protected static function getType (): string { |
|
157 | + final protected static function getType(): string { |
|
158 | 158 | return 'order'; |
159 | 159 | } |
160 | 160 | |
161 | - final public function __toString (): string { |
|
161 | + final public function __toString(): string { |
|
162 | 162 | return "orders/{$this->getId()}"; |
163 | 163 | } |
164 | 164 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - public function cancel () { |
|
172 | + public function cancel() { |
|
173 | 173 | assert($this->hasId()); |
174 | 174 | $remote = $this->api->post("{$this}/cancel", []); |
175 | 175 | return $this->import($remote['order'])->notify('save'); |
@@ -180,38 +180,38 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return $this |
182 | 182 | */ |
183 | - public function close () { |
|
183 | + public function close() { |
|
184 | 184 | assert($this->hasId()); |
185 | 185 | $remote = $this->api->post("{$this}/close", []); |
186 | 186 | return $this->import($remote['order'])->notify('save'); |
187 | 187 | } |
188 | 188 | |
189 | - final protected function getDir (): string { |
|
189 | + final protected function getDir(): string { |
|
190 | 190 | return 'orders'; |
191 | 191 | } |
192 | 192 | |
193 | - final protected function getMetafieldDir (): string { |
|
193 | + final protected function getMetafieldDir(): string { |
|
194 | 194 | return "{$this}/metafields"; |
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | 198 | * @return Discount |
199 | 199 | */ |
200 | - public function newDiscount () { |
|
200 | + public function newDiscount() { |
|
201 | 201 | return $this->data['discount_codes']->add(Discount::toData($this, [])); |
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | 205 | * @return Fulfillment |
206 | 206 | */ |
207 | - public function newFulfillment () { |
|
207 | + public function newFulfillment() { |
|
208 | 208 | return $this->data['fulfillments']->add(Fulfillment::toData($this, ['order_id' => $this->getId()])); |
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | 212 | * @return Refund |
213 | 213 | */ |
214 | - public function newRefund () { |
|
214 | + public function newRefund() { |
|
215 | 215 | assert($this->hasId()); |
216 | 216 | return $this->data['refunds']->add(Refund::toData($this, ['order_id' => $this->getId()])); |
217 | 217 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * @return Shipping |
221 | 221 | */ |
222 | - public function newShipping () { |
|
222 | + public function newShipping() { |
|
223 | 223 | return $this->data['shipping_lines']->add(Shipping::toData($this, [])); |
224 | 224 | } |
225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return $this |
230 | 230 | */ |
231 | - public function reopen () { |
|
231 | + public function reopen() { |
|
232 | 232 | assert($this->hasId()); |
233 | 233 | $remote = $this->api->post("{$this}/open", []); |
234 | 234 | return $this->import($remote['order'])->notify('save'); |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | |
27 | 27 | use EntityTrait; |
28 | 28 | |
29 | - final protected static function getType (): string { |
|
29 | + final protected static function getType(): string { |
|
30 | 30 | return 'inventory_level'; |
31 | 31 | } |
32 | 32 | |
33 | - final public function __toString (): string { |
|
33 | + final public function __toString(): string { |
|
34 | 34 | return "inventory_levels.json?inventory_item_id={$this->getInventoryItemId()}&location_id={$this->getLocationId()}"; |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @return null|Location |
39 | 39 | */ |
40 | - public function getLocation () { |
|
40 | + public function getLocation() { |
|
41 | 41 | return $this->api->getLocation($this->getLocationId()); |
42 | 42 | } |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return $this |
48 | 48 | */ |
49 | - public function save () { |
|
49 | + public function save() { |
|
50 | 50 | if ($this->isDiff()) { |
51 | 51 | if ($this->getUpdatedAt()) { |
52 | 52 | $remote = $this->api->post('inventory_levels/adjust', $this->getData()); |
@@ -50,8 +50,7 @@ |
||
50 | 50 | if ($this->isDiff()) { |
51 | 51 | if ($this->getUpdatedAt()) { |
52 | 52 | $remote = $this->api->post('inventory_levels/adjust', $this->getData()); |
53 | - } |
|
54 | - else { |
|
53 | + } else { |
|
55 | 54 | $remote = $this->api->post('inventory_levels/connect', $this->getData()); |
56 | 55 | } |
57 | 56 | $this->import($remote['inventory_level']); |
@@ -27,15 +27,15 @@ |
||
27 | 27 | const FORMAT_JSON = 'json'; |
28 | 28 | const FORMAT_XML = 'xml'; |
29 | 29 | |
30 | - final protected static function getType (): string { |
|
30 | + final protected static function getType(): string { |
|
31 | 31 | return 'carrier_service'; |
32 | 32 | } |
33 | 33 | |
34 | - final public function __toString (): string { |
|
34 | + final public function __toString(): string { |
|
35 | 35 | return "carrier_services/{$this->getId()}"; |
36 | 36 | } |
37 | 37 | |
38 | - final protected function getDir (): string { |
|
38 | + final protected function getDir(): string { |
|
39 | 39 | return 'carrier_services'; |
40 | 40 | } |
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | use IndestructibleTrait; |
70 | 70 | use MetafieldTrait; |
71 | 71 | |
72 | - final protected static function getMetafieldType (): string { |
|
72 | + final protected static function getMetafieldType(): string { |
|
73 | 73 | return 'shop'; |
74 | 74 | } |
75 | 75 | |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param Api $api |
78 | 78 | * @return static |
79 | 79 | */ |
80 | - public static function load (Api $api) { |
|
80 | + public static function load(Api $api) { |
|
81 | 81 | return new static($api, $api->get('shop')['shop']); |
82 | 82 | } |
83 | 83 | |
84 | - final public function __toString (): string { |
|
84 | + final public function __toString(): string { |
|
85 | 85 | return $this->getMyshopifyDomain(); |
86 | 86 | } |
87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return $this |
92 | 92 | */ |
93 | - final public function save () { |
|
93 | + final public function save() { |
|
94 | 94 | return $this->notify('save'); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | \ No newline at end of file |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string $key |
76 | 76 | * @param string $password |
77 | 77 | */ |
78 | - public function __construct (string $domain, string $key, string $password) { |
|
78 | + public function __construct(string $domain, string $key, string $password) { |
|
79 | 79 | $this->domain = $domain; |
80 | 80 | $this->key = $key; |
81 | 81 | $this->password = $password; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return null|mixed |
91 | 91 | * @internal |
92 | 92 | */ |
93 | - public function __call ($method, array $args) { |
|
93 | + public function __call($method, array $args) { |
|
94 | 94 | $ch = curl_init(); |
95 | 95 | $method = strtoupper($method); |
96 | 96 | if ($method[0] === 'P') { |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * @return int |
160 | 160 | */ |
161 | - public function getBucket (): int { |
|
161 | + public function getBucket(): int { |
|
162 | 162 | return $this->bucket; |
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | 166 | * @return int |
167 | 167 | */ |
168 | - public function getLastCallAt (): int { |
|
168 | + public function getLastCallAt(): int { |
|
169 | 169 | return $this->lastCallAt; |
170 | 170 | } |
171 | 171 | |
@@ -173,28 +173,28 @@ discard block |
||
173 | 173 | * @param string $id |
174 | 174 | * @return null|Location |
175 | 175 | */ |
176 | - public function getLocation (string $id) { |
|
176 | + public function getLocation(string $id) { |
|
177 | 177 | return $this->getLocations()[$id] ?? null; |
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * @return Location[] |
182 | 182 | */ |
183 | - public function getLocations () { |
|
183 | + public function getLocations() { |
|
184 | 184 | return $this->locations ?? $this->locations = Location::loadAll($this); |
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | 188 | * @return Closure |
189 | 189 | */ |
190 | - public function getLogger (): Closure { |
|
190 | + public function getLogger(): Closure { |
|
191 | 191 | return $this->logger; |
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
195 | 195 | * @return Shop |
196 | 196 | */ |
197 | - public function getShop () { |
|
197 | + public function getShop() { |
|
198 | 198 | return $this->shop ?? $this->shop = Shop::load($this); |
199 | 199 | } |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param string|null $id |
205 | 205 | * @return null|User |
206 | 206 | */ |
207 | - public function getUser (string $id = null) { |
|
207 | + public function getUser(string $id = null) { |
|
208 | 208 | return $id ? User::load($this, $id) : User::me($this); |
209 | 209 | } |
210 | 210 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param Closure $logger |
213 | 213 | * @return $this |
214 | 214 | */ |
215 | - public function setLogger (Closure $logger) { |
|
215 | + public function setLogger(Closure $logger) { |
|
216 | 216 | $this->logger = $logger; |
217 | 217 | return $this; |
218 | 218 | } |
@@ -98,8 +98,7 @@ |
||
98 | 98 | $payload = json_encode($args[1], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
99 | 99 | curl_setopt($ch, CURLOPT_POST, true); |
100 | 100 | curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); |
101 | - } |
|
102 | - else { |
|
101 | + } else { |
|
103 | 102 | $query = $args[1] ?? []; |
104 | 103 | $payload = null; |
105 | 104 | } |