mirror of
https://github.com/retailcrm/mg-bot-api-client-go.git
synced 2024-11-21 20:36:05 +03:00
MessageSendRequest.TransportAttachments and ChannelSettings
This commit is contained in:
commit
3d8f69362b
@ -5,10 +5,8 @@ env:
|
|||||||
- MG_DEBUG=false
|
- MG_DEBUG=false
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- '1.8'
|
- '1.13'
|
||||||
- '1.9'
|
- '1.14'
|
||||||
- '1.10'
|
|
||||||
- '1.11'
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- go get -v github.com/google/go-querystring/query
|
- go get -v github.com/google/go-querystring/query
|
||||||
|
@ -376,6 +376,44 @@ func TestMgClient_MessageSendText(t *testing.T) {
|
|||||||
assert.NotEmpty(t, data.MessageID)
|
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) {
|
func TestMgClient_MessageSendProduct(t *testing.T) {
|
||||||
c := client()
|
c := client()
|
||||||
|
|
||||||
|
36
v1/types.go
36
v1/types.go
@ -71,6 +71,10 @@ const (
|
|||||||
MsgCurrencyKzt = "kzt"
|
MsgCurrencyKzt = "kzt"
|
||||||
MsgCurrencyUsd = "usd"
|
MsgCurrencyUsd = "usd"
|
||||||
MsgCurrencyEur = "eur"
|
MsgCurrencyEur = "eur"
|
||||||
|
|
||||||
|
SuggestionTypeText = "text"
|
||||||
|
SuggestionTypeEmail = "email"
|
||||||
|
SuggestionTypePhone = "phone"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MgClient type
|
// MgClient type
|
||||||
@ -173,14 +177,24 @@ type (
|
|||||||
}
|
}
|
||||||
|
|
||||||
MessageSendRequest struct {
|
MessageSendRequest struct {
|
||||||
Type string `url:"type,omitempty" json:"type"`
|
Type string `url:"type,omitempty" json:"type"`
|
||||||
Content string `url:"content,omitempty" json:"content"`
|
Content string `url:"content,omitempty" json:"content"`
|
||||||
Product *MessageProduct `url:"product,omitempty" json:"product"`
|
Product *MessageProduct `url:"product,omitempty" json:"product"`
|
||||||
Order *MessageOrder `url:"order,omitempty" json:"order"`
|
Order *MessageOrder `url:"order,omitempty" json:"order"`
|
||||||
Items []Item `url:"order,omitempty" json:"items"`
|
Items []Item `url:"order,omitempty" json:"items"`
|
||||||
Scope string `url:"scope,omitempty" json:"scope"`
|
Scope string `url:"scope,omitempty" json:"scope"`
|
||||||
ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"`
|
ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"`
|
||||||
QuoteMessageId uint64 `url:"quote_message_id,omitempty" json:"quote_message_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 {
|
MessageEditRequest struct {
|
||||||
@ -575,6 +589,12 @@ type (
|
|||||||
} `json:"status"`
|
} `json:"status"`
|
||||||
|
|
||||||
Text ChannelSettingsText `json:"text"`
|
Text ChannelSettingsText `json:"text"`
|
||||||
|
|
||||||
|
Suggestions struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
Phone string `json:"phone"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
} `json:"suggestions"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user