chatwootapi

package
v0.0.0-...-a0a47c7 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MessageTypeString

func MessageTypeString(messageType MessageType) string

Types

type Attachment

type Attachment struct {
	ID        int    `json:"id"`
	FileType  string `json:"file_type"`
	AccountID int    `json:"account_id"`
	DataURL   string `json:"data_url"`
	ThumbURL  string `json:"thumb_url"`
}

type ChatwootAPI

type ChatwootAPI struct {
	BaseURL     string
	AccountID   int
	InboxID     int
	AccessToken string

	Client *http.Client
}

func CreateChatwootAPI

func CreateChatwootAPI(baseURL string, accountID int, inboxID int, accessToken string) *ChatwootAPI

func (*ChatwootAPI) AddConversationLabel

func (api *ChatwootAPI) AddConversationLabel(conversationID int, labels []string) error

func (*ChatwootAPI) ContactIDForMxid

func (api *ChatwootAPI) ContactIDForMxid(userID mid.UserID) (int, error)

func (*ChatwootAPI) CreateContact

func (api *ChatwootAPI) CreateContact(userID mid.UserID) (int, error)

func (*ChatwootAPI) CreateConversation

func (api *ChatwootAPI) CreateConversation(sourceID string, contactID int, additionalAttrs map[string]string) (*Conversation, error)

func (*ChatwootAPI) DeleteMessage

func (api *ChatwootAPI) DeleteMessage(conversationID int, messageID int) error

func (*ChatwootAPI) DoRequest

func (api *ChatwootAPI) DoRequest(req *http.Request) (*http.Response, error)

func (*ChatwootAPI) DownloadAttachment

func (api *ChatwootAPI) DownloadAttachment(url string) ([]byte, error)

func (*ChatwootAPI) GetChatwootConversation

func (api *ChatwootAPI) GetChatwootConversation(conversationID int) (*Conversation, error)

func (*ChatwootAPI) MakeUri

func (api *ChatwootAPI) MakeUri(endpoint string) string

func (*ChatwootAPI) SendAttachmentMessage

func (api *ChatwootAPI) SendAttachmentMessage(conversationID int, filename string, mimeType string, fileData io.Reader, messageType MessageType) (*Message, error)

func (*ChatwootAPI) SendPrivateMessage

func (api *ChatwootAPI) SendPrivateMessage(conversationID int, content string) (*Message, error)

func (*ChatwootAPI) SendTextMessage

func (api *ChatwootAPI) SendTextMessage(conversationID int, content string, messageType MessageType) (*Message, error)

func (*ChatwootAPI) SetConversationCustomAttributes

func (api *ChatwootAPI) SetConversationCustomAttributes(conversationID int, customAttrs map[string]string) error

type Contact

type Contact struct {
	ID         int    `json:"id"`
	Email      string `json:"email"`
	Identifier string `json:"identifier"`
}

Contact

type ContactPayload

type ContactPayload struct {
	Payload ContactPayloadInner `json:"payload"`
}

type ContactPayloadInner

type ContactPayloadInner struct {
	Contact Contact `json:"contact"`
}

type ContactsPayload

type ContactsPayload struct {
	Payload []Contact `json:"payload"`
}

type ContentAttributes

type ContentAttributes struct {
	Deleted bool `json:"deleted"`
}

type Conversation

type Conversation struct {
	ID               int               `json:"id"`
	AccountID        int               `json:"account_id"`
	InboxID          int               `json:"inbox_id"`
	Messages         []Message         `json:"messages"`
	Meta             ConversationMeta  `json:"meta"`
	CustomAttributes map[string]string `json:"custom_attributes"`
}

type ConversationMeta

type ConversationMeta struct {
	Sender Contact `json:"sender"`
}

type ConversationStatusChanged

type ConversationStatusChanged struct {
	ID     int    `json:"id"`
	Status string `json:"status"`
}

type ConversationsPayload

type ConversationsPayload struct {
	Payload []Conversation `json:"payload"`
}

type CreateContactPayload

type CreateContactPayload struct {
	InboxID     int    `json:"inbox_id"`
	Name        string `json:"name"`
	Email       string `json:"email"`
	PhoneNumber string `json:"phone_number"`
	Identifier  string `json:"identifier"`
}

type Message

type Message struct {
	ID          int          `json:"id"`
	Content     *string      `json:"content"`
	Private     bool         `json:"private"`
	Attachments []Attachment `json:"attachments"`
	Sender      Sender       `json:"sender"`
}

type MessageCreated

type MessageCreated struct {
	ID                int                `json:"id"`
	Content           string             `json:"content"`
	CreatedAt         string             `json:"created_at"`
	MessageType       string             `json:"message_type"`
	ContentType       string             `json:"content_type"`
	ContentAttributes *ContentAttributes `json:"content_attributes"`
	Private           bool               `json:"private"`
	Conversation      Conversation       `json:"conversation"`
}

type MessageType

type MessageType int
const (
	IncomingMessage MessageType = iota
	OutgoingMessage
)

type Sender

type Sender struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	Type          string `json:"user"`
	AvailableName string `json:"available_name"`
}

Jump to

Keyboard shortcuts

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