Documentation ¶
Index ¶
- Constants
- func OptionDebug() func(*MgClient)
- func OptionHTTPClient(client *http.Client) func(*MgClient)
- func OptionLogger(logger BasicLogger) func(*MgClient)
- type Attachment
- type AttachmentList
- type BasicLogger
- type BotsRequest
- type BotsResponseItem
- type CRUDChannelSettings
- type Channel
- type ChannelResponseItem
- type ChannelSettings
- type ChannelSettingsText
- type ChannelSupports
- type ChannelsRequest
- type Chat
- type ChatResponseItem
- type ChatsRequest
- type Command
- type CommandEditRequest
- type CommandsRequest
- type CommandsResponseItem
- type CustomersRequest
- type CustomersResponseItem
- type DebugLogger
- type Dialog
- type DialogAssignRequest
- type DialogAssignResponse
- type DialogResponseItem
- type DialogTagsAddRequest
- type DialogTagsDeleteRequest
- type DialogUnassignResponse
- type DialogsRequest
- type EventMeta
- type EventUserJoinedChatData
- type FileMeta
- type FullFileResponse
- type InfoRequest
- type Item
- type Member
- type MemberResponseItem
- type MembersRequest
- type Message
- type MessageEditRequest
- type MessageOrder
- type MessageOrderCost
- type MessageOrderDelivery
- type MessageOrderItem
- type MessageOrderPayment
- type MessageOrderPaymentStatus
- type MessageOrderQuantity
- type MessageOrderStatus
- type MessageProduct
- type MessageSendRequest
- type MessageSendResponse
- type MessagesRequest
- type MessagesResponseItem
- type MgClient
- func (c *MgClient) Bots(request BotsRequest) ([]BotsResponseItem, int, error)
- func (c *MgClient) Channels(request ChannelsRequest) ([]ChannelResponseItem, int, error)
- func (c *MgClient) Chats(request ChatsRequest) ([]ChatResponseItem, int, error)
- func (c *MgClient) CommandDelete(request string) (map[string]interface{}, int, error)
- func (c *MgClient) CommandEdit(request CommandEditRequest) (CommandsResponseItem, int, error)
- func (c *MgClient) Commands(request CommandsRequest) ([]CommandsResponseItem, int, error)
- func (c *MgClient) Customers(request CustomersRequest) ([]CustomersResponseItem, int, error)
- func (c *MgClient) DeleteRequest(url string, parameters []byte) ([]byte, int, error)
- func (c *MgClient) DialogAssign(request DialogAssignRequest) (DialogAssignResponse, int, error)
- func (c *MgClient) DialogClose(request uint64) (map[string]interface{}, int, error)
- func (c *MgClient) DialogTagsDelete(request DialogTagsDeleteRequest) (int, error)
- func (c *MgClient) DialogUnassign(dialogID uint64) (DialogUnassignResponse, int, error)
- func (c *MgClient) Dialogs(request DialogsRequest) ([]DialogResponseItem, int, error)
- func (c *MgClient) DialogsTagsAdd(request DialogTagsAddRequest) (int, error)
- func (c *MgClient) Error(info []byte) error
- func (c *MgClient) GetFile(request string) (FullFileResponse, int, error)
- func (c *MgClient) GetRequest(url string, parameters []byte) ([]byte, int, error)
- func (c *MgClient) Info(request InfoRequest) (map[string]interface{}, int, error)
- func (c *MgClient) Members(request MembersRequest) ([]MemberResponseItem, int, error)
- func (c *MgClient) MessageDelete(request uint64) (map[string]interface{}, int, error)
- func (c *MgClient) MessageEdit(request MessageEditRequest) (map[string]interface{}, int, error)
- func (c *MgClient) MessageSend(request MessageSendRequest) (MessageSendResponse, int, error)
- func (c *MgClient) Messages(request MessagesRequest) ([]MessagesResponseItem, int, error)
- func (c *MgClient) PatchRequest(url string, parameters []byte) ([]byte, int, error)
- func (c *MgClient) PostRequest(url string, parameters io.Reader) ([]byte, int, error)
- func (c *MgClient) PutRequest(url string, parameters []byte) ([]byte, int, error)
- func (c *MgClient) UploadFile(request io.Reader) (UploadFileResponse, int, error)
- func (c *MgClient) UploadFileByURL(request UploadFileByUrlRequest) (UploadFileResponse, int, error)
- func (c *MgClient) Users(request UsersRequest) ([]UsersResponseItem, int, error)
- func (c *MgClient) WithLogger(logger BasicLogger) *MgClient
- func (c *MgClient) WsMeta(events []string) (string, http.Header, error)
- type Option
- type QuoteMessage
- type Responsible
- type Suggestion
- type SystemMessage
- type SystemMessageDialog
- type TagsAdd
- type TagsDelete
- type TextMessage
- type TransportAttachments
- type UploadFileByUrlRequest
- type UploadFileResponse
- type UserRef
- type UsersRequest
- type UsersResponseItem
- type Utm
- type WsEvent
- type WsEventBotUpdatedData
- type WsEventChannelUpdatedData
- type WsEventChatCreatedData
- type WsEventChatUpdatedData
- type WsEventChatsDeletedData
- type WsEventCustomerUpdatedData
- type WsEventDialogAssignData
- type WsEventDialogClosedData
- type WsEventDialogOpenedData
- type WsEventMessageDeletedData
- type WsEventMessageNewData
- type WsEventMessageUpdatedData
- type WsEventUserLeaveData
- type WsEventUserOnlineUpdatedData
- type WsEventUserUpdatedData
Constants ¶
const ( ChannelTypeTelegram string = "telegram" ChannelTypeFacebook string = "fbmessenger" ChannelTypeViber string = "viber" ChannelTypeWhatsapp string = "whatsapp" ChannelTypeSkype string = "skype" ChannelTypeVk string = "vk" ChannelTypeInstagram string = "instagram" ChannelTypeConsultant string = "consultant" ChannelTypeCustom string = "custom" ChatMemberStateActive string = "active" ChatMemberStateKicked string = "kicked" ChatMemberStateLeaved string = "leaved" MessageScopePublic string = "public" MessageScopePrivate string = "private" WsEventMessageNew string = "message_new" WsEventMessageUpdated string = "message_updated" WsEventMessageDeleted string = "message_deleted" WsEventDialogOpened string = "dialog_opened" WsEventDialogClosed string = "dialog_closed" WsEventDialogAssign string = "dialog_assign" WsEventChatCreated string = "chat_created" WsEventChatUpdated string = "chat_updated" WsEventChatUnreadUpdated string = "chat_unread_updated" WsEventUserOnlineUpdated string = "user_online_updated" WsEventUserJoined string = "user_joined_chat" WsEventUserLeave string = "user_left_chat" WsEventUserUpdated string = "user_updated" WsCustomerUpdated string = "customer_updated" WsBotUpdated string = "bot_updated" WsEventChannelUpdated string = "channel_updated" WsEventSettingsUpdated string = "settings_updated" WsEventChatsDeleted string = "chats_deleted" ChannelFeatureNone string = "none" ChannelFeatureReceive string = "receive" ChannelFeatureSend string = "send" ChannelFeatureBoth string = "both" BotRoleDistributor string = "distributor" BotRoleResponsible string = "responsible" MsgTypeText string = "text" MsgTypeSystem string = "system" MsgTypeCommand string = "command" MsgTypeOrder string = "order" MsgTypeProduct string = "product" MsgTypeFile string = "file" MsgTypeImage string = "image" MsgOrderStatusCodeNew = "new" MsgOrderStatusCodeApproval = "approval" MsgOrderStatusCodeAssembling = "assembling" MsgOrderStatusCodeDelivery = "delivery" MsgOrderStatusCodeComplete = "complete" MsgOrderStatusCodeCancel = "cancel" MsgCurrencyRub = "rub" MsgCurrencyUah = "uah" MsgCurrencyByr = "byr" MsgCurrencyKzt = "kzt" MsgCurrencyUsd = "usd" MsgCurrencyEur = "eur" SuggestionTypeText = "text" SuggestionTypeEmail = "email" SuggestionTypePhone = "phone" ColorLightRed = "light-red" ColorLightBlue = "light-blue" ColorLightGreen = "light-green" ColorLightOrange = "light-orange" ColorLightGray = "light-gray" ColorLightGrayishBlue = "light-grayish-blue" ColorRed = "red" ColorBlue = "blue" ColorGreen = "green" ColorOrange = "orange" ColorGray = "gray" ColorGrayishBlue = "grayish-blue" )
Variables ¶
This section is empty.
Functions ¶
func OptionDebug ¶ added in v1.5.15
func OptionDebug() func(*MgClient)
OptionDebug enables debug mode for MgClient
func OptionHTTPClient ¶ added in v1.5.15
OptionHTTPClient set custom http.Client for MgClient
func OptionLogger ¶ added in v1.5.15
func OptionLogger(logger BasicLogger) func(*MgClient)
OptionLogger sets the provided logger instance into the MgClient
Types ¶
type Attachment ¶ added in v1.3.1
type Attachment struct { ID string `json:"id"` Mime string `json:"type"` Caption string `json:"caption"` Size uint64 `json:"size"` PreviewURL *string `json:"preview_url,omitempty"` Height *uint64 `json:"height,omitempty"` Width *uint64 `json:"width,omitempty"` }
Single entity types
type AttachmentList ¶ added in v1.3.1
type AttachmentList struct { Items []Attachment `json:"items"` Note string `json:"note"` }
Single entity types
type BasicLogger ¶ added in v1.3.0
type BasicLogger interface {
Printf(string, ...interface{})
}
BasicLogger provides basic functionality for logging.
func DebugLoggerAdapter ¶ added in v1.3.0
func DebugLoggerAdapter(logger DebugLogger) BasicLogger
DebugLoggerAdapter returns BasicLogger that calls underlying DebugLogger.Debugf.
type BotsRequest ¶
type BotsRequest struct { ID uint64 `url:"id,omitempty"` Active uint8 `url:"active,omitempty"` Self uint8 `url:"self,omitempty"` Role string `url:"role,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type BotsResponseItem ¶
type BotsResponseItem struct { ID uint64 `json:"id"` Name string `json:"name"` ClientID string `json:"client_id,omitempty"` AvatarUrl string `json:"avatar_url,omitempty"` CreatedAt string `json:"created_at,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` DeactivatedAt string `json:"deactivated_at,omitempty"` IsActive bool `json:"is_active"` IsSelf bool `json:"is_self"` Roles []string `json:"roles,omitempty"` }
Response types
type CRUDChannelSettings ¶ added in v1.2.7
type CRUDChannelSettings struct { Creating string `json:"creating"` // none, receive, send, both Editing string `json:"editing"` // none, receive, send, both Deleting string `json:"deleting"` // none, receive, send, both }
Channel settings
type Channel ¶
type Channel struct { ID uint64 `json:"id"` TransportID uint64 `json:"transport_id"` Type string `json:"type"` Name string `json:"name"` Supports ChannelSupports `json:"supports"` }
Single entity types
type ChannelResponseItem ¶
type ChannelResponseItem struct { ID uint64 `json:"id"` Type string `json:"type"` Name string `json:"name"` Settings ChannelSettings `json:"settings"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` ActivatedAt string `json:"activated_at"` DeactivatedAt string `json:"deactivated_at"` IsActive bool `json:"is_active"` }
Response types
type ChannelSettings ¶ added in v1.0.1
type ChannelSettings struct { CustomerExternalID string `json:"customer_external_id"` SendingPolicy struct { NewCustomer string `json:"new_customer"` AfterReplyTimeout string `json:"after_reply_timeout"` } `json:"sending_policy"` Status struct { Delivered string `json:"delivered"` Read string `json:"read"` } `json:"status"` Text ChannelSettingsText `json:"text"` Product struct { CRUDChannelSettings } `json:"product"` Order struct { CRUDChannelSettings } `json:"order"` Image struct { CRUDChannelSettings Quoting string `json:"quoting"` MaxItemsCount int `json:"max_items_count"` NoteMaxCharsCount uint16 `json:"note_max_chars_count"` } `json:"image"` File struct { CRUDChannelSettings Quoting string `json:"quoting"` MaxItemsCount int `json:"max_items_count"` NoteMaxCharsCount uint16 `json:"note_max_chars_count"` } `json:"file"` Audio struct { Creating string `json:"creating"` Quoting string `json:"quoting"` Deleting string `json:"deleting"` MaxItemsCount int `json:"max_items_count"` } `json:"audio"` Suggestions struct { Text string `json:"text"` Phone string `json:"phone"` Email string `json:"email"` } `json:"suggestions"` }
Channel settings
type ChannelSettingsText ¶ added in v1.0.1
type ChannelSettingsText struct { CRUDChannelSettings Quoting string `json:"quoting"` // none, receive, send, both MaxCharsCount uint16 `json:"max_chars_count"` }
Channel settings
type ChannelSupports ¶
type ChannelSupports struct { Messages []string `json:"messages"` Statuses []string `json:"statuses"` }
Single entity types
type ChannelsRequest ¶
type ChannelsRequest struct { ID uint64 `url:"id,omitempty"` Types []string `url:"types,omitempty"` Active uint8 `url:"active,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type Chat ¶ added in v1.0.4
type Chat struct { ID uint64 `json:"id"` Avatar string `json:"avatar"` Name string `json:"name"` Channel *Channel `json:"channel,omitempty"` Members []Member `json:"members"` Customer *UserRef `json:"customer"` AuthorID uint64 `json:"author_id"` LastMessage *Message `json:"last_message"` LastActivity string `json:"last_activity"` }
Single entity types
type ChatResponseItem ¶
type ChatResponseItem struct { ID uint64 `json:"id"` Avatar string `json:"avatar"` Name string `json:"name"` Channel Channel `json:"channel,omitempty"` Customer UserRef `json:"customer"` AuthorID uint64 `json:"author_id"` LastMessage Message `json:"last_message"` LastActivity string `json:"last_activity"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
Response types
type ChatsRequest ¶
type ChatsRequest struct { ID uint64 `url:"id,omitempty"` ChannelID uint64 `url:"channel_id,omitempty" json:"channel_id"` ChannelType string `url:"channel_type,omitempty" json:"channel_type"` CustomerID uint64 `url:"customer_id,omitempty" json:"customer_id"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type Command ¶
type Command struct { ID uint64 BotID uint64 Name string Description string CreatedAt string UpdatedAt string }
Single entity types
type CommandEditRequest ¶
type CommandEditRequest struct { Name string `url:"name,omitempty" json:"name"` Description string `url:"description,omitempty" json:"description"` }
Request types
type CommandsRequest ¶
type CommandsRequest struct { ID uint64 `url:"id,omitempty"` Name string `url:"name,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type CommandsResponseItem ¶
type CommandsResponseItem struct { ID uint64 `json:"id"` Name string `json:"name"` Description string `json:"description"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at,omitempty"` }
Response types
type CustomersRequest ¶
type CustomersRequest struct { ID uint64 `url:"id,omitempty"` ChannelID uint64 `url:"channel_id,omitempty" json:"channel_id"` ChannelType string `url:"channel_type,omitempty" json:"channel_type"` ExternalID string `url:"external_id,omitempty" json:"external_id"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type CustomersResponseItem ¶
type CustomersResponseItem struct { ID uint64 `json:"id"` ExternalID string `json:"external_id,omitempty"` ChannelId uint64 `json:"channel_id,omitempty"` Username string `json:"username,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at,omitempty"` RevokedAt string `json:"revoked_at,omitempty"` Avatar string `json:"avatar_url,omitempty"` ProfileURL string `json:"profile_url,omitempty"` Country string `json:"country,omitempty"` Language string `json:"language,omitempty"` Phone string `json:"phone,omitempty"` Email string `json:"email,omitempty"` Utm *Utm `json:"utm,omitempty"` }
Response types
type DebugLogger ¶ added in v1.3.0
type DebugLogger interface {
Debugf(string, ...interface{})
}
DebugLogger can be used to easily wrap any logger with Debugf method into the BasicLogger instance.
type Dialog ¶ added in v1.0.4
type Dialog struct { ID uint64 `json:"id"` BeginMessageID *uint64 `json:"begin_message_id"` EndingMessageID *uint64 `json:"ending_message_id"` Chat *Chat `json:"chat"` Responsible *Responsible `json:"responsible"` CreatedAt string `json:"created_at"` ClosedAt *string `json:"closed_at"` }
Single entity types
type DialogAssignRequest ¶
type DialogAssignRequest struct { DialogID uint64 `url:"dialog_id,omitempty" json:"dialog_id"` UserID uint64 `url:"user_id,omitempty" json:"user_id"` BotID uint64 `url:"bot_id,omitempty" json:"bot_id"` }
Request types
type DialogAssignResponse ¶
type DialogAssignResponse struct { Responsible Responsible `json:"responsible"` PreviousResponsible Responsible `json:"previous_responsible,omitempty"` LeftUserID uint64 `json:"left_user_id,omitempty"` IsReAssign bool `json:"is_reassign"` }
Response types
type DialogResponseItem ¶
type DialogResponseItem struct { ID uint64 `json:"id"` ChatID uint64 `json:"chat_id"` BeginMessageID uint64 `json:"begin_message_id,omitempty"` EndingMessageID uint64 `json:"ending_message_id,omitempty"` BotID uint64 `json:"bot_id,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at,omitempty"` ClosedAt string `json:"closed_at,omitempty"` IsAssigned bool `json:"is_assigned"` Responsible Responsible `json:"responsible,omitempty"` IsActive bool `json:"is_active"` }
Response types
type DialogTagsAddRequest ¶ added in v1.5.14
type DialogTagsAddRequest struct { DialogID uint64 `url:"dialog_id,omitempty"` Tags []TagsAdd `json:"tags"` }
Request types
type DialogTagsDeleteRequest ¶ added in v1.5.14
type DialogTagsDeleteRequest struct { DialogID uint64 `url:"dialog_id,omitempty"` Tags []TagsDelete `json:"tags"` }
Request types
type DialogUnassignResponse ¶ added in v1.2.5
type DialogUnassignResponse struct {
PreviousResponsible Responsible `json:"previous_responsible,omitempty"`
}
Response types
type DialogsRequest ¶
type DialogsRequest struct { ID uint64 `url:"id,omitempty"` ChatID string `url:"chat_id,omitempty" json:"chat_id"` UserID string `url:"user_id,omitempty" json:"user_id"` BotID string `url:"bot_id,omitempty" json:"bot_id"` Assign uint8 `url:"assign,omitempty"` Active uint8 `url:"active,omitempty"` Since string `url:"since,omitempty"` SinceID int `url:"since_id,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type EventMeta ¶ added in v1.0.2
type EventMeta struct {
Timestamp int64 `json:"timestamp"`
}
WS event types
type EventUserJoinedChatData ¶ added in v1.0.4
Events
type FullFileResponse ¶ added in v1.1.0
type FullFileResponse struct { ID string `json:"id,omitempty"` Type string `json:"type,omitempty"` Size int `json:"size,omitempty"` Url string `json:"url,omitempty"` }
Response types
type InfoRequest ¶
type InfoRequest struct { Name string `url:"name,omitempty" json:"name"` Avatar string `url:"avatar_url,omitempty" json:"avatar_url,omitempty"` Roles []string `url:"roles,omitempty" json:"roles"` }
Request types
type Member ¶ added in v1.0.4
type Member struct { IsAuthor bool `json:"is_author"` State string `json:"state"` User *UserRef `json:"user"` }
Single entity types
type MemberResponseItem ¶
type MemberResponseItem struct { ID uint64 `json:"id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at,omitempty"` IsAuthor bool `json:"is_author"` State string `json:"state"` ChatID uint64 `json:"chat_id"` UserID uint64 `json:"user_id"` }
Response types
type MembersRequest ¶
type MembersRequest struct { ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"` UserID string `url:"user_id,omitempty" json:"user_id"` State string `url:"state,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type Message ¶
type Message struct { ID uint64 `json:"id"` Time string `json:"time"` Type string `json:"type"` Scope string `json:"scope"` ChatID uint64 `json:"chat_id"` IsRead bool `json:"is_read"` IsEdit bool `json:"is_edit"` Status string `json:"status"` Chat *Chat `json:"chat"` From *UserRef `json:"from"` Product *MessageProduct `json:"product,omitempty"` Order *MessageOrder `json:"order,omitempty"` *TextMessage *SystemMessage *AttachmentList }
Single entity types
type MessageEditRequest ¶
type MessageEditRequest struct { ID uint64 `url:"id,omitempty"` Content string `url:"content,omitempty" json:"content"` }
Request types
type MessageOrder ¶ added in v1.0.10
type MessageOrder struct { Number string `json:"number"` Url string `json:"url,omitempty"` Date string `json:"date,omitempty"` Cost *MessageOrderCost `json:"cost,omitempty"` Status *MessageOrderStatus `json:"status,omitempty"` Delivery *MessageOrderDelivery `json:"delivery"` Payments []MessageOrderPayment `json:"payment"` Items []MessageOrderItem `json:"items,omitempty"` }
Single entity types
type MessageOrderCost ¶ added in v1.0.10
type MessageOrderCost struct { Value float32 `json:"value,omitempty"` Currency string `json:"currency"` }
Single entity types
type MessageOrderDelivery ¶ added in v1.0.15
type MessageOrderDelivery struct { Name string `json:"name"` Price *MessageOrderCost `json:"price"` Address string `json:"address"` Comment string `json:"comment,omitempty"` }
Single entity types
type MessageOrderItem ¶ added in v1.0.10
type MessageOrderItem struct { Name string `json:"name,omitempty"` Url string `json:"url,omitempty"` Img string `json:"img,omitempty"` Quantity *MessageOrderQuantity `json:"quantity,omitempty"` Price *MessageOrderCost `json:"price,omitempty"` }
Single entity types
type MessageOrderPayment ¶ added in v1.0.15
type MessageOrderPayment struct { Name string `json:"name"` Status *MessageOrderPaymentStatus `json:"status"` Amount *MessageOrderCost `json:"amount"` }
Single entity types
type MessageOrderPaymentStatus ¶ added in v1.0.15
Single entity types
type MessageOrderQuantity ¶ added in v1.0.10
Single entity types
type MessageOrderStatus ¶ added in v1.0.10
type MessageOrderStatus struct { Code string `json:"code,omitempty"` Name string `json:"name,omitempty"` }
Single entity types
type MessageProduct ¶ added in v1.0.10
type MessageProduct struct { ID uint64 `json:"id"` Name string `json:"name"` Article string `json:"article,omitempty"` Url string `json:"url,omitempty"` Img string `json:"img,omitempty"` Cost *MessageOrderCost `json:"cost,omitempty"` Quantity *MessageOrderQuantity `json:"quantity,omitempty"` }
Single entity types
type MessageSendRequest ¶
type MessageSendRequest struct { Type string `url:"type,omitempty" json:"type"` Content string `url:"content,omitempty" json:"content"` Product *MessageProduct `url:"product,omitempty" json:"product"` Order *MessageOrder `url:"order,omitempty" json:"order"` Items []Item `url:"order,omitempty" json:"items"` Scope string `url:"scope,omitempty" json:"scope"` ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"` QuoteMessageId uint64 `url:"quote_message_id,omitempty" json:"quote_message_id"` TransportAttachments *TransportAttachments `url:"transport_attachments,omitempty" json:"transport_attachments"` }
Request types
type MessageSendResponse ¶
Response types
type MessagesRequest ¶
type MessagesRequest struct { ID []int `url:"id,omitempty"` ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"` DialogID uint64 `url:"dialog_id,omitempty" json:"dialog_id"` UserID uint64 `url:"user_id,omitempty" json:"user_id"` CustomerID uint64 `url:"customer_id,omitempty" json:"customer_id"` BotID uint64 `url:"bot_id,omitempty" json:"bot_id"` ChannelID uint64 `url:"channel_id,omitempty" json:"channel_id"` ChannelType string `url:"channel_type,omitempty" json:"channel_type"` Scope string `url:"scope,omitempty"` Type string `url:"type,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type MessagesResponseItem ¶
type MessagesResponseItem struct { Message ChannelID uint64 `json:"channel_id,omitempty"` ChannelSentAt string `json:"channel_sent_at,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
Response types
type MgClient ¶
type MgClient struct { URL string `json:"url"` Token string `json:"token"` Debug bool `json:"debug"` // contains filtered or unexported fields }
MgClient type
func (*MgClient) Bots ¶
func (c *MgClient) Bots(request BotsRequest) ([]BotsResponseItem, int, error)
Bots get all available bots
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Bots() if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, bot := range data { fmt.Printf("%v %v\n", bot.Name, bot.CreatedAt) }
func (*MgClient) Channels ¶
func (c *MgClient) Channels(request ChannelsRequest) ([]ChannelResponseItem, int, error)
Channels get all available channels
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Channels() if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, channel := range data { fmt.Printf("%v %v\n", channel.Type, channel.CreatedAt) }
func (*MgClient) Chats ¶
func (c *MgClient) Chats(request ChatsRequest) ([]ChatResponseItem, int, error)
Chats get all available chats
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Chats(ChatsRequest{ChannelType:ChannelTypeWhatsapp}) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, chat := range data { fmt.Printf("%v %v\n", chat.Customer, chat.LastMessage) }
func (*MgClient) CommandDelete ¶
CommandDelete delete selected command for bot
Example:
var client = v1.New("https://demo.url", "09jIJ") _, status, err := client.CommandDelete(show_payment_types) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) }
func (*MgClient) CommandEdit ¶
func (c *MgClient) CommandEdit(request CommandEditRequest) (CommandsResponseItem, int, error)
CommandEdit create or change command for bot
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.CommandEdit(CommandEditRequest{ BotID: 1, Name: "show_payment_types", Description: "Get available payment types", }) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } fmt.Printf("%v %v\n", data.Name, data.Description)
func (*MgClient) Commands ¶
func (c *MgClient) Commands(request CommandsRequest) ([]CommandsResponseItem, int, error)
Commands get all available commands for bot
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Commands() if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, command := range data { fmt.Printf("%v %v\n", command.Name, command.Description) }
func (*MgClient) Customers ¶
func (c *MgClient) Customers(request CustomersRequest) ([]CustomersResponseItem, int, error)
Customers get all available customers
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Customers() if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, customer := range data { fmt.Printf("%v %v\n", customer.FirstName, customer.Avatar) }
func (*MgClient) DeleteRequest ¶
DeleteRequest implements DELETE Request
func (*MgClient) DialogAssign ¶
func (c *MgClient) DialogAssign(request DialogAssignRequest) (DialogAssignResponse, int, error)
DialogAssign allows to assign dialog to Bot or User
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.DialogAssign(DialogAssignRequest{DialogID: 1, UserID: 6}) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } fmt.Printf("%v %v\n", data.Responsible, data.LeftUserID )
func (*MgClient) DialogClose ¶
DialogClose close selected dialog
Example:
var client = v1.New("https://demo.url", "09jIJ") _, status, err := client.DialogClose(123) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) }
func (*MgClient) DialogTagsDelete ¶ added in v1.5.14
func (c *MgClient) DialogTagsDelete(request DialogTagsDeleteRequest) (int, error)
DialogTagsDelete allows to assign dialog to Bot or User
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.DialogsTagsAdd(DialogTagsDelete{DialogID: uint64(1),Tags: []TagsDelete{{Name: "foo"}}})
func (*MgClient) DialogUnassign ¶ added in v1.2.5
func (c *MgClient) DialogUnassign(dialogID uint64) (DialogUnassignResponse, int, error)
DialogUnassign allows to remove responsible from the dialogue
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.DialogUnassign(1) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } fmt.Printf("%v\n", data.Responsible)
func (*MgClient) Dialogs ¶
func (c *MgClient) Dialogs(request DialogsRequest) ([]DialogResponseItem, int, error)
Dialogs get all available dialogs
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Dialogs(DialogsRequest{Active:1}) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, dialog := range data { fmt.Printf("%v %v\n", dialog.ChatID, dialog.CreatedAt) }
func (*MgClient) DialogsTagsAdd ¶ added in v1.5.14
func (c *MgClient) DialogsTagsAdd(request DialogTagsAddRequest) (int, error)
DialogsTagsAdd allows to assign dialog to Bot or User
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.DialogsTagsAdd(DialogTagsAddRequest{DialogID: uint64(1),Tags: []TagsAdd{{Name: "foo"}}})
func (*MgClient) GetFile ¶ added in v1.1.0
func (c *MgClient) GetFile(request string) (FullFileResponse, int, error)
GetFile implement get file url
Example:
var client = v1.New("https://token.url", "cb8ccf05e38a47543ad8477d4999be73bff503ea6") data, status, err := client.GetFile("file_ID") if err != nil { fmt.Printf("%v", err) } fmt.Printf("%s\n", data.ID)
func (*MgClient) GetRequest ¶
GetRequest implements GET Request
func (*MgClient) Info ¶
func (c *MgClient) Info(request InfoRequest) (map[string]interface{}, int, error)
Info updates bot information
Example:
var client = v1.New("https://demo.url", "09jIJ") _, status, err := client.Info(InfoRequest{Name: "AWESOME", Avatar: "https://example.com/logo.svg"}) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) }
func (*MgClient) Members ¶
func (c *MgClient) Members(request MembersRequest) ([]MemberResponseItem, int, error)
Members get all available chat members
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Members(MembersRequest{State:ChatMemberStateActive}) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, member := range data { fmt.Printf("%v\n", member.CreatedAt) }
func (*MgClient) MessageDelete ¶
MessageDelete delete selected message
Example:
var client = v1.New("https://demo.url", "09jIJ") _, status, err := client.MessageDelete(123) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) }
func (*MgClient) MessageEdit ¶
func (c *MgClient) MessageEdit(request MessageEditRequest) (map[string]interface{}, int, error)
MessageEdit update selected message
Example:
var client = v1.New("https://demo.url", "09jIJ") _, status, err := client.MessageEdit(MessageEditRequest{ ID: 123, Content: "test", }) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) }
func (*MgClient) MessageSend ¶
func (c *MgClient) MessageSend(request MessageSendRequest) (MessageSendResponse, int, error)
MessageSend send message
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.MessageSend(MessageSendRequest{ Scope: "public", Content: "test", ChatID: i, }) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) }
fmt.Printf("%v \n", data.MessageID, data.Time)
func (*MgClient) Messages ¶
func (c *MgClient) Messages(request MessagesRequest) ([]MessagesResponseItem, int, error)
Messages get all available messages
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Messages(MessagesRequest{UserID:5}) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, message := range data { fmt.Printf("%v %v %v\n", message.ChatID, message.CreatedAt, message.CustomerID) }
func (*MgClient) PatchRequest ¶
PatchRequest implements PATCH Request
func (*MgClient) PostRequest ¶
PostRequest implements POST Request
func (*MgClient) PutRequest ¶
PutRequest implements PUT Request
func (*MgClient) UploadFile ¶ added in v1.1.0
UploadFile upload file
Example:
resp, err := http.Get("https://via.placeholder.com/300") if err != nil { fmt.Printf("%v", err) } defer resp.Body.Close() var client = v1.New("https://token.url", "cb8ccf05e38a47543ad8477d4999be73bff503ea6") data, status, err := client.UploadFile(resp.Body) if err != nil { fmt.Printf("%v", err) } fmt.Printf("%s\n%s", data.ID, status)
func (*MgClient) UploadFileByURL ¶ added in v1.1.0
func (c *MgClient) UploadFileByURL(request UploadFileByUrlRequest) (UploadFileResponse, int, error)
UploadFileByURL upload file by url
Example:
uploadFileResponse, st, err := c.UploadFileByURL(UploadFileByUrlRequest{ Url: "https://via.placeholder.com/300", }) if err != nil { fmt.Printf("%v", err) } fmt.Printf("%s\n%s", uploadFileResponse.ID, status)
func (*MgClient) Users ¶
func (c *MgClient) Users(request UsersRequest) ([]UsersResponseItem, int, error)
Users get all available users
Example:
var client = v1.New("https://demo.url", "09jIJ") data, status, err := client.Users(UsersRequest:{Active:1}) if err != nil { fmt.Printf("%v", err) } if status >= http.StatusBadRequest { fmt.Printf("%v", err) } for _, user := range data { fmt.Printf("%v %v\n", user.FirstName, user.IsOnline) }
func (*MgClient) WithLogger ¶ added in v1.3.0
func (c *MgClient) WithLogger(logger BasicLogger) *MgClient
WithLogger sets the provided logger instance into the Client. Deprecated: Use functional option OptionLogger instead
type QuoteMessage ¶
type QuoteMessage struct { ID uint64 `json:"id"` Content string `json:"content"` Time string `json:"time"` From *UserRef `json:"from"` }
Single entity types
type Responsible ¶
type Responsible struct { ID int64 `json:"id"` Type string `json:"type"` AssignAt string `json:"assigned_at"` }
Single entity types
type Suggestion ¶ added in v1.2.6
type Suggestion struct { Type string `url:"type,omitempty" json:"type"` Title string `url:"title,omitempty" json:"title"` }
Request types
type SystemMessage ¶
type SystemMessage struct { Action string `json:"action"` Dialog *SystemMessageDialog `json:"dialog,omitempty"` User *UserRef `json:"user,omitempty"` Responsible *UserRef `json:"responsible,omitempty"` }
Single entity types
type SystemMessageDialog ¶
type SystemMessageDialog struct {
ID uint64 `json:"id"`
}
Single entity types
type TagsDelete ¶ added in v1.5.14
type TagsDelete struct {
Name string `json:"name"`
}
Request types
type TextMessage ¶
type TextMessage struct { Content string `json:"content"` Quote *QuoteMessage `json:"quote"` Actions []string `json:"actions"` }
Single entity types
type TransportAttachments ¶ added in v1.2.6
type TransportAttachments struct {
Suggestions []Suggestion `url:"suggestions,omitempty" json:"suggestions"`
}
Request types
type UploadFileByUrlRequest ¶ added in v1.1.0
type UploadFileByUrlRequest struct {
Url string `json:"url"`
}
Request types
type UploadFileResponse ¶ added in v1.1.0
type UploadFileResponse struct { ID string `json:"id"` Hash string `json:"hash"` Type string `json:"type"` Meta FileMeta `json:"meta"` MimeType string `json:"mime_type"` Size int `json:"size"` Url *string `json:"source_url"` CreatedAt time.Time `json:"created_at"` }
Response types
type UserRef ¶
type UserRef struct { ID uint64 `json:"id"` ExternalID string `json:"external_id"` Avatar string `json:"avatar"` Type string `json:"type"` Name string `json:"name"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Phone string `json:"phone,omitempty"` Email string `json:"email,omitempty"` IsAdmin bool `json:"is_admin"` Available bool `json:"available"` IsTechnicalAccount bool `json:"is_technical_account"` }
Single entity types
type UsersRequest ¶
type UsersRequest struct { ID uint64 `url:"id,omitempty"` ExternalID string `url:"external_id,omitempty" json:"external_id"` Online uint8 `url:"online,omitempty"` Active uint8 `url:"active,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Limit int `url:"limit,omitempty"` }
Request types
type UsersResponseItem ¶
type UsersResponseItem struct { ID uint64 `json:"id"` ExternalID string `json:"external_id,omitempty"` Username string `json:"username,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at,omitempty"` RevokedAt string `json:"revoked_at,omitempty"` Available bool `json:"available"` IsOnline bool `json:"is_online"` Connected bool `json:"connected"` IsActive bool `json:"is_active"` IsTechnicalAccount bool `json:"is_technical_account"` Avatar string `json:"avatar_url,omitempty"` }
Response types
type Utm ¶ added in v1.5.8
type Utm struct { Source string `json:"source"` Medium string `json:"medium"` Campaign string `json:"campaign"` Term string `json:"term"` Content string `json:"content"` }
Single entity types
type WsEvent ¶ added in v1.0.2
type WsEvent struct { Type string `json:"type"` Meta EventMeta `json:"meta"` AppID uint `json:"app_id"` Data json.RawMessage `json:"data"` }
WS event types
type WsEventChannelUpdatedData ¶ added in v1.5.2
type WsEventChannelUpdatedData struct {
Channel *ChannelResponseItem `json:"channel"`
}
Events
type WsEventChatCreatedData ¶ added in v1.0.4
type WsEventChatCreatedData struct {
Chat *Chat `json:"chat"`
}
Events
type WsEventChatUpdatedData ¶ added in v1.0.4
type WsEventChatUpdatedData struct {
Chat *Chat `json:"chat"`
}
Events
type WsEventChatsDeletedData ¶ added in v1.5.0
type WsEventChatsDeletedData struct {
ChatIds []int64 `json:"chat_ids"`
}
Events
type WsEventCustomerUpdatedData ¶ added in v1.0.17
type WsEventCustomerUpdatedData struct {
*UserRef
}
Events
type WsEventDialogAssignData ¶ added in v1.0.4
Events
type WsEventDialogClosedData ¶ added in v1.0.4
type WsEventDialogClosedData struct {
Dialog *Dialog `json:"dialog"`
}
Events
type WsEventDialogOpenedData ¶ added in v1.0.4
type WsEventDialogOpenedData struct {
Dialog *Dialog `json:"dialog"`
}
Events
type WsEventMessageDeletedData ¶ added in v1.0.4
type WsEventMessageDeletedData struct {
Message *Message `json:"message"`
}
Events
type WsEventMessageNewData ¶ added in v1.0.4
type WsEventMessageNewData struct {
Message *Message `json:"message"`
}
Events
type WsEventMessageUpdatedData ¶ added in v1.0.4
type WsEventMessageUpdatedData struct {
Message *Message `json:"message"`
}
Events
type WsEventUserLeaveData ¶ added in v1.0.4
type WsEventUserLeaveData struct { Reason string `json:"reason"` Chat struct { ID uint64 `json:"id"` } `json:"chat"` User struct { ID uint64 `json:"id"` } `json:"user"` }
Events
type WsEventUserOnlineUpdatedData ¶ added in v1.2.0
type WsEventUserOnlineUpdatedData struct { User *UserRef `json:"user"` Online bool `json:"online"` Connected bool `json:"connected"` }
Events
type WsEventUserUpdatedData ¶ added in v1.0.4
Events