mirror of
https://github.com/retailcrm/mg-bot-api-client-go.git
synced 2024-11-21 20:36:05 +03:00
add product & order to message send
This commit is contained in:
parent
55b0a617b0
commit
5ead7292fd
@ -191,10 +191,11 @@ func TestMgClient_Messages(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMgClient_MessageSend(t *testing.T) {
|
||||
func TestMgClient_MessageSendText(t *testing.T) {
|
||||
c := client()
|
||||
i, err := strconv.ParseUint(os.Getenv("MG_BOT_CHAT"), 10, 64)
|
||||
message := MessageSendRequest{
|
||||
Type: MsgTypeText,
|
||||
Scope: "public",
|
||||
Content: "test",
|
||||
ChatID: i,
|
||||
@ -208,11 +209,42 @@ func TestMgClient_MessageSend(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, data.MessageID)
|
||||
}
|
||||
func TestMgClient_MessageSendProduct(t *testing.T) {
|
||||
c := client()
|
||||
|
||||
msg, _, err := c.MessageSend(MessageSendRequest{
|
||||
Type: MsgTypeProduct,
|
||||
ChatID: 5,
|
||||
Scope: "public",
|
||||
Product: &MessageProduct{
|
||||
ID: 1,
|
||||
Name: "Some Product",
|
||||
Article: "Art-111",
|
||||
Url: "https://example.com",
|
||||
Img: "http://example.com/pic.jpg",
|
||||
Cost: &MessageOrderCost{
|
||||
Value: 29900,
|
||||
Currency: "rub",
|
||||
},
|
||||
Quantity: &MessageOrderQuantity{
|
||||
Value: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
assert.NoError(t, err)
|
||||
t.Logf("%v", msg)
|
||||
}
|
||||
|
||||
func TestMgClient_MessageEdit(t *testing.T) {
|
||||
c := client()
|
||||
i, err := strconv.ParseUint(os.Getenv("MG_BOT_CHAT"), 10, 64)
|
||||
message := MessageSendRequest{
|
||||
Type: MsgTypeText,
|
||||
Scope: "public",
|
||||
Content: "test",
|
||||
ChatID: i,
|
||||
@ -243,6 +275,7 @@ func TestMgClient_MessageDelete(t *testing.T) {
|
||||
c := client()
|
||||
i, err := strconv.ParseUint(os.Getenv("MG_BOT_CHAT"), 10, 64)
|
||||
message := MessageSendRequest{
|
||||
Type: MsgTypeText,
|
||||
Scope: "public",
|
||||
Content: "test",
|
||||
ChatID: i,
|
||||
|
18
v1/types.go
18
v1/types.go
@ -42,6 +42,12 @@ const (
|
||||
|
||||
BotRoleDistributor string = "distributor"
|
||||
BotRoleResponsible string = "responsible"
|
||||
|
||||
MsgTypeText string = "text"
|
||||
MsgTypeSystem string = "system"
|
||||
MsgTypeCommand string = "command"
|
||||
MsgTypeOrder string = "order"
|
||||
MsgTypeProduct string = "product"
|
||||
)
|
||||
|
||||
// MgClient type
|
||||
@ -136,10 +142,13 @@ type (
|
||||
}
|
||||
|
||||
MessageSendRequest struct {
|
||||
Content string `url:"content,omitempty" json:"content"`
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
MessageEditRequest struct {
|
||||
@ -391,6 +400,7 @@ type (
|
||||
ID uint64 `json:"id"`
|
||||
Avatar string `json:"avatar"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
FirstName string `json:"first_name,omitempty"`
|
||||
LastName string `json:"last_name,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user