add pageLink
field to message
This commit is contained in:
commit
9819c5c796
@ -3,8 +3,10 @@ package v1
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -497,6 +499,7 @@ func (t *MGClientTest) Test_TextMessages() {
|
|||||||
ExternalID: "external_id",
|
ExternalID: "external_id",
|
||||||
Type: MsgTypeText,
|
Type: MsgTypeText,
|
||||||
Text: "hello!",
|
Text: "hello!",
|
||||||
|
PageLink: "https://example.loca/catalog/1",
|
||||||
},
|
},
|
||||||
Originator: OriginatorCustomer,
|
Originator: OriginatorCustomer,
|
||||||
Customer: Customer{
|
Customer: Customer{
|
||||||
@ -515,6 +518,17 @@ func (t *MGClientTest) Test_TextMessages() {
|
|||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
t.gock().
|
t.gock().
|
||||||
Post(t.transportURL("messages")).
|
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).
|
Reply(http.StatusOK).
|
||||||
JSON(
|
JSON(
|
||||||
MessagesResponse{
|
MessagesResponse{
|
||||||
@ -598,6 +612,7 @@ func (t *MGClientTest) Test_UpdateMessages() {
|
|||||||
EditMessageRequestMessage{
|
EditMessageRequestMessage{
|
||||||
ExternalID: "editing",
|
ExternalID: "editing",
|
||||||
Text: "hello hello!",
|
Text: "hello hello!",
|
||||||
|
PageLink: "https://example.local/1",
|
||||||
},
|
},
|
||||||
1,
|
1,
|
||||||
}
|
}
|
||||||
@ -605,6 +620,17 @@ func (t *MGClientTest) Test_UpdateMessages() {
|
|||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
t.gock().
|
t.gock().
|
||||||
Put(t.transportURL("messages")).
|
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).
|
Reply(http.StatusOK).
|
||||||
JSON(
|
JSON(
|
||||||
MessagesResponse{
|
MessagesResponse{
|
||||||
|
@ -283,6 +283,7 @@ type Message struct {
|
|||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
Note string `json:"note,omitempty"`
|
Note string `json:"note,omitempty"`
|
||||||
Items []Item `json:"items,omitempty"`
|
Items []Item `json:"items,omitempty"`
|
||||||
|
PageLink string `json:"page_link,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessage struct.
|
// SendMessage struct.
|
||||||
@ -302,6 +303,7 @@ type EditMessageRequestMessage struct {
|
|||||||
ExternalID string `json:"external_id"`
|
ExternalID string `json:"external_id"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
EditedAt int64 `json:"edited_at"`
|
EditedAt int64 `json:"edited_at"`
|
||||||
|
PageLink string `json:"page_link,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendHistoryMessageRequest struct {
|
type SendHistoryMessageRequest struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user