1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Daaner\NovaPoshta\Models; |
4
|
|
|
|
5
|
|
|
use Daaner\NovaPoshta\NovaPoshta; |
6
|
|
|
use Daaner\NovaPoshta\Traits\AdditionalServiceProperty; |
7
|
|
|
use Daaner\NovaPoshta\Traits\DateTimes; |
8
|
|
|
use Daaner\NovaPoshta\Traits\InternetDocumentProperty; |
9
|
|
|
use Daaner\NovaPoshta\Traits\Limit; |
10
|
|
|
|
11
|
|
|
class AdditionalService extends NovaPoshta |
12
|
|
|
{ |
13
|
|
|
protected $model = 'AdditionalService'; |
14
|
|
|
protected $calledMethod; |
15
|
|
|
protected $methodProperties = []; |
16
|
|
|
|
17
|
|
|
use InternetDocumentProperty, AdditionalServiceProperty, Limit, DateTimes; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Проверка возможности создания заявки на возврат. |
21
|
|
|
* |
22
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a778f519-8512-11ec-8ced-005056b2dbe1 Возможность возврата |
23
|
|
|
* |
24
|
|
|
* @param string $ttn Номер ТТН |
25
|
|
|
* @return array |
26
|
|
|
*/ |
27
|
|
|
public function CheckPossibilityCreateReturn(string $ttn): array |
28
|
|
|
{ |
29
|
|
|
$this->calledMethod = 'CheckPossibilityCreateReturn'; |
30
|
|
|
|
31
|
|
|
$this->methodProperties['Number'] = $ttn; |
32
|
|
|
|
33
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Проверка возможности создания заявки на переадресацию отправки. |
38
|
|
|
* |
39
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a8d29fc2-8512-11ec-8ced-005056b2dbe1 Возможность переадресации |
40
|
|
|
* |
41
|
|
|
* @param string $ttn Номер ТТН |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
|
|
public function checkPossibilityForRedirecting(string $ttn): array |
45
|
|
|
{ |
46
|
|
|
$this->calledMethod = 'checkPossibilityForRedirecting'; |
47
|
|
|
|
48
|
|
|
$this->methodProperties['Number'] = $ttn; |
49
|
|
|
|
50
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Получение списка причин возврата. |
55
|
|
|
* |
56
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7a6bacb-8512-11ec-8ced-005056b2dbe1 Список причин возврата |
57
|
|
|
* |
58
|
|
|
* @return array |
59
|
|
|
*/ |
60
|
|
|
public function getReturnReasons(): array |
61
|
|
|
{ |
62
|
|
|
$this->calledMethod = 'getReturnReasons'; |
63
|
|
|
|
64
|
|
|
$this->methodProperties = null; |
65
|
|
|
|
66
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Получение списка подтипов причины возврата. |
71
|
|
|
* |
72
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7cb69ee-8512-11ec-8ced-005056b2dbe1 Список подтипов причины возврата |
73
|
|
|
* |
74
|
|
|
* @param string|null $ref Ref причины |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function getReturnReasonsSubtypes(?string $ref = null): array |
78
|
|
|
{ |
79
|
|
|
$this->calledMethod = 'getReturnReasonsSubtypes'; |
80
|
|
|
|
81
|
|
|
$this->methodProperties['ReasonRef'] = $ref ?: config('novaposhta.ref_return_reasons'); |
82
|
|
|
|
83
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Получение списка заявок на возврат. |
88
|
|
|
* |
89
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7cb69ee-8512-11ec-8ced-005056b2dbe1 Список заявок на возврат |
90
|
|
|
* |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
|
|
public function getReturnOrdersList(): array |
94
|
|
|
{ |
95
|
|
|
$this->calledMethod = 'getReturnOrdersList'; |
96
|
|
|
|
97
|
|
|
$this->methodProperties = null; |
98
|
|
|
|
99
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Получение списка заявок на переадресацию отправлений. |
104
|
|
|
* |
105
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a8faa2e6-8512-11ec-8ced-005056b2dbe1 Список заявок на переадресацию |
106
|
|
|
* |
107
|
|
|
* @return array |
108
|
|
|
*/ |
109
|
|
|
public function getRedirectionOrdersList(): array |
110
|
|
|
{ |
111
|
|
|
$this->calledMethod = 'getRedirectionOrdersList'; |
112
|
|
|
|
113
|
|
|
$this->methodProperties = null; |
114
|
|
|
|
115
|
|
|
$this->addLimit(); |
116
|
|
|
$this->getPage(); |
117
|
|
|
|
118
|
|
|
$this->getNumber(); |
119
|
|
|
$this->getDateBeginEnd(); |
120
|
|
|
|
121
|
|
|
if ($this->Ref) { |
122
|
|
|
$this->methodProperties['Ref'] = $this->Ref; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Создание заявки на возврат. |
130
|
|
|
* |
131
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7fb4a3a-8512-11ec-8ced-005056b2dbe1 Возврат на адрес отправителя |
132
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/5a64f960-e7fa-11ec-a60f-48df37b921db Возврат на новый адрес отделения |
133
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/175baec3-8f0d-11ec-8ced-005056b2dbe1 Возврат на новый адрес по адресной доставке |
134
|
|
|
* |
135
|
|
|
* @param string $ttn Номер ТТН |
136
|
|
|
* @param bool|null $isRedirecting Флаг, что заявка является переадресацией |
137
|
|
|
* @return array |
138
|
|
|
*/ |
139
|
|
|
public function save(string $ttn, ?bool $isRedirecting = false): array |
140
|
|
|
{ |
141
|
|
|
$this->calledMethod = 'save'; |
142
|
|
|
|
143
|
|
|
$this->methodProperties['IntDocNumber'] = $ttn; |
144
|
|
|
|
145
|
|
|
$this->getPaymentMethod(); |
146
|
|
|
$this->getNote(); |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Переадресация или возврат |
150
|
|
|
*/ |
151
|
|
|
if ($isRedirecting) { |
152
|
|
|
$this->methodProperties['OrderType'] = 'orderRedirecting'; |
153
|
|
|
$this->getPayerType(); |
154
|
|
|
$this->getCustomer(); |
155
|
|
|
$this->getServiceType(); |
156
|
|
|
$this->getRecipientData(); |
157
|
|
|
} else { |
158
|
|
|
$this->methodProperties['OrderType'] = 'orderCargoReturn'; |
159
|
|
|
|
160
|
|
|
// При возврате нужно указать причину и подтип причины |
161
|
|
|
$this->getReason(); |
162
|
|
|
$this->getSubtypeReason(); |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Возврат/переадресация на адрес отправления. |
166
|
|
|
*/ |
167
|
|
|
$this->getReturnAddressRef(); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
if (! $this->Note) { |
171
|
|
|
$this->methodProperties['Note'] = config('novaposhta.return_note'); |
172
|
|
|
|
173
|
|
|
if ($isRedirecting) { |
174
|
|
|
$this->methodProperties['Note'] = config('novaposhta.redirecting_note'); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Возврат/переадресация на новый адрес отделения. |
180
|
|
|
*/ |
181
|
|
|
$this->getRecipientWarehouse(); |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Возврат/переадресация на новый адрес по адресной доставке. |
185
|
|
|
*/ |
186
|
|
|
$this->getRecipientSettlement(); |
187
|
|
|
|
188
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Создание заявки на переадресацию. |
193
|
|
|
* |
194
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/98acb0f6-8f0b-11ec-8ced-005056b2dbe1 Создание заявки на переадресацию |
195
|
|
|
* |
196
|
|
|
* @param string $ttn Номер ТТН |
197
|
|
|
* @return array |
198
|
|
|
*/ |
199
|
|
|
public function saveRedirecting(string $ttn): array |
200
|
|
|
{ |
201
|
|
|
return $this->save($ttn, true); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Удаление заявки на возврат, заявку об изменении данных или заявку переадресации. |
206
|
|
|
* |
207
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a85bb34b-8512-11ec-8ced-005056b2dbe1 Удаление заявки |
208
|
|
|
* |
209
|
|
|
* @param string $Ref Ref заявки |
210
|
|
|
* @return array |
211
|
|
|
*/ |
212
|
|
|
public function delete(string $Ref): array |
213
|
|
|
{ |
214
|
|
|
$this->calledMethod = 'delete'; |
215
|
|
|
|
216
|
|
|
$this->methodProperties['Ref'] = $Ref; |
217
|
|
|
|
218
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Проверка продления хранения ТТН. |
223
|
|
|
* |
224
|
|
|
* @param string $ttn Номер ТТН |
225
|
|
|
* @return array |
226
|
|
|
*/ |
227
|
|
|
public function CheckPossibilityTermExtension(string $ttn): array |
228
|
|
|
{ |
229
|
|
|
$this->calledMethod = 'CheckPossibilityTermExtension'; |
230
|
|
|
|
231
|
|
|
$this->methodProperties['IntDocNumber'] = $ttn; |
232
|
|
|
|
233
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Проверка на изменения в ТТН. |
239
|
|
|
* |
240
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a886b776-8512-11ec-8ced-005056b2dbe1 Проверка на изменения в накладной |
241
|
|
|
* |
242
|
|
|
* @param string $ttn Номер ТТН |
243
|
|
|
* @return array |
244
|
|
|
*/ |
245
|
|
|
public function CheckPossibilityChangeEW(string $ttn): array |
246
|
|
|
{ |
247
|
|
|
$this->calledMethod = 'CheckPossibilityChangeEW'; |
248
|
|
|
|
249
|
|
|
$this->methodProperties['IntDocNumber'] = $ttn; |
250
|
|
|
|
251
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
|