add fields in TemplateInfo model for message with template
This commit is contained in:
parent
716d9edbcb
commit
99d0e45ffd
10
v1/types.go
10
v1/types.go
@ -175,7 +175,7 @@ type FullFileResponse struct {
|
|||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
Size int `json:"size,omitempty"`
|
Size int `json:"size,omitempty"`
|
||||||
Url string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
MimeType string `json:"mime_type,omitempty"`
|
MimeType string `json:"mime_type,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,13 @@ type Suggestion struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TemplateInfo struct {
|
type TemplateInfo struct {
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Lang string `json:"lang"`
|
||||||
|
HeaderParams *HeaderParams `json:"headerParams,omitempty"`
|
||||||
|
Footer string `json:"footer,omitempty"`
|
||||||
|
ButtonParams []ButtonParam `json:"buttonParams,omitempty"`
|
||||||
Args []string `json:"args,omitempty"`
|
Args []string `json:"args,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,3 +170,43 @@ func TestTransportErrorResponse(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTemplateInfoUnmarshal(t *testing.T) {
|
||||||
|
tmplJSON := `{
|
||||||
|
"code": "namespace#BABA_JABA#ru",
|
||||||
|
"name": "BABA_JABA",
|
||||||
|
"lang": "ru",
|
||||||
|
"namespace": "namespace",
|
||||||
|
"args": ["BABA", "JABA"],
|
||||||
|
"headerParams": {
|
||||||
|
"textVars": ["Hey", "Jony"],
|
||||||
|
"imageUrl": "https://example.com/intaro/ddd22",
|
||||||
|
"videoUrl": "https://example.com/intaro/ddd23",
|
||||||
|
"documentUrl": "https://example.com/intaro/ddd24"
|
||||||
|
},
|
||||||
|
"footer": "Scooter",
|
||||||
|
"buttonParams": [
|
||||||
|
{
|
||||||
|
"urlParameter": "ququq",
|
||||||
|
"type": "URL",
|
||||||
|
"text": "CHUCHUH"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`
|
||||||
|
|
||||||
|
var tmpl TemplateInfo
|
||||||
|
assert.NoError(t, json.Unmarshal([]byte(tmplJSON), &tmpl))
|
||||||
|
assert.Equal(t, "namespace#BABA_JABA#ru", tmpl.Code)
|
||||||
|
assert.Equal(t, "namespace", tmpl.Namespace)
|
||||||
|
assert.Equal(t, "BABA_JABA", tmpl.Name)
|
||||||
|
assert.Equal(t, "ru", tmpl.Lang)
|
||||||
|
assert.Equal(t, []string{"BABA", "JABA"}, tmpl.Args)
|
||||||
|
assert.Equal(t, []string{"Hey", "Jony"}, tmpl.HeaderParams.TextVars)
|
||||||
|
assert.Equal(t, "https://example.com/intaro/ddd22", tmpl.HeaderParams.ImageURL)
|
||||||
|
assert.Equal(t, "https://example.com/intaro/ddd23", tmpl.HeaderParams.VideoURL)
|
||||||
|
assert.Equal(t, "https://example.com/intaro/ddd24", tmpl.HeaderParams.DocumentURL)
|
||||||
|
assert.Equal(t, "Scooter", tmpl.Footer)
|
||||||
|
assert.Equal(t, "URL", string(tmpl.ButtonParams[0].ButtonType))
|
||||||
|
assert.Equal(t, "ququq", tmpl.ButtonParams[0].URLParameter)
|
||||||
|
assert.Equal(t, "CHUCHUH", tmpl.ButtonParams[0].Text)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user