|
1
|
|
|
<?php |
|
2
|
|
|
namespace RetailCrm; |
|
3
|
|
|
|
|
4
|
|
|
use RetailCrm\Http\Client; |
|
5
|
|
|
use RetailCrm\Response\ApiResponse; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* retailCRM API client class |
|
9
|
|
|
*/ |
|
10
|
|
|
class ApiClient |
|
11
|
|
|
{ |
|
12
|
|
|
const VERSION = 'v3'; |
|
13
|
|
|
|
|
14
|
|
|
protected $client; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Site code |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $siteCode; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Client creating |
|
23
|
|
|
* |
|
24
|
|
|
* @param string $url |
|
25
|
|
|
* @param string $apiKey |
|
26
|
|
|
* @param string $siteCode |
|
|
|
|
|
|
27
|
|
|
* @return mixed |
|
|
|
|
|
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct($url, $apiKey, $site = null) |
|
30
|
|
|
{ |
|
31
|
|
|
if ('/' != substr($url, strlen($url) - 1, 1)) { |
|
32
|
|
|
$url .= '/'; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
$url = $url . 'api/' . self::VERSION; |
|
36
|
|
|
|
|
37
|
|
|
$this->client = new Client($url, array('apiKey' => $apiKey)); |
|
38
|
|
|
$this->siteCode = $site; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Create a order |
|
43
|
|
|
* |
|
44
|
|
|
* @param array $order |
|
45
|
|
|
* @param string $site (default: null) |
|
46
|
|
|
* @return ApiResponse |
|
47
|
|
|
*/ |
|
48
|
|
View Code Duplication |
public function ordersCreate(array $order, $site = null) |
|
|
|
|
|
|
49
|
|
|
{ |
|
50
|
|
|
if (!sizeof($order)) { |
|
51
|
|
|
throw new \InvalidArgumentException('Parameter `order` must contains a data'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
return $this->client->makeRequest("/orders/create", Client::METHOD_POST, $this->fillSite($site, array( |
|
55
|
|
|
'order' => json_encode($order) |
|
56
|
|
|
))); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Edit a order |
|
61
|
|
|
* |
|
62
|
|
|
* @param array $order |
|
63
|
|
|
* @param string $site (default: null) |
|
64
|
|
|
* @return ApiResponse |
|
65
|
|
|
*/ |
|
66
|
|
View Code Duplication |
public function ordersEdit(array $order, $by = 'externalId', $site = null) |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
if (!sizeof($order)) { |
|
69
|
|
|
throw new \InvalidArgumentException('Parameter `order` must contains a data'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$this->checkIdParameter($by); |
|
73
|
|
|
|
|
74
|
|
|
if (!isset($order[$by])) { |
|
75
|
|
|
throw new \InvalidArgumentException(sprintf('Order array must contain the "%s" parameter.', $by)); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return $this->client->makeRequest( |
|
79
|
|
|
"/orders/" . $order[$by] . "/edit", |
|
80
|
|
|
Client::METHOD_POST, |
|
81
|
|
|
$this->fillSite($site, array( |
|
82
|
|
|
'order' => json_encode($order), |
|
83
|
|
|
'by' => $by, |
|
84
|
|
|
)) |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Upload array of the orders |
|
90
|
|
|
* |
|
91
|
|
|
* @param array $orders |
|
92
|
|
|
* @param string $site (default: null) |
|
93
|
|
|
* @return ApiResponse |
|
94
|
|
|
*/ |
|
95
|
|
View Code Duplication |
public function ordersUpload(array $orders, $site = null) |
|
|
|
|
|
|
96
|
|
|
{ |
|
97
|
|
|
if (!sizeof($orders)) { |
|
98
|
|
|
throw new \InvalidArgumentException('Parameter `orders` must contains array of the orders'); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
return $this->client->makeRequest("/orders/upload", Client::METHOD_POST, $this->fillSite($site, array( |
|
102
|
|
|
'orders' => json_encode($orders), |
|
103
|
|
|
))); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Get order by id or externalId |
|
108
|
|
|
* |
|
109
|
|
|
* @param string $id |
|
110
|
|
|
* @param string $by (default: 'externalId') |
|
111
|
|
|
* @param string $site (default: null) |
|
112
|
|
|
* @return ApiResponse |
|
113
|
|
|
*/ |
|
114
|
|
View Code Duplication |
public function ordersGet($id, $by = 'externalId', $site = null) |
|
|
|
|
|
|
115
|
|
|
{ |
|
116
|
|
|
$this->checkIdParameter($by); |
|
117
|
|
|
|
|
118
|
|
|
return $this->client->makeRequest("/orders/$id", Client::METHOD_GET, $this->fillSite($site, array( |
|
119
|
|
|
'by' => $by |
|
120
|
|
|
))); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Returns a orders history |
|
125
|
|
|
* |
|
126
|
|
|
* @param \DateTime $startDate (default: null) |
|
127
|
|
|
* @param \DateTime $endDate (default: null) |
|
128
|
|
|
* @param int $limit (default: 100) |
|
129
|
|
|
* @param int $offset (default: 0) |
|
130
|
|
|
* @param bool $skipMyChanges (default: true) |
|
131
|
|
|
* @return ApiResponse |
|
132
|
|
|
*/ |
|
133
|
|
|
public function ordersHistory( |
|
134
|
|
|
\DateTime $startDate = null, |
|
135
|
|
|
\DateTime $endDate = null, |
|
136
|
|
|
$limit = 100, |
|
137
|
|
|
$offset = 0, |
|
138
|
|
|
$skipMyChanges = true |
|
139
|
|
|
) { |
|
140
|
|
|
$parameters = array(); |
|
141
|
|
|
|
|
142
|
|
|
if ($startDate) { |
|
143
|
|
|
$parameters['startDate'] = $startDate->format('Y-m-d H:i:s'); |
|
144
|
|
|
} |
|
145
|
|
|
if ($endDate) { |
|
146
|
|
|
$parameters['endDate'] = $endDate->format('Y-m-d H:i:s'); |
|
147
|
|
|
} |
|
148
|
|
|
if ($limit) { |
|
149
|
|
|
$parameters['limit'] = (int) $limit; |
|
150
|
|
|
} |
|
151
|
|
|
if ($offset) { |
|
152
|
|
|
$parameters['offset'] = (int) $offset; |
|
153
|
|
|
} |
|
154
|
|
|
if ($skipMyChanges) { |
|
155
|
|
|
$parameters['skipMyChanges'] = (bool) $skipMyChanges; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
return $this->client->makeRequest('/orders/history', Client::METHOD_GET, $parameters); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* Returns filtered orders list |
|
163
|
|
|
* |
|
164
|
|
|
* @param array $filter (default: array()) |
|
165
|
|
|
* @param int $page (default: null) |
|
166
|
|
|
* @param int $limit (default: null) |
|
167
|
|
|
* @return ApiResponse |
|
168
|
|
|
*/ |
|
169
|
|
View Code Duplication |
public function ordersList(array $filter = array(), $page = null, $limit = null) |
|
|
|
|
|
|
170
|
|
|
{ |
|
171
|
|
|
$parameters = array(); |
|
172
|
|
|
|
|
173
|
|
|
if (sizeof($filter)) { |
|
174
|
|
|
$parameters['filter'] = $filter; |
|
175
|
|
|
} |
|
176
|
|
|
if (null !== $page) { |
|
177
|
|
|
$parameters['page'] = (int) $page; |
|
178
|
|
|
} |
|
179
|
|
|
if (null !== $limit) { |
|
180
|
|
|
$parameters['limit'] = (int) $limit; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
return $this->client->makeRequest('/orders', Client::METHOD_GET, $parameters); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* Returns statuses of the orders |
|
188
|
|
|
* |
|
189
|
|
|
* @param array $ids (default: array()) |
|
190
|
|
|
* @param array $externalIds (default: array()) |
|
191
|
|
|
* @return ApiResponse |
|
192
|
|
|
*/ |
|
193
|
|
|
public function ordersStatuses(array $ids = array(), array $externalIds = array()) |
|
194
|
|
|
{ |
|
195
|
|
|
$parameters = array(); |
|
196
|
|
|
|
|
197
|
|
|
if (sizeof($ids)) { |
|
198
|
|
|
$parameters['ids'] = $ids; |
|
199
|
|
|
} |
|
200
|
|
|
if (sizeof($externalIds)) { |
|
201
|
|
|
$parameters['externalIds'] = $externalIds; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
return $this->client->makeRequest('/orders/statuses', Client::METHOD_GET, $parameters); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* Save order IDs' (id and externalId) association in the CRM |
|
209
|
|
|
* |
|
210
|
|
|
* @param array $ids |
|
211
|
|
|
* @return ApiResponse |
|
212
|
|
|
*/ |
|
213
|
|
View Code Duplication |
public function ordersFixExternalIds(array $ids) |
|
|
|
|
|
|
214
|
|
|
{ |
|
215
|
|
|
if (!sizeof($ids)) { |
|
216
|
|
|
throw new \InvalidArgumentException('Method parameter must contains at least one IDs pair'); |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
return $this->client->makeRequest("/orders/fix-external-ids", Client::METHOD_POST, array( |
|
220
|
|
|
'orders' => json_encode($ids), |
|
221
|
|
|
)); |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Get orders assembly history |
|
226
|
|
|
* |
|
227
|
|
|
* @param array $filter (default: array()) |
|
228
|
|
|
* @param int $page (default: null) |
|
229
|
|
|
* @param int $limit (default: null) |
|
230
|
|
|
* @return ApiResponse |
|
231
|
|
|
*/ |
|
232
|
|
View Code Duplication |
public function ordersPacksHistory(array $filter = array(), $page = null, $limit = null) |
|
|
|
|
|
|
233
|
|
|
{ |
|
234
|
|
|
$parameters = array(); |
|
235
|
|
|
|
|
236
|
|
|
if (sizeof($filter)) { |
|
237
|
|
|
$parameters['filter'] = $filter; |
|
238
|
|
|
} |
|
239
|
|
|
if (null !== $page) { |
|
240
|
|
|
$parameters['page'] = (int) $page; |
|
241
|
|
|
} |
|
242
|
|
|
if (null !== $limit) { |
|
243
|
|
|
$parameters['limit'] = (int) $limit; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
return $this->client->makeRequest('/orders/packs/history', Client::METHOD_GET, $parameters); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Create a customer |
|
251
|
|
|
* |
|
252
|
|
|
* @param array $customer |
|
253
|
|
|
* @param string $site (default: null) |
|
254
|
|
|
* @return ApiResponse |
|
255
|
|
|
*/ |
|
256
|
|
View Code Duplication |
public function customersCreate(array $customer, $site = null) |
|
|
|
|
|
|
257
|
|
|
{ |
|
258
|
|
|
if (!sizeof($customer)) { |
|
259
|
|
|
throw new \InvalidArgumentException('Parameter `customer` must contains a data'); |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
return $this->client->makeRequest("/customers/create", Client::METHOD_POST, $this->fillSite($site, array( |
|
263
|
|
|
'customer' => json_encode($customer) |
|
264
|
|
|
))); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
/** |
|
268
|
|
|
* Edit a customer |
|
269
|
|
|
* |
|
270
|
|
|
* @param array $customer |
|
271
|
|
|
* @param string $by (default: 'externalId') |
|
272
|
|
|
* @param string $site (default: null) |
|
273
|
|
|
* @return ApiResponse |
|
274
|
|
|
*/ |
|
275
|
|
View Code Duplication |
public function customersEdit(array $customer, $by = 'externalId', $site = null) |
|
|
|
|
|
|
276
|
|
|
{ |
|
277
|
|
|
if (!sizeof($customer)) { |
|
278
|
|
|
throw new \InvalidArgumentException('Parameter `customer` must contains a data'); |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
$this->checkIdParameter($by); |
|
282
|
|
|
|
|
283
|
|
|
if (!isset($customer[$by])) { |
|
284
|
|
|
throw new \InvalidArgumentException(sprintf('Customer array must contain the "%s" parameter.', $by)); |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
return $this->client->makeRequest( |
|
288
|
|
|
"/customers/" . $customer[$by] . "/edit", |
|
289
|
|
|
Client::METHOD_POST, |
|
290
|
|
|
$this->fillSite( |
|
291
|
|
|
$site, |
|
292
|
|
|
array( |
|
293
|
|
|
'customer' => json_encode($customer), |
|
294
|
|
|
'by' => $by |
|
295
|
|
|
) |
|
296
|
|
|
) |
|
297
|
|
|
); |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* Upload array of the customers |
|
302
|
|
|
* |
|
303
|
|
|
* @param array $customers |
|
304
|
|
|
* @param string $site (default: null) |
|
305
|
|
|
* @return ApiResponse |
|
306
|
|
|
*/ |
|
307
|
|
View Code Duplication |
public function customersUpload(array $customers, $site = null) |
|
|
|
|
|
|
308
|
|
|
{ |
|
309
|
|
|
if (!sizeof($customers)) { |
|
310
|
|
|
throw new \InvalidArgumentException('Parameter `customers` must contains array of the customers'); |
|
311
|
|
|
} |
|
312
|
|
|
|
|
313
|
|
|
return $this->client->makeRequest("/customers/upload", Client::METHOD_POST, $this->fillSite($site, array( |
|
314
|
|
|
'customers' => json_encode($customers), |
|
315
|
|
|
))); |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* Get customer by id or externalId |
|
320
|
|
|
* |
|
321
|
|
|
* @param string $id |
|
322
|
|
|
* @param string $by (default: 'externalId') |
|
323
|
|
|
* @param string $site (default: null) |
|
324
|
|
|
* @return ApiResponse |
|
325
|
|
|
*/ |
|
326
|
|
View Code Duplication |
public function customersGet($id, $by = 'externalId', $site = null) |
|
|
|
|
|
|
327
|
|
|
{ |
|
328
|
|
|
$this->checkIdParameter($by); |
|
329
|
|
|
|
|
330
|
|
|
return $this->client->makeRequest("/customers/$id", Client::METHOD_GET, $this->fillSite($site, array( |
|
331
|
|
|
'by' => $by |
|
332
|
|
|
))); |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
/** |
|
336
|
|
|
* Returns filtered customers list |
|
337
|
|
|
* |
|
338
|
|
|
* @param array $filter (default: array()) |
|
339
|
|
|
* @param int $page (default: null) |
|
340
|
|
|
* @param int $limit (default: null) |
|
341
|
|
|
* @return ApiResponse |
|
342
|
|
|
*/ |
|
343
|
|
View Code Duplication |
public function customersList(array $filter = array(), $page = null, $limit = null) |
|
|
|
|
|
|
344
|
|
|
{ |
|
345
|
|
|
$parameters = array(); |
|
346
|
|
|
|
|
347
|
|
|
if (sizeof($filter)) { |
|
348
|
|
|
$parameters['filter'] = $filter; |
|
349
|
|
|
} |
|
350
|
|
|
if (null !== $page) { |
|
351
|
|
|
$parameters['page'] = (int) $page; |
|
352
|
|
|
} |
|
353
|
|
|
if (null !== $limit) { |
|
354
|
|
|
$parameters['limit'] = (int) $limit; |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
return $this->client->makeRequest('/customers', Client::METHOD_GET, $parameters); |
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
/** |
|
361
|
|
|
* Save customer IDs' (id and externalId) association in the CRM |
|
362
|
|
|
* |
|
363
|
|
|
* @param array $ids |
|
364
|
|
|
* @return ApiResponse |
|
365
|
|
|
*/ |
|
366
|
|
View Code Duplication |
public function customersFixExternalIds(array $ids) |
|
|
|
|
|
|
367
|
|
|
{ |
|
368
|
|
|
if (!sizeof($ids)) { |
|
369
|
|
|
throw new \InvalidArgumentException('Method parameter must contains at least one IDs pair'); |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
return $this->client->makeRequest("/customers/fix-external-ids", Client::METHOD_POST, array( |
|
373
|
|
|
'customers' => json_encode($ids), |
|
374
|
|
|
)); |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* Get purchace prices & stock balance |
|
379
|
|
|
* |
|
380
|
|
|
* @param array $filter (default: array()) |
|
381
|
|
|
* @param int $page (default: null) |
|
382
|
|
|
* @param int $limit (default: null) |
|
383
|
|
|
* @param string $site (default: null) |
|
384
|
|
|
* @return ApiResponse |
|
385
|
|
|
*/ |
|
386
|
|
View Code Duplication |
public function storeInventories(array $filter = array(), $page = null, $limit = null, $site = null) |
|
|
|
|
|
|
387
|
|
|
{ |
|
388
|
|
|
$parameters = array(); |
|
389
|
|
|
|
|
390
|
|
|
if (sizeof($filter)) { |
|
391
|
|
|
$parameters['filter'] = $filter; |
|
392
|
|
|
} |
|
393
|
|
|
if (null !== $page) { |
|
394
|
|
|
$parameters['page'] = (int) $page; |
|
395
|
|
|
} |
|
396
|
|
|
if (null !== $limit) { |
|
397
|
|
|
$parameters['limit'] = (int) $limit; |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
return $this->client->makeRequest('/store/inventories', Client::METHOD_GET, $this->fillSite($site, $parameters)); |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
/** |
|
404
|
|
|
* Upload store inventories |
|
405
|
|
|
* |
|
406
|
|
|
* @param array $offers |
|
407
|
|
|
* @param string $site (default: null) |
|
408
|
|
|
* @return ApiResponse |
|
409
|
|
|
*/ |
|
410
|
|
View Code Duplication |
public function storeInventoriesUpload(array $offers, $site = null) |
|
|
|
|
|
|
411
|
|
|
{ |
|
412
|
|
|
if (!sizeof($offers)) { |
|
413
|
|
|
throw new \InvalidArgumentException('Parameter `offers` must contains array of the customers'); |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
return $this->client->makeRequest( |
|
417
|
|
|
"/store/inventories/upload", |
|
418
|
|
|
Client::METHOD_POST, |
|
419
|
|
|
$this->fillSite($site, array('offers' => json_encode($offers))) |
|
420
|
|
|
); |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
/** |
|
424
|
|
|
* Returns deliveryServices list |
|
425
|
|
|
* |
|
426
|
|
|
* @return ApiResponse |
|
427
|
|
|
*/ |
|
428
|
|
|
public function deliveryServicesList() |
|
429
|
|
|
{ |
|
430
|
|
|
return $this->client->makeRequest('/reference/delivery-services', Client::METHOD_GET); |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
/** |
|
434
|
|
|
* Returns deliveryTypes list |
|
435
|
|
|
* |
|
436
|
|
|
* @return ApiResponse |
|
437
|
|
|
*/ |
|
438
|
|
|
public function deliveryTypesList() |
|
439
|
|
|
{ |
|
440
|
|
|
return $this->client->makeRequest('/reference/delivery-types', Client::METHOD_GET); |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
/** |
|
444
|
|
|
* Returns orderMethods list |
|
445
|
|
|
* |
|
446
|
|
|
* @return ApiResponse |
|
447
|
|
|
*/ |
|
448
|
|
|
public function orderMethodsList() |
|
449
|
|
|
{ |
|
450
|
|
|
return $this->client->makeRequest('/reference/order-methods', Client::METHOD_GET); |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
/** |
|
454
|
|
|
* Returns orderTypes list |
|
455
|
|
|
* |
|
456
|
|
|
* @return ApiResponse |
|
457
|
|
|
*/ |
|
458
|
|
|
public function orderTypesList() |
|
459
|
|
|
{ |
|
460
|
|
|
return $this->client->makeRequest('/reference/order-types', Client::METHOD_GET); |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
/** |
|
464
|
|
|
* Returns paymentStatuses list |
|
465
|
|
|
* |
|
466
|
|
|
* @return ApiResponse |
|
467
|
|
|
*/ |
|
468
|
|
|
public function paymentStatusesList() |
|
469
|
|
|
{ |
|
470
|
|
|
return $this->client->makeRequest('/reference/payment-statuses', Client::METHOD_GET); |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
/** |
|
474
|
|
|
* Returns paymentTypes list |
|
475
|
|
|
* |
|
476
|
|
|
* @return ApiResponse |
|
477
|
|
|
*/ |
|
478
|
|
|
public function paymentTypesList() |
|
479
|
|
|
{ |
|
480
|
|
|
return $this->client->makeRequest('/reference/payment-types', Client::METHOD_GET); |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
/** |
|
484
|
|
|
* Returns productStatuses list |
|
485
|
|
|
* |
|
486
|
|
|
* @return ApiResponse |
|
487
|
|
|
*/ |
|
488
|
|
|
public function productStatusesList() |
|
489
|
|
|
{ |
|
490
|
|
|
return $this->client->makeRequest('/reference/product-statuses', Client::METHOD_GET); |
|
491
|
|
|
} |
|
492
|
|
|
|
|
493
|
|
|
/** |
|
494
|
|
|
* Returns statusGroups list |
|
495
|
|
|
* |
|
496
|
|
|
* @return ApiResponse |
|
497
|
|
|
*/ |
|
498
|
|
|
public function statusGroupsList() |
|
499
|
|
|
{ |
|
500
|
|
|
return $this->client->makeRequest('/reference/status-groups', Client::METHOD_GET); |
|
501
|
|
|
} |
|
502
|
|
|
|
|
503
|
|
|
/** |
|
504
|
|
|
* Returns statuses list |
|
505
|
|
|
* |
|
506
|
|
|
* @return ApiResponse |
|
507
|
|
|
*/ |
|
508
|
|
|
public function statusesList() |
|
509
|
|
|
{ |
|
510
|
|
|
return $this->client->makeRequest('/reference/statuses', Client::METHOD_GET); |
|
511
|
|
|
} |
|
512
|
|
|
|
|
513
|
|
|
/** |
|
514
|
|
|
* Returns sites list |
|
515
|
|
|
* |
|
516
|
|
|
* @return ApiResponse |
|
517
|
|
|
*/ |
|
518
|
|
|
public function sitesList() |
|
519
|
|
|
{ |
|
520
|
|
|
return $this->client->makeRequest('/reference/sites', Client::METHOD_GET); |
|
521
|
|
|
} |
|
522
|
|
|
|
|
523
|
|
|
/** |
|
524
|
|
|
* Edit deliveryService |
|
525
|
|
|
* |
|
526
|
|
|
* @param array $data delivery service data |
|
527
|
|
|
* @return ApiResponse |
|
528
|
|
|
*/ |
|
529
|
|
View Code Duplication |
public function deliveryServicesEdit(array $data) |
|
|
|
|
|
|
530
|
|
|
{ |
|
531
|
|
|
if (!isset($data['code'])) { |
|
532
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
533
|
|
|
} |
|
534
|
|
|
|
|
535
|
|
|
return $this->client->makeRequest( |
|
536
|
|
|
'/reference/delivery-services/' . $data['code'] . '/edit', |
|
537
|
|
|
Client::METHOD_POST, |
|
538
|
|
|
array( |
|
539
|
|
|
'deliveryService' => json_encode($data) |
|
540
|
|
|
) |
|
541
|
|
|
); |
|
542
|
|
|
} |
|
543
|
|
|
|
|
544
|
|
|
/** |
|
545
|
|
|
* Edit deliveryType |
|
546
|
|
|
* |
|
547
|
|
|
* @param array $data delivery type data |
|
548
|
|
|
* @return ApiResponse |
|
549
|
|
|
*/ |
|
550
|
|
View Code Duplication |
public function deliveryTypesEdit(array $data) |
|
|
|
|
|
|
551
|
|
|
{ |
|
552
|
|
|
if (!isset($data['code'])) { |
|
553
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
return $this->client->makeRequest( |
|
557
|
|
|
'/reference/delivery-types/' . $data['code'] . '/edit', |
|
558
|
|
|
Client::METHOD_POST, |
|
559
|
|
|
array( |
|
560
|
|
|
'deliveryType' => json_encode($data) |
|
561
|
|
|
) |
|
562
|
|
|
); |
|
563
|
|
|
} |
|
564
|
|
|
|
|
565
|
|
|
/** |
|
566
|
|
|
* Edit orderMethod |
|
567
|
|
|
* |
|
568
|
|
|
* @param array $data order method data |
|
569
|
|
|
* @return ApiResponse |
|
570
|
|
|
*/ |
|
571
|
|
View Code Duplication |
public function orderMethodsEdit(array $data) |
|
|
|
|
|
|
572
|
|
|
{ |
|
573
|
|
|
if (!isset($data['code'])) { |
|
574
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
575
|
|
|
} |
|
576
|
|
|
|
|
577
|
|
|
return $this->client->makeRequest( |
|
578
|
|
|
'/reference/order-methods/' . $data['code'] . '/edit', |
|
579
|
|
|
Client::METHOD_POST, |
|
580
|
|
|
array( |
|
581
|
|
|
'orderMethod' => json_encode($data) |
|
582
|
|
|
) |
|
583
|
|
|
); |
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
/** |
|
587
|
|
|
* Edit orderType |
|
588
|
|
|
* |
|
589
|
|
|
* @param array $data order type data |
|
590
|
|
|
* @return ApiResponse |
|
591
|
|
|
*/ |
|
592
|
|
View Code Duplication |
public function orderTypesEdit(array $data) |
|
|
|
|
|
|
593
|
|
|
{ |
|
594
|
|
|
if (!isset($data['code'])) { |
|
595
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
596
|
|
|
} |
|
597
|
|
|
|
|
598
|
|
|
return $this->client->makeRequest( |
|
599
|
|
|
'/reference/order-types/' . $data['code'] . '/edit', |
|
600
|
|
|
Client::METHOD_POST, |
|
601
|
|
|
array( |
|
602
|
|
|
'orderType' => json_encode($data) |
|
603
|
|
|
) |
|
604
|
|
|
); |
|
605
|
|
|
} |
|
606
|
|
|
|
|
607
|
|
|
/** |
|
608
|
|
|
* Edit paymentStatus |
|
609
|
|
|
* |
|
610
|
|
|
* @param array $data payment status data |
|
611
|
|
|
* @return ApiResponse |
|
612
|
|
|
*/ |
|
613
|
|
View Code Duplication |
public function paymentStatusesEdit(array $data) |
|
|
|
|
|
|
614
|
|
|
{ |
|
615
|
|
|
if (!isset($data['code'])) { |
|
616
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
|
|
return $this->client->makeRequest( |
|
620
|
|
|
'/reference/payment-statuses/' . $data['code'] . '/edit', |
|
621
|
|
|
Client::METHOD_POST, |
|
622
|
|
|
array( |
|
623
|
|
|
'paymentStatus' => json_encode($data) |
|
624
|
|
|
) |
|
625
|
|
|
); |
|
626
|
|
|
} |
|
627
|
|
|
|
|
628
|
|
|
/** |
|
629
|
|
|
* Edit paymentType |
|
630
|
|
|
* |
|
631
|
|
|
* @param array $data payment type data |
|
632
|
|
|
* @return ApiResponse |
|
633
|
|
|
*/ |
|
634
|
|
View Code Duplication |
public function paymentTypesEdit(array $data) |
|
|
|
|
|
|
635
|
|
|
{ |
|
636
|
|
|
if (!isset($data['code'])) { |
|
637
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
638
|
|
|
} |
|
639
|
|
|
|
|
640
|
|
|
return $this->client->makeRequest( |
|
641
|
|
|
'/reference/payment-types/' . $data['code'] . '/edit', |
|
642
|
|
|
Client::METHOD_POST, |
|
643
|
|
|
array( |
|
644
|
|
|
'paymentType' => json_encode($data) |
|
645
|
|
|
) |
|
646
|
|
|
); |
|
647
|
|
|
} |
|
648
|
|
|
|
|
649
|
|
|
/** |
|
650
|
|
|
* Edit productStatus |
|
651
|
|
|
* |
|
652
|
|
|
* @param array $data product status data |
|
653
|
|
|
* @return ApiResponse |
|
654
|
|
|
*/ |
|
655
|
|
View Code Duplication |
public function productStatusesEdit(array $data) |
|
|
|
|
|
|
656
|
|
|
{ |
|
657
|
|
|
if (!isset($data['code'])) { |
|
658
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
659
|
|
|
} |
|
660
|
|
|
|
|
661
|
|
|
return $this->client->makeRequest( |
|
662
|
|
|
'/reference/product-statuses/' . $data['code'] . '/edit', |
|
663
|
|
|
Client::METHOD_POST, |
|
664
|
|
|
array( |
|
665
|
|
|
'productStatus' => json_encode($data) |
|
666
|
|
|
) |
|
667
|
|
|
); |
|
668
|
|
|
} |
|
669
|
|
|
|
|
670
|
|
|
/** |
|
671
|
|
|
* Edit order status |
|
672
|
|
|
* |
|
673
|
|
|
* @param array $data status data |
|
674
|
|
|
* @return ApiResponse |
|
675
|
|
|
*/ |
|
676
|
|
View Code Duplication |
public function statusesEdit(array $data) |
|
|
|
|
|
|
677
|
|
|
{ |
|
678
|
|
|
if (!isset($data['code'])) { |
|
679
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
680
|
|
|
} |
|
681
|
|
|
|
|
682
|
|
|
return $this->client->makeRequest( |
|
683
|
|
|
'/reference/statuses/' . $data['code'] . '/edit', |
|
684
|
|
|
Client::METHOD_POST, |
|
685
|
|
|
array( |
|
686
|
|
|
'status' => json_encode($data) |
|
687
|
|
|
) |
|
688
|
|
|
); |
|
689
|
|
|
} |
|
690
|
|
|
|
|
691
|
|
|
/** |
|
692
|
|
|
* Edit site |
|
693
|
|
|
* |
|
694
|
|
|
* @param array $data site data |
|
695
|
|
|
* @return ApiResponse |
|
696
|
|
|
*/ |
|
697
|
|
View Code Duplication |
public function sitesEdit(array $data) |
|
|
|
|
|
|
698
|
|
|
{ |
|
699
|
|
|
if (!isset($data['code'])) { |
|
700
|
|
|
throw new \InvalidArgumentException('Data must contain "code" parameter.'); |
|
701
|
|
|
} |
|
702
|
|
|
|
|
703
|
|
|
return $this->client->makeRequest( |
|
704
|
|
|
'/reference/sites/' . $data['code'] . '/edit', |
|
705
|
|
|
Client::METHOD_POST, |
|
706
|
|
|
array( |
|
707
|
|
|
'site' => json_encode($data) |
|
708
|
|
|
) |
|
709
|
|
|
); |
|
710
|
|
|
} |
|
711
|
|
|
|
|
712
|
|
|
/** |
|
713
|
|
|
* Update CRM basic statistic |
|
714
|
|
|
* |
|
715
|
|
|
* @return ApiResponse |
|
716
|
|
|
*/ |
|
717
|
|
|
public function statisticUpdate() |
|
718
|
|
|
{ |
|
719
|
|
|
return $this->client->makeRequest('/statistic/update', Client::METHOD_GET); |
|
720
|
|
|
} |
|
721
|
|
|
|
|
722
|
|
|
/** |
|
723
|
|
|
* Return current site |
|
724
|
|
|
* |
|
725
|
|
|
* @return string |
|
726
|
|
|
*/ |
|
727
|
|
|
public function getSite() |
|
728
|
|
|
{ |
|
729
|
|
|
return $this->siteCode; |
|
730
|
|
|
} |
|
731
|
|
|
|
|
732
|
|
|
/** |
|
733
|
|
|
* Set site |
|
734
|
|
|
* |
|
735
|
|
|
* @param string $site |
|
736
|
|
|
* @return void |
|
737
|
|
|
*/ |
|
738
|
|
|
public function setSite($site) |
|
739
|
|
|
{ |
|
740
|
|
|
$this->siteCode = $site; |
|
741
|
|
|
} |
|
742
|
|
|
|
|
743
|
|
|
/** |
|
744
|
|
|
* Check ID parameter |
|
745
|
|
|
* |
|
746
|
|
|
* @param string $by |
|
747
|
|
|
* @return bool |
|
748
|
|
|
*/ |
|
749
|
|
|
protected function checkIdParameter($by) |
|
750
|
|
|
{ |
|
751
|
|
|
$allowedForBy = array('externalId', 'id'); |
|
752
|
|
|
if (!in_array($by, $allowedForBy)) { |
|
753
|
|
|
throw new \InvalidArgumentException(sprintf( |
|
754
|
|
|
'Value "%s" for parameter "by" is not valid. Allowed values are %s.', |
|
755
|
|
|
$by, |
|
756
|
|
|
implode(', ', $allowedForBy) |
|
757
|
|
|
)); |
|
758
|
|
|
} |
|
759
|
|
|
|
|
760
|
|
|
return true; |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
/** |
|
764
|
|
|
* Fill params by site value |
|
765
|
|
|
* |
|
766
|
|
|
* @param string $site |
|
767
|
|
|
* @param array $params |
|
768
|
|
|
* @return array |
|
769
|
|
|
*/ |
|
770
|
|
|
protected function fillSite($site, array $params) |
|
771
|
|
|
{ |
|
772
|
|
|
if ($site) { |
|
773
|
|
|
$params['site'] = $site; |
|
774
|
|
|
} elseif ($this->siteCode) { |
|
775
|
|
|
$params['site'] = $this->siteCode; |
|
776
|
|
|
} |
|
777
|
|
|
|
|
778
|
|
|
return $params; |
|
779
|
|
|
} |
|
780
|
|
|
} |
|
781
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.