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