1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Appwilio\RussianPostSDK\Dispatching\Entities; |
6
|
|
|
|
7
|
|
|
use Appwilio\RussianPostSDK\Dispatching\DataAware; |
8
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Instantiator; |
9
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Enum\AddressType; |
10
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable; |
11
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Entities\NormalizedAddress; |
12
|
|
|
|
13
|
|
|
final class Address implements Arrayable |
14
|
|
|
{ |
15
|
|
|
use DataAware; |
16
|
|
|
|
17
|
|
|
public static function fromNormalizedAddress(NormalizedAddress $address): self |
18
|
|
|
{ |
19
|
|
|
if ($address->isUnuseful()) { |
20
|
|
|
throw new \InvalidArgumentException('Неприемлемый адрес.'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
return Instantiator::instantiateFrom(self::class, $address, [ |
24
|
|
|
'id', 'original-address', 'quality-code', 'validation-code' |
25
|
|
|
]); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function __construct(?string $addressType = null) |
29
|
|
|
{ |
30
|
|
|
$this->setType($addressType ?? AddressType::DEFAULT); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function setType(string $addressType) |
34
|
|
|
{ |
35
|
|
|
$this->data['address-type'] = $addressType; |
36
|
|
|
|
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getAddressType(): string |
41
|
|
|
{ |
42
|
|
|
return $this->get('address-type'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getCountryCode(): ?string |
46
|
|
|
{ |
47
|
|
|
return $this->get('mail-direct'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function setCountryCode(int $countryCode) |
51
|
|
|
{ |
52
|
|
|
$this->data['mail-direct'] = $countryCode; |
53
|
|
|
|
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getIndex(): ?string |
58
|
|
|
{ |
59
|
|
|
return $this->get('index'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function setIndex(string $index) |
63
|
|
|
{ |
64
|
|
|
$this->data['index'] = $index; |
65
|
|
|
|
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getArea(): ?string |
70
|
|
|
{ |
71
|
|
|
return $this->get('area'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function setArea(string $area) |
75
|
|
|
{ |
76
|
|
|
$this->data['area'] = $area; |
77
|
|
|
|
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function getPlace(): ?string |
82
|
|
|
{ |
83
|
|
|
return $this->get('place'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function setPlace(string $place) |
87
|
|
|
{ |
88
|
|
|
$this->data['place'] = $place; |
89
|
|
|
|
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getRegion(): ?string |
94
|
|
|
{ |
95
|
|
|
return $this->get('region'); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function setRegion(string $region) |
99
|
|
|
{ |
100
|
|
|
$this->data['region'] = $region; |
101
|
|
|
|
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getLocation(): ?string |
106
|
|
|
{ |
107
|
|
|
return $this->get('location'); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function setLocation(string $location) |
111
|
|
|
{ |
112
|
|
|
$this->data['location'] = $location; |
113
|
|
|
|
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getStreet(): ?string |
118
|
|
|
{ |
119
|
|
|
return $this->get('street'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function setStreet(string $street) |
123
|
|
|
{ |
124
|
|
|
$this->data['street'] = $street; |
125
|
|
|
|
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function getHouse(): ?string |
130
|
|
|
{ |
131
|
|
|
return $this->get('house'); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function setHouse(string $house) |
135
|
|
|
{ |
136
|
|
|
$this->data['house'] = $house; |
137
|
|
|
|
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function getRoom(): ?string |
142
|
|
|
{ |
143
|
|
|
return $this->get('room'); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function setRoom(string $room) |
147
|
|
|
{ |
148
|
|
|
$this->data['room'] = $room; |
149
|
|
|
|
150
|
|
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function getSlash(): ?string |
154
|
|
|
{ |
155
|
|
|
return $this->get('slash'); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function setSlash(string $slash) |
159
|
|
|
{ |
160
|
|
|
$this->data['slash'] = $slash; |
161
|
|
|
|
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function getBuilding(): ?string |
166
|
|
|
{ |
167
|
|
|
return $this->get('building'); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function setBuilding(string $building) |
171
|
|
|
{ |
172
|
|
|
$this->data['building'] = $building; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
public function getCorpus(): ?string |
178
|
|
|
{ |
179
|
|
|
return $this->get('corpus'); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function setCorpus(string $corpus) |
183
|
|
|
{ |
184
|
|
|
$this->data['corpus'] = $corpus; |
185
|
|
|
|
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
public function getLetter(): ?string |
190
|
|
|
{ |
191
|
|
|
return $this->get('letter'); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
public function setLetter(string $letter) |
195
|
|
|
{ |
196
|
|
|
$this->data['letter'] = $letter; |
197
|
|
|
|
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
public function getHotel(): ?string |
202
|
|
|
{ |
203
|
|
|
return $this->get('hotel'); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
public function setHotel(string $hotel) |
207
|
|
|
{ |
208
|
|
|
$this->data['hotel'] = $hotel; |
209
|
|
|
|
210
|
|
|
return $this; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
public function getVladenie(): ?string |
214
|
|
|
{ |
215
|
|
|
return $this->get('vladenie'); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
public function setVladenie(string $vladenie) |
219
|
|
|
{ |
220
|
|
|
$this->data['vladenie'] = $vladenie; |
221
|
|
|
|
222
|
|
|
return $this; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
public function getNumAddressType(): ?string |
226
|
|
|
{ |
227
|
|
|
return $this->get('num-address-type'); |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
|