1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of RussianPost SDK package. |
5
|
|
|
* |
6
|
|
|
* © Appwilio (http://appwilio.com), JhaoDa (https://github.com/jhaoda) |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\PostOffices\Responses; |
15
|
|
|
|
16
|
|
|
use Appwilio\RussianPostSDK\Dispatching\DataAware; |
17
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Instantiator; |
18
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Http\ArrayOf; |
19
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable; |
20
|
|
|
|
21
|
|
|
final class PostOffice implements Arrayable |
22
|
|
|
{ |
23
|
|
|
use DataAware; |
24
|
|
|
|
25
|
|
|
public function getAddress(): string |
26
|
|
|
{ |
27
|
|
|
return $this->get('address-source'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getPostalCode(): string |
31
|
|
|
{ |
32
|
|
|
return $this->get('postal-code'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function isPermanentlyClosed(): bool |
36
|
|
|
{ |
37
|
|
|
return $this->get('is-closed'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function isTemporarilyClosed(): bool |
41
|
|
|
{ |
42
|
|
|
return $this->get('is-temporary-closed'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getTemporarilyClosedReason(): ?string |
46
|
|
|
{ |
47
|
|
|
return $this->get('temporary-closed-reason'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getDistrict(): ?string |
51
|
|
|
{ |
52
|
|
|
return $this->get('district'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getRegion(): ?string |
56
|
|
|
{ |
57
|
|
|
return $this->get('region'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getSettlement(): ?string |
61
|
|
|
{ |
62
|
|
|
return $this->get('settlement'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getTypeId(): int |
66
|
|
|
{ |
67
|
|
|
return $this->get('type-id'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getTypeCode(): string |
71
|
|
|
{ |
72
|
|
|
return $this->get('type-code'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getUfpsCode(): ?string |
76
|
|
|
{ |
77
|
|
|
return $this->get('ufps-code'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function hasNearestPostOffice(): bool |
81
|
|
|
{ |
82
|
|
|
return isset($this->data['nearest-post-office']); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getNearestPostOffice(): ?PostOffice |
86
|
|
|
{ |
87
|
|
|
return Instantiator::instantiate(self::class, $this->get('nearest-post-office')); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return Phone[]|null |
92
|
|
|
*/ |
93
|
|
|
public function getPhones() |
94
|
|
|
{ |
95
|
|
|
return Instantiator::instantiate(new ArrayOf(Phone::class), $this->get('phones')); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return WorkingHours[]|null |
100
|
|
|
*/ |
101
|
|
|
public function getWorkingHours() |
102
|
|
|
{ |
103
|
|
|
return Instantiator::instantiate(new ArrayOf(WorkingHours::class), $this->get('working-hours')); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return WorkingHours[]|null |
108
|
|
|
*/ |
109
|
|
|
public function getCurrentDayWorkingHours() |
110
|
|
|
{ |
111
|
|
|
return Instantiator::instantiate(new ArrayOf(WorkingHours::class), $this->get('current-day-working-hours')); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return WorkingHours[]|null |
116
|
|
|
*/ |
117
|
|
|
public function getNextDayWorkingHours() |
118
|
|
|
{ |
119
|
|
|
return Instantiator::instantiate(new ArrayOf(WorkingHours::class), $this->get('next-day-working-hours')); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getCoordinates(): Coordinates |
123
|
|
|
{ |
124
|
|
|
return new Coordinates($this->get('latitude'), $this->get('longitude')); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return Service[]|null |
129
|
|
|
*/ |
130
|
|
|
public function getServices() |
131
|
|
|
{ |
132
|
|
|
return Instantiator::instantiate(new ArrayOf(Service::class), $this->get('service-groups')); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|