Passed
Push — main ( 6bf038...55787e )
by Aleksandr
08:10
created

Order   A

Complexity

Total Complexity 37

Size/Duplication

Total Lines 533
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 76
c 1
b 0
f 0
dl 0
loc 533
ccs 92
cts 92
cp 1
rs 9.44
wmc 37

37 Methods

Rating   Name   Duplication   Size   Complexity  
A setPayType() 0 4 1
A setService() 0 4 1
A getDeliverySet() 0 3 1
A setItems() 0 4 1
A getReceiver() 0 3 1
A getPriced() 0 3 1
A getPayType() 0 3 1
A setBarcode() 0 4 1
A setInstruction() 0 4 1
A getItems() 0 3 1
A getService() 0 3 1
A setWeight() 0 4 1
A setPriced() 0 4 1
A setReceiver() 0 4 1
A setDepartment() 0 4 1
A setPackages() 0 4 1
A getInstruction() 0 3 1
A setInshPrice() 0 4 1
A getQuantity() 0 3 1
A getPackages() 0 3 1
A getAcceptpartially() 0 3 1
A getWeight() 0 3 1
A setAcceptpartially() 0 4 1
A setQuantity() 0 4 1
A setUpsnak() 0 4 1
A getErrors() 0 3 1
A setPrice() 0 4 1
A setNumber() 0 4 1
A setRuPostType() 0 4 1
A getRuPostType() 0 3 1
A getBarcode() 0 3 1
A getNumber() 0 3 1
A getPrice() 0 3 1
A getInshPrice() 0 3 1
A getDepartment() 0 3 1
A setDeliverySet() 0 4 1
A getUpsnak() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DalliSDK\Models;
6
7
use DalliSDK\Models\Responses\Error;
8
use DalliSDK\Traits\Fillable;
9
use JMS\Serializer\Annotation as JMS;
10
11
/**
12
 * Модель заявки (заказа)
13
 *
14
 * @see https://api.dalli-service.com/v1/doc/createbasket
15
 * @JMS\XmlRoot("order")
16
 */
17
class Order
18
{
19
    use Fillable;
20
21
    /**
22
     * Штрих-код заказа в системе Dalli (аттрибут)
23
     *
24
     * @JMS\Type("string")
25
     * @JMS\SerializedName("barcode")
26
     */
27
    private ?string $barcode = null;
28
29
    /**
30
     * Номер заявки в учетной системе ИМ (обязательный атрибут)
31
     *
32
     * @JMS\XmlAttribute()
33
     * @JMS\Type("string")
34
     * @JMS\SerializedName("number")
35
     */
36
    private string $number;
37
38
    /**
39
     * Информации о получателе (обязательный тег)
40
     *
41
     * @JMS\Type("DalliSDK\Models\Receiver")
42
     * @JMS\SerializedName("receiver")
43
     */
44
    private Receiver $receiver;
45
46
    /**
47
     * Код торговой точки (для использования необходимо согласование с персональным менеджером).
48
     * Работает только для экспресс доставки (код 2).
49
     * При другом типе доставки игнорируется
50
     *
51
     * @JMS\Type("string")
52
     * @JMS\SerializedName("department")
53
     */
54
    private ?string $department = null;
55
56
    /**
57
     * Тип доставки (код из соответствующего справочника). Обязательный тег
58
     *
59
     * @see https://api.dalli-service.com/v1/doc/request-types-of-delivery
60
     * @JMS\Type("int")
61
     * @JMS\SerializedName("service")
62
     */
63
    private int $service;
64
65
    /**
66
     * Общий вес в килограммах (если пусто = 0.1)
67
     *
68
     * @JMS\Type("float")
69
     * @JMS\SerializedName("weight")
70
     */
71
    private ?float $weight;
72
73
    /**
74
     * Количество мест, не путать с количеством товара (если пусто = 1)
75
     *
76
     * @JMS\Type("int")
77
     * @JMS\SerializedName("quantity")
78
     */
79
    private int $quantity;
80
81
    /**
82
     * Тип оплаты получателем (если пусто или неверно = cash)
83
     * Может быть:
84
     *  CASH - наличными, при получении (по умолчанию)
85
     *  CARD - картой, при получении
86
     *  NO - без оплаты, поле price будет обнулено
87
     *
88
     * @JMS\Type("string")
89
     * @JMS\SerializedName("paytype")
90
     */
91
    private ?string $payType = null;
92
93
94
    /**
95
     * Тип услуги Почты России
96
     * Может быть:
97
     *  1 - Посылка онлайн
98
     *  2 - Курьер онлайн
99
     *  3 - Посылка нестандартная
100
     *  4 - Посылка 1-го класса
101
     *
102
     * @JMS\Type("int")
103
     * @JMS\SerializedName("type")
104
     */
105
    private ?int $ruPostType = null;
106
107
    /**
108
     * Сумма наложенного платежа
109
     *
110
     * @JMS\Type("float")
111
     * @JMS\SerializedName("price")
112
     */
113
    private ?float $price = null;
114
115
    /**
116
     * Стоимость доставки.
117
     * Её возьмут с получателя в любом случае, если курьер был на адресе
118
     *
119
     * @JMS\Type("float")
120
     * @JMS\SerializedName("priced")
121
     */
122
    private ?float $priced = null;
123
124
    /**
125
     * Объявленная ценность
126
     *
127
     * @JMS\Type("float")
128
     * @JMS\SerializedName("inshprice")
129
     */
130
    private ?float $inshPrice = null;
131
132
    /**
133
     * Признак необходимости возврата (T - нужен возврат, F -  не нужен возврат)
134
     *
135
     * @JMS\Type("string")
136
     * @JMS\SerializedName("upsnak")
137
     */
138
    private ?string $upsnak = null;
139
140
    /**
141
     * Поручение, примечание для курьера
142
     *
143
     * @JMS\Type("string")
144
     * @JMS\SerializedName("instruction")
145
     */
146
    private ?string $instruction = null;
147
148
    /**
149
     * Разрешение/запрет частичного выкупа.
150
     * Принимает значения:
151
     *  YES - когда частичный выкуп доступен,
152
     *  NO - если не доступен.
153
     * По-умолчанию берётся значение из карточки клиента
154
     *
155
     * @JMS\Type("string")
156
     * @JMS\SerializedName("acceptpartially")
157
     */
158
    private ?string $acceptpartially = null;
159
160
    /**
161
     * Настройка дифференциальной стоимости доставки
162
     * Внимание! При явном указании дифференциальной стоимости доставки игнорируется тег priced, а так же настройки Личного Кабинета.
163
     * Если у вас одинаковые условия по стоимости доставки для всех заявок, тогда вы можете задать их глобально в Личном Кабинете
164
     *
165
     * @see https://api.dalli-service.com/v1/doc/request-types-of-delivery
166
     * @JMS\Type("DalliSDK\Models\DeliverySet")
167
     * @JMS\SerializedName("deliveryset")
168
     */
169
    private DeliverySet $deliverySet;
170
171
    /**
172
     * Корневой контейнер вложений (товаров)
173
     *
174
     * @JMS\Type("array<DalliSDK\Models\Item>")
175
     * @JMS\XmlList(entry = "item")
176
     * @JMS\SerializedName("items")
177
     * @var Item[]
178
     */
179
    private ?array $items = null;
180
181
    /**
182
     * Корневой контейнер мест (грузоместа)
183
     * Для получения доступа к добавлению мест обратитесь к вашему менеджеру. По умолчанию, данная опция недоступна.
184
     *
185
     * @JMS\Type("array<DalliSDK\Models\Packages>")
186
     * @JMS\XmlList(entry = "package")
187
     * @JMS\SerializedName("packages")
188
     * @var Package[]
189
     */
190
    private ?array $packages = null;
191
192
    /**
193
     * Если запрос был с ошибкой, то ответ мапится сюда
194
     *
195
     * @JMS\Type("array<DalliSDK\Models\Responses\Error>")
196
     * @JMS\XmlList(inline = false, entry = "error")
197
     * @var Error[]
198
     *
199
     */
200
    private ?array $errors = null;
201
202
    /**
203
     * @return string
204
     */
205 2
    public function getNumber(): string
206
    {
207 2
        return $this->number;
208
    }
209
210
    /**
211
     * @param string $number
212
     *
213
     * @return Order
214
     */
215 4
    public function setNumber(string $number): Order
216
    {
217 4
        $this->number = $number;
218 4
        return $this;
219
    }
220
221
    /**
222
     * @return Receiver
223
     */
224 1
    public function getReceiver(): Receiver
225
    {
226 1
        return $this->receiver;
227
    }
228
229
    /**
230
     * @param Receiver $receiver
231
     *
232
     * @return Order
233
     */
234 4
    public function setReceiver(Receiver $receiver): Order
235
    {
236 4
        $this->receiver = $receiver;
237 4
        return $this;
238
    }
239
240
    /**
241
     * @return string|null
242
     */
243 1
    public function getDepartment(): ?string
244
    {
245 1
        return $this->department;
246
    }
247
248
    /**
249
     * @param string|null $department
250
     *
251
     * @return Order
252
     */
253 1
    public function setDepartment(?string $department): Order
254
    {
255 1
        $this->department = $department;
256 1
        return $this;
257
    }
258
259
    /**
260
     * @return int
261
     */
262 1
    public function getService(): int
263
    {
264 1
        return $this->service;
265
    }
266
267
    /**
268
     * @param int $service
269
     *
270
     * @return Order
271
     */
272 3
    public function setService(int $service): Order
273
    {
274 3
        $this->service = $service;
275 3
        return $this;
276
    }
277
278
    /**
279
     * @return float|null
280
     */
281 1
    public function getWeight(): ?float
282
    {
283 1
        return $this->weight;
284
    }
285
286
    /**
287
     * @param float|null $weight
288
     *
289
     * @return Order
290
     */
291 3
    public function setWeight(?float $weight): Order
292
    {
293 3
        $this->weight = $weight;
294 3
        return $this;
295
    }
296
297
    /**
298
     * @return int
299
     */
300 1
    public function getQuantity(): int
301
    {
302 1
        return $this->quantity;
303
    }
304
305
    /**
306
     * @param int $quantity
307
     *
308
     * @return Order
309
     */
310 3
    public function setQuantity(int $quantity): Order
311
    {
312 3
        $this->quantity = $quantity;
313 3
        return $this;
314
    }
315
316
    /**
317
     * @return string|null
318
     */
319 1
    public function getPayType(): ?string
320
    {
321 1
        return $this->payType;
322
    }
323
324
    /**
325
     * @param string|null $payType
326
     *
327
     * @return Order
328
     */
329 3
    public function setPayType(?string $payType): Order
330
    {
331 3
        $this->payType = $payType;
332 3
        return $this;
333
    }
334
335
    /**
336
     * @return float|null
337
     */
338 1
    public function getPrice(): ?float
339
    {
340 1
        return $this->price;
341
    }
342
343
    /**
344
     * @param float|null $price
345
     *
346
     * @return Order
347
     */
348 4
    public function setPrice(?float $price): Order
349
    {
350 4
        $this->price = $price;
351 4
        return $this;
352
    }
353
354
    /**
355
     * @return float|null
356
     */
357 1
    public function getPriced(): ?float
358
    {
359 1
        return $this->priced;
360
    }
361
362
    /**
363
     * @param float|null $priced
364
     *
365
     * @return Order
366
     */
367 3
    public function setPriced(?float $priced): Order
368
    {
369 3
        $this->priced = $priced;
370 3
        return $this;
371
    }
372
373
    /**
374
     * @return float|null
375
     */
376 1
    public function getInshPrice(): ?float
377
    {
378 1
        return $this->inshPrice;
379
    }
380
381
    /**
382
     * @param float|null $inshPrice
383
     *
384
     * @return Order
385
     */
386 4
    public function setInshPrice(?float $inshPrice): Order
387
    {
388 4
        $this->inshPrice = $inshPrice;
389 4
        return $this;
390
    }
391
392
    /**
393
     * @return string|null
394
     */
395 1
    public function getUpsnak(): ?string
396
    {
397 1
        return $this->upsnak;
398
    }
399
400
    /**
401
     * @param string|null $upsnak
402
     *
403
     * @return Order
404
     */
405 2
    public function setUpsnak(?string $upsnak): Order
406
    {
407 2
        $this->upsnak = $upsnak;
408 2
        return $this;
409
    }
410
411
    /**
412
     * @return string|null
413
     */
414 1
    public function getInstruction(): ?string
415
    {
416 1
        return $this->instruction;
417
    }
418
419
    /**
420
     * @param string|null $instruction
421
     *
422
     * @return Order
423
     */
424 4
    public function setInstruction(?string $instruction): Order
425
    {
426 4
        $this->instruction = $instruction;
427 4
        return $this;
428
    }
429
430
    /**
431
     * @return string|null
432
     */
433 1
    public function getAcceptpartially(): ?string
434
    {
435 1
        return $this->acceptpartially;
436
    }
437
438
    /**
439
     * @param string|null $acceptpartially
440
     *
441
     * @return Order
442
     */
443 2
    public function setAcceptpartially(?string $acceptpartially): Order
444
    {
445 2
        $this->acceptpartially = $acceptpartially;
446 2
        return $this;
447
    }
448
449
    /**
450
     * @return DeliverySet
451
     */
452 1
    public function getDeliverySet(): DeliverySet
453
    {
454 1
        return $this->deliverySet;
455
    }
456
457
    /**
458
     * @param DeliverySet $deliverySet
459
     *
460
     * @return Order
461
     */
462 2
    public function setDeliverySet(DeliverySet $deliverySet): Order
463
    {
464 2
        $this->deliverySet = $deliverySet;
465 2
        return $this;
466
    }
467
468
    /**
469
     * @return array|null
470
     */
471 1
    public function getItems(): ?array
472
    {
473 1
        return $this->items;
474
    }
475
476
    /**
477
     * @param array|null $items
478
     *
479
     * @return Order
480
     */
481 3
    public function setItems(?array $items): Order
482
    {
483 3
        $this->items = $items;
484 3
        return $this;
485
    }
486
487
    /**
488
     * @return array|null
489
     */
490 1
    public function getPackages(): ?array
491
    {
492 1
        return $this->packages;
493
    }
494
495
    /**
496
     * @param array|null $packages
497
     *
498
     * @return Order
499
     */
500 1
    public function setPackages(?array $packages): Order
501
    {
502 1
        $this->packages = $packages;
503 1
        return $this;
504
    }
505
506
    /**
507
     * @return string|null
508
     */
509 2
    public function getBarcode(): ?string
510
    {
511 2
        return $this->barcode;
512
    }
513
514
    /**
515
     * @param string $barcode
516
     *
517
     * @return Order
518
     */
519 2
    public function setBarcode(string $barcode): Order
520
    {
521 2
        $this->barcode = $barcode;
522 2
        return $this;
523
    }
524
525
    /**
526
     * @return array|null
527
     */
528 1
    public function getErrors(): ?array
529
    {
530 1
        return $this->errors;
531
    }
532
533
    /**
534
     * @return int|null
535
     */
536 1
    public function getRuPostType(): ?int
537
    {
538 1
        return $this->ruPostType;
539
    }
540
541
    /**
542
     * @param int|null $ruPostType
543
     *
544
     * @return Order
545
     */
546 2
    public function setRuPostType(?int $ruPostType): Order
547
    {
548 2
        $this->ruPostType = $ruPostType;
549 2
        return $this;
550
    }
551
}
552