Merge pull request #2 from blide/master

update api
This commit is contained in:
Alex Lushpai 2018-08-30 13:42:49 +03:00 committed by GitHub
commit b44efbc0ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"`
@ -86,12 +78,11 @@ 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"`
} }
DialogsRequest struct { DialogsRequest struct {
@ -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"`
} }
@ -138,9 +130,8 @@ 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"`
} }
@ -160,28 +150,26 @@ type (
// Response types // Response types
type ( 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"` ClientID string `json:"client_id,omitempty"`
Events []string `json:"events,omitempty,brackets"` AvatarUrl string `json:"avatar_url,omitempty"`
ClientID string `json:"client_id,omitempty"` CreatedAt string `json:"created_at,omitempty"`
AvatarUrl string `json:"avatar_url,omitempty"` UpdatedAt string `json:"updated_at,omitempty"`
CreatedAt string `json:"created_at,omitempty"` DeactivatedAt string `json:"deactivated_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"` IsActive bool `json:"is_active"`
DeactivatedAt string `json:"deactivated_at,omitempty"` IsSelf bool `json:"is_self"`
IsActive bool `json:"is_active"`
IsSelf bool `json:"is_self"`
} }
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"`
DeactivatedAt string `json:"deactivated_at"` DeactivatedAt string `json:"deactivated_at"`
IsActive bool `json:"is_active"` IsActive bool `json:"is_active"`
} }
UsersResponseItem struct { UsersResponseItem struct {
@ -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"`
}
)