Merge pull request #20 from gwinn/master
update features, remove events
This commit is contained in:
commit
db54931d25
20
README.md
20
README.md
@ -27,19 +27,17 @@ func main() {
|
||||
var client = v1.New("https://token.url", "cb8ccf05e38a47543ad8477d49bcba99be73bff503ea6")
|
||||
ch := Channel{
|
||||
Type: "telegram",
|
||||
Events: []string{
|
||||
"message_sent",
|
||||
"message_read",
|
||||
},
|
||||
Settings: ChannelSettings{
|
||||
ReceiveMessageMode: MsgModeAlways,
|
||||
SpamAllowed: false,
|
||||
Features: ChannelFeatures{
|
||||
StatusDelivered: ChannelFeatureNone,
|
||||
MessageDeleting: ChannelFeatureSend,
|
||||
MessageEditing: ChannelFeatureBoth,
|
||||
MessageQuoting: ChannelFeatureBoth,
|
||||
ImageMessage: ChannelFeatureReceive,
|
||||
Status: Status{
|
||||
Delivered: ChannelFeatureNone,
|
||||
Read: ChannelFeatureReceive,
|
||||
},
|
||||
Text: ChannelSettingsText{
|
||||
Creating: ChannelFeatureBoth,
|
||||
Editing: ChannelFeatureSend,
|
||||
Quoting: ChannelFeatureReceive,
|
||||
Deleting: ChannelFeatureBoth,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
40
v1/client.go
40
v1/client.go
@ -26,19 +26,17 @@ func New(url string, token string) *MgClient {
|
||||
//
|
||||
// request := ActivateRequest{
|
||||
// Type: "telegram",
|
||||
// Events: []string{
|
||||
// "message_sent",
|
||||
// "message_read",
|
||||
// },
|
||||
// Settings: ChannelSettings{
|
||||
// ReceiveMessageMode: MsgModeAlways,
|
||||
// SpamAllowed: false,
|
||||
// Features: ChannelFeatures{
|
||||
// StatusDelivered: ChannelFeatureNone,
|
||||
// MessageDeleting: ChannelFeatureSend,
|
||||
// MessageEditing: ChannelFeatureBoth,
|
||||
// MessageQuoting: ChannelFeatureBoth,
|
||||
// ImageMessage: ChannelFeatureReceive,
|
||||
// Status: Status{
|
||||
// Delivered: ChannelFeatureNone,
|
||||
// Read: ChannelFeatureReceive,
|
||||
// },
|
||||
// Text: ChannelSettingsText{
|
||||
// Creating: ChannelFeatureBoth,
|
||||
// Editing: ChannelFeatureBoth,
|
||||
// Quoting: ChannelFeatureReceive,
|
||||
// Deleting: ChannelFeatureSend,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
@ -79,19 +77,17 @@ func (c *MgClient) ActivateTransportChannel(request Channel) (ActivateResponse,
|
||||
// request := ActivateRequest{
|
||||
// ID: 3053450384,
|
||||
// Type: "telegram",
|
||||
// Events: []string{
|
||||
// "message_sent",
|
||||
// "message_read",
|
||||
// },
|
||||
// Settings: ChannelSettings{
|
||||
// ReceiveMessageMode: MsgModeNever,
|
||||
// SpamAllowed: false,
|
||||
// Features: ChannelFeatures{
|
||||
// StatusDelivered: ChannelFeatureNone,
|
||||
// MessageDeleting: ChannelFeatureSend,
|
||||
// MessageEditing: ChannelFeatureBoth,
|
||||
// MessageQuoting: ChannelFeatureBoth,
|
||||
// ImageMessage: ChannelFeatureReceive,
|
||||
// Status: Status{
|
||||
// Delivered: ChannelFeatureNone,
|
||||
// Read: ChannelFeatureReceive,
|
||||
// },
|
||||
// Text: ChannelSettingsText{
|
||||
// Creating: ChannelFeatureBoth,
|
||||
// Editing: ChannelFeatureSend,
|
||||
// Quoting: ChannelFeatureReceive,
|
||||
// Deleting: ChannelFeatureBoth,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
|
@ -24,19 +24,17 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) {
|
||||
ch := Channel{
|
||||
ID: channelId,
|
||||
Type: "telegram",
|
||||
Events: []string{
|
||||
"message_sent",
|
||||
"message_read",
|
||||
},
|
||||
Settings: ChannelSettings{
|
||||
ReceiveMessageMode: MsgModeAlways,
|
||||
SpamAllowed: false,
|
||||
Features: ChannelFeatures{
|
||||
StatusDelivered: ChannelFeatureNone,
|
||||
MessageDeleting: ChannelFeatureSend,
|
||||
MessageEditing: ChannelFeatureBoth,
|
||||
MessageQuoting: ChannelFeatureBoth,
|
||||
ImageMessage: ChannelFeatureReceive,
|
||||
SpamAllowed: false,
|
||||
Status: Status{
|
||||
Delivered: ChannelFeatureNone,
|
||||
Read: ChannelFeatureReceive,
|
||||
},
|
||||
Text: ChannelSettingsText{
|
||||
Creating: ChannelFeatureBoth,
|
||||
Editing: ChannelFeatureSend,
|
||||
Quoting: ChannelFeatureReceive,
|
||||
Deleting: ChannelFeatureBoth,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -54,21 +52,17 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) {
|
||||
c := client()
|
||||
ch := Channel{
|
||||
Type: "telegram",
|
||||
Events: []string{
|
||||
"message_sent",
|
||||
"message_updated",
|
||||
"message_deleted",
|
||||
"message_read",
|
||||
},
|
||||
Settings: ChannelSettings{
|
||||
ReceiveMessageMode: MsgModeNever,
|
||||
SpamAllowed: false,
|
||||
Features: ChannelFeatures{
|
||||
StatusDelivered: ChannelFeatureNone,
|
||||
MessageDeleting: ChannelFeatureSend,
|
||||
MessageEditing: ChannelFeatureBoth,
|
||||
MessageQuoting: ChannelFeatureBoth,
|
||||
ImageMessage: ChannelFeatureReceive,
|
||||
SpamAllowed: false,
|
||||
Status: Status{
|
||||
Delivered: ChannelFeatureNone,
|
||||
Read: ChannelFeatureBoth,
|
||||
},
|
||||
Text: ChannelSettingsText{
|
||||
Creating: ChannelFeatureBoth,
|
||||
Editing: ChannelFeatureSend,
|
||||
Quoting: ChannelFeatureBoth,
|
||||
Deleting: ChannelFeatureSend,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -98,21 +92,17 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) {
|
||||
c := client()
|
||||
ch := Channel{
|
||||
ID: channelId,
|
||||
Events: []string{
|
||||
"message_sent",
|
||||
"message_updated",
|
||||
"message_deleted",
|
||||
"message_read",
|
||||
},
|
||||
Settings: ChannelSettings{
|
||||
ReceiveMessageMode: "always",
|
||||
SpamAllowed: false,
|
||||
Features: ChannelFeatures{
|
||||
StatusDelivered: ChannelFeatureNone,
|
||||
MessageDeleting: ChannelFeatureSend,
|
||||
MessageEditing: ChannelFeatureBoth,
|
||||
MessageQuoting: ChannelFeatureBoth,
|
||||
ImageMessage: ChannelFeatureReceive,
|
||||
SpamAllowed: false,
|
||||
Status: Status{
|
||||
Delivered: ChannelFeatureNone,
|
||||
Read: ChannelFeatureBoth,
|
||||
},
|
||||
Text: ChannelSettingsText{
|
||||
Creating: ChannelFeatureBoth,
|
||||
Editing: ChannelFeatureBoth,
|
||||
Quoting: ChannelFeatureBoth,
|
||||
Deleting: ChannelFeatureBoth,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
31
v1/types.go
31
v1/types.go
@ -10,9 +10,6 @@ const (
|
||||
ChannelFeatureReceive string = "receive"
|
||||
ChannelFeatureSend string = "send"
|
||||
ChannelFeatureBoth string = "both"
|
||||
|
||||
MsgModeNever string = "never"
|
||||
MsgModeAlways string = "always"
|
||||
)
|
||||
|
||||
// MgClient type
|
||||
@ -27,26 +24,28 @@ type MgClient struct {
|
||||
type Channel struct {
|
||||
ID uint64 `json:"id,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Events []string `json:"events,omitempty,brackets"`
|
||||
Settings ChannelSettings `json:"settings,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// ChannelSettings struct
|
||||
type ChannelSettings struct {
|
||||
Features ChannelFeatures `json:"features"`
|
||||
ReceiveMessageMode string `json:"receive_message_mode"`
|
||||
SpamAllowed bool `json:"spam_allowed"`
|
||||
SpamAllowed bool `json:"spam_allowed"`
|
||||
Status Status `json:"status"`
|
||||
Text ChannelSettingsText `json:"text"`
|
||||
}
|
||||
|
||||
// ChannelFeatures struct
|
||||
type ChannelFeatures struct {
|
||||
StatusDelivered string `json:"status_delivered"`
|
||||
StatusRead string `json:"status_read"`
|
||||
MessageDeleting string `json:"message_deleting"`
|
||||
MessageEditing string `json:"message_editing"`
|
||||
MessageQuoting string `json:"message_quoting"`
|
||||
ImageMessage string `json:"image_message"`
|
||||
FileMessage string `json:"file_message"`
|
||||
// Status struct
|
||||
type Status struct {
|
||||
Delivered string `json:"delivered"`
|
||||
Read string `json:"read"`
|
||||
}
|
||||
|
||||
// ChannelSettingsText struct
|
||||
type ChannelSettingsText struct {
|
||||
Creating string `json:"creating"`
|
||||
Editing string `json:"editing"`
|
||||
Quoting string `json:"quoting"`
|
||||
Deleting string `json:"deleting"`
|
||||
}
|
||||
|
||||
// ActivateResponse channel activation response
|
||||
|
Loading…
Reference in New Issue
Block a user