-
Notifications
You must be signed in to change notification settings - Fork 3
/
orderRequestBuilder.go
505 lines (348 loc) · 8.62 KB
/
orderRequestBuilder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
package dpd
import (
"time"
)
//NewCreateOrderRequest ...
func NewCreateOrderRequest() *CreateOrderRequest {
var orders []*Order
req := &CreateOrderRequest{
Header: &Header{},
Order: orders,
}
return req
}
//SetDatePickup ...
func (r *CreateOrderRequest) SetDatePickup(time time.Time) *CreateOrderRequest {
d := time.Format("2006-01-02")
r.Header.DatePickup = &d
return r
}
//SetPayer ...
func (r *CreateOrderRequest) SetPayer(payer int64) *CreateOrderRequest {
r.Header.Payer = &payer
return r
}
//SetSender ...
func (r *CreateOrderRequest) SetSender(address Address) *CreateOrderRequest {
r.Header.SenderAddress = &address
return r
}
//SetPickupTimePeriod ...
func (r *CreateOrderRequest) SetPickupTimePeriod(period string) *CreateOrderRequest {
r.Header.PickupTimePeriod = &period
return r
}
//SetRegularNum regular DPD order number. Ask your manager about correct number if you use it
func (r *CreateOrderRequest) SetRegularNum(num string) *CreateOrderRequest {
r.Header.RegularNum = &num
return r
}
//AddOrder to CreateOrderRequest
func (r *CreateOrderRequest) AddOrder(order *Order) *CreateOrderRequest {
r.Order = append(r.Order, order)
return r
}
//NewOrder ...
func NewOrder() *Order {
var parcel []*Parcel
var extraService []*ExtraService
var extraParameter []*ExtraParameter
var unitLoad []*UnitLoadOrder
return &Order{
ExtraParam: extraParameter,
ExtraService: extraService,
Parcel: parcel,
UnitLoad: unitLoad,
}
}
//SetInternalOrderNumber imply client side order number
func (o *Order) SetInternalOrderNumber(number string) *Order {
o.OrderNumberInternal = &number
return o
}
//SetServiceCode code of DPD service
func (o *Order) SetServiceCode(code string) *Order {
o.ServiceCode = &code
return o
}
//SetServiceVariant delivery variant& Four variants are available(ДД, ДТ, ТД, ТТ)
func (o *Order) SetServiceVariant(variant string) *Order {
o.ServiceVariant = &variant
return o
}
//SetCargoCount ...
func (o *Order) SetCargoCount(num int) *Order {
o.CargoNumPack = &num
return o
}
//SetCargoWeight ...
func (o *Order) SetCargoWeight(weight float64) *Order {
o.CargoWeight = &weight
return o
}
//SetCargoVolume ...
func (o *Order) SetCargoVolume(volume float64) *Order {
o.CargoVolume = &volume
return o
}
//SetValuableCargo ...
func (o *Order) SetValuableCargo(flag bool) *Order {
o.CargoRegistered = &flag
return o
}
//SetCargoValue ...
func (o *Order) SetCargoValue(value float64) *Order {
o.CargoValue = &value
return o
}
//SetCargoCategory ...
func (o *Order) SetCargoCategory(category string) *Order {
o.CargoCategory = &category
return o
}
func (o *Order) SetDeliveryTimePeriod(period string) *Order {
o.DeliveryTimePeriod = &period
return o
}
func (o *Order) SetPaymentType(pType string) *Order {
o.PaymentType = &pType
return o
}
func (o *Order) SetReceiverAddress(address *Address) *Order {
o.ReceiverAddress = address
return o
}
func (o *Order) SetReturnAddress(address *Address) *Order {
o.ReturnAddress = address
return o
}
func (o *Order) AddExtraParameter(parameter *ExtraParameter) *Order {
o.ExtraParam = append(o.ExtraParam, parameter)
return o
}
func (o *Order) AddExtraService(service *ExtraService) *Order {
o.ExtraService = append(o.ExtraService, service)
return o
}
func (o *Order) AddParcel(parcel *Parcel) *Order {
o.Parcel = append(o.Parcel, parcel)
return o
}
func (o *Order) AddUnitLoad(load *UnitLoadOrder) *Order {
o.UnitLoad = append(o.UnitLoad, load)
return o
}
func NewAddress() *Address {
return new(Address)
}
func (a *Address) SetCode(code string) *Address {
a.Code = &code
return a
}
func (a *Address) SetName(name string) *Address {
a.Name = &name
return a
}
func (a *Address) SetTerminalCode(code string) *Address {
a.TerminalCode = &code
return a
}
func (a *Address) SetAddressString(address string) *Address {
a.AddressString = &address
return a
}
func (a *Address) SetCountryName(name string) *Address {
a.CountryName = &name
return a
}
func (a *Address) SetZip(zip string) *Address {
a.Index = &zip
return a
}
func (a *Address) SetRegion(region string) *Address {
a.Region = ®ion
return a
}
func (a *Address) SetCity(city string) *Address {
a.City = &city
return a
}
func (a *Address) SetStreet(street string) *Address {
a.Street = &street
return a
}
func (a *Address) SetStreetAbbr(abbr string) *Address {
a.StreetAbbr = &abbr
return a
}
func (a *Address) SetHouse(house string) *Address {
a.House = &house
return a
}
func (a *Address) SetHousing(housing string) *Address {
a.HouseKorpus = &housing
return a
}
func (a *Address) SetBuilding(building string) *Address {
a.Str = &building
return a
}
func (a *Address) SetPossession(possession string) *Address {
a.Vlad = &possession
return a
}
func (a *Address) SetExtraInfo(info string) *Address {
a.ExtraInfo = &info
return a
}
func (a *Address) SetOffice(office string) *Address {
a.Office = &office
return a
}
func (a *Address) SetFlat(flat string) *Address {
a.Flat = &flat
return a
}
func (a *Address) SetWorkTimeFrom(start string) *Address {
a.WorkTimeFrom = &start
return a
}
func (a *Address) SetWorkTimeTo(end string) *Address {
a.WorkTimeTo = &end
return a
}
func (a *Address) SetDinnerTimeFrom(start string) *Address {
a.DinnerTimeFrom = &start
return a
}
func (a *Address) SetDinnerTimeTo(end string) *Address {
a.DinnerTimeTo = &end
return a
}
func (a *Address) SetContactFullName(fullName string) *Address {
a.ContactFio = &fullName
return a
}
func (a *Address) SetContactPhone(phone string) *Address {
a.ContactPhone = &phone
return a
}
func (a *Address) SetContactEmail(email string) *Address {
a.ContactEmail = &email
return a
}
func (a *Address) SetInstructions(instructions string) *Address {
a.Instructions = &instructions
return a
}
func (a *Address) SetNeedPass(flag bool) *Address {
a.NeedPass = &flag
return a
}
func NewParcel() *Parcel {
return new(Parcel)
}
func (p *Parcel) SetNumber(number string) *Parcel {
p.Number = &number
return p
}
func (p *Parcel) SetDPDParcelNumber(number int64) *Parcel {
p.DpdParcelNumber = &number
return p
}
func (p *Parcel) SetNumberForPrint(number string) *Parcel {
p.NumberForPrint = &number
return p
}
func (p *Parcel) SetBoxNeeded(needed int) *Parcel {
p.BoxNeeded = &needed
return p
}
func (p *Parcel) SetWeight(weight float64) *Parcel {
p.Weight = &weight
return p
}
func (p *Parcel) SetLength(length float64) *Parcel {
p.Length = &length
return p
}
func (p *Parcel) SetWidth(width float64) *Parcel {
p.Width = &width
return p
}
func (p *Parcel) SetHeight(height float64) *Parcel {
p.Height = &height
return p
}
func (p *Parcel) SetInsuranceCost(cost float64) *Parcel {
p.InsuranceCost = &cost
return p
}
func (p *Parcel) SetCodAmount(amount float64) *Parcel {
p.CodAmount = &amount
return p
}
func NewUpdateOrderRequest() *UpdateOrderRequest {
var parcels []*Parcel
req := new(UpdateOrderRequest)
req.Parcel = parcels
return new(UpdateOrderRequest)
}
func (r *UpdateOrderRequest) SetDPDOrderNumber(number string) *UpdateOrderRequest {
r.OrderNum = &number
return r
}
func (r *UpdateOrderRequest) SetInternalOrderNumber(number string) *UpdateOrderRequest {
r.OrderNumberInternal = &number
return r
}
func (r *UpdateOrderRequest) SetCargoNumPack(num int) *UpdateOrderRequest {
r.CargoNumPack = &num
return r
}
func (r *UpdateOrderRequest) SetCargoWeight(weight float64) *UpdateOrderRequest {
r.CargoWeight = &weight
return r
}
func (r *UpdateOrderRequest) SetCargoVolume(volume float64) *UpdateOrderRequest {
r.CargoVolume = &volume
return r
}
func (r *UpdateOrderRequest) SetCargoValue(value float64) *UpdateOrderRequest {
r.CargoValue = &value
return r
}
func (r *UpdateOrderRequest) SetCargoCategory(category string) *UpdateOrderRequest {
r.CargoCategory = &category
return r
}
func (r *UpdateOrderRequest) AddParcel(parcel *Parcel) *UpdateOrderRequest {
r.Parcel = append(r.Parcel, parcel)
return r
}
func NewOrderToCancel() *OrderToCancel {
return new(OrderToCancel)
}
func (o *OrderToCancel) SetInternalOrderNumber(number string) *OrderToCancel {
o.OrderNumberInternal = &number
return o
}
func (o *OrderToCancel) SetDPDOrderNumber(number string) *OrderToCancel {
o.OrderNum = &number
return o
}
func (o *OrderToCancel) SetPickupDate(time time.Time) *OrderToCancel {
d := time.Format("2006-01-02")
o.PickupDate = &d
return o
}
func NewCancelOrderRequest() *CancelOrderRequest {
var orders []*OrderToCancel
req := new(CancelOrderRequest)
req.Cancel = orders
return req
}
func (r *CancelOrderRequest) AddOrder(order *OrderToCancel) *CancelOrderRequest {
r.Cancel = append(r.Cancel, order)
return r
}