1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Orders\Entites; |
6
|
|
|
|
7
|
|
|
use Appwilio\RussianPostSDK\Dispatching\DataAware; |
8
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable; |
9
|
|
|
|
10
|
|
|
final class CustomsDeclaration implements Arrayable |
11
|
|
|
{ |
12
|
|
|
use DataAware; |
13
|
|
|
|
14
|
|
|
/** @var CustomsDeclarationItem[] */ |
15
|
|
|
private $items; |
16
|
|
|
|
17
|
|
|
public function __construct($entriesType, $currency) |
18
|
|
|
{ |
19
|
|
|
$this->data['entries-type'] = $entriesType; |
20
|
|
|
$this->data['currency'] = $currency; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function addItem(CustomsDeclarationItem $item): void |
24
|
|
|
{ |
25
|
|
|
$this->items[] = $item; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function addInvoice(string $number) |
29
|
|
|
{ |
30
|
|
|
$this->data['with-invoice'] = true; |
31
|
|
|
$this->data['invoice-number'] = $number; |
32
|
|
|
|
33
|
|
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function addCertificate(string $number) |
37
|
|
|
{ |
38
|
|
|
$this->data['with-certificate'] = true; |
39
|
|
|
$this->data['certificate-number'] = $number; |
40
|
|
|
|
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function addLicense(string $number) |
45
|
|
|
{ |
46
|
|
|
$this->data['with-license'] = true; |
47
|
|
|
$this->data['license-number'] = $number; |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getCurrency(): string |
53
|
|
|
{ |
54
|
|
|
return $this->get('entries-type'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getEntriesType(): string |
58
|
|
|
{ |
59
|
|
|
return $this->get('invoice-number'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getInvoice(): ?string |
63
|
|
|
{ |
64
|
|
|
return $this->get('invoice-number'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getCertificate(): ?string |
68
|
|
|
{ |
69
|
|
|
return $this->get('certificate-number'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getLicense(): ?string |
73
|
|
|
{ |
74
|
|
|
return $this->get('license-number'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function hasInvoice(): bool |
78
|
|
|
{ |
79
|
|
|
return (bool) $this->get('with-invoice'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function hasCertificate(): bool |
83
|
|
|
{ |
84
|
|
|
return (bool) $this->get('with-certificate'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function hasLicense(): bool |
88
|
|
|
{ |
89
|
|
|
return (bool) $this->get('with-license'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function toArray(): array |
93
|
|
|
{ |
94
|
|
|
foreach ($this->items as $entry) { |
95
|
|
|
$this->data['customs-entries'][] = $entry->toArray(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return $this->data; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|