From 9dcd7c92505f0dc1e7c274331a79e93e7c01a000 Mon Sep 17 00:00:00 2001 From: Alexander Kulinich Date: Mon, 10 Aug 2020 18:15:24 +0300 Subject: [PATCH 1/2] leave support for versions 1.13 and 1.14 in travis due to the dependence on testify --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 44eac81..17a09c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,8 @@ env: - MG_DEBUG=false go: - - '1.8' - - '1.9' - - '1.10' - - '1.11' + - '1.13' + - '1.14' before_install: - go get -v github.com/google/go-querystring/query From 2ffec7419bc81b2e3ba625a1b690c6d85943ebc0 Mon Sep 17 00:00:00 2001 From: Alexander Kulinich Date: Fri, 7 Aug 2020 19:29:25 +0300 Subject: [PATCH 2/2] added fields MessageSendRequest.TransportAttachments and ChannelSettings.Suggestions --- v1/client_test.go | 38 ++++++++++++++++++++++++++++++++++++++ v1/types.go | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/v1/client_test.go b/v1/client_test.go index 3d190c9..4e9d9bc 100644 --- a/v1/client_test.go +++ b/v1/client_test.go @@ -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() diff --git a/v1/types.go b/v1/types.go index c7f8947..2d4d404 100644 --- a/v1/types.go +++ b/v1/types.go @@ -71,6 +71,10 @@ const ( MsgCurrencyKzt = "kzt" MsgCurrencyUsd = "usd" MsgCurrencyEur = "eur" + + SuggestionTypeText = "text" + SuggestionTypeEmail = "email" + SuggestionTypePhone = "phone" ) // MgClient type @@ -173,14 +177,24 @@ type ( } MessageSendRequest struct { - Type string `url:"type,omitempty" json:"type"` - Content string `url:"content,omitempty" json:"content"` - Product *MessageProduct `url:"product,omitempty" json:"product"` - Order *MessageOrder `url:"order,omitempty" json:"order"` - Items []Item `url:"order,omitempty" json:"items"` - 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"` + Type string `url:"type,omitempty" json:"type"` + Content string `url:"content,omitempty" json:"content"` + Product *MessageProduct `url:"product,omitempty" json:"product"` + Order *MessageOrder `url:"order,omitempty" json:"order"` + Items []Item `url:"order,omitempty" json:"items"` + 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"` } )