|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Daaner\NovaPoshta\Traits; |
|
4
|
|
|
|
|
5
|
|
|
trait InternetDocumentProperty |
|
6
|
|
|
{ |
|
7
|
|
|
protected $Ref; |
|
8
|
|
|
protected $PayerType; |
|
9
|
|
|
protected $ServiceType; |
|
10
|
|
|
protected $PaymentMethod; |
|
11
|
|
|
protected $CargoType; |
|
12
|
|
|
protected $SeatsAmount; |
|
13
|
|
|
protected $Cost; |
|
14
|
|
|
protected $Weight; |
|
15
|
|
|
protected $BackwardDeliveryData; |
|
16
|
|
|
protected $Note; |
|
17
|
|
|
protected $AdditionalInformation; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @param string $Ref |
|
22
|
|
|
* |
|
23
|
|
|
* @return $this |
|
24
|
|
|
*/ |
|
25
|
|
|
public function setRef(string $Ref) |
|
26
|
|
|
{ |
|
27
|
|
|
$this->Ref = $Ref; |
|
28
|
|
|
|
|
29
|
|
|
return $this; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getRef() |
|
33
|
|
|
{ |
|
34
|
|
|
if (!$this->Ref) { |
|
35
|
|
|
return $this; |
|
36
|
|
|
} |
|
37
|
|
|
$this->methodProperties['Ref'] = $this->Ref; |
|
38
|
|
|
|
|
39
|
|
|
return $this; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param string $PayerType |
|
44
|
|
|
* Устанавливаем значение плательщика. По умолчанию значение из конфига |
|
45
|
|
|
* @see https://devcenter.novaposhta.ua/docs/services/55702570a0fe4f0cf4fc53ed/operations/55702571a0fe4f0b64838913 |
|
46
|
|
|
* @return $this |
|
47
|
|
|
*/ |
|
48
|
|
|
public function setPayerType($PayerType) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->PayerType = $PayerType; |
|
51
|
|
|
|
|
52
|
|
|
return $this; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function getPayerType() |
|
56
|
|
|
{ |
|
57
|
|
|
if (! $this->PayerType) { |
|
58
|
|
|
$this->PayerType = config('novaposhta.payer_type'); |
|
59
|
|
|
} |
|
60
|
|
|
$this->methodProperties['PayerType'] = $this->PayerType; |
|
61
|
|
|
|
|
62
|
|
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param string $ServiceType |
|
67
|
|
|
* Устанавливаем тип доставки. По умолчанию значение из конфига |
|
68
|
|
|
* @see https://devcenter.novaposhta.ua/docs/services/55702570a0fe4f0cf4fc53ed/operations/55702571a0fe4f0b6483890e |
|
69
|
|
|
* @return $this |
|
70
|
|
|
*/ |
|
71
|
|
|
public function setServiceType($ServiceType) |
|
72
|
|
|
{ |
|
73
|
|
|
$this->ServiceType = $ServiceType; |
|
74
|
|
|
|
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getServiceType() |
|
79
|
|
|
{ |
|
80
|
|
|
if (! $this->ServiceType) { |
|
81
|
|
|
$this->ServiceType = config('novaposhta.service_type'); |
|
82
|
|
|
} |
|
83
|
|
|
$this->methodProperties['ServiceType'] = $this->ServiceType; |
|
84
|
|
|
|
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @param string $PaymentMethod |
|
90
|
|
|
* Устанавливаем форму оплаты. По умолчанию значение из конфига |
|
91
|
|
|
* @see https://devcenter.novaposhta.ua/docs/services/55702570a0fe4f0cf4fc53ed/operations/55702571a0fe4f0b6483890d |
|
92
|
|
|
* @return $this |
|
93
|
|
|
*/ |
|
94
|
|
|
public function setPaymentMethod($PaymentMethod) |
|
95
|
|
|
{ |
|
96
|
|
|
$this->PaymentMethod = $PaymentMethod; |
|
97
|
|
|
|
|
98
|
|
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function getPaymentMethod() |
|
102
|
|
|
{ |
|
103
|
|
|
if (! $this->PaymentMethod) { |
|
104
|
|
|
$this->PaymentMethod = config('novaposhta.payment_method'); |
|
105
|
|
|
} |
|
106
|
|
|
$this->methodProperties['PaymentMethod'] = $this->PaymentMethod; |
|
107
|
|
|
|
|
108
|
|
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @param string $CargoType |
|
113
|
|
|
* Устанавливаем тип груза. По умолчанию значение из конфига |
|
114
|
|
|
* @see https://devcenter.novaposhta.ua/docs/services/55702570a0fe4f0cf4fc53ed/operations/55702571a0fe4f0b64838909 |
|
115
|
|
|
* @return this |
|
116
|
|
|
*/ |
|
117
|
|
|
public function setCargoType($CargoType) |
|
118
|
|
|
{ |
|
119
|
|
|
$this->CargoType = $CargoType; |
|
120
|
|
|
|
|
121
|
|
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function getCargoType() |
|
125
|
|
|
{ |
|
126
|
|
|
if (! $this->CargoType) { |
|
127
|
|
|
$this->CargoType = config('novaposhta.cargo_type'); |
|
128
|
|
|
} |
|
129
|
|
|
$this->methodProperties['CargoType'] = $this->CargoType; |
|
130
|
|
|
|
|
131
|
|
|
return $this; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param string $Description |
|
136
|
|
|
* Устанавливаем описание груза. По умолчанию из конфига |
|
137
|
|
|
* @return this |
|
138
|
|
|
*/ |
|
139
|
|
|
public function setDescription($Description) |
|
140
|
|
|
{ |
|
141
|
|
|
if ($Description) { |
|
142
|
|
|
$this->methodProperties['Description'] = $Description; |
|
143
|
|
|
} else { |
|
144
|
|
|
$this->methodProperties['Description'] = config('novaposhta.description'); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
return $this; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param string $SeatsAmount |
|
152
|
|
|
* Кол-во мест груза по умолчанию |
|
153
|
|
|
* @return this |
|
154
|
|
|
*/ |
|
155
|
|
|
public function setSeatsAmount($SeatsAmount) |
|
156
|
|
|
{ |
|
157
|
|
|
$this->SeatsAmount = $SeatsAmount; |
|
158
|
|
|
|
|
159
|
|
|
return $this; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
public function getSeatsAmount() |
|
163
|
|
|
{ |
|
164
|
|
|
if (! $this->SeatsAmount) { |
|
165
|
|
|
$this->SeatsAmount = config('novaposhta.seats_amount'); |
|
166
|
|
|
} |
|
167
|
|
|
$this->methodProperties['SeatsAmount'] = $this->SeatsAmount; |
|
168
|
|
|
|
|
169
|
|
|
return $this; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @param string $Cost |
|
174
|
|
|
* Устанавливаем стоимость груза. По умолчанию значение из конфига |
|
175
|
|
|
* @return this |
|
176
|
|
|
*/ |
|
177
|
|
|
public function setCost($Cost) |
|
178
|
|
|
{ |
|
179
|
|
|
$this->Cost = $Cost; |
|
180
|
|
|
|
|
181
|
|
|
return $this; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
public function getCost() |
|
185
|
|
|
{ |
|
186
|
|
|
if (! $this->Cost) { |
|
187
|
|
|
$this->Cost = config('novaposhta.cost'); |
|
188
|
|
|
} |
|
189
|
|
|
$this->methodProperties['Cost'] = $this->Cost; |
|
190
|
|
|
|
|
191
|
|
|
return $this; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @param string $Note |
|
196
|
|
|
* Описание к адресу для курьера или отделения |
|
197
|
|
|
* Применяется в основном, если нет текущей улицы при адресной доставке |
|
198
|
|
|
* @return this |
|
199
|
|
|
*/ |
|
200
|
|
|
public function setNote($Note) |
|
201
|
|
|
{ |
|
202
|
|
|
$this->Note = $Note; |
|
203
|
|
|
|
|
204
|
|
|
return $this; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
public function getNote() |
|
208
|
|
|
{ |
|
209
|
|
|
if ($this->Note) { |
|
210
|
|
|
$this->methodProperties['Note'] = $this->Note; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
return $this; |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
/** |
|
217
|
|
|
* @param string $AdditionalInformation |
|
218
|
|
|
* Описание к ТТН для отображения в кабинете |
|
219
|
|
|
* @return this |
|
220
|
|
|
*/ |
|
221
|
|
|
public function setAdditionalInformation($AdditionalInformation) |
|
222
|
|
|
{ |
|
223
|
|
|
$this->AdditionalInformation = $AdditionalInformation; |
|
224
|
|
|
|
|
225
|
|
|
return $this; |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
public function getAdditionalInformation() |
|
229
|
|
|
{ |
|
230
|
|
|
if ($this->AdditionalInformation) { |
|
231
|
|
|
$this->methodProperties['AdditionalInformation'] = $this->AdditionalInformation; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
return $this; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @param string|int $RedeliveryString |
|
239
|
|
|
* @param string|null $PayerType |
|
240
|
|
|
* @param string|null $CargoType |
|
241
|
|
|
* @param array|null $addition |
|
242
|
|
|
* @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/575fe852a0fe4f0aa0754760 |
|
243
|
|
|
* Услуга обратной доставки. По умолчанию значения из конфига |
|
244
|
|
|
* @return this |
|
245
|
|
|
*/ |
|
246
|
|
|
public function setBackwardDeliveryData($RedeliveryString, $PayerType = null, $CargoType = null) |
|
247
|
|
|
{ |
|
248
|
|
|
if (! $PayerType) { |
|
249
|
|
|
$PayerType = config('novaposhta.back_delivery_payer_type'); |
|
250
|
|
|
} |
|
251
|
|
|
if (! $CargoType) { |
|
252
|
|
|
$CargoType = config('novaposhta.back_delivery_cargo_type'); |
|
253
|
|
|
} |
|
254
|
|
|
$this->BackwardDeliveryData = [ |
|
255
|
|
|
'PayerType' => $PayerType, |
|
256
|
|
|
'CargoType' => $CargoType, |
|
257
|
|
|
'RedeliveryString' => $RedeliveryString, |
|
258
|
|
|
]; |
|
259
|
|
|
|
|
260
|
|
|
return $this; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
public function getBackwardDeliveryData() |
|
264
|
|
|
{ |
|
265
|
|
|
if ($this->BackwardDeliveryData) { |
|
266
|
|
|
$this->methodProperties['BackwardDeliveryData'][] = $this->BackwardDeliveryData; |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
return $this; |
|
270
|
|
|
} |
|
271
|
|
|
} |
|
272
|
|
|
|