mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
Add multi dictionary custom field support
This commit is contained in:
parent
e513134df9
commit
afb7c1b881
@ -1266,7 +1266,10 @@ func TestClient_CorporateCustomer(t *testing.T) {
|
|||||||
"averageSumm": 0,
|
"averageSumm": 0,
|
||||||
"ordersCount": 0,
|
"ordersCount": 0,
|
||||||
"costSumm": 0,
|
"costSumm": 0,
|
||||||
"customFields": [],
|
"customFields": {
|
||||||
|
"animal": "cat",
|
||||||
|
"animal_multiselect": ["cat", "dog"]
|
||||||
|
},
|
||||||
"personalDiscount": 10,
|
"personalDiscount": 10,
|
||||||
"mainCompany": {
|
"mainCompany": {
|
||||||
"id": 26,
|
"id": 26,
|
||||||
@ -1482,7 +1485,13 @@ func TestClient_CorporateCustomerCompanies(t *testing.T) {
|
|||||||
"averageSumm": 0,
|
"averageSumm": 0,
|
||||||
"ordersCount": 0,
|
"ordersCount": 0,
|
||||||
"costSumm": 0,
|
"costSumm": 0,
|
||||||
"customFields": []
|
"customFields": {
|
||||||
|
"field_multiselect": ["test1", "test2"],
|
||||||
|
"field_select": "test3",
|
||||||
|
"field_string": "test_string",
|
||||||
|
"field_float": 4.56,
|
||||||
|
"field_integer": 789
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
19
testutils.go
19
testutils.go
@ -85,7 +85,7 @@ func getLoyaltyAccountCreate() SerializedCreateLoyaltyAccount {
|
|||||||
return SerializedCreateLoyaltyAccount{
|
return SerializedCreateLoyaltyAccount{
|
||||||
SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{
|
SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{
|
||||||
PhoneNumber: "89151005004",
|
PhoneNumber: "89151005004",
|
||||||
CustomFields: []string{"dog"},
|
CustomFields: []interface{}{"dog"},
|
||||||
},
|
},
|
||||||
Customer: SerializedEntityCustomer{
|
Customer: SerializedEntityCustomer{
|
||||||
ID: 123,
|
ID: 123,
|
||||||
@ -103,7 +103,9 @@ func getLoyaltyAccountCreateResponse() CreateLoyaltyAccountResponse {
|
|||||||
LoyaltyLevel: LoyaltyLevel{},
|
LoyaltyLevel: LoyaltyLevel{},
|
||||||
CreatedAt: "2022-11-24 12:39:37",
|
CreatedAt: "2022-11-24 12:39:37",
|
||||||
ActivatedAt: "2022-11-24 12:39:37",
|
ActivatedAt: "2022-11-24 12:39:37",
|
||||||
CustomFields: []string{"dog"},
|
CustomFields: map[string]interface{}{
|
||||||
|
"animal": "dog",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +120,9 @@ func getLoyaltyAccountEditResponse() EditLoyaltyAccountResponse {
|
|||||||
LoyaltyLevel: LoyaltyLevel{},
|
LoyaltyLevel: LoyaltyLevel{},
|
||||||
CreatedAt: "2022-11-24 12:39:37",
|
CreatedAt: "2022-11-24 12:39:37",
|
||||||
ActivatedAt: "2022-11-24 12:39:37",
|
ActivatedAt: "2022-11-24 12:39:37",
|
||||||
CustomFields: []string{"dog"},
|
CustomFields: map[string]interface{}{
|
||||||
|
"animal": "dog",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +138,7 @@ func getLoyaltyAccountResponse() string {
|
|||||||
},
|
},
|
||||||
"customer": {
|
"customer": {
|
||||||
"id": 123,
|
"id": 123,
|
||||||
"customFields": [],
|
"customFields": {},
|
||||||
"firstName": "Руслан1",
|
"firstName": "Руслан1",
|
||||||
"lastName": "Ефанов",
|
"lastName": "Ефанов",
|
||||||
"patronymic": ""
|
"patronymic": ""
|
||||||
@ -154,7 +158,12 @@ func getLoyaltyAccountResponse() string {
|
|||||||
"createdAt": "2022-11-24 12:39:37",
|
"createdAt": "2022-11-24 12:39:37",
|
||||||
"activatedAt": "2022-11-24 12:39:37",
|
"activatedAt": "2022-11-24 12:39:37",
|
||||||
"status": "activated",
|
"status": "activated",
|
||||||
"customFields": []
|
"customFields": {
|
||||||
|
"custom_multiselect": ["test1", "test3"],
|
||||||
|
"custom_select": "test2",
|
||||||
|
"custom_integer": 456,
|
||||||
|
"custom_float": 8.43
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
|
246
types.go
246
types.go
@ -122,41 +122,41 @@ Customer related types
|
|||||||
|
|
||||||
// Customer type.
|
// Customer type.
|
||||||
type Customer struct {
|
type Customer struct {
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
ExternalID string `json:"externalId,omitempty"`
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
FirstName string `json:"firstName,omitempty"`
|
FirstName string `json:"firstName,omitempty"`
|
||||||
LastName string `json:"lastName,omitempty"`
|
LastName string `json:"lastName,omitempty"`
|
||||||
Patronymic string `json:"patronymic,omitempty"`
|
Patronymic string `json:"patronymic,omitempty"`
|
||||||
Sex string `json:"sex,omitempty"`
|
Sex string `json:"sex,omitempty"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
Phones []Phone `json:"phones,omitempty"`
|
Phones []Phone `json:"phones,omitempty"`
|
||||||
Address *Address `json:"address,omitempty"`
|
Address *Address `json:"address,omitempty"`
|
||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
Birthday string `json:"birthday,omitempty"`
|
Birthday string `json:"birthday,omitempty"`
|
||||||
ManagerID int `json:"managerId,omitempty"`
|
ManagerID int `json:"managerId,omitempty"`
|
||||||
Vip bool `json:"vip,omitempty"`
|
Vip bool `json:"vip,omitempty"`
|
||||||
Bad bool `json:"bad,omitempty"`
|
Bad bool `json:"bad,omitempty"`
|
||||||
Site string `json:"site,omitempty"`
|
Site string `json:"site,omitempty"`
|
||||||
Source *Source `json:"source,omitempty"`
|
Source *Source `json:"source,omitempty"`
|
||||||
Contragent *Contragent `json:"contragent,omitempty"`
|
Contragent *Contragent `json:"contragent,omitempty"`
|
||||||
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
||||||
CumulativeDiscount float32 `json:"cumulativeDiscount,omitempty"`
|
CumulativeDiscount float32 `json:"cumulativeDiscount,omitempty"`
|
||||||
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
||||||
EmailMarketingUnsubscribedAt string `json:"emailMarketingUnsubscribedAt,omitempty"`
|
EmailMarketingUnsubscribedAt string `json:"emailMarketingUnsubscribedAt,omitempty"`
|
||||||
AvgMarginSumm float32 `json:"avgMarginSumm,omitempty"`
|
AvgMarginSumm float32 `json:"avgMarginSumm,omitempty"`
|
||||||
MarginSumm float32 `json:"marginSumm,omitempty"`
|
MarginSumm float32 `json:"marginSumm,omitempty"`
|
||||||
TotalSumm float32 `json:"totalSumm,omitempty"`
|
TotalSumm float32 `json:"totalSumm,omitempty"`
|
||||||
AverageSumm float32 `json:"averageSumm,omitempty"`
|
AverageSumm float32 `json:"averageSumm,omitempty"`
|
||||||
OrdersCount int `json:"ordersCount,omitempty"`
|
OrdersCount int `json:"ordersCount,omitempty"`
|
||||||
CostSumm float32 `json:"costSumm,omitempty"`
|
CostSumm float32 `json:"costSumm,omitempty"`
|
||||||
MaturationTime int `json:"maturationTime,omitempty"`
|
MaturationTime int `json:"maturationTime,omitempty"`
|
||||||
FirstClientID string `json:"firstClientId,omitempty"`
|
FirstClientID string `json:"firstClientId,omitempty"`
|
||||||
LastClientID string `json:"lastClientId,omitempty"`
|
LastClientID string `json:"lastClientId,omitempty"`
|
||||||
BrowserID string `json:"browserId,omitempty"`
|
BrowserID string `json:"browserId,omitempty"`
|
||||||
MgCustomerID string `json:"mgCustomerId,omitempty"`
|
MgCustomerID string `json:"mgCustomerId,omitempty"`
|
||||||
PhotoURL string `json:"photoUrl,omitempty"`
|
PhotoURL string `json:"photoUrl,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||||
Tags []Tag `json:"tags,omitempty"`
|
Tags []Tag `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CorporateCustomer type.
|
// CorporateCustomer type.
|
||||||
@ -167,7 +167,7 @@ type CorporateCustomer struct {
|
|||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
Vip bool `json:"vip,omitempty"`
|
Vip bool `json:"vip,omitempty"`
|
||||||
Bad bool `json:"bad,omitempty"`
|
Bad bool `json:"bad,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||||
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
||||||
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
||||||
ManagerID int `json:"managerId,omitempty"`
|
ManagerID int `json:"managerId,omitempty"`
|
||||||
@ -218,17 +218,17 @@ type CorporateCustomerContactCustomer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Company struct {
|
type Company struct {
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
IsMain bool `json:"isMain,omitempty"`
|
IsMain bool `json:"isMain,omitempty"`
|
||||||
ExternalID string `json:"externalId,omitempty"`
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
Active bool `json:"active,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Brand string `json:"brand,omitempty"`
|
Brand string `json:"brand,omitempty"`
|
||||||
Site string `json:"site,omitempty"`
|
Site string `json:"site,omitempty"`
|
||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
Contragent *Contragent `json:"contragent,omitempty"`
|
Contragent *Contragent `json:"contragent,omitempty"`
|
||||||
Address *IdentifiersPair `json:"address,omitempty"`
|
Address *IdentifiersPair `json:"address,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CorporateCustomerNote type.
|
// CorporateCustomerNote type.
|
||||||
@ -291,57 +291,57 @@ type Properties map[string]Property
|
|||||||
|
|
||||||
// Order type.
|
// Order type.
|
||||||
type Order struct {
|
type Order struct {
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
ExternalID string `json:"externalId,omitempty"`
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
Number string `json:"number,omitempty"`
|
Number string `json:"number,omitempty"`
|
||||||
FirstName string `json:"firstName,omitempty"`
|
FirstName string `json:"firstName,omitempty"`
|
||||||
LastName string `json:"lastName,omitempty"`
|
LastName string `json:"lastName,omitempty"`
|
||||||
Patronymic string `json:"patronymic,omitempty"`
|
Patronymic string `json:"patronymic,omitempty"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone,omitempty"`
|
||||||
AdditionalPhone string `json:"additionalPhone,omitempty"`
|
AdditionalPhone string `json:"additionalPhone,omitempty"`
|
||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
StatusUpdatedAt string `json:"statusUpdatedAt,omitempty"`
|
StatusUpdatedAt string `json:"statusUpdatedAt,omitempty"`
|
||||||
ManagerID int `json:"managerId,omitempty"`
|
ManagerID int `json:"managerId,omitempty"`
|
||||||
Mark int `json:"mark,omitempty"`
|
Mark int `json:"mark,omitempty"`
|
||||||
Call bool `json:"call,omitempty"`
|
Call bool `json:"call,omitempty"`
|
||||||
Expired bool `json:"expired,omitempty"`
|
Expired bool `json:"expired,omitempty"`
|
||||||
FromAPI bool `json:"fromApi,omitempty"`
|
FromAPI bool `json:"fromApi,omitempty"`
|
||||||
MarkDatetime string `json:"markDatetime,omitempty"`
|
MarkDatetime string `json:"markDatetime,omitempty"`
|
||||||
CustomerComment string `json:"customerComment,omitempty"`
|
CustomerComment string `json:"customerComment,omitempty"`
|
||||||
ManagerComment string `json:"managerComment,omitempty"`
|
ManagerComment string `json:"managerComment,omitempty"`
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
StatusComment string `json:"statusComment,omitempty"`
|
StatusComment string `json:"statusComment,omitempty"`
|
||||||
FullPaidAt string `json:"fullPaidAt,omitempty"`
|
FullPaidAt string `json:"fullPaidAt,omitempty"`
|
||||||
Site string `json:"site,omitempty"`
|
Site string `json:"site,omitempty"`
|
||||||
OrderType string `json:"orderType,omitempty"`
|
OrderType string `json:"orderType,omitempty"`
|
||||||
OrderMethod string `json:"orderMethod,omitempty"`
|
OrderMethod string `json:"orderMethod,omitempty"`
|
||||||
CountryIso string `json:"countryIso,omitempty"`
|
CountryIso string `json:"countryIso,omitempty"`
|
||||||
Summ float32 `json:"summ,omitempty"`
|
Summ float32 `json:"summ,omitempty"`
|
||||||
TotalSumm float32 `json:"totalSumm,omitempty"`
|
TotalSumm float32 `json:"totalSumm,omitempty"`
|
||||||
PrepaySum float32 `json:"prepaySum,omitempty"`
|
PrepaySum float32 `json:"prepaySum,omitempty"`
|
||||||
PurchaseSumm float32 `json:"purchaseSumm,omitempty"`
|
PurchaseSumm float32 `json:"purchaseSumm,omitempty"`
|
||||||
DiscountManualAmount float32 `json:"discountManualAmount,omitempty"`
|
DiscountManualAmount float32 `json:"discountManualAmount,omitempty"`
|
||||||
DiscountManualPercent float32 `json:"discountManualPercent,omitempty"`
|
DiscountManualPercent float32 `json:"discountManualPercent,omitempty"`
|
||||||
Weight float32 `json:"weight,omitempty"`
|
Weight float32 `json:"weight,omitempty"`
|
||||||
Length int `json:"length,omitempty"`
|
Length int `json:"length,omitempty"`
|
||||||
Width int `json:"width,omitempty"`
|
Width int `json:"width,omitempty"`
|
||||||
Height int `json:"height,omitempty"`
|
Height int `json:"height,omitempty"`
|
||||||
ShipmentStore string `json:"shipmentStore,omitempty"`
|
ShipmentStore string `json:"shipmentStore,omitempty"`
|
||||||
ShipmentDate string `json:"shipmentDate,omitempty"`
|
ShipmentDate string `json:"shipmentDate,omitempty"`
|
||||||
ClientID string `json:"clientId,omitempty"`
|
ClientID string `json:"clientId,omitempty"`
|
||||||
Shipped bool `json:"shipped,omitempty"`
|
Shipped bool `json:"shipped,omitempty"`
|
||||||
UploadedToExternalStoreSystem bool `json:"uploadedToExternalStoreSystem,omitempty"`
|
UploadedToExternalStoreSystem bool `json:"uploadedToExternalStoreSystem,omitempty"`
|
||||||
Source *Source `json:"source,omitempty"`
|
Source *Source `json:"source,omitempty"`
|
||||||
Contragent *Contragent `json:"contragent,omitempty"`
|
Contragent *Contragent `json:"contragent,omitempty"`
|
||||||
Customer *Customer `json:"customer,omitempty"`
|
Customer *Customer `json:"customer,omitempty"`
|
||||||
Delivery *OrderDelivery `json:"delivery,omitempty"`
|
Delivery *OrderDelivery `json:"delivery,omitempty"`
|
||||||
Marketplace *OrderMarketplace `json:"marketplace,omitempty"`
|
Marketplace *OrderMarketplace `json:"marketplace,omitempty"`
|
||||||
Items []OrderItem `json:"items,omitempty"`
|
Items []OrderItem `json:"items,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||||
Payments OrderPayments `json:"payments,omitempty"`
|
Payments OrderPayments `json:"payments,omitempty"`
|
||||||
ApplyRound *bool `json:"applyRound,omitempty"`
|
ApplyRound *bool `json:"applyRound,omitempty"`
|
||||||
PrivilegeType string `json:"privilegeType,omitempty"`
|
PrivilegeType string `json:"privilegeType,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrdersStatus type.
|
// OrdersStatus type.
|
||||||
@ -732,9 +732,9 @@ type NonWorkingDays struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SerializedBaseLoyaltyAccount struct {
|
type SerializedBaseLoyaltyAccount struct {
|
||||||
PhoneNumber string `json:"phoneNumber,omitempty"`
|
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||||
CardNumber string `json:"cardNumber,omitempty"`
|
CardNumber string `json:"cardNumber,omitempty"`
|
||||||
CustomFields []string `json:"customFields,omitempty"`
|
CustomFields []interface{} `json:"customFields,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SerializedCreateLoyaltyAccount struct {
|
type SerializedCreateLoyaltyAccount struct {
|
||||||
@ -1240,11 +1240,13 @@ type CustomFields struct {
|
|||||||
InGroupActions bool `json:"inGroupActions,omitempty"`
|
InGroupActions bool `json:"inGroupActions,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
Entity string `json:"entity,omitempty"`
|
Entity string `json:"entity,omitempty"`
|
||||||
Default string `json:"default,omitempty"`
|
// Deprecated: Use DefaultTyped instead.
|
||||||
Ordering int `json:"ordering,omitempty"`
|
Default string `json:"default,omitempty"`
|
||||||
DisplayArea string `json:"displayArea,omitempty"`
|
Ordering int `json:"ordering,omitempty"`
|
||||||
ViewMode string `json:"viewMode,omitempty"`
|
DisplayArea string `json:"displayArea,omitempty"`
|
||||||
Dictionary string `json:"dictionary,omitempty"`
|
ViewMode string `json:"viewMode,omitempty"`
|
||||||
|
Dictionary string `json:"dictionary,omitempty"`
|
||||||
|
DefaultTyped interface{} `json:"default_typed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1330,22 +1332,22 @@ type DeliveryTypeInfo struct {
|
|||||||
|
|
||||||
// LoyaltyAccount type.
|
// LoyaltyAccount type.
|
||||||
type LoyaltyAccount struct {
|
type LoyaltyAccount struct {
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
PhoneNumber string `json:"phoneNumber,omitempty"`
|
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||||
CardNumber string `json:"cardNumber,omitempty"`
|
CardNumber string `json:"cardNumber,omitempty"`
|
||||||
Amount float64 `json:"amount,omitempty"`
|
Amount float64 `json:"amount,omitempty"`
|
||||||
LoyaltyLevel LoyaltyLevel `json:"level,omitempty"`
|
LoyaltyLevel LoyaltyLevel `json:"level,omitempty"`
|
||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
ActivatedAt string `json:"activatedAt,omitempty"`
|
ActivatedAt string `json:"activatedAt,omitempty"`
|
||||||
ConfirmedPhoneAt string `json:"confirmedPhoneAt,omitempty"`
|
ConfirmedPhoneAt string `json:"confirmedPhoneAt,omitempty"`
|
||||||
LastCheckID int `json:"lastCheckId,omitempty"`
|
LastCheckID int `json:"lastCheckId,omitempty"`
|
||||||
CustomFields []string `json:"customFields,omitempty"`
|
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||||
Loyalty Loyalty `json:"loyalty,omitempty"`
|
Loyalty Loyalty `json:"loyalty,omitempty"`
|
||||||
Customer Customer `json:"customer,omitempty"`
|
Customer Customer `json:"customer,omitempty"`
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
OrderSum float64 `json:"orderSum,omitempty"`
|
OrderSum float64 `json:"orderSum,omitempty"`
|
||||||
NextLevelSum float64 `json:"nextLevelSum,omitempty"`
|
NextLevelSum float64 `json:"nextLevelSum,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loyalty type.
|
// Loyalty type.
|
||||||
|
Loading…
Reference in New Issue
Block a user