Documentation
¶
Index ¶
- Constants
- type BotsRequest
- type BotsResponseItem
- 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 Dialog
- type DialogAssignRequest
- type DialogAssignResponse
- type DialogResponseItem
- type DialogsRequest
- type EventMeta
- type EventUserJoinedChatData
- type InfoRequest
- type Member
- type MemberResponseItem
- type MembersRequest
- type Message
- type MessageEditRequest
- type MessageOrder
- type MessageOrderCost
- type MessageOrderItem
- 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) Dialogs(request DialogsRequest) ([]DialogResponseItem, int, error)
- func (c *MgClient) Error(info []byte) 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 []byte) ([]byte, int, error)
- func (c *MgClient) PutRequest(url string, parameters []byte) ([]byte, int, error)
- func (c *MgClient) Users(request UsersRequest) ([]UsersResponseItem, int, error)
- func (c *MgClient) WsMeta(events []string) (string, http.Header, error)
- type QuoteMessage
- type Responsible
- type SystemMessage
- type SystemMessageDialog
- type TextMessage
- type UserRef
- type UsersRequest
- type UsersResponseItem
- type WsEvent
- type WsEventChatCreatedData
- type WsEventChatUpdatedData
- type WsEventDialogAssignData
- type WsEventDialogClosedData
- type WsEventDialogOpenedData
- type WsEventMessageDeletedData
- type WsEventMessageNewData
- type WsEventMessageUpdatedData
- type WsEventUserLeaveData
- 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" WsEventDialogAssing string = "dialog_assign" WsEventChatCreated string = "chat_created" WsEventChatUpdated string = "chat_updated" WsEventUserJoined string = "user_joined_chat" WsEventUserLeave string = "user_left_chat" WsEventUserUpdated string = "user_updated" 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" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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"`
}
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 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 {
SpamAllowed bool `json:"spam_allowed"`
Status struct {
Delivered string `json:"delivered"`
Read string `json:"read"`
} `json:"status"`
Text ChannelSettingsText `json:"text"`
}
Channel settings
type ChannelSettingsText ¶ added in v1.0.1
type ChannelSettingsText struct {
Creating string `json:"creating"`
Editing string `json:"editing"`
Quoting string `json:"quoting"`
Deleting string `json:"deleting"`
}
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"`
}
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"`
Since string `url:"since,omitempty"`
Until string `url:"until,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"`
}
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"`
ExternalID string `url:"external_id,omitempty" json:"external_id"`
Since string `url:"since,omitempty"`
Until string `url:"until,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"`
}
Response types
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 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"`
Until string `url:"until,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 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"`
}
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"`
From *UserRef `json:"from"`
Product *MessageProduct `json:"product,omitempty"`
Order *MessageOrder `json:"order,omitempty"`
*TextMessage
*SystemMessage
}
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"`
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 MessageOrderItem ¶ added in v1.0.10
type MessageOrderItem struct {
Name string `json:"name,omitempty"`
Url string `json:"url,omitempty"`
Quantity *MessageOrderQuantity `json:"quantity,omitempty"`
Price *MessageOrderCost `json:"price,omitempty"`
}
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"`
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"`
}
Request types
type MessageSendResponse ¶
Response types
type MessagesRequest ¶
type MessagesRequest struct {
ID uint64 `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"`
}
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)
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) 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) 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) 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)
}
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 SystemMessage ¶
type SystemMessage struct {
Action string `json:"action"`
Dialog *SystemMessageDialog `json:"dialog,omitempty"`
User *UserRef `json:"user,omitempty"`
}
Single entity types
type SystemMessageDialog ¶
type SystemMessageDialog struct {
ID uint64 `json:"id"`
}
Single entity types
type TextMessage ¶
type TextMessage struct {
Content string `json:"content"`
Quote *QuoteMessage `json:"quote"`
Actions []string `json:"actions"`
}
Single entity types
type UserRef ¶
type UserRef struct {
ID uint64 `json:"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"`
}
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"`
}
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"`
IsOnline bool `json:"is_online"`
IsActive bool `json:"is_active"`
Avatar string `json:"avatar_url,omitempty"`
}
Response 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 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 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 WsEventUserUpdatedData ¶ added in v1.0.4
type WsEventUserUpdatedData struct {
*UserRef
}
Events