v1

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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"

	ChannelFeatureNone    string = "none"
	ChannelFeatureReceive string = "receive"
	ChannelFeatureSend    string = "send"
	ChannelFeatureBoth    string = "both"
)

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"`
	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"`
}

Response types

type Channel

type Channel struct {
	ID          uint64          `json:"id"`
	TransportID uint64          `json:"transport_id"`
	Type        string          `json:"type"`
	Supports    ChannelSupports `json:"supports"`
}

Single entity types

type ChannelResponseItem

type ChannelResponseItem struct {
	ID            uint64          `json:"id"`
	Type          string          `json:"type"`
	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 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 DialogAssignRequest

type DialogAssignRequest struct {
	DialogID  uint64 `url:"dialog_id,omitempty" json:"dialog_id"`
	ManagerID uint64 `url:"manager_id,omitempty" json:"manager_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"`
	LeftManagerID       uint64      `json:"left_manager_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"`
	ManagerID string `url:"manager_id,omitempty" json:"manager_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 InfoRequest

type InfoRequest struct {
	Name   string `url:"name,omitempty" json:"name"`
	Avatar string `url:"avatar_url,omitempty" json:"avatar_url"`
}

Request 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"`
	ChatID uint64 `json:"chat_id"`
	IsRead bool   `json:"is_read"`
	Status string `json:"status"`
	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 MessageSendRequest

type MessageSendRequest struct {
	Content        string `url:"content,omitempty" json:"content"`
	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

type MessageSendResponse struct {
	MessageID uint64 `json:"message_id"`
	Time      string `json:"time"`
}

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"`
	ManagerID   uint64 `url:"manager_id,omitempty" json:"manager_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 New

func New(url string, token string) *MgClient

New initialize client

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

func (c *MgClient) CommandDelete(request string) (map[string]interface{}, int, error)

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

func (c *MgClient) DeleteRequest(url string, parameters []byte) ([]byte, int, error)

DeleteRequest implements DELETE Request

func (*MgClient) DialogAssign

func (c *MgClient) DialogAssign(request DialogAssignRequest) (DialogAssignResponse, int, error)

func (*MgClient) DialogClose

func (c *MgClient) DialogClose(request uint64) (map[string]interface{}, int, error)

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) Error

func (c *MgClient) Error(info []byte) error

func (*MgClient) GetRequest

func (c *MgClient) GetRequest(url string, parameters []byte) ([]byte, int, error)

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

func (c *MgClient) MessageDelete(request uint64) (map[string]interface{}, int, error)

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{ManagerID: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

func (c *MgClient) PatchRequest(url string, parameters []byte) ([]byte, int, error)

PatchRequest implements PATCH Request

func (*MgClient) PostRequest

func (c *MgClient) PostRequest(url string, parameters []byte) ([]byte, int, error)

PostRequest implements POST Request

func (*MgClient) PutRequest

func (c *MgClient) PutRequest(url string, parameters []byte) ([]byte, int, error)

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 {
	Scope   string       `json:"scope"`
	Content string       `json:"content"`
	From    UserRef      `json:"from"`
	Quote   QuoteMessage `json:"quote"`
	IsEdit  bool         `json:"is_edit"`
	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"`
	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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL