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
|
|
|
$this->methodProperties['Number'] = $ttn; |
31
|
|
|
|
32
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Проверка возможности создания заявки на переадресацию отправки. |
37
|
|
|
* |
38
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a8d29fc2-8512-11ec-8ced-005056b2dbe1 Возможность переадресации |
39
|
|
|
* |
40
|
|
|
* @param string $ttn |
41
|
|
|
* @return array |
42
|
|
|
*/ |
43
|
|
|
public function checkPossibilityForRedirecting(string $ttn): array |
44
|
|
|
{ |
45
|
|
|
$this->calledMethod = 'checkPossibilityForRedirecting'; |
46
|
|
|
$this->methodProperties['Number'] = $ttn; |
47
|
|
|
|
48
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Получение списка причин возврата. |
53
|
|
|
* |
54
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7a6bacb-8512-11ec-8ced-005056b2dbe1 Список причин возврата |
55
|
|
|
* |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function getReturnReasons(): array |
59
|
|
|
{ |
60
|
|
|
$this->calledMethod = 'getReturnReasons'; |
61
|
|
|
$this->methodProperties = null; |
62
|
|
|
|
63
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Получение списка подтипов причины возврата. |
68
|
|
|
* |
69
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7cb69ee-8512-11ec-8ced-005056b2dbe1 Список подтипов причины возврата |
70
|
|
|
* |
71
|
|
|
* @param string|null $ref |
72
|
|
|
* @return array |
73
|
|
|
*/ |
74
|
|
|
public function getReturnReasonsSubtypes(?string $ref = null): array |
75
|
|
|
{ |
76
|
|
|
$this->calledMethod = 'getReturnReasonsSubtypes'; |
77
|
|
|
$this->methodProperties['ReasonRef'] = $ref ?: config('novaposhta.ref_return_reasons'); |
78
|
|
|
|
79
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Получение списка заявок на возврат. |
84
|
|
|
* |
85
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7cb69ee-8512-11ec-8ced-005056b2dbe1 Список заявок на возврат |
86
|
|
|
* |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public function getReturnOrdersList(): array |
90
|
|
|
{ |
91
|
|
|
$this->calledMethod = 'getReturnOrdersList'; |
92
|
|
|
$this->methodProperties = null; |
93
|
|
|
|
94
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Получение списка заявок на переадресацию отправлений. |
99
|
|
|
* |
100
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a8faa2e6-8512-11ec-8ced-005056b2dbe1 Список заявок на переадресацию |
101
|
|
|
* |
102
|
|
|
* @return array |
103
|
|
|
*/ |
104
|
|
|
public function getRedirectionOrdersList(): array |
105
|
|
|
{ |
106
|
|
|
$this->calledMethod = 'getRedirectionOrdersList'; |
107
|
|
|
$this->methodProperties = null; |
108
|
|
|
|
109
|
|
|
$this->addLimit(); |
110
|
|
|
$this->getPage(); |
111
|
|
|
|
112
|
|
|
$this->getNumber(); |
113
|
|
|
$this->getDateBeginEnd(); |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
if ($this->Ref) { |
117
|
|
|
$this->methodProperties['Ref'] = $this->Ref; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Создание заявки на возврат. |
125
|
|
|
* |
126
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7fb4a3a-8512-11ec-8ced-005056b2dbe1 Возврат на адрес отправителя |
127
|
|
|
* |
128
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/5a64f960-e7fa-11ec-a60f-48df37b921db Возврат на новый адрес отделения |
129
|
|
|
* |
130
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/175baec3-8f0d-11ec-8ced-005056b2dbe1 Возврат на новый адрес по адресной доставке |
131
|
|
|
* |
132
|
|
|
* @param string $ttn |
133
|
|
|
* @return array |
134
|
|
|
*/ |
135
|
|
|
public function save(string $ttn): array |
136
|
|
|
{ |
137
|
|
|
$this->calledMethod = 'save'; |
138
|
|
|
|
139
|
|
|
$this->methodProperties['IntDocNumber'] = $ttn; |
140
|
|
|
$this->methodProperties['OrderType'] = 'orderCargoReturn'; |
141
|
|
|
$this->getPaymentMethod(); |
142
|
|
|
$this->getReason(); |
143
|
|
|
$this->getSubtypeReason(); |
144
|
|
|
$this->getNote(); |
145
|
|
|
|
146
|
|
|
if (! $this->Note) { |
147
|
|
|
$this->methodProperties['Note'] = config('novaposhta.return_note'); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Возврат на адрес отправления. |
152
|
|
|
*/ |
153
|
|
|
$this->getReturnAddressRef(); |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Возврат на новый адрес отделения. |
157
|
|
|
*/ |
158
|
|
|
$this->getRecipientWarehouse(); |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Возврат на новый адрес по адресной доставке. |
162
|
|
|
*/ |
163
|
|
|
$this->getRecipientSettlement(); |
164
|
|
|
|
165
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Удаление заявки на возврат, заявку об изменении данных или заявку переадресации. |
170
|
|
|
* |
171
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a85bb34b-8512-11ec-8ced-005056b2dbe1 Удаление заявки |
172
|
|
|
* |
173
|
|
|
* @param string $Ref |
174
|
|
|
* @return array |
175
|
|
|
*/ |
176
|
|
|
public function delete(string $Ref): array |
177
|
|
|
{ |
178
|
|
|
$this->calledMethod = 'delete'; |
179
|
|
|
|
180
|
|
|
$this->methodProperties['Ref'] = $Ref; |
181
|
|
|
|
182
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|