mirror of
https://github.com/retailcrm/mg-bot-api-client-go.git
synced 2024-11-21 20:36:05 +03:00
Add Utm
field to the CustomersResponseItem
struct
This commit is contained in:
commit
582acf20eb
@ -244,10 +244,44 @@ func TestMgClient_Customers(t *testing.T) {
|
|||||||
|
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
|
response := `
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"channel_id": 1,
|
||||||
|
"created_at":
|
||||||
|
"2018-01-01T00:00:00.000000Z",
|
||||||
|
"utm": {
|
||||||
|
"source": "test"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"channel_id": 1,
|
||||||
|
"created_at":
|
||||||
|
"2018-01-01T00:00:00.000000Z",
|
||||||
|
"utm": {
|
||||||
|
"source": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"channel_id": 1,
|
||||||
|
"created_at":
|
||||||
|
"2018-01-01T00:00:00.000000Z",
|
||||||
|
"utm": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"channel_id": 1,
|
||||||
|
"created_at": "2018-01-01T00:00:00.000000Z"
|
||||||
|
}
|
||||||
|
]`
|
||||||
|
|
||||||
gock.New(mgURL).
|
gock.New(mgURL).
|
||||||
Get("/api/bot/v1/customers").
|
Get("/api/bot/v1/customers").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
BodyString(`[{"id": 1,"channel_id": 1, "created_at": "2018-01-01T00:00:00.000000Z"}]`)
|
BodyString(response)
|
||||||
|
|
||||||
req := CustomersRequest{}
|
req := CustomersRequest{}
|
||||||
|
|
||||||
@ -262,6 +296,11 @@ func TestMgClient_Customers(t *testing.T) {
|
|||||||
for _, customer := range data {
|
for _, customer := range data {
|
||||||
assert.NotEmpty(t, customer.ChannelId)
|
assert.NotEmpty(t, customer.ChannelId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, "test", data[0].Utm.Source)
|
||||||
|
assert.Equal(t, "", data[1].Utm.Source)
|
||||||
|
assert.Nil(t, data[2].Utm)
|
||||||
|
assert.Nil(t, data[3].Utm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMgClient_Chats(t *testing.T) {
|
func TestMgClient_Chats(t *testing.T) {
|
||||||
|
@ -287,6 +287,7 @@ type (
|
|||||||
Language string `json:"language,omitempty"`
|
Language string `json:"language,omitempty"`
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone,omitempty"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
|
Utm *Utm `json:"utm,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatResponseItem struct {
|
ChatResponseItem struct {
|
||||||
@ -592,6 +593,14 @@ type (
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Caption string `json:"caption"`
|
Caption string `json:"caption"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utm struct {
|
||||||
|
Source string `json:"source"`
|
||||||
|
Medium string `json:"medium"`
|
||||||
|
Campaign string `json:"campaign"`
|
||||||
|
Term string `json:"term"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// Channel settings
|
// Channel settings
|
||||||
|
Loading…
Reference in New Issue
Block a user