Merge pull request #18 from gwinn/master
add constants with feature values
This commit is contained in:
commit
993f0114b8
12
README.md
12
README.md
@ -32,14 +32,14 @@ func main() {
|
|||||||
"message_read",
|
"message_read",
|
||||||
},
|
},
|
||||||
Settings: ChannelSettings{
|
Settings: ChannelSettings{
|
||||||
ReceiveMessageMode: "always",
|
ReceiveMessageMode: MsgModeAlways,
|
||||||
SpamAllowed: false,
|
SpamAllowed: false,
|
||||||
Features: ChannelFeatures{
|
Features: ChannelFeatures{
|
||||||
StatusDelivered: "none",
|
StatusDelivered: ChannelFeatureNone,
|
||||||
MessageDeleting: "send",
|
MessageDeleting: ChannelFeatureSend,
|
||||||
MessageEditing: "both",
|
MessageEditing: ChannelFeatureBoth,
|
||||||
MessageQuoting: "both",
|
MessageQuoting: ChannelFeatureBoth,
|
||||||
ImageMessage: "receive",
|
ImageMessage: ChannelFeatureReceive,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
26
v1/client.go
26
v1/client.go
@ -31,14 +31,14 @@ func New(url string, token string) *MgClient {
|
|||||||
// "message_read",
|
// "message_read",
|
||||||
// },
|
// },
|
||||||
// Settings: ChannelSettings{
|
// Settings: ChannelSettings{
|
||||||
// ReceiveMessageMode: "always",
|
// ReceiveMessageMode: MsgModeAlways,
|
||||||
// SpamAllowed: false,
|
// SpamAllowed: false,
|
||||||
// Features: ChannelFeatures{
|
// Features: ChannelFeatures{
|
||||||
// StatusDelivered: "none",
|
// StatusDelivered: ChannelFeatureNone,
|
||||||
// MessageDeleting: "send",
|
// MessageDeleting: ChannelFeatureSend,
|
||||||
// MessageEditing: "both",
|
// MessageEditing: ChannelFeatureBoth,
|
||||||
// MessageQuoting: "both",
|
// MessageQuoting: ChannelFeatureBoth,
|
||||||
// ImageMessage: "receive",
|
// ImageMessage: ChannelFeatureReceive,
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// }
|
// }
|
||||||
@ -84,14 +84,14 @@ func (c *MgClient) ActivateTransportChannel(request Channel) (ActivateResponse,
|
|||||||
// "message_read",
|
// "message_read",
|
||||||
// },
|
// },
|
||||||
// Settings: ChannelSettings{
|
// Settings: ChannelSettings{
|
||||||
// ReceiveMessageMode: "always",
|
// ReceiveMessageMode: MsgModeTimeLimited,
|
||||||
// SpamAllowed: false,
|
// SpamAllowed: false,
|
||||||
// Features: ChannelFeatures{
|
// Features: ChannelFeatures{
|
||||||
// StatusDelivered: "none",
|
// StatusDelivered: ChannelFeatureNone,
|
||||||
// MessageDeleting: "send",
|
// MessageDeleting: ChannelFeatureSend,
|
||||||
// MessageEditing: "both",
|
// MessageEditing: ChannelFeatureBoth,
|
||||||
// MessageQuoting: "both",
|
// MessageQuoting: ChannelFeatureBoth,
|
||||||
// ImageMessage: "receive",
|
// ImageMessage: ChannelFeatureReceive,
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// }
|
// }
|
||||||
@ -277,7 +277,7 @@ func (c *MgClient) DeleteMessage(request DeleteData) (MessagesResponse, int, err
|
|||||||
outgoing, _ := json.Marshal(&request)
|
outgoing, _ := json.Marshal(&request)
|
||||||
|
|
||||||
data, status, err := c.DeleteRequest(
|
data, status, err := c.DeleteRequest(
|
||||||
"/messages/",
|
"/messages",
|
||||||
[]byte(outgoing),
|
[]byte(outgoing),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -29,14 +29,14 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) {
|
|||||||
"message_read",
|
"message_read",
|
||||||
},
|
},
|
||||||
Settings: ChannelSettings{
|
Settings: ChannelSettings{
|
||||||
ReceiveMessageMode: "always",
|
ReceiveMessageMode: MsgModeAlways,
|
||||||
SpamAllowed: false,
|
SpamAllowed: false,
|
||||||
Features: ChannelFeatures{
|
Features: ChannelFeatures{
|
||||||
StatusDelivered: "none",
|
StatusDelivered: ChannelFeatureNone,
|
||||||
MessageDeleting: "send",
|
MessageDeleting: ChannelFeatureSend,
|
||||||
MessageEditing: "both",
|
MessageEditing: ChannelFeatureBoth,
|
||||||
MessageQuoting: "both",
|
MessageQuoting: ChannelFeatureBoth,
|
||||||
ImageMessage: "receive",
|
ImageMessage: ChannelFeatureReceive,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -61,14 +61,14 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) {
|
|||||||
"message_read",
|
"message_read",
|
||||||
},
|
},
|
||||||
Settings: ChannelSettings{
|
Settings: ChannelSettings{
|
||||||
ReceiveMessageMode: "always",
|
ReceiveMessageMode: MsgModeTimeLimited,
|
||||||
SpamAllowed: false,
|
SpamAllowed: false,
|
||||||
Features: ChannelFeatures{
|
Features: ChannelFeatures{
|
||||||
StatusDelivered: "none",
|
StatusDelivered: ChannelFeatureNone,
|
||||||
MessageDeleting: "send",
|
MessageDeleting: ChannelFeatureSend,
|
||||||
MessageEditing: "both",
|
MessageEditing: ChannelFeatureBoth,
|
||||||
MessageQuoting: "both",
|
MessageQuoting: ChannelFeatureBoth,
|
||||||
ImageMessage: "receive",
|
ImageMessage: ChannelFeatureReceive,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -108,11 +108,11 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) {
|
|||||||
ReceiveMessageMode: "always",
|
ReceiveMessageMode: "always",
|
||||||
SpamAllowed: false,
|
SpamAllowed: false,
|
||||||
Features: ChannelFeatures{
|
Features: ChannelFeatures{
|
||||||
StatusDelivered: "none",
|
StatusDelivered: ChannelFeatureNone,
|
||||||
MessageDeleting: "send",
|
MessageDeleting: ChannelFeatureSend,
|
||||||
MessageEditing: "both",
|
MessageEditing: ChannelFeatureBoth,
|
||||||
MessageQuoting: "both",
|
MessageQuoting: ChannelFeatureBoth,
|
||||||
ImageMessage: "receive",
|
ImageMessage: ChannelFeatureReceive,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
45
v1/types.go
45
v1/types.go
@ -5,6 +5,17 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ChannelFeatureNone string = "none"
|
||||||
|
ChannelFeatureReceive string = "receive"
|
||||||
|
ChannelFeatureSend string = "send"
|
||||||
|
ChannelFeatureBoth string = "both"
|
||||||
|
|
||||||
|
MsgModeNever string = "never"
|
||||||
|
MsgModeTimeLimited string = "time-limited"
|
||||||
|
MsgModeAlways string = "always"
|
||||||
|
)
|
||||||
|
|
||||||
// MgClient type
|
// MgClient type
|
||||||
type MgClient struct {
|
type MgClient struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
@ -59,22 +70,22 @@ type DeleteResponse struct {
|
|||||||
|
|
||||||
// User struct
|
// User struct
|
||||||
type User struct {
|
type User struct {
|
||||||
ExternalID string `json:"external_id" json:"external_id"`
|
ExternalID string `json:"external_id"`
|
||||||
Nickname string `json:"nickname" json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
Firstname string `json:"first_name,omitempty" json:"first_name"`
|
Firstname string `json:"first_name,omitempty"`
|
||||||
Lastname string `json:"last_name,omitempty" json:"last_name"`
|
Lastname string `json:"last_name,omitempty"`
|
||||||
Avatar string `json:"avatar,omitempty" json:"avatar"`
|
Avatar string `json:"avatar,omitempty"`
|
||||||
ProfileURL string `json:"profile_url,omitempty" json:"profile_url"`
|
ProfileURL string `json:"profile_url,omitempty"`
|
||||||
Country string `json:"country,omitempty" json:"country"`
|
Country string `json:"country,omitempty"`
|
||||||
Language string `json:"language,omitempty" json:"language"`
|
Language string `json:"language,omitempty"`
|
||||||
Phone string `json:"phone,omitempty" json:"phone"`
|
Phone string `json:"phone,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message struct
|
// Message struct
|
||||||
type Message struct {
|
type Message struct {
|
||||||
ExternalID string `json:"external_id" json:"external_id"`
|
ExternalID string `json:"external_id"`
|
||||||
Type string `json:"type,omitempty" json:"type"`
|
Type string `json:"type,omitempty"`
|
||||||
Text string `json:"text,omitempty" json:"text"`
|
Text string `json:"text,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessage struct
|
// SendMessage struct
|
||||||
@ -91,11 +102,11 @@ type UpdateMessage struct {
|
|||||||
|
|
||||||
// SendData struct
|
// SendData struct
|
||||||
type SendData struct {
|
type SendData struct {
|
||||||
Message SendMessage `json:"message" json:"message"`
|
Message SendMessage `json:"message"`
|
||||||
User User `json:"user" json:"user"`
|
User User `json:"user"`
|
||||||
Channel uint64 `json:"channel" json:"channel"`
|
Channel uint64 `json:"channel"`
|
||||||
ExternalChatID string `json:"external_chat_id" json:"external_chat_id"`
|
ExternalChatID string `json:"external_chat_id"`
|
||||||
Quote *SendMessageRequestQuote `json:"quote,omitempty" json:"quote,omitempty"`
|
Quote *SendMessageRequestQuote `json:"quote,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendMessageRequestQuote struct {
|
type SendMessageRequestQuote struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user