Merge pull request #34 from DmitryZagorulko/feature-files
improve file and image elem in channel settings struct, minor fixes
This commit is contained in:
commit
483fd79b52
@ -57,6 +57,12 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) {
|
|||||||
Creating: ChannelFeatureBoth,
|
Creating: ChannelFeatureBoth,
|
||||||
Deleting: ChannelFeatureSend,
|
Deleting: ChannelFeatureSend,
|
||||||
},
|
},
|
||||||
|
Image: ChannelSettingsFilesBase{
|
||||||
|
Creating: ChannelFeatureBoth,
|
||||||
|
},
|
||||||
|
File: ChannelSettingsFilesBase{
|
||||||
|
Creating: ChannelFeatureBoth,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +100,12 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) {
|
|||||||
Creating: ChannelFeatureBoth,
|
Creating: ChannelFeatureBoth,
|
||||||
Deleting: ChannelFeatureSend,
|
Deleting: ChannelFeatureSend,
|
||||||
},
|
},
|
||||||
|
Image: ChannelSettingsFilesBase{
|
||||||
|
Creating: ChannelFeatureBoth,
|
||||||
|
},
|
||||||
|
File: ChannelSettingsFilesBase{
|
||||||
|
Creating: ChannelFeatureBoth,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +155,12 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) {
|
|||||||
Creating: ChannelFeatureBoth,
|
Creating: ChannelFeatureBoth,
|
||||||
Deleting: ChannelFeatureSend,
|
Deleting: ChannelFeatureSend,
|
||||||
},
|
},
|
||||||
|
Image: ChannelSettingsFilesBase{
|
||||||
|
Creating: ChannelFeatureBoth,
|
||||||
|
},
|
||||||
|
File: ChannelSettingsFilesBase{
|
||||||
|
Creating: ChannelFeatureBoth,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +173,7 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) {
|
|||||||
t.Logf("Update selected channel: %v", data.ChannelID)
|
t.Logf("Update selected channel: %v", data.ChannelID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMgClient_Messages(t *testing.T) {
|
func TestMgClient_TextMessages(t *testing.T) {
|
||||||
c := client()
|
c := client()
|
||||||
t.Logf("%v", ext)
|
t.Logf("%v", ext)
|
||||||
|
|
||||||
@ -187,6 +205,46 @@ func TestMgClient_Messages(t *testing.T) {
|
|||||||
t.Logf("Message %v is sent", data.MessageID)
|
t.Logf("Message %v is sent", data.MessageID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMgClient_ImageMessages(t *testing.T) {
|
||||||
|
c := client()
|
||||||
|
t.Logf("%v", ext)
|
||||||
|
|
||||||
|
uploadFileResponse, st, err := c.UploadFileByURL(UploadFileByUrlRequest{
|
||||||
|
Url: "https://via.placeholder.com/300",
|
||||||
|
})
|
||||||
|
|
||||||
|
if st != http.StatusOK {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
snd := SendData{
|
||||||
|
Message: Message{
|
||||||
|
ExternalID: ext,
|
||||||
|
Type: MsgTypeImage,
|
||||||
|
Items: []Item{{ID: uploadFileResponse.ID}},
|
||||||
|
},
|
||||||
|
User: User{
|
||||||
|
ExternalID: "6",
|
||||||
|
Nickname: "octopus",
|
||||||
|
Firstname: "Joe",
|
||||||
|
},
|
||||||
|
Channel: channelID,
|
||||||
|
ExternalChatID: "24798237492374",
|
||||||
|
}
|
||||||
|
|
||||||
|
data, status, err := c.Messages(snd)
|
||||||
|
|
||||||
|
if status != http.StatusOK {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.Time.String() == "" {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("Message %v is sent", data.MessageID)
|
||||||
|
}
|
||||||
|
|
||||||
func TestMgClient_UpdateMessages(t *testing.T) {
|
func TestMgClient_UpdateMessages(t *testing.T) {
|
||||||
c := client()
|
c := client()
|
||||||
t.Logf("%v", ext)
|
t.Logf("%v", ext)
|
||||||
|
17
v1/types.go
17
v1/types.go
@ -26,6 +26,10 @@ const (
|
|||||||
MsgTypeOrder string = "order"
|
MsgTypeOrder string = "order"
|
||||||
// MsgTypeProduct product card
|
// MsgTypeProduct product card
|
||||||
MsgTypeProduct string = "product"
|
MsgTypeProduct string = "product"
|
||||||
|
// MsgTypeFile file card
|
||||||
|
MsgTypeFile string = "file"
|
||||||
|
// MsgTypeImage image card
|
||||||
|
MsgTypeImage string = "image"
|
||||||
|
|
||||||
// MsgOrderStatusCodeNew order status group new
|
// MsgOrderStatusCodeNew order status group new
|
||||||
MsgOrderStatusCodeNew = "new"
|
MsgOrderStatusCodeNew = "new"
|
||||||
@ -66,8 +70,8 @@ type ChannelSettings struct {
|
|||||||
Text ChannelSettingsText `json:"text"`
|
Text ChannelSettingsText `json:"text"`
|
||||||
Product Product `json:"product"`
|
Product Product `json:"product"`
|
||||||
Order Order `json:"order"`
|
Order Order `json:"order"`
|
||||||
Files ChannelSettingsFilesBase `json:"files"`
|
File ChannelSettingsFilesBase `json:"file"`
|
||||||
Images ChannelSettingsFilesBase `json:"images"`
|
Image ChannelSettingsFilesBase `json:"image"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product type
|
// Product type
|
||||||
@ -115,7 +119,7 @@ type FullFileResponse struct {
|
|||||||
|
|
||||||
// UploadFileResponse uploaded file data
|
// UploadFileResponse uploaded file data
|
||||||
type UploadFileResponse struct {
|
type UploadFileResponse struct {
|
||||||
ID []byte `json:"id"`
|
ID string `json:"id"`
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Meta FileMeta `json:"meta"`
|
Meta FileMeta `json:"meta"`
|
||||||
@ -198,6 +202,7 @@ type Message struct {
|
|||||||
ExternalID string `json:"external_id"`
|
ExternalID string `json:"external_id"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessage struct
|
// SendMessage struct
|
||||||
@ -228,6 +233,12 @@ type SendData struct {
|
|||||||
Quote *SendMessageRequestQuote `json:"quote,omitempty"`
|
Quote *SendMessageRequestQuote `json:"quote,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Item struct
|
||||||
|
type Item struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Caption string `json:"caption"`
|
||||||
|
}
|
||||||
|
|
||||||
// SendMessageRequestQuote type
|
// SendMessageRequestQuote type
|
||||||
type SendMessageRequestQuote struct {
|
type SendMessageRequestQuote struct {
|
||||||
ExternalID string `json:"external_id"`
|
ExternalID string `json:"external_id"`
|
||||||
|
Loading…
Reference in New Issue
Block a user