mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
fix model fields
This commit is contained in:
parent
280f078632
commit
8377a8789d
@ -6563,12 +6563,20 @@ func (c *Client) EditMGChannelTemplate(req EditMGChannelTemplateRequest) (int, e
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if string(templates) == "null" {
|
||||||
|
templates = []byte(`[]`)
|
||||||
|
}
|
||||||
|
|
||||||
removed, err := json.Marshal(req.Removed)
|
removed, err := json.Marshal(req.Removed)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if string(removed) == "null" {
|
||||||
|
removed = []byte(`[]`)
|
||||||
|
}
|
||||||
|
|
||||||
values := url.Values{
|
values := url.Values{
|
||||||
"templates": {string(templates)},
|
"templates": {string(templates)},
|
||||||
"removed": {string(removed)},
|
"removed": {string(removed)},
|
||||||
|
@ -7896,4 +7896,19 @@ func TestClient_EditMGChannelTemplate(t *testing.T) {
|
|||||||
code, err := client().EditMGChannelTemplate(request)
|
code, err := client().EditMGChannelTemplate(request)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, statuses[code])
|
assert.True(t, statuses[code])
|
||||||
|
|
||||||
|
reqValue = url.Values{
|
||||||
|
"templates": {tmplsJSON},
|
||||||
|
"removed": {"[]"},
|
||||||
|
}
|
||||||
|
|
||||||
|
gock.New(crmURL).
|
||||||
|
Post("reference/mg-channels/templates/edit").
|
||||||
|
Body(strings.NewReader(reqValue.Encode())).
|
||||||
|
Reply(http.StatusOK)
|
||||||
|
|
||||||
|
request = EditMGChannelTemplateRequest{Templates: tmpls}
|
||||||
|
code, err = client().EditMGChannelTemplate(request)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.True(t, statuses[code])
|
||||||
}
|
}
|
||||||
|
@ -517,5 +517,5 @@ func getMGTemplatesResponse() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getMGTemplatesForEdit() string {
|
func getMGTemplatesForEdit() string {
|
||||||
return `[{"header":{"text":{"parts":["Hello,",{"var":"custom"}],"example":["Henry"]},"document":{"example":"https://example.com/file/123.pdf"},"image":{"example":"https://example.com/file/123.png"},"video":{"example":"https://example.com/file/123.mp4"}},"lang":"en","category":"test_0","code":"namespace#name_0#ru","name":"name_0","namespace":"namespace","footer":"footer_0","verificationStatus":"REJECTED","template":["Text_0",{"var":"custom"}],"templateExample":["WIU"],"buttons":[{"type":"PHONE_NUMBER","text":"your-phone-button-text","phoneNumber":"+79895553535"},{"type":"QUICK_REPLY","text":"Yes"},{"type":"URL","url":"https://example.com/file/{{1}}","text":"button","example":["https://www.website.com/dynamic-url-example"]}],"channel":{"type":"fbmessenger","name":"JABAAAAAAAAAA","id":1,"externalId":1,"allowedSendByPhone":false,"active":true},"id":1,"externalId":10,"active":true}]`
|
return `[{"header":{"text":{"parts":["Hello,",{"var":"custom"}],"example":["Henry"]},"document":{"example":"https://example.com/file/123.pdf"},"image":{"example":"https://example.com/file/123.png"},"video":{"example":"https://example.com/file/123.mp4"}},"lang":"en","category":"test_0","code":"namespace#name_0#ru","name":"name_0","namespace":"namespace","footer":"footer_0","verificationStatus":"REJECTED","template":["Text_0",{"var":"custom"}],"buttons":[{"type":"PHONE_NUMBER","text":"your-phone-button-text","phoneNumber":"+79895553535"},{"type":"QUICK_REPLY","text":"Yes"},{"type":"URL","url":"https://example.com/file/{{1}}","text":"button","example":["https://www.website.com/dynamic-url-example"]}],"templateExample":["WIU"],"id":1,"externalId":10,"mgChannelId":110,"active":true}]`
|
||||||
}
|
}
|
||||||
|
5
types.go
5
types.go
@ -1474,6 +1474,7 @@ type MGChannel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MGChannelTemplate struct {
|
type MGChannelTemplate struct {
|
||||||
|
Channel *MGChannel `json:"channel,omitempty"`
|
||||||
Header *Header `json:"header"`
|
Header *Header `json:"header"`
|
||||||
Lang string `json:"lang"`
|
Lang string `json:"lang"`
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
@ -1483,10 +1484,10 @@ type MGChannelTemplate struct {
|
|||||||
Footer string `json:"footer,omitempty"`
|
Footer string `json:"footer,omitempty"`
|
||||||
VerificationStatus string `json:"verificationStatus,omitempty"`
|
VerificationStatus string `json:"verificationStatus,omitempty"`
|
||||||
BodyTemplate TemplateItemList `json:"template"`
|
BodyTemplate TemplateItemList `json:"template"`
|
||||||
BodyTemplateExample []string `json:"templateExample"`
|
|
||||||
Buttons []Button `json:"buttons,omitempty"`
|
Buttons []Button `json:"buttons,omitempty"`
|
||||||
Channel MGChannel `json:"channel"`
|
BodyTemplateExample []string `json:"templateExample"`
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
ExternalID int `json:"externalId,omitempty"`
|
ExternalID int `json:"externalId,omitempty"`
|
||||||
|
MGChannelID int `json:"mgChannelId"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user