update api

This commit is contained in:
Roman Shakhov 2018-08-30 13:35:11 +03:00
parent a1680b7629
commit fc301725fd
2 changed files with 52 additions and 44 deletions

View File

@ -293,9 +293,7 @@ func TestMgClient_Commands(t *testing.T) {
func TestMgClient_CommandEditDelete(t *testing.T) { func TestMgClient_CommandEditDelete(t *testing.T) {
c := client() c := client()
i, err := strconv.ParseUint(os.Getenv("MG_BOT_ID"), 10, 64)
req := CommandEditRequest{ req := CommandEditRequest{
BotID: i,
Name: "show_payment_types", Name: "show_payment_types",
Description: "Get available payment types", Description: "Get available payment types",
} }

View File

@ -22,17 +22,10 @@ const (
MessageScopePublic string = "public" MessageScopePublic string = "public"
MessageScopePrivate string = "private" MessageScopePrivate string = "private"
BotEventMessageNew string = "message_new" ChannelFeatureNone string = "none"
BotEventMessageUpdated string = "message_updated" ChannelFeatureReceive string = "receive"
BotEventMessageDeleted string = "message_deleted" ChannelFeatureSend string = "send"
BotEventDialogOpened string = "dialog_opened" ChannelFeatureBoth string = "both"
BotEventDialogClosed string = "dialog_closed"
BotEventDialogAssing string = "dialog_assign"
BotEventChatCreated string = "chat_created"
BotEventChatUpdated string = "chat_updated"
BotEventUserJoined string = "user_joined_chat"
BotEventUserLeave string = "user_left_chat"
BotEventUserUpdated string = "user_updated"
) )
// MgClient type // MgClient type
@ -47,7 +40,6 @@ type MgClient struct {
type ( type (
BotsRequest struct { BotsRequest struct {
ID uint64 `url:"id,omitempty"` ID uint64 `url:"id,omitempty"`
Self bool `url:"self,omitempty"`
Active uint8 `url:"active,omitempty"` Active uint8 `url:"active,omitempty"`
Since string `url:"since,omitempty"` Since string `url:"since,omitempty"`
Until string `url:"until,omitempty"` Until string `url:"until,omitempty"`
@ -87,8 +79,7 @@ type (
MembersRequest struct { MembersRequest struct {
ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"` ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"`
ManagerID string `url:"manager_id,omitempty" json:"manager_id"` UserID string `url:"user_id,omitempty" json:"user_id"`
CustomerID string `url:"customer_id,omitempty" json:"customer_id"`
State string `url:"state,omitempty"` State string `url:"state,omitempty"`
Since string `url:"since,omitempty"` Since string `url:"since,omitempty"`
Until string `url:"until,omitempty"` Until string `url:"until,omitempty"`
@ -99,7 +90,7 @@ type (
ChatID string `url:"chat_id,omitempty" json:"chat_id"` ChatID string `url:"chat_id,omitempty" json:"chat_id"`
ManagerID string `url:"manager_id,omitempty" json:"manager_id"` ManagerID string `url:"manager_id,omitempty" json:"manager_id"`
BotID string `url:"bot_id,omitempty" json:"bot_id"` BotID string `url:"bot_id,omitempty" json:"bot_id"`
Assigned uint8 `url:"assigned,omitempty"` Assign uint8 `url:"assign,omitempty"`
Active uint8 `url:"active,omitempty"` Active uint8 `url:"active,omitempty"`
Since string `url:"since,omitempty"` Since string `url:"since,omitempty"`
Until string `url:"until,omitempty"` Until string `url:"until,omitempty"`
@ -121,6 +112,7 @@ type (
ChannelID uint64 `url:"channel_id,omitempty" json:"channel_id"` ChannelID uint64 `url:"channel_id,omitempty" json:"channel_id"`
ChannelType string `url:"channel_type,omitempty" json:"channel_type"` ChannelType string `url:"channel_type,omitempty" json:"channel_type"`
Scope string `url:"scope,omitempty"` Scope string `url:"scope,omitempty"`
Type string `url:"type,omitempty"`
Since string `url:"since,omitempty"` Since string `url:"since,omitempty"`
Until string `url:"until,omitempty"` Until string `url:"until,omitempty"`
} }
@ -140,7 +132,6 @@ type (
InfoRequest struct { InfoRequest struct {
Name string `url:"name,omitempty" json:"name"` Name string `url:"name,omitempty" json:"name"`
Avatar string `url:"avatar_url,omitempty" json:"avatar_url"` Avatar string `url:"avatar_url,omitempty" json:"avatar_url"`
Events []string `url:"events,omitempty" json:"events,brackets"`
} }
CommandsRequest struct { CommandsRequest struct {
@ -151,7 +142,6 @@ type (
} }
CommandEditRequest struct { CommandEditRequest struct {
BotID uint64 `url:"bot_id,omitempty" json:"bot_id"`
Name string `url:"name,omitempty" json:"name"` Name string `url:"name,omitempty" json:"name"`
Description string `url:"description,omitempty" json:"description"` Description string `url:"description,omitempty" json:"description"`
} }
@ -162,8 +152,6 @@ type (
BotsResponseItem struct { BotsResponseItem struct {
ID uint64 `json:"id"` ID uint64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description,omitempty"`
Events []string `json:"events,omitempty,brackets"`
ClientID string `json:"client_id,omitempty"` ClientID string `json:"client_id,omitempty"`
AvatarUrl string `json:"avatar_url,omitempty"` AvatarUrl string `json:"avatar_url,omitempty"`
CreatedAt string `json:"created_at,omitempty"` CreatedAt string `json:"created_at,omitempty"`
@ -176,7 +164,7 @@ type (
ChannelResponseItem struct { ChannelResponseItem struct {
ID uint64 `json:"id"` ID uint64 `json:"id"`
Type string `json:"type"` Type string `json:"type"`
Events []string `json:"events,omitempty,brackets"` Settings ChannelSettings `json:"settings"`
CreatedAt string `json:"created_at"` CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"` UpdatedAt string `json:"updated_at"`
ActivatedAt string `json:"activated_at"` ActivatedAt string `json:"activated_at"`
@ -213,6 +201,7 @@ type (
Country string `json:"country,omitempty"` Country string `json:"country,omitempty"`
Language string `json:"language,omitempty"` Language string `json:"language,omitempty"`
Phone string `json:"phone,omitempty"` Phone string `json:"phone,omitempty"`
Email string `json:"email,omitempty"`
} }
ChatResponseItem struct { ChatResponseItem struct {
@ -356,3 +345,24 @@ type (
UpdatedAt string UpdatedAt string
} }
) )
// Channel settings
type (
ChannelSettingsText struct {
Creating string `json:"creating"`
Editing string `json:"editing"`
Quoting string `json:"quoting"`
Deleting string `json:"deleting"`
}
ChannelSettings struct {
SpamAllowed bool `json:"spam_allowed"`
Status struct {
Delivered string `json:"delivered"`
Read string `json:"read"`
} `json:"status"`
Text ChannelSettingsText `json:"text"`
}
)