mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
New field Tags in Customer struct
This commit is contained in:
commit
e9c6bf7474
@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -273,6 +274,10 @@ func TestClient_CustomerChange(t *testing.T) {
|
||||
Street: "Кутузовский",
|
||||
Building: "14",
|
||||
},
|
||||
Tags: []Tag{
|
||||
{"first", "#3e89b6", false},
|
||||
{"second", "#ffa654", false},
|
||||
},
|
||||
}
|
||||
|
||||
defer gock.Off()
|
||||
@ -337,7 +342,23 @@ func TestClient_CustomerChange(t *testing.T) {
|
||||
Get(fmt.Sprintf("/api/v5/customers/%v", f.ExternalID)).
|
||||
MatchParam("by", ByExternalID).
|
||||
Reply(200).
|
||||
BodyString(`{"success": true}`)
|
||||
BodyString(`{
|
||||
"success": true,
|
||||
"customer": {
|
||||
"tags": [
|
||||
{
|
||||
"name": "first",
|
||||
"color": "#3e89b6",
|
||||
"attached": false
|
||||
},
|
||||
{
|
||||
"name": "second",
|
||||
"color": "#ffa654",
|
||||
"attached": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}`)
|
||||
|
||||
data, status, err := c.Customer(f.ExternalID, ByExternalID, "")
|
||||
if err.Error() != "" {
|
||||
@ -351,6 +372,10 @@ func TestClient_CustomerChange(t *testing.T) {
|
||||
if data.Success != true {
|
||||
t.Errorf("%v", err.ApiError())
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(data.Customer.Tags, f.Tags) {
|
||||
t.Errorf("%v", err.ApiError())
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_CustomerChange_Fail(t *testing.T) {
|
||||
|
@ -149,6 +149,7 @@ type Customer struct {
|
||||
MgCustomerID string `json:"mgCustomerId,omitempty"`
|
||||
PhotoURL string `json:"photoUrl,omitempty"`
|
||||
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
|
||||
Tags []Tag `json:"tags,brackets,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomer type
|
||||
@ -1101,3 +1102,10 @@ type Activity struct {
|
||||
Active bool `json:"active"`
|
||||
Freeze bool `json:"freeze"`
|
||||
}
|
||||
|
||||
// Tag struct
|
||||
type Tag struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Attached bool `json:"attached,omitempty"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user