added fields MessageSendRequest.TransportAttachments and ChannelSettings.Suggestions

This commit is contained in:
Alexander Kulinich 2020-08-07 19:29:25 +03:00
parent 9dcd7c9250
commit 2ffec7419b
2 changed files with 66 additions and 8 deletions

View File

@ -319,6 +319,44 @@ func TestMgClient_MessageSendText(t *testing.T) {
assert.NotEmpty(t, data.MessageID)
}
func TestMgClient_MessageSendTextWithSuggestions(t *testing.T) {
c := client()
i := uint64(1)
message := MessageSendRequest{
Type: MsgTypeText,
Scope: "public",
Content: "test message with suggestions",
ChatID: i,
TransportAttachments: &TransportAttachments{
Suggestions: []Suggestion{
{
Type: SuggestionTypeText,
Title: "text suggestion",
},
{Type: SuggestionTypeEmail},
{Type: SuggestionTypePhone},
},
},
}
defer gock.Off()
gock.New(mgURL).
Post("/api/bot/v1/messages").
JSON(message).
Reply(200).
BodyString(`{"message_id": 1, "time": "2018-01-01T00:00:00+03:00"}`)
data, status, err := c.MessageSend(message)
if err != nil {
t.Errorf("%d %v", status, err)
}
assert.NoError(t, err)
assert.NotEmpty(t, data.MessageID)
}
func TestMgClient_MessageSendProduct(t *testing.T) {
c := client()

View File

@ -71,6 +71,10 @@ const (
MsgCurrencyKzt = "kzt"
MsgCurrencyUsd = "usd"
MsgCurrencyEur = "eur"
SuggestionTypeText = "text"
SuggestionTypeEmail = "email"
SuggestionTypePhone = "phone"
)
// MgClient type
@ -181,6 +185,16 @@ type (
Scope string `url:"scope,omitempty" json:"scope"`
ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"`
QuoteMessageId uint64 `url:"quote_message_id,omitempty" json:"quote_message_id"`
TransportAttachments *TransportAttachments `url:"transport_attachments,omitempty" json:"transport_attachments"`
}
TransportAttachments struct {
Suggestions []Suggestion `url:"suggestions,omitempty" json:"suggestions"`
}
Suggestion struct {
Type string `url:"type,omitempty" json:"type"`
Title string `url:"title,omitempty" json:"title"`
}
MessageEditRequest struct {
@ -571,6 +585,12 @@ type (
} `json:"status"`
Text ChannelSettingsText `json:"text"`
Suggestions struct {
Text string `json:"text"`
Phone string `json:"phone"`
Email string `json:"email"`
} `json:"suggestions"`
}
)