-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtypes.go
1624 lines (1454 loc) · 61.4 KB
/
types.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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package retailcrm
import (
"encoding/json"
"net/http"
"reflect"
"strings"
)
// ByID is "id" constant to use as `by` property in methods.
const ByID = "id"
// ByExternalId is "externalId" constant to use as `by` property in methods.
const ByExternalID = "externalId"
// Client type.
type Client struct {
URL string
Key string
Debug bool
httpClient *http.Client
logger BasicLogger
}
// Pagination type.
type Pagination struct {
Limit int `json:"limit,omitempty"`
TotalCount int `json:"totalCount,omitempty"`
CurrentPage int `json:"currentPage,omitempty"`
TotalPageCount int `json:"totalPageCount,omitempty"`
}
// Address type.
type Address struct {
Index string `json:"index,omitempty"`
CountryIso string `json:"countryIso,omitempty"`
Region string `json:"region,omitempty"`
RegionID int `json:"regionId,omitempty"`
City string `json:"city,omitempty"`
CityID int `json:"cityId,omitempty"`
CityType string `json:"cityType,omitempty"`
Street string `json:"street,omitempty"`
StreetID int `json:"streetId,omitempty"`
StreetType string `json:"streetType,omitempty"`
Building string `json:"building,omitempty"`
Flat string `json:"flat,omitempty"`
Floor int `json:"floor,omitempty"`
Block int `json:"block,omitempty"`
House string `json:"house,omitempty"`
Housing string `json:"housing,omitempty"`
Metro string `json:"metro,omitempty"`
Notes string `json:"notes,omitempty"`
Text string `json:"text,omitempty"`
}
// GeoHierarchyRow type.
type GeoHierarchyRow struct {
Country string `json:"country,omitempty"`
Region string `json:"region,omitempty"`
RegionID int `json:"regionId,omitempty"`
City string `json:"city,omitempty"`
CityID int `json:"cityId,omitempty"`
}
// Source type.
type Source struct {
Source string `json:"source,omitempty"`
Medium string `json:"medium,omitempty"`
Campaign string `json:"campaign,omitempty"`
Keyword string `json:"keyword,omitempty"`
Content string `json:"content,omitempty"`
ClientID string `json:"client_id,omitempty"`
Site string `json:"site,omitempty"`
Order LinkedOrder `json:"order,omitempty"`
Customer SerializedEntityCustomer `json:"customer,omitempty"`
}
// Contragent type.
type Contragent struct {
ContragentType string `json:"contragentType,omitempty"`
LegalName string `json:"legalName,omitempty"`
LegalAddress string `json:"legalAddress,omitempty"`
INN string `json:"INN,omitempty"`
OKPO string `json:"OKPO,omitempty"`
KPP string `json:"KPP,omitempty"`
OGRN string `json:"OGRN,omitempty"`
OGRNIP string `json:"OGRNIP,omitempty"`
CertificateNumber string `json:"certificateNumber,omitempty"`
CertificateDate string `json:"certificateDate,omitempty"`
BIK string `json:"BIK,omitempty"`
Bank string `json:"bank,omitempty"`
BankAddress string `json:"bankAddress,omitempty"`
CorrAccount string `json:"corrAccount,omitempty"`
BankAccount string `json:"bankAccount,omitempty"`
}
// APIKey type.
type APIKey struct {
Current bool `json:"current,omitempty"`
}
// Property type.
type Property struct {
Code string `json:"code,omitempty"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Sites []string `json:"Sites,omitempty"`
}
// IdentifiersPair type.
type IdentifiersPair struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
}
// DeliveryTime type.
type DeliveryTime struct {
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Custom string `json:"custom,omitempty"`
}
/**
Customer related types
*/
// Customer type.
type Customer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Patronymic string `json:"patronymic,omitempty"`
Sex string `json:"sex,omitempty"`
Email string `json:"email,omitempty"`
Phones []Phone `json:"phones,omitempty"`
Address *Address `json:"address,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Birthday string `json:"birthday,omitempty"`
ManagerID int `json:"managerId,omitempty"`
Vip bool `json:"vip,omitempty"`
Bad bool `json:"bad,omitempty"`
Site string `json:"site,omitempty"`
Source *Source `json:"source,omitempty"`
Contragent *Contragent `json:"contragent,omitempty"`
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
CumulativeDiscount float32 `json:"cumulativeDiscount,omitempty"`
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
EmailMarketingUnsubscribedAt string `json:"emailMarketingUnsubscribedAt,omitempty"`
AvgMarginSumm float32 `json:"avgMarginSumm,omitempty"`
MarginSumm float32 `json:"marginSumm,omitempty"`
TotalSumm float32 `json:"totalSumm,omitempty"`
AverageSumm float32 `json:"averageSumm,omitempty"`
OrdersCount int `json:"ordersCount,omitempty"`
CostSumm float32 `json:"costSumm,omitempty"`
MaturationTime int `json:"maturationTime,omitempty"`
FirstClientID string `json:"firstClientId,omitempty"`
LastClientID string `json:"lastClientId,omitempty"`
BrowserID string `json:"browserId,omitempty"`
MgCustomerID string `json:"mgCustomerId,omitempty"`
PhotoURL string `json:"photoUrl,omitempty"`
CustomFields CustomFieldMap `json:"customFields,omitempty"`
Tags []Tag `json:"tags,omitempty"`
}
// CorporateCustomer type.
type CorporateCustomer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Nickname string `json:"nickName,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Vip bool `json:"vip,omitempty"`
Bad bool `json:"bad,omitempty"`
CustomFields CustomFieldMap `json:"customFields,omitempty"`
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
ManagerID int `json:"managerId,omitempty"`
Source *Source `json:"source,omitempty"`
CustomerContacts []CorporateCustomerContact `json:"customerContacts,omitempty"`
Companies []Company `json:"companies,omitempty"`
Addresses []CorporateCustomerAddress `json:"addresses,omitempty"`
}
type CorporateCustomerContact struct {
IsMain bool `json:"isMain,omitempty"`
Customer CorporateCustomerContactCustomer `json:"customer,omitempty"`
Companies []IdentifiersPair `json:"companies,omitempty"`
}
// CorporateCustomerAddress type. Address didn't inherited in order to simplify declaration.
type CorporateCustomerAddress struct {
ID int `json:"id,omitempty"`
Index string `json:"index,omitempty"`
CountryISO string `json:"countryIso,omitempty"`
Region string `json:"region,omitempty"`
RegionID int `json:"regionId,omitempty"`
City string `json:"city,omitempty"`
CityID int `json:"cityId,omitempty"`
CityType string `json:"cityType,omitempty"`
Street string `json:"street,omitempty"`
StreetID int `json:"streetId,omitempty"`
StreetType string `json:"streetType,omitempty"`
Building string `json:"building,omitempty"`
Flat string `json:"flat,omitempty"`
IntercomCode string `json:"intercomCode,omitempty"`
Floor int `json:"floor,omitempty"`
Block int `json:"block,omitempty"`
House string `json:"house,omitempty"`
Housing string `json:"housing,omitempty"`
Metro string `json:"metro,omitempty"`
Notes string `json:"notes,omitempty"`
Text string `json:"text,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Name string `json:"name,omitempty"`
}
type CorporateCustomerContactCustomer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
BrowserID string `json:"browserId,omitempty"`
Site string `json:"site,omitempty"`
}
type Company struct {
ID int `json:"id,omitempty"`
IsMain bool `json:"isMain,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Active bool `json:"active,omitempty"`
Name string `json:"name,omitempty"`
Brand string `json:"brand,omitempty"`
Site string `json:"site,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Contragent *Contragent `json:"contragent,omitempty"`
Address *IdentifiersPair `json:"address,omitempty"`
CustomFields CustomFieldMap `json:"customFields,omitempty"`
}
// CorporateCustomerNote type.
type CorporateCustomerNote struct {
ManagerID int `json:"managerId,omitempty"`
Text string `json:"text,omitempty"`
Customer *IdentifiersPair `json:"customer,omitempty"`
}
// Phone type.
type Phone struct {
Number string `json:"number,omitempty"`
}
// CustomerHistoryRecord type.
type CustomerHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Created bool `json:"created,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
OldValue interface{} `json:"oldValue,omitempty"`
NewValue interface{} `json:"newValue,omitempty"`
User *User `json:"user,omitempty"`
APIKey *APIKey `json:"apiKey,omitempty"`
Customer *Customer `json:"customer,omitempty"`
Address *CustomerAddressWithIsMain `json:"address,omitempty"`
}
type CustomerAddressWithIsMain struct {
ID int `json:"id"`
ExternalID string `json:"externalId,omitempty"`
Name string `json:"name,omitempty"`
IsMain bool `json:"isMain"`
}
// CorporateCustomerHistoryRecord type.
type CorporateCustomerHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Created bool `json:"created,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
OldValue interface{} `json:"oldValue,omitempty"`
NewValue interface{} `json:"newValue,omitempty"`
User *User `json:"user,omitempty"`
APIKey *APIKey `json:"apiKey,omitempty"`
CorporateCustomer *CorporateCustomer `json:"corporateCustomer,omitempty"`
}
/**
Order related types
*/
type OrderPayments map[string]OrderPayment
type StringMap map[string]string
type CustomFieldMap map[string]interface{}
type Properties map[string]Property
// Order type.
type Order struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Number string `json:"number,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Patronymic string `json:"patronymic,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
AdditionalPhone string `json:"additionalPhone,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
StatusUpdatedAt string `json:"statusUpdatedAt,omitempty"`
ManagerID int `json:"managerId,omitempty"`
Mark int `json:"mark,omitempty"`
Call bool `json:"call,omitempty"`
Expired bool `json:"expired,omitempty"`
FromAPI bool `json:"fromApi,omitempty"`
MarkDatetime string `json:"markDatetime,omitempty"`
CustomerComment string `json:"customerComment,omitempty"`
ManagerComment string `json:"managerComment,omitempty"`
Status string `json:"status,omitempty"`
StatusComment string `json:"statusComment,omitempty"`
FullPaidAt string `json:"fullPaidAt,omitempty"`
Site string `json:"site,omitempty"`
OrderType string `json:"orderType,omitempty"`
OrderMethod string `json:"orderMethod,omitempty"`
CountryIso string `json:"countryIso,omitempty"`
Summ float32 `json:"summ,omitempty"`
TotalSumm float32 `json:"totalSumm,omitempty"`
PrepaySum float32 `json:"prepaySum,omitempty"`
PurchaseSumm float32 `json:"purchaseSumm,omitempty"`
DiscountManualAmount float32 `json:"discountManualAmount,omitempty"`
DiscountManualPercent float32 `json:"discountManualPercent,omitempty"`
Weight float32 `json:"weight,omitempty"`
Length int `json:"length,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
ShipmentStore string `json:"shipmentStore,omitempty"`
ShipmentDate string `json:"shipmentDate,omitempty"`
ClientID string `json:"clientId,omitempty"`
Shipped bool `json:"shipped,omitempty"`
UploadedToExternalStoreSystem bool `json:"uploadedToExternalStoreSystem,omitempty"`
Source *Source `json:"source,omitempty"`
Contragent *Contragent `json:"contragent,omitempty"`
Customer *Customer `json:"customer,omitempty"`
Delivery *OrderDelivery `json:"delivery,omitempty"`
Marketplace *OrderMarketplace `json:"marketplace,omitempty"`
Items []OrderItem `json:"items,omitempty"`
CustomFields CustomFieldMap `json:"customFields,omitempty"`
Payments OrderPayments `json:"payments,omitempty"`
ApplyRound *bool `json:"applyRound,omitempty"`
PrivilegeType string `json:"privilegeType,omitempty"`
DialogID int `json:"dialogId,omitempty"`
Links []OrderLink `json:"links,omitempty"`
Currency string `json:"currency,omitempty"`
}
// LinkedOrder type.
type LinkedOrder struct {
Number string `json:"number,omitempty"`
ExternalID string `json:"externalID,omitempty"`
ID int `json:"id,omitempty"`
}
// OrderLink type.
type OrderLink struct {
Comment string `json:"comment,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Order LinkedOrder `json:"order,omitempty"`
}
// SerializedOrderLink type.
type SerializedOrderLink struct {
Comment string `json:"comment,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Orders []LinkedOrder `json:"orders,omitempty"`
}
// ClientID type.
type ClientID struct {
Value string `json:"value"`
CreateAt string `json:"createAt,omitempty"`
Site string `json:"site,omitempty"`
Customer SerializedEntityCustomer `json:"customer,omitempty"`
Order LinkedOrder `json:"order,omitempty"`
}
// Currency type.
type Currency struct {
Code string `json:"code,omitempty"`
ID int `json:"id,omitempty"`
ManualConvertNominal int `json:"manualConvertNominal,omitempty"`
AutoConvertExtraPercent int `json:"autoConvertExtraPercent,omitempty"`
IsBase bool `json:"isBase,omitempty"`
IsAutoConvert bool `json:"isAutoConvert,omitempty"`
ManualConvertValue float32 `json:"manualConvertValue,omitempty"`
}
// OrdersStatus type.
type OrdersStatus struct {
ID int `json:"id"`
ExternalID string `json:"externalId,omitempty"`
Status string `json:"status"`
Group string `json:"group"`
}
// OrderDelivery type.
type OrderDelivery struct {
Code string `json:"code,omitempty"`
IntegrationCode string `json:"integrationCode,omitempty"`
Cost float32 `json:"cost,omitempty"`
NetCost float32 `json:"netCost,omitempty"`
VatRate string `json:"vatRate,omitempty"`
Date string `json:"date,omitempty"`
Time *OrderDeliveryTime `json:"time,omitempty"`
Address *Address `json:"address,omitempty"`
Service *OrderDeliveryService `json:"service,omitempty"`
Data *OrderDeliveryData `json:"data,omitempty"`
}
// OrderDeliveryTime type.
type OrderDeliveryTime struct {
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Custom string `json:"custom,omitempty"`
}
// OrderDeliveryService type.
type OrderDeliveryService struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
}
// OrderDeliveryDataBasic type.
type OrderDeliveryDataBasic struct {
TrackNumber string `json:"trackNumber,omitempty"`
Status string `json:"status,omitempty"`
PickuppointAddress string `json:"pickuppointAddress,omitempty"`
PayerType string `json:"payerType,omitempty"`
}
// OrderDeliveryData type.
type OrderDeliveryData struct {
OrderDeliveryDataBasic
AdditionalFields map[string]interface{}
}
// UnmarshalJSON method.
func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error {
var additionalData map[string]interface{}
err := json.Unmarshal(b, &additionalData)
if err != nil {
return err
}
err = json.Unmarshal(b, &v.OrderDeliveryDataBasic)
if err != nil {
return err
}
object := reflect.TypeOf(v.OrderDeliveryDataBasic)
for i := 0; i < object.NumField(); i++ {
field := object.Field(i)
if i, ok := field.Tag.Lookup("json"); ok {
name := strings.Split(i, ",")[0]
delete(additionalData, strings.TrimSpace(name))
} else {
delete(additionalData, field.Name)
}
}
v.AdditionalFields = additionalData
return nil
}
// MarshalJSON method.
func (v OrderDeliveryData) MarshalJSON() ([]byte, error) {
result := map[string]interface{}{}
data, _ := json.Marshal(v.OrderDeliveryDataBasic)
err := json.Unmarshal(data, &result)
if err != nil {
return nil, err
}
for key, value := range v.AdditionalFields {
result[key] = value
}
return json.Marshal(result)
}
// OrderMarketplace type.
type OrderMarketplace struct {
Code string `json:"code,omitempty"`
OrderID string `json:"orderId,omitempty"`
}
// OrderPayment type.
type OrderPayment struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
PaidAt string `json:"paidAt,omitempty"`
Amount float32 `json:"amount,omitempty"`
Comment string `json:"comment,omitempty"`
}
// OrderItem type.
type OrderItem struct {
ID int `json:"id,omitempty"`
InitialPrice float32 `json:"initialPrice,omitempty"`
PurchasePrice float32 `json:"purchasePrice,omitempty"`
DiscountTotal float32 `json:"discountTotal,omitempty"`
DiscountManualAmount float32 `json:"discountManualAmount,omitempty"`
DiscountManualPercent float32 `json:"discountManualPercent,omitempty"`
ProductName string `json:"productName,omitempty"`
VatRate string `json:"vatRate,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Quantity float32 `json:"quantity,omitempty"`
Status string `json:"status,omitempty"`
Comment string `json:"comment,omitempty"`
IsCanceled bool `json:"isCanceled,omitempty"`
Offer Offer `json:"offer,omitempty"`
Properties Properties `json:"properties,omitempty"`
PriceType *PriceType `json:"priceType,omitempty"`
}
// OrdersHistoryRecord type.
type OrdersHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Created bool `json:"created,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
OldValue interface{} `json:"oldValue,omitempty"`
NewValue interface{} `json:"newValue,omitempty"`
User *User `json:"user,omitempty"`
APIKey *APIKey `json:"apiKey,omitempty"`
Order *Order `json:"order,omitempty"`
Ancestor *Order `json:"ancestor,omitempty"`
Item *OrderItem `json:"item,omitempty"`
Payment *Payment `json:"payment"`
CombinedTo *Order `json:"combinedTo,omitempty"`
}
// Pack type.
type Pack struct {
ID int `json:"id,omitempty"`
PurchasePrice float32 `json:"purchasePrice,omitempty"`
Quantity float32 `json:"quantity,omitempty"`
Store string `json:"store,omitempty"`
ShipmentDate string `json:"shipmentDate,omitempty"`
InvoiceNumber string `json:"invoiceNumber,omitempty"`
DeliveryNoteNumber string `json:"deliveryNoteNumber,omitempty"`
Item *PackItem `json:"item,omitempty"`
ItemID int `json:"itemId,omitempty"`
Unit *Unit `json:"unit,omitempty"`
}
// PackItem type.
type PackItem struct {
ID int `json:"id,omitempty"`
Order *Order `json:"order,omitempty"`
Offer *Offer `json:"offer,omitempty"`
}
// PacksHistoryRecord type.
type PacksHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Created bool `json:"created,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
OldValue interface{} `json:"oldValue,omitempty"`
NewValue interface{} `json:"newValue,omitempty"`
User *User `json:"user,omitempty"`
Pack *Pack `json:"pack,omitempty"`
}
// Offer type.
type Offer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Name string `json:"name,omitempty"`
XMLID string `json:"xmlId,omitempty"`
Article string `json:"article,omitempty"`
VatRate string `json:"vatRate,omitempty"`
Price float32 `json:"price,omitempty"`
PurchasePrice float32 `json:"purchasePrice,omitempty"`
Quantity float32 `json:"quantity,omitempty"`
Height float32 `json:"height,omitempty"`
Width float32 `json:"width,omitempty"`
Length float32 `json:"length,omitempty"`
Weight float32 `json:"weight,omitempty"`
Stores []Inventory `json:"stores,omitempty"`
Properties StringMap `json:"properties,omitempty"`
Prices []OfferPrice `json:"prices,omitempty"`
Images []string `json:"images,omitempty"`
Unit *Unit `json:"unit,omitempty"`
Product *Product `json:"product,omitempty"`
}
// Inventory type.
type Inventory struct {
PurchasePrice float32 `json:"purchasePrice,omitempty"`
Quantity float32 `json:"quantity,omitempty"`
Store string `json:"store,omitempty"`
}
// InventoryUpload type.
type InventoryUpload struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
XMLID string `json:"xmlId,omitempty"`
Stores []InventoryUploadStore `json:"stores,omitempty"`
}
// InventoryUploadStore type.
type InventoryUploadStore struct {
PurchasePrice float32 `json:"purchasePrice,omitempty"`
Available float32 `json:"available,omitempty"`
Code string `json:"code,omitempty"`
}
// OfferPrice type.
type OfferPrice struct {
Price float32 `json:"price,omitempty"`
Ordering int `json:"ordering,omitempty"`
PriceType string `json:"priceType,omitempty"`
Currency string `json:"currency,omitempty"`
}
// OfferPriceUpload type.
type OfferPriceUpload struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
XMLID string `json:"xmlId,omitempty"`
Site string `json:"site,omitempty"`
Prices []PriceUpload `json:"prices,omitempty"`
}
// PriceUpload type.
type PriceUpload struct {
Code string `json:"code,omitempty"`
Price float32 `json:"price,omitempty"`
}
// Unit type.
type Unit struct {
Code string `json:"code"`
Name string `json:"name"`
Sym string `json:"sym"`
Default bool `json:"default,omitempty"`
Active bool `json:"active,omitempty"`
}
/**
User related types
*/
// User type.
type User struct {
ID int `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Patronymic string `json:"patronymic,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Active bool `json:"active,omitempty"`
Online bool `json:"online,omitempty"`
Position string `json:"position,omitempty"`
IsAdmin bool `json:"isAdmin,omitempty"`
IsManager bool `json:"isManager,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Status string `json:"status,omitempty"`
Groups []UserGroup `json:"groups,omitempty"`
MGUserID uint64 `json:"mgUserId,omitempty"`
}
// UserGroup type.
type UserGroup struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
SignatureTemplate string `json:"signatureTemplate,omitempty"`
IsManager bool `json:"isManager,omitempty"`
IsDeliveryMen bool `json:"isDeliveryMen,omitempty"`
DeliveryTypes []string `json:"deliveryTypes,omitempty"`
BreakdownOrderTypes []string `json:"breakdownOrderTypes,omitempty"`
BreakdownSites []string `json:"breakdownSites,omitempty"`
BreakdownOrderMethods []string `json:"breakdownOrderMethods,omitempty"`
GrantedOrderTypes []string `json:"grantedOrderTypes,omitempty"`
GrantedSites []string `json:"grantedSites,omitempty"`
}
/**
Task related types
*/
// Task type.
type Task struct {
ID int `json:"id,omitempty"`
PerformerID int `json:"performerId,omitempty"`
Text string `json:"text,omitempty"`
Commentary string `json:"commentary,omitempty"`
Datetime string `json:"datetime,omitempty"`
Complete bool `json:"complete,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Creator int `json:"creator,omitempty"`
Performer int `json:"performer,omitempty"`
Phone string `json:"phone,omitempty"`
PhoneSite string `json:"phoneSite,omitempty"`
Customer *Customer `json:"customer,omitempty"`
Order *Order `json:"order,omitempty"`
}
/*
Notes related types
*/
// Note type.
type Note struct {
ID int `json:"id,omitempty"`
ManagerID int `json:"managerId,omitempty"`
Text string `json:"text,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Customer *Customer `json:"customer,omitempty"`
}
/*
Payments related types
*/
// Payment type.
type Payment struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
PaidAt string `json:"paidAt,omitempty"`
Amount float32 `json:"amount,omitempty"`
Comment string `json:"comment,omitempty"`
Status string `json:"status,omitempty"`
Type string `json:"type,omitempty"`
Order *Order `json:"order,omitempty"`
}
/*
Segment related types
*/
// Segment type.
type Segment struct {
ID int `json:"id,omitempty"`
Code string `json:"code,omitempty"`
Name string `json:"name,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
CustomersCount int `json:"customersCount,omitempty"`
IsDynamic bool `json:"isDynamic,omitempty"`
Active bool `json:"active,omitempty"`
}
/*
* Settings related types
*/
// SettingsNode represents an item in settings. All settings nodes contains only string value and update time for now.
type SettingsNode struct {
Value string `json:"value"`
UpdatedAt string `json:"updated_at"`
}
// WorkTime type.
type WorkTime struct {
DayType string `json:"day_type"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
LunchStartTime string `json:"lunch_start_time"`
LunchEndTime string `json:"lunch_end_time"`
}
// NonWorkingDays type.
type NonWorkingDays struct {
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
}
type SerializedBaseLoyaltyAccount struct {
PhoneNumber string `json:"phoneNumber,omitempty"`
CardNumber string `json:"cardNumber,omitempty"`
CustomFields []interface{} `json:"customFields,omitempty"`
}
type SerializedCreateLoyaltyAccount struct {
SerializedBaseLoyaltyAccount
Customer SerializedEntityCustomer `json:"customer"`
}
type SerializedEditLoyaltyAccount struct {
SerializedBaseLoyaltyAccount
}
type ChannelSetting struct {
Site string `json:"site"`
OrderType string `json:"order_type"`
OrderMethod string `json:"order_method"`
}
type MgOrderCreationSettings struct {
Channels map[int]ChannelSetting `json:"channels"`
Default ChannelSetting `json:"default"`
}
type MgSettings struct {
OrderCreation MgOrderCreationSettings `json:"order_creation"`
}
// Settings type. Contains retailCRM configuration.
type Settings struct {
DefaultCurrency SettingsNode `json:"default_currency"`
SystemLanguage SettingsNode `json:"system_language"`
Timezone SettingsNode `json:"timezone"`
MgSettings MgSettings `json:"mg"`
WorkTimes []WorkTime `json:"work_times"`
NonWorkingDays []NonWorkingDays `json:"non_working_days"`
}
/**
Reference related types
*/
// CostGroup type.
type CostGroup struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Color string `json:"color,omitempty"`
Active bool `json:"active,omitempty"`
Ordering int `json:"ordering,omitempty"`
}
// CostItem type.
type CostItem struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Group string `json:"group,omitempty"`
Type string `json:"type,omitempty"`
Active bool `json:"active,omitempty"`
AppliesToOrders bool `json:"appliesToOrders,omitempty"`
AppliesToUsers bool `json:"appliesToUsers,omitempty"`
Ordering int `json:"ordering,omitempty"`
Source *Source `json:"source,omitempty"`
}
// Courier type.
type Courier struct {
ID int `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Patronymic string `json:"patronymic,omitempty"`
Email string `json:"email,omitempty"`
Description string `json:"description,omitempty"`
Active bool `json:"active,omitempty"`
Phone *Phone `json:"phone,omitempty"`
}
// DeliveryService type.
type DeliveryService struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
}
// DeliveryType type.
type DeliveryType struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
DefaultCost float32 `json:"defaultCost,omitempty"`
DefaultNetCost float32 `json:"defaultNetCost,omitempty"`
Description string `json:"description,omitempty"`
IntegrationCode string `json:"integrationCode,omitempty"`
VatRate string `json:"vatRate,omitempty"`
DefaultForCrm bool `json:"defaultForCrm,omitempty"`
DeliveryServices []string `json:"deliveryServices,omitempty"`
PaymentTypes []string `json:"paymentTypes,omitempty"` // Deprecated, use DeliveryPaymentTypes
DeliveryPaymentTypes []DeliveryPaymentType `json:"deliveryPaymentTypes,omitempty"`
Currency string `json:"currency,omitempty"`
}
type DeliveryPaymentType struct {
Code string `json:"code"`
Cod bool `json:"cod,omitempty"`
}
// LegalEntity type.
type LegalEntity struct {
Code string `json:"code,omitempty"`
VatRate string `json:"vatRate,omitempty"`
CountryIso string `json:"countryIso,omitempty"`
ContragentType string `json:"contragentType,omitempty"`
LegalName string `json:"legalName,omitempty"`
LegalAddress string `json:"legalAddress,omitempty"`
INN string `json:"INN,omitempty"`
OKPO string `json:"OKPO,omitempty"`
KPP string `json:"KPP,omitempty"`
OGRN string `json:"OGRN,omitempty"`
OGRNIP string `json:"OGRNIP,omitempty"`
CertificateNumber string `json:"certificateNumber,omitempty"`
CertificateDate string `json:"certificateDate,omitempty"`
BIK string `json:"BIK,omitempty"`
Bank string `json:"bank,omitempty"`
BankAddress string `json:"bankAddress,omitempty"`
CorrAccount string `json:"corrAccount,omitempty"`
BankAccount string `json:"bankAccount,omitempty"`
}
type SerializedEntityCustomer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
}
// OrderMethod type.
type OrderMethod struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
DefaultForCRM bool `json:"defaultForCrm,omitempty"`
DefaultForAPI bool `json:"defaultForApi,omitempty"`
}
// OrderType type.
type OrderType struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
DefaultForCRM bool `json:"defaultForCrm,omitempty"`
DefaultForAPI bool `json:"defaultForApi,omitempty"`
}
// PaymentStatus type.
type PaymentStatus struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
DefaultForCRM bool `json:"defaultForCrm,omitempty"`
DefaultForAPI bool `json:"defaultForApi,omitempty"`
PaymentComplete bool `json:"paymentComplete,omitempty"`
Description string `json:"description,omitempty"`
Ordering int `json:"ordering,omitempty"`
PaymentTypes []string `json:"paymentTypes,omitempty"`
}
// PaymentType type.
type PaymentType struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
DefaultForCRM bool `json:"defaultForCrm,omitempty"`
DefaultForAPI bool `json:"defaultForApi,omitempty"`
Description string `json:"description,omitempty"`
DeliveryTypes []string `json:"deliveryTypes,omitempty"`
PaymentStatuses []string `json:"PaymentStatuses,omitempty"`
}
// PriceType type.
type PriceType struct {
ID int `json:"id,omitempty"`
Code string `json:"code,omitempty"`
Name string `json:"name,omitempty"`
Active bool `json:"active,omitempty"`
Default bool `json:"default,omitempty"`
Description string `json:"description,omitempty"`
FilterExpression string `json:"filterExpression,omitempty"`
Ordering int `json:"ordering,omitempty"`
Groups []string `json:"groups,omitempty"`
Geo []GeoHierarchyRow `json:"geo,omitempty"`
Currency string `json:"currency,omitempty"`
}
// ProductStatus type.
type ProductStatus struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
Ordering int `json:"ordering,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
CancelStatus bool `json:"cancelStatus,omitempty"`
OrderStatusByProductStatus string `json:"orderStatusByProductStatus,omitempty"`
OrderStatusForProductStatus string `json:"orderStatusForProductStatus,omitempty"`
}
// Status type.
type Status struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
Ordering int `json:"ordering,omitempty"`
Group string `json:"group,omitempty"`
}
// StatusGroup type.
type StatusGroup struct {