getAdditionalInformation()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
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 $AfterpaymentOnGoodsCost;
17
    protected $Note;
18
    protected $AdditionalInformation;
19
20
    /**
21
     * Устанавливаем значение Ref.
22
     *
23
     * @param  string  $Ref  Указываем Ref
24
     * @return $this
25
     */
26
    public function setRef(string $Ref): self
27
    {
28
        $this->Ref = $Ref;
29
30
        return $this;
31
    }
32
33
    public function getRef(): void
34
    {
35
        $this->methodProperties['Ref'] = $this->Ref;
36
    }
37
38
    /**
39
     * Устанавливаем значение плательщика. По умолчанию значение конфига.
40
     *
41
     * @param  string  $PayerType  Значение плательщика ('Sender', 'Recipient', 'ThirdPerson')
42
     * @return $this
43
     */
44
    public function setPayerType(string $PayerType): self
45
    {
46
        $this->PayerType = $PayerType;
47
48
        return $this;
49
    }
50
51
    /**
52
     * @return void
53
     */
54
    public function getPayerType(): void
55
    {
56
        $this->methodProperties['PayerType'] = $this->PayerType ?: config('novaposhta.payer_type');
57
    }
58
59
    /**
60
     * Устанавливаем тип доставки. По умолчанию значение конфига.
61
     *
62
     * @param  string  $ServiceType  Тип доставки ('DoorsDoors', 'DoorsWarehouse', 'WarehouseWarehouse', 'WarehouseDoors')
63
     * @return $this
64
     */
65
    public function setServiceType(string $ServiceType): self
66
    {
67
        $this->ServiceType = $ServiceType;
68
69
        return $this;
70
    }
71
72
    /**
73
     * @return void
74
     */
75
    public function getServiceType(): void
76
    {
77
        $this->methodProperties['ServiceType'] = $this->ServiceType ?: config('novaposhta.service_type');
78
    }
79
80
    /**
81
     * Устанавливаем форму оплаты. По умолчанию значение конфига.
82
     *
83
     * @param  string  $PaymentMethod  Форма оплаты ('Cash', 'NonCash')
84
     * @return $this
85
     */
86
    public function setPaymentMethod(string $PaymentMethod): self
87
    {
88
        $this->PaymentMethod = $PaymentMethod;
89
90
        return $this;
91
    }
92
93
    /**
94
     * Разные значения по умолчанию для разных моделей.
95
     *
96
     * @return void
97
     */
98
    public function getPaymentMethod(): void
99
    {
100
        if ($this->model == 'AdditionalService') {
101
            $this->methodProperties['PaymentMethod'] = $this->PaymentMethod ?: config('novaposhta.return_cash_method');
102
        } elseif ($this->model == 'orderTermExtension') {
103
            $this->methodProperties['PaymentMethod'] = $this->PaymentMethod ?: config('novaposhta.term_payment_method');
104
        } else {
105
            $this->methodProperties['PaymentMethod'] = $this->PaymentMethod ?: config('novaposhta.payment_method');
106
        }
107
    }
108
109
    /**
110
     * Устанавливаем тип груза. По умолчанию значение конфига.
111
     *
112
     * @param  string  $CargoType  Tип груза ('Cargo', 'Documents', 'TiresWheels', 'Pallet', 'Parcel')
113
     * @return $this
114
     */
115
    public function setCargoType(string $CargoType): self
116
    {
117
        $this->CargoType = $CargoType;
118
119
        return $this;
120
    }
121
122
    /**
123
     * @return void
124
     */
125
    public function getCargoType(): void
126
    {
127
        $this->methodProperties['CargoType'] = $this->CargoType ?: config('novaposhta.cargo_type');
128
    }
129
130
    /**
131
     * Устанавливаем описание груза. По умолчанию из конфига.
132
     *
133
     * @param  string|null  $description  Описание груза
134
     * @return $this
135
     */
136
    public function setDescription(?string $description): self
137
    {
138
        $this->methodProperties['Description'] = $description ?: config('novaposhta.description');
139
140
        return $this;
141
    }
142
143
    /**
144
     * Кол-во мест груза по умолчанию.
145
     *
146
     * @param  string  $SeatsAmount  Количество мест отправки
147
     * @return $this
148
     */
149
    public function setSeatsAmount(string $SeatsAmount): self
150
    {
151
        $this->SeatsAmount = $SeatsAmount;
152
153
        return $this;
154
    }
155
156
    /**
157
     * @return void
158
     */
159
    public function getSeatsAmount(): void
160
    {
161
        $this->methodProperties['SeatsAmount'] = $this->SeatsAmount ?: config('novaposhta.seats_amount');
162
    }
163
164
    /**
165
     * Устанавливаем стоимость груза. По умолчанию значение конфига.
166
     *
167
     * @param  string  $cost  Оценочная стоимость
168
     * @return $this
169
     */
170
    public function setCost(string $cost): self
171
    {
172
        $this->Cost = $cost;
173
174
        return $this;
175
    }
176
177
    /**
178
     * @return void
179
     */
180
    public function getCost(): void
181
    {
182
        $this->methodProperties['Cost'] = $this->Cost ?: config('novaposhta.cost');
183
    }
184
185
    /**
186
     * Описание к адресу для курьера или отделения.
187
     * Применяется в основном, если нет текущей улицы при адресной доставке.
188
     *
189
     * @param  string  $note  Пометка
190
     * @return $this
191
     */
192
    public function setNote(string $note): self
193
    {
194
        $this->Note = $note;
195
196
        return $this;
197
    }
198
199
    /**
200
     * @return void
201
     */
202
    public function getNote(): void
203
    {
204
        if ($this->Note) {
205
            $this->methodProperties['Note'] = $this->Note;
206
        }
207
    }
208
209
    /**
210
     * Описание к ТТН для отображения в кабинете.
211
     *
212
     * @param  string  $AdditionalInformation  Дополнительная информация к грузу
213
     * @return $this
214
     */
215
    public function setAdditionalInformation(string $AdditionalInformation): self
216
    {
217
        $this->AdditionalInformation = $AdditionalInformation;
218
219
        return $this;
220
    }
221
222
    /**
223
     * @return void
224
     */
225
    public function getAdditionalInformation(): void
226
    {
227
        if ($this->AdditionalInformation) {
228
            $this->methodProperties['AdditionalInformation'] = $this->AdditionalInformation;
229
        }
230
    }
231
232
    /**
233
     * Услуга обратной доставки. По умолчанию значения конфига.
234
     *
235
     * @param  string|int  $RedeliveryString  Обратная доставка денег (наложный платеж)
236
     * @param  string|null  $PayerType  Значение плательщика ('Sender', 'Recipient', 'ThirdPerson')
237
     * @param  string|null  $CargoType  Tип груза ('Cargo', 'Documents', 'TiresWheels', 'Pallet', 'Parcel')
238
     * @return $this
239
     */
240
    public function setBackwardDeliveryData($RedeliveryString, ?string $PayerType = null, ?string $CargoType = null): self
241
    {
242
        if (! $PayerType) {
243
            $PayerType = config('novaposhta.back_delivery_payer_type');
244
        }
245
        if (! $CargoType) {
246
            $CargoType = config('novaposhta.back_delivery_cargo_type');
247
        }
248
        $this->BackwardDeliveryData = [
249
            'PayerType' => $PayerType,
250
            'CargoType' => $CargoType,
251
            'RedeliveryString' => $RedeliveryString,
252
        ];
253
254
        return $this;
255
    }
256
257
    /**
258
     * Услуга Контроль оплаты.
259
     *
260
     * @param  string|int  $AfterpaymentOnGoodsCost  Контроль оплаты (Наложка на карту предпринимателя)
261
     * @return $this
262
     */
263
    public function setAfterpaymentOnGoodsCost($AfterpaymentOnGoodsCost): self
264
    {
265
        $this->AfterpaymentOnGoodsCost = $AfterpaymentOnGoodsCost;
266
267
        return $this;
268
    }
269
270
    /**
271
     * @return void
272
     */
273
    public function getBackwardDeliveryData(): void
274
    {
275
        if ($this->AfterpaymentOnGoodsCost) {
276
            $this->methodProperties['AfterpaymentOnGoodsCost'] = $this->AfterpaymentOnGoodsCost;
277
        } elseif ($this->BackwardDeliveryData) {
278
            $this->methodProperties['BackwardDeliveryData'][] = $this->BackwardDeliveryData;
279
        }
280
    }
281
}
282