chatwootapi

package
v0.0.0-...-cf0fe10 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountID

type AccountID int

type Attachment

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

type AttachmentID

type AttachmentID int

type ChatwootAPI

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

	Client *http.Client
}

func CreateChatwootAPI

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

func (*ChatwootAPI) ContactIDForMXID

func (api *ChatwootAPI) ContactIDForMXID(ctx context.Context, userID id.UserID) (ContactID, error)

func (*ChatwootAPI) CreateContact

func (api *ChatwootAPI) CreateContact(ctx context.Context, userID id.UserID, name string) (ContactID, error)

func (*ChatwootAPI) CreateConversation

func (api *ChatwootAPI) CreateConversation(ctx context.Context, sourceID string, contactID ContactID, additionalAttrs map[string]string) (*Conversation, error)

func (*ChatwootAPI) DeleteMessage

func (api *ChatwootAPI) DeleteMessage(ctx context.Context, conversationID ConversationID, messageID MessageID) error

func (*ChatwootAPI) DoRequest

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

func (*ChatwootAPI) DownloadAttachment

func (api *ChatwootAPI) DownloadAttachment(ctx context.Context, url string) ([]byte, error)

func (*ChatwootAPI) GetChatwootConversation

func (api *ChatwootAPI) GetChatwootConversation(ctx context.Context, conversationID ConversationID) (*Conversation, error)

func (*ChatwootAPI) GetConversation

func (api *ChatwootAPI) GetConversation(ctx context.Context, id ConversationID) (*Conversation, error)

func (*ChatwootAPI) GetConversationLabels

func (api *ChatwootAPI) GetConversationLabels(ctx context.Context, conversationID ConversationID) ([]string, error)

func (*ChatwootAPI) MakeURI

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

func (*ChatwootAPI) SendAttachmentMessage

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

func (*ChatwootAPI) SendPrivateMessage

func (api *ChatwootAPI) SendPrivateMessage(ctx context.Context, conversationID ConversationID, content string) (*Message, error)

func (*ChatwootAPI) SendTextMessage

func (api *ChatwootAPI) SendTextMessage(ctx context.Context, conversationID ConversationID, content string, messageType MessageType) (*Message, error)

func (*ChatwootAPI) SetConversationCustomAttributes

func (api *ChatwootAPI) SetConversationCustomAttributes(ctx context.Context, conversationID ConversationID, customAttrs map[string]string) error

func (*ChatwootAPI) SetConversationLabels

func (api *ChatwootAPI) SetConversationLabels(ctx context.Context, conversationID ConversationID, labels []string) error

func (*ChatwootAPI) ToggleStatus

func (api *ChatwootAPI) ToggleStatus(ctx context.Context, conversationID ConversationID, status ConversationStatus) error

type Contact

type Contact struct {
	ID          ContactID `json:"id"`
	Identifier  string    `json:"identifier"`
	PhoneNumber string    `json:"phone_number,omitempty"`
	Email       string    `json:"email,omitempty"`
}

Contact

type ContactID

type ContactID int

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               ConversationID    `json:"id"`
	AccountID        AccountID         `json:"account_id"`
	InboxID          InboxID           `json:"inbox_id"`
	Messages         []Message         `json:"messages"`
	Meta             ConversationMeta  `json:"meta"`
	CustomAttributes map[string]string `json:"custom_attributes"`
}

type ConversationID

type ConversationID int

type ConversationLabelsPayload

type ConversationLabelsPayload struct {
	Payload []string `json:"payload"`
}

type ConversationMeta

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

type ConversationStatus

type ConversationStatus string
const (
	ConversationStatusOpen     ConversationStatus = "open"
	ConversationStatusResolved ConversationStatus = "resolved"
	ConversationStatusPending  ConversationStatus = "pending"
)

type ConversationsPayload

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

type CreateContactPayload

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

type InboxID

type InboxID int

type Message

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

type MessageCreated

type MessageCreated struct {
	ID                MessageID          `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 MessageID

type MessageID int

type MessageType

type MessageType string
const (
	IncomingMessage MessageType = "incoming"
	OutgoingMessage MessageType = "outgoing"
)

type Sender

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

type SenderID

type SenderID int

Jump to

Keyboard shortcuts

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