Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateToken(token string) error
- type APIError
- type Button
- type Buttons
- type Chat
- type ChatFilter
- type ChatRequest
- type ChatRole
- type Chats
- type Client
- func (c *Client) AddChat(chat *ChatRequest) (*Chat, error)
- func (c *Client) AddChatTags(chatID uint, tagIDs []uint) error
- func (c *Client) AddChatUsers(chatID uint, membersIDs []uint, silent bool) error
- func (c *Client) AddMessage(message *MessageRequest) (*Message, error)
- func (c *Client) AddReaction(messageID uint, emoji string) error
- func (c *Client) AddTag(groupTagName string) (*Tag, error)
- func (c *Client) AddThreadMessage(messageID uint, message *MessageRequest) (*Message, error)
- func (c *Client) AddThreadMessageText(messageID uint, text string) (*Message, error)
- func (c *Client) AddUser(user *UserRequest) (*User, error)
- func (c *Client) ArchiveChat(chatID uint) error
- func (c *Client) ChangeMessageText(messageID uint, text string) (*Message, error)
- func (c *Client) DeleteMessage(messageID uint) error
- func (c *Client) DeleteReaction(messageID uint, emoji string) error
- func (c *Client) DeleteTag(groupTagID uint) error
- func (c *Client) DeleteUser(userID uint) error
- func (c *Client) EditChat(chatID uint, chat *ChatRequest) (*Chat, error)
- func (c *Client) EditMessage(messageID uint, message *MessageRequest) (*Message, error)
- func (c *Client) EditTag(groupTagID uint, groupTagName string) (*Tag, error)
- func (c *Client) EditUser(userID uint, user *UserRequest) (*User, error)
- func (c *Client) Engine() *req.Engine
- func (c *Client) ExcludeChatTag(chatID, tagID uint) error
- func (c *Client) ExcludeChatUser(chatID, userID uint) error
- func (c *Client) GetChat(chatID uint) (*Chat, error)
- func (c *Client) GetChats(filter ...ChatFilter) (Chats, error)
- func (c *Client) GetMessage(messageID uint) (*Message, error)
- func (c *Client) GetMessageReads(messageID uint) ([]uint, error)
- func (c *Client) GetProperties() (Properties, error)
- func (c *Client) GetReactions(messageID uint) (Reactions, error)
- func (c *Client) GetTag(groupTagID uint) (*Tag, error)
- func (c *Client) GetTagUsers(groupTagID uint) (Users, error)
- func (c *Client) GetTags() (Tags, error)
- func (c *Client) GetThread(threadID uint) (*Thread, error)
- func (c *Client) GetUser(userID uint) (*User, error)
- func (c *Client) GetUsers(searchQuery ...string) (Users, error)
- func (c *Client) NewThread(messageID uint) (*Thread, error)
- func (c *Client) PinMessage(messageID uint) error
- func (c *Client) SendMessageToChat(chatID uint, text string) (*Message, error)
- func (c *Client) SendMessageToThread(threadID uint, text string) (*Message, error)
- func (c *Client) SendMessageToUser(userID uint, text string) (*Message, error)
- func (c *Client) SetChatUserRole(chatID, userID uint, role ChatRole) error
- func (c *Client) SetUserAgent(app, ver string)
- func (c *Client) UnarchiveChat(chatID uint) error
- func (c *Client) UnpinMessage(messageID uint) error
- func (c *Client) UploadFile(file string) (*File, error)
- type Date
- type EntityType
- type File
- type FileType
- type Files
- type Forwarding
- type InviteStatus
- type Message
- type MessageRequest
- type Properties
- type Property
- func (p *Property) Date() time.Time
- func (p *Property) Int() int
- func (p *Property) IsDate() bool
- func (p *Property) IsLink() bool
- func (p *Property) IsNumber() bool
- func (p *Property) IsSet() bool
- func (p *Property) IsText() bool
- func (p *Property) String() string
- func (p *Property) ToDate() (time.Time, error)
- func (p *Property) ToInt() (int, error)
- type PropertyRequest
- type PropertyRequests
- type PropertyType
- type Reaction
- type Reactions
- type Status
- type Tag
- type Tags
- type Thread
- type Upload
- type User
- type UserRequest
- type UserRole
- type Users
- func (u Users) Active() Users
- func (u Users) Admins() Users
- func (u Users) Bots() Users
- func (u Users) Find(nicknameOrEmail string) *User
- func (u Users) Get(id uint) *User
- func (u Users) Guests() Users
- func (u Users) InChat(chat *Chat) Users
- func (u Users) Invited() Users
- func (u Users) People() Users
- func (u Users) Regular() Users
- func (u Users) Suspended() Users
- type Webhook
- type WebhookEvent
- type WebhookThread
- type WebhookType
Constants ¶
const API_URL = "https://api.pachca.com/api/shared/v1"
API_URL is URL of Pachca API
const APP_URL = "https://app.pachca.com"
APP_URL is application URL used to generate links
Variables ¶
var ( ErrNilClient = errors.New("Client is nil") ErrNilUserRequest = errors.New("User requests is nil") ErrNilChatRequest = errors.New("Chat requests is nil") ErrNilMessageRequest = errors.New("Message requests is nil") ErrNilProperty = errors.New("Property requests is nil") ErrEmptyToken = errors.New("Token is empty") ErrEmptyTag = errors.New("Group tag is empty") ErrEmptyMessage = errors.New("Message text is empty") ErrEmptyUserEmail = errors.New("User email is required for creating user account") ErrEmptyChatName = errors.New("Name is required for creating new chat") ErrEmptyUsersIDS = errors.New("Users IDs are empty") ErrEmptyTagsIDS = errors.New("Tags IDs are empty") ErrEmptyFilePath = errors.New("Path to file is empty") ErrInvalidToken = errors.New("Token has wrong format") ErrInvalidMessageID = errors.New("Message ID must be greater than 0") ErrInvalidChatID = errors.New("Chat ID must be greater than 0") ErrInvalidUserID = errors.New("User ID must be greater than 0") ErrInvalidThreadID = errors.New("Thread ID must be greater than 0") ErrInvalidTagID = errors.New("Group tag ID must be greater than 0") ErrInvalidEntityID = errors.New("Entity ID must be greater than 0") ErrBlankEmoji = errors.New("Non-blank emoji is required") )
Functions ¶
func ValidateToken ¶
ValidateToken validates API access token
Types ¶
type APIError ¶
type APIError struct { Key string `json:"key"` Value string `json:"value"` Message string `json:"message"` Code string `json:"code"` StatusCode int }
APIError contains API error info
type Chat ¶
type Chat struct { Members []uint `json:"member_ids"` GroupTags []uint `json:"group_tag_ids"` ID uint `json:"id"` OwnerID uint `json:"owner_id"` Name string `json:"name"` MeetRoomURL string `json:"meet_room_url"` CreatedAt Date `json:"created_at"` LastMessageAt Date `json:"last_message_at"` IsPublic bool `json:"public"` IsChannel bool `json:"channel"` }
Chat contains info about channel
type ChatFilter ¶
ChatFilter is configuration for filtering chats
func (ChatFilter) ToQuery ¶
func (f ChatFilter) ToQuery() req.Query
ToQuery converts filter struct to request query
type ChatRequest ¶
type ChatRequest struct { Name string `json:"name,omitempty"` Members []uint `json:"member_ids,omitempty"` Groups []uint `json:"group_tag_ids,omitempty"` IsChannel bool `json:"channel,omitempty"` IsPublic bool `json:"public,omitempty"` }
ChatRequest is a struct with information needed to create or modify a chat
type Chats ¶
type Chats []*Chat
Chats is slice of chats
type Client ¶
type Client struct { BatchSize int // BatchSize is a number of items for paginated requests MaxFileSize int64 // Maximum file size to upload // contains filtered or unexported fields }
Client is Pachca API client
func (*Client) AddChat ¶
func (c *Client) AddChat(chat *ChatRequest) (*Chat, error)
AddChat creates new chat
func (*Client) AddChatTags ¶
AddChatTags adds group tags to the chat
func (*Client) AddChatUsers ¶
AddChatUsers adds users with given IDs to the chat
func (*Client) AddMessage ¶
func (c *Client) AddMessage(message *MessageRequest) (*Message, error)
AddMessage creates new message to user or chat
func (*Client) AddReaction ¶
AddReaction adds given emoji reaction to the message
func (*Client) AddThreadMessage ¶
func (c *Client) AddThreadMessage(messageID uint, message *MessageRequest) (*Message, error)
AddThreadMessage helper to create thread and add new message to it
func (*Client) AddThreadMessageText ¶ added in v0.2.0
AddThreadMessageText helper to create thread and add new message with given text to it
func (*Client) AddUser ¶
func (c *Client) AddUser(user *UserRequest) (*User, error)
AddUser creates a new user
func (*Client) ArchiveChat ¶ added in v0.3.0
ArchiveChat sends chat to archive
func (*Client) ChangeMessageText ¶
ChangeMessageText helper to change message text
func (*Client) DeleteMessage ¶
DeleteMessage deletes message with given ID
func (*Client) DeleteReaction ¶
DeleteReaction removes given emoji reaction from the message
func (*Client) DeleteUser ¶
DeleteUser deletes an existing user
func (*Client) EditChat ¶
func (c *Client) EditChat(chatID uint, chat *ChatRequest) (*Chat, error)
EditChat modifies chat
func (*Client) EditMessage ¶
func (c *Client) EditMessage(messageID uint, message *MessageRequest) (*Message, error)
EditMessage modifies message
func (*Client) EditUser ¶
func (c *Client) EditUser(userID uint, user *UserRequest) (*User, error)
EditUser modifies an existing user
func (*Client) ExcludeChatTag ¶
ExcludeChatTag excludes the group tag from the chat
func (*Client) ExcludeChatUser ¶
ExcludeChatUser excludes the user from the chat
func (*Client) GetChats ¶
func (c *Client) GetChats(filter ...ChatFilter) (Chats, error)
GetChats returns all chats and conversations
func (*Client) GetMessage ¶
GetMessage returns info about message
func (*Client) GetMessageReads ¶ added in v0.4.0
GetMessageReads returns a slice with IDs of users who have read the message
func (*Client) GetProperties ¶
func (c *Client) GetProperties() (Properties, error)
GetProperties returns custom properties
func (*Client) GetReactions ¶
GetReactions returns slice with reactions added to given message
func (*Client) GetTagUsers ¶
GetTagUsers returns slice with users with given tag
func (*Client) PinMessage ¶
PinMessage pins message to chat
func (*Client) SendMessageToChat ¶
SendMessageToChat helper to send message to chat with given ID
func (*Client) SendMessageToThread ¶
SendMessageToThread helper to send message to thread with given ID
func (*Client) SendMessageToUser ¶
SendMessageToUser helper to send message to user with given ID
func (*Client) SetChatUserRole ¶ added in v0.4.0
SetChatUserRole sets user role in given chat
func (*Client) SetUserAgent ¶
SetUserAgent sets user-agent info
func (*Client) UnarchiveChat ¶ added in v0.3.0
UnarchiveChat restores chat from archive
func (*Client) UnpinMessage ¶
UnpinMessage unpins message from chat
func (*Client) UploadFile ¶
UploadFile uploads new file and returns key of it
type EntityType ¶
type EntityType string
EntityType is type of entity type
const ( ENTITY_TYPE_DISCUSSION EntityType = "discussion" ENTITY_TYPE_THREAD EntityType = "thread" ENTITY_TYPE_USER EntityType = "user" )
type File ¶
type File struct { ID uint `json:"id,omitempty"` Key string `json:"key"` Name string `json:"name"` Type FileType `json:"file_type"` URL string `json:"url,omitempty"` Size uint `json:"size,omitempty"` }
File contains info about message attachment
type Forwarding ¶
type Forwarding struct { OriginalMessageID uint `json:"original_message_id"` OriginalChatID uint `json:"original_chat_id"` AuthorID uint `json:"author_id"` OriginalThreadID uint `json:"original_thread_id"` OriginalThreadMessageID uint `json:"original_thread_message_id"` OriginalThreadParentChatID uint `json:"original_thread_parent_chat_id"` OriginalCreatedAt Date `json:"original_created_at"` }
Forwarding contains info about message forwarding
type InviteStatus ¶
type InviteStatus string
InviteStatus is type of invite status
const ( INVITE_SENT InviteStatus = "sent" INVITE_CONFIRMED InviteStatus = "confirmed" )
type Message ¶
type Message struct { ID uint `json:"id"` EntityID uint `json:"entity_id"` ChatID uint `json:"chat_id"` ParentMessageID uint `json:"parent_message_id"` UsedID uint `json:"user_id"` EntityType EntityType `json:"entity_type"` Content string `json:"content"` CreatedAt Date `json:"created_at"` Thread *Thread `json:"thread"` Files Files `json:"files"` Buttons Buttons `json:"buttons"` Forwarding *Forwarding `json:"forwarding"` }
Message contains info about message
type MessageRequest ¶
type MessageRequest struct { EntityType EntityType `json:"entity_type,omitempty"` EntityID uint `json:"entity_id,omitempty"` Content string `json:"content,omitempty"` Files Files `json:"files,omitempty"` Buttons Buttons `json:"buttons,omitempty"` ParentMessageID Buttons `json:"parent_message_id,omitempty"` SkipInviteMentions bool `json:"skip_invite_mentions,omitempty"` }
MessageRequest is a struct with information needed to create or modify a message
type Properties ¶
type Properties []*Property
Properties is a slice of properties
func (Properties) Find ¶ added in v0.1.0
func (p Properties) Find(name string) *Property
Find returns custom property with given name
func (Properties) FindAny ¶ added in v0.1.0
func (p Properties) FindAny(name ...string) *Property
FindAny returns first found property with one of given names
func (Properties) Get ¶
func (p Properties) Get(id uint) *Property
Get returns custom property with given ID
func (Properties) Has ¶ added in v0.1.0
func (p Properties) Has(name string) bool
Has returns true if properties contains property with given name
func (Properties) HasAny ¶ added in v0.1.0
func (p Properties) HasAny(name ...string) bool
HasAny returns true if properties contains property with one of given names
func (Properties) Names ¶ added in v0.0.2
func (p Properties) Names() []string
Names returns slice with properties names
type Property ¶
type Property struct { ID uint `json:"id"` Type PropertyType `json:"data_type"` Name string `json:"name"` Value string `json:"value"` }
Property is custom property
type PropertyRequest ¶ added in v0.1.1
PropertyRequest is a struct with property info
func NewPropertyRequest ¶ added in v0.1.1
func NewPropertyRequest(id uint, value any) *PropertyRequest
NewPropertyRequest creates new custom property
type PropertyRequests ¶ added in v0.1.1
type PropertyRequests []*PropertyRequest
PropertyRequests is a slice with properties requests
type PropertyType ¶
type PropertyType string
PropertyType is type for property type
const ( PROP_TYPE_DATE PropertyType = "date" PROP_TYPE_LINK PropertyType = "link" PROP_TYPE_NUMBER PropertyType = "number" PROP_TYPE_TEXT PropertyType = "text" )
type Reaction ¶
type Reaction struct { UserID uint `json:"user_id"` CreatedAt Date `json:"created_at"` Emoji string `json:"code"` }
Reaction contains reaction info
type Status ¶
type Status struct { Emoji string `json:"emoji"` Title string `json:"title"` ExpiresAt Date `json:"expires_at"` }
Status is user status
type Tag ¶
type Tag struct { ID uint `json:"id"` Name string `json:"name"` UsersCount int `json:"users_count"` }
Tag contains info about tag
type Tags ¶
type Tags []*Tag
Tags is a slice of tags
type Thread ¶
type Thread struct { ID uint `json:"id"` ChatID uint `json:"chat_id"` MessageID uint `json:"message_id"` MessageChatID uint `json:"message_chat_id"` UpdatedAt Date `json:"updated_at"` }
Thread contains info about thread
type Upload ¶
type Upload struct { ContentDisposition string `json:"Content-Disposition"` ACL string `json:"acl"` Policy string `json:"policy"` Credential string `json:"x-amz-credential"` Algorithm string `json:"x-amz-algorithm"` Date string `json:"x-amz-date"` Signature string `json:"x-amz-signature"` Key string `json:"key"` DirectURL string `json:"direct_url"` }
Upload contains upload info used for uploading files
type User ¶
type User struct { ID uint `json:"id"` CreatedAt Date `json:"created_at"` ImageURL string `json:"image_url"` Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Nickname string `json:"nickname"` Role UserRole `json:"role"` PhoneNumber string `json:"phone_number"` TimeZone string `json:"time_zone"` Title string `json:"title"` InviteStatus InviteStatus `json:"invite_status"` Department string `json:"department"` Properties Properties `json:"custom_properties"` Tags []string `json:"list_tags"` Status *Status `json:"user_status"` IsBot bool `json:"bot"` IsSuspended bool `json:"suspended"` }
User contains info about user
type UserRequest ¶
type UserRequest struct { Email string `json:"email,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Nickname string `json:"nickname,omitempty"` Role UserRole `json:"role,omitempty"` PhoneNumber string `json:"phone_number,omitempty"` Title string `json:"title,omitempty"` Department string `json:"department,omitempty"` Properties PropertyRequests `json:"custom_properties,omitempty"` Tags []string `json:"list_tags,omitempty"` IsSuspended bool `json:"suspended,omitempty"` SkipEmailNotify bool `json:"skip_email_notify,omitempty"` }
UserRequest is a struct with information needed to create or modify a user
type Users ¶
type Users []*User
Users is a slice of users
type Webhook ¶
type Webhook struct { Type WebhookType `json:"type"` ID uint `json:"id"` // message Event WebhookEvent `json:"event"` // message, reaction EntityType EntityType `json:"entity_type"` // message EntityID uint `json:"entity_id"` // message Content string `json:"content"` // message Emoji string `json:"code"` // reaction Data string `json:"data"` // button UserID uint `json:"user_id"` // message, reaction CreatedAt Date `json:"created_at"` // message, reaction, button ChatID uint `json:"chat_id"` // message MessageID uint `json:"message_id"` // reaction, button ParentMessageID uint `json:"parent_message_id"` // message Thread *Thread `json:"thread"` // message }
WebhookMessage is message webhook payload
func (*Webhook) IsReaction ¶
IsReaction returns true if webhook contains data for reaction event
type WebhookEvent ¶
type WebhookEvent string
WebhookEvent is type for webhook events
const ( WEBHOOK_EVENT_NEW WebhookEvent = "new" WEBHOOK_EVENT_UPDATE WebhookEvent = "update" WEBHOOK_EVENT_DELETE WebhookEvent = "delete" )
type WebhookThread ¶
type WebhookThread struct { MessageID uint `json:"message_id"` MessageChatID uint `json:"message_chat_id"` }
WebhookThread contains info about message thread
type WebhookType ¶
type WebhookType string
WebhookType is type for webhook types
const ( WEBHOOK_TYPE_MESSAGE WebhookType = "message" WEBHOOK_TYPE_REACTION WebhookType = "reaction" WEBHOOK_TYPE_BUTTON WebhookType = "button" )