|
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
|
|
|
* Устанавливаем значение Ref |
|
21
|
|
|
* |
|
22
|
|
|
* @param string $Ref |
|
23
|
|
|
*/ |
|
24
|
|
|
public function setRef(string $Ref): void |
|
25
|
|
|
{ |
|
26
|
|
|
$this->Ref = $Ref; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function getRef(): void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->methodProperties['Ref'] = $this->Ref; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Устанавливаем значение плательщика. По умолчанию значение конфига. |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $PayerType |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
public function setPayerType(string $PayerType): void |
|
41
|
|
|
{ |
|
42
|
|
|
$this->PayerType = $PayerType; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return void |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getPayerType(): void |
|
49
|
|
|
{ |
|
50
|
|
|
$this->methodProperties['PayerType'] = $this->PayerType ?: config('novaposhta.payer_type'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Устанавливаем тип доставки. По умолчанию значение конфига. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string $ServiceType |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
|
|
public function setServiceType(string $ServiceType): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->ServiceType = $ServiceType; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return void |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getServiceType(): void |
|
68
|
|
|
{ |
|
69
|
|
|
$this->methodProperties['ServiceType'] = $this->ServiceType ?: config('novaposhta.service_type'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Устанавливаем форму оплаты. По умолчанию значение конфига. |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $PaymentMethod |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
public function setPaymentMethod(string $PaymentMethod): void |
|
79
|
|
|
{ |
|
80
|
|
|
$this->PaymentMethod = $PaymentMethod; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return void |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getPaymentMethod(): void |
|
87
|
|
|
{ |
|
88
|
|
|
$this->methodProperties['PaymentMethod'] = $this->PaymentMethod ?: config('novaposhta.payment_method'); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Устанавливаем тип груза. По умолчанию значение конфига. |
|
93
|
|
|
* |
|
94
|
|
|
* @param string $CargoType |
|
95
|
|
|
* @return void |
|
96
|
|
|
*/ |
|
97
|
|
|
public function setCargoType(string $CargoType): void |
|
98
|
|
|
{ |
|
99
|
|
|
$this->CargoType = $CargoType; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return void |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getCargoType(): void |
|
106
|
|
|
{ |
|
107
|
|
|
$this->methodProperties['CargoType'] = $this->CargoType ?: config('novaposhta.cargo_type'); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Устанавливаем описание груза. По умолчанию из конфига. |
|
112
|
|
|
* |
|
113
|
|
|
* @param string|null $description |
|
114
|
|
|
* @return void |
|
115
|
|
|
*/ |
|
116
|
|
|
public function setDescription(?string $description): void |
|
117
|
|
|
{ |
|
118
|
|
|
$this->methodProperties['Description'] = $description ?: config('novaposhta.description'); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Кол-во мест груза по умолчанию. |
|
123
|
|
|
* |
|
124
|
|
|
* @param string $SeatsAmount |
|
125
|
|
|
* @return void |
|
126
|
|
|
*/ |
|
127
|
|
|
public function setSeatsAmount(string $SeatsAmount): void |
|
128
|
|
|
{ |
|
129
|
|
|
$this->SeatsAmount = $SeatsAmount; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @return void |
|
134
|
|
|
*/ |
|
135
|
|
|
public function getSeatsAmount(): void |
|
136
|
|
|
{ |
|
137
|
|
|
$this->methodProperties['SeatsAmount'] = $this->SeatsAmount ?: config('novaposhta.seats_amount'); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Устанавливаем стоимость груза. По умолчанию значение конфига. |
|
142
|
|
|
* |
|
143
|
|
|
* @param string $cost |
|
144
|
|
|
* @return void |
|
145
|
|
|
*/ |
|
146
|
|
|
public function setCost(string $cost): void |
|
147
|
|
|
{ |
|
148
|
|
|
$this->Cost = $cost; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @return void |
|
153
|
|
|
*/ |
|
154
|
|
|
public function getCost(): void |
|
155
|
|
|
{ |
|
156
|
|
|
$this->methodProperties['Cost'] = $this->Cost ?: config('novaposhta.cost'); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Описание к адресу для курьера или отделения. |
|
161
|
|
|
* Применяется в основном, если нет текущей улицы при адресной доставке. |
|
162
|
|
|
* |
|
163
|
|
|
* @param string $note |
|
164
|
|
|
* @return void |
|
165
|
|
|
*/ |
|
166
|
|
|
public function setNote(string $note): void |
|
167
|
|
|
{ |
|
168
|
|
|
$this->Note = $note; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @return void |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getNote(): void |
|
175
|
|
|
{ |
|
176
|
|
|
if ($this->Note) { |
|
177
|
|
|
$this->methodProperties['Note'] = $this->Note; |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Описание к ТТН для отображения в кабинете. |
|
183
|
|
|
* |
|
184
|
|
|
* @param string $AdditionalInformation |
|
185
|
|
|
* @return void |
|
186
|
|
|
*/ |
|
187
|
|
|
public function setAdditionalInformation(string $AdditionalInformation): void |
|
188
|
|
|
{ |
|
189
|
|
|
$this->AdditionalInformation = $AdditionalInformation; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @return void |
|
194
|
|
|
*/ |
|
195
|
|
|
public function getAdditionalInformation(): void |
|
196
|
|
|
{ |
|
197
|
|
|
if ($this->AdditionalInformation) { |
|
198
|
|
|
$this->methodProperties['AdditionalInformation'] = $this->AdditionalInformation; |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* Услуга обратной доставки. По умолчанию значения конфига. |
|
204
|
|
|
* |
|
205
|
|
|
* @param string|int $RedeliveryString |
|
206
|
|
|
* @param string|null $PayerType |
|
207
|
|
|
* @param string|null $CargoType |
|
208
|
|
|
* @return void |
|
209
|
|
|
*/ |
|
210
|
|
|
public function setBackwardDeliveryData($RedeliveryString, ?string $PayerType = null, ?string $CargoType = null): void |
|
211
|
|
|
{ |
|
212
|
|
|
if (! $PayerType) { |
|
213
|
|
|
$PayerType = config('novaposhta.back_delivery_payer_type'); |
|
214
|
|
|
} |
|
215
|
|
|
if (! $CargoType) { |
|
216
|
|
|
$CargoType = config('novaposhta.back_delivery_cargo_type'); |
|
217
|
|
|
} |
|
218
|
|
|
$this->BackwardDeliveryData = [ |
|
219
|
|
|
'PayerType' => $PayerType, |
|
220
|
|
|
'CargoType' => $CargoType, |
|
221
|
|
|
'RedeliveryString' => $RedeliveryString, |
|
222
|
|
|
]; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* @return void |
|
227
|
|
|
*/ |
|
228
|
|
|
public function getBackwardDeliveryData(): void |
|
229
|
|
|
{ |
|
230
|
|
|
if ($this->BackwardDeliveryData) { |
|
231
|
|
|
$this->methodProperties['BackwardDeliveryData'][] = $this->BackwardDeliveryData; |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
} |
|
235
|
|
|
|