1
0
mirror of synced 2024-11-22 04:56:06 +03:00

add pageLink field to message

This commit is contained in:
Pavel 2023-12-14 15:38:11 +03:00 committed by GitHub
commit 9819c5c796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -3,8 +3,10 @@ package v1
import (
"bytes"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strings"
"testing"
@ -497,6 +499,7 @@ func (t *MGClientTest) Test_TextMessages() {
ExternalID: "external_id",
Type: MsgTypeText,
Text: "hello!",
PageLink: "https://example.loca/catalog/1",
},
Originator: OriginatorCustomer,
Customer: Customer{
@ -515,6 +518,17 @@ func (t *MGClientTest) Test_TextMessages() {
defer gock.Off()
t.gock().
Post(t.transportURL("messages")).
Filter(func(request *http.Request) bool {
data, err := ioutil.ReadAll(request.Body)
if err != nil {
return false
}
request.Body = ioutil.NopCloser(bytes.NewReader(data))
var snd SendData
t.Require().NoError(json.Unmarshal(data, &snd))
return t.Assert().Equal("https://example.loca/catalog/1", snd.Message.PageLink)
}).
Reply(http.StatusOK).
JSON(
MessagesResponse{
@ -598,6 +612,7 @@ func (t *MGClientTest) Test_UpdateMessages() {
EditMessageRequestMessage{
ExternalID: "editing",
Text: "hello hello!",
PageLink: "https://example.local/1",
},
1,
}
@ -605,6 +620,17 @@ func (t *MGClientTest) Test_UpdateMessages() {
defer gock.Off()
t.gock().
Put(t.transportURL("messages")).
Filter(func(request *http.Request) bool {
data, err := ioutil.ReadAll(request.Body)
if err != nil {
return false
}
request.Body = ioutil.NopCloser(bytes.NewReader(data))
var snd SendData
t.Require().NoError(json.Unmarshal(data, &snd))
return t.Assert().Equal("https://example.local/1", snd.Message.PageLink)
}).
Reply(http.StatusOK).
JSON(
MessagesResponse{

View File

@ -283,6 +283,7 @@ type Message struct {
Text string `json:"text,omitempty"`
Note string `json:"note,omitempty"`
Items []Item `json:"items,omitempty"`
PageLink string `json:"page_link,omitempty"`
}
// SendMessage struct.
@ -302,6 +303,7 @@ type EditMessageRequestMessage struct {
ExternalID string `json:"external_id"`
Text string `json:"text"`
EditedAt int64 `json:"edited_at"`
PageLink string `json:"page_link,omitempty"`
}
type SendHistoryMessageRequest struct {