mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-21 20:36: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,
|
||||
"ordersCount": 0,
|
||||
"costSumm": 0,
|
||||
"customFields": [],
|
||||
"customFields": {
|
||||
"animal": "cat",
|
||||
"animal_multiselect": ["cat", "dog"]
|
||||
},
|
||||
"personalDiscount": 10,
|
||||
"mainCompany": {
|
||||
"id": 26,
|
||||
@ -1482,7 +1485,13 @@ func TestClient_CorporateCustomerCompanies(t *testing.T) {
|
||||
"averageSumm": 0,
|
||||
"ordersCount": 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{
|
||||
SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{
|
||||
PhoneNumber: "89151005004",
|
||||
CustomFields: []string{"dog"},
|
||||
CustomFields: []interface{}{"dog"},
|
||||
},
|
||||
Customer: SerializedEntityCustomer{
|
||||
ID: 123,
|
||||
@ -103,7 +103,9 @@ func getLoyaltyAccountCreateResponse() CreateLoyaltyAccountResponse {
|
||||
LoyaltyLevel: LoyaltyLevel{},
|
||||
CreatedAt: "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{},
|
||||
CreatedAt: "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": {
|
||||
"id": 123,
|
||||
"customFields": [],
|
||||
"customFields": {},
|
||||
"firstName": "Руслан1",
|
||||
"lastName": "Ефанов",
|
||||
"patronymic": ""
|
||||
@ -154,7 +158,12 @@ func getLoyaltyAccountResponse() string {
|
||||
"createdAt": "2022-11-24 12:39:37",
|
||||
"activatedAt": "2022-11-24 12:39:37",
|
||||
"status": "activated",
|
||||
"customFields": []
|
||||
"customFields": {
|
||||
"custom_multiselect": ["test1", "test3"],
|
||||
"custom_select": "test2",
|
||||
"custom_integer": 456,
|
||||
"custom_float": 8.43
|
||||
}
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
14
types.go
14
types.go
@ -155,7 +155,7 @@ type Customer struct {
|
||||
BrowserID string `json:"browserId,omitempty"`
|
||||
MgCustomerID string `json:"mgCustomerId,omitempty"`
|
||||
PhotoURL string `json:"photoUrl,omitempty"`
|
||||
CustomFields StringMap `json:"customFields,omitempty"`
|
||||
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||
Tags []Tag `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ type CorporateCustomer struct {
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Vip bool `json:"vip,omitempty"`
|
||||
Bad bool `json:"bad,omitempty"`
|
||||
CustomFields StringMap `json:"customFields,omitempty"`
|
||||
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
||||
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
||||
ManagerID int `json:"managerId,omitempty"`
|
||||
@ -228,7 +228,7 @@ type Company struct {
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Contragent *Contragent `json:"contragent,omitempty"`
|
||||
Address *IdentifiersPair `json:"address,omitempty"`
|
||||
CustomFields StringMap `json:"customFields,omitempty"`
|
||||
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomerNote type.
|
||||
@ -338,7 +338,7 @@ type Order struct {
|
||||
Delivery *OrderDelivery `json:"delivery,omitempty"`
|
||||
Marketplace *OrderMarketplace `json:"marketplace,omitempty"`
|
||||
Items []OrderItem `json:"items,omitempty"`
|
||||
CustomFields StringMap `json:"customFields,omitempty"`
|
||||
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||
Payments OrderPayments `json:"payments,omitempty"`
|
||||
ApplyRound *bool `json:"applyRound,omitempty"`
|
||||
PrivilegeType string `json:"privilegeType,omitempty"`
|
||||
@ -734,7 +734,7 @@ type NonWorkingDays struct {
|
||||
type SerializedBaseLoyaltyAccount struct {
|
||||
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||
CardNumber string `json:"cardNumber,omitempty"`
|
||||
CustomFields []string `json:"customFields,omitempty"`
|
||||
CustomFields []interface{} `json:"customFields,omitempty"`
|
||||
}
|
||||
|
||||
type SerializedCreateLoyaltyAccount struct {
|
||||
@ -1240,11 +1240,13 @@ type CustomFields struct {
|
||||
InGroupActions bool `json:"inGroupActions,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Entity string `json:"entity,omitempty"`
|
||||
// Deprecated: Use DefaultTyped instead.
|
||||
Default string `json:"default,omitempty"`
|
||||
Ordering int `json:"ordering,omitempty"`
|
||||
DisplayArea string `json:"displayArea,omitempty"`
|
||||
ViewMode string `json:"viewMode,omitempty"`
|
||||
Dictionary string `json:"dictionary,omitempty"`
|
||||
DefaultTyped interface{} `json:"default_typed,omitempty"`
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1340,7 +1342,7 @@ type LoyaltyAccount struct {
|
||||
ActivatedAt string `json:"activatedAt,omitempty"`
|
||||
ConfirmedPhoneAt string `json:"confirmedPhoneAt,omitempty"`
|
||||
LastCheckID int `json:"lastCheckId,omitempty"`
|
||||
CustomFields []string `json:"customFields,omitempty"`
|
||||
CustomFields map[string]interface{} `json:"customFields,omitempty"`
|
||||
Loyalty Loyalty `json:"loyalty,omitempty"`
|
||||
Customer Customer `json:"customer,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user