pachca

package module
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

README

Codacy badge GitHub Actions CI Status GitHub Actions CodeQL Status

CI StatusContributingLicense


pachca is Go package for working with Pachca API.

CI Status

Branch Status
master CI
develop CI

Contributing

Before contributing to this project please read our Contributing Guidelines.

License

Apache License, Version 2.0

Documentation

Index

Constants

View Source
const (
	SORT_FIELD_ID           = "id"
	SORT_FIELD_LAST_MESSAGE = "last_message_at"
)
View Source
const (
	SORT_ORDER_ASC  = "asc"
	SORT_ORDER_DESC = "desc"
)
View Source
const API_URL = "https://api.pachca.com/api/shared/v1"

API_URL is URL of Pachca API

View Source
const APP_URL = "https://app.pachca.com"

APP_URL is application URL used to generate links

View Source
const MAX_PAGES = 1_000

MAX_PAGES is the maximum number of pages using for listing items

View Source
const MAX_PER_PAGE = 50

MAX_PER_PAGE is the maximum number of entities per page

Variables

View Source
var (
	ErrNilClient           = errors.New("client is nil")
	ErrNilUserRequest      = errors.New("user request is nil")
	ErrNilChatRequest      = errors.New("chat request is nil")
	ErrNilMessageRequest   = errors.New("message request is nil")
	ErrNilPropertyRequest  = errors.New("property request is nil")
	ErrNilViewRequest      = errors.New("view request is nil")
	ErrNilView             = errors.New("view data 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")
	ErrInvalidBotID        = errors.New("bot ID must be greater than 0")
	ErrInvalidEventID      = errors.New("invalid event ID")
	ErrBlankReaction       = errors.New("non-blank emoji is required")
	ErrEmptyPreviews       = errors.New("previews map has no data")
	ErrInvalidMessageLimit = errors.New("number of messages must be greater than 0")
	ErrViewHasNoBlocks     = errors.New("view has no blocks")
	ErrEmptyTriggerID      = errors.New("view has empty trigger ID")
	ErrInvalidMaxPages     = errors.New("minimum number of result pages must be greater than 0")
	ErrEmptyWebhookURL     = errors.New("webhook URL is empty")
)

Functions

func ValidateToken

func ValidateToken(token string) error

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

func (APIError) Error

func (e APIError) Error() string

Error returns error text

type Button

type Button struct {
	Text string `json:"text"`
	URL  string `json:"url,omitempty"`
	Data string `json:"data,omitempty"`
}

Button contains info about message button

type ButtonLine added in v0.11.0

type ButtonLine []*Button

ButtonLine is a single row of buttons

type Buttons

type Buttons []ButtonLine

Buttons is a slice of buttons

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"`
	IsPersonal    bool   `json:"personal"`
}

Chat contains info about channel

func (*Chat) URL

func (c *Chat) URL() string

URL returns chat URL

type ChatFilter

type ChatFilter struct {
	Sort              map[string]string
	LastMessageAfter  time.Time
	LastMessageBefore time.Time
	Public            bool
}

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"`
	IsPersonal bool   `json:"personal,omitempty"`
}

ChatRequest is a struct with information needed to create or modify a chat

type ChatRole added in v0.4.0

type ChatRole string

ChatRole is type of user in chat

const (
	CHAT_ROLE_ADMIN  ChatRole = "admin"
	CHAT_ROLE_OWNER  ChatRole = "owner"
	CHAT_ROLE_EDITOR ChatRole = "editor"
	CHAT_ROLE_MEMBER ChatRole = "member"

	CHAT_ROLE_ANY ChatRole = "all"
)

type Chats

type Chats []*Chat

Chats is slice of chats

func (Chats) Channels

func (c Chats) Channels() Chats

Channels returns slice with channels

func (Chats) Communal added in v0.1.0

func (c Chats) Communal() Chats

Communal returns communal chats (non-p2p)

func (Chats) Find added in v0.1.0

func (c Chats) Find(name string) *Chat

Find returns chat with given name

func (Chats) Get

func (c Chats) Get(id uint) *Chat

Get returns chat with given ID

func (Chats) Personal added in v0.1.0

func (c Chats) Personal() Chats

Personal returns p2p chats

func (Chats) Public

func (c Chats) Public() Chats

Public returns slice with public 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 NewClient

func NewClient(token string) (*Client, error)

NewClient creates new client with given token

func (*Client) AddChat

func (c *Client) AddChat(chat *ChatRequest) (*Chat, error)

AddChat creates new chat

https://dev.pachca.com/chats/create

func (*Client) AddChatTags

func (c *Client) AddChatTags(chatID uint, tagIDs []uint) error

AddChatTags adds group tags to the chat

https://dev.pachca.com/members/add-group-tags

func (*Client) AddChatUsers

func (c *Client) AddChatUsers(chatID uint, membersIDs []uint, silent bool) error

AddChatUsers adds users with given IDs to the chat, channel or thread

https://dev.pachca.com/members/add-members

func (*Client) AddLinkPreview added in v0.5.0

func (c *Client) AddLinkPreview(messageID uint, previews LinkPreviews) error

AddLinkPreview adds link previews to message with given ID

https://dev.pachca.com/link-previews/add-link-previews

func (*Client) AddMessage

func (c *Client) AddMessage(message *MessageRequest) (*Message, error)

AddMessage creates new message to user or chat

https://dev.pachca.com/messages/create

func (*Client) AddReaction

func (c *Client) AddReaction(messageID uint, reaction string) error

AddReaction adds given emoji reaction to the message. To add custom reaction add it name after amoji using ":" as separator. For example "😲:omg".

https://dev.pachca.com/reactions/add-reactions

func (*Client) AddTag

func (c *Client) AddTag(groupTagName string) (*Tag, error)

AddTag creates new group tag

https://dev.pachca.com/group-tags/create

func (*Client) AddThreadMessage

func (c *Client) AddThreadMessage(messageID uint, message *MessageRequest) (*Thread, *Message, error)

AddThreadMessage helper to create thread and add new message to it

func (*Client) AddThreadMessageText added in v0.2.0

func (c *Client) AddThreadMessageText(messageID uint, text string) (*Thread, *Message, error)

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

https://dev.pachca.com/users/create

func (*Client) ArchiveChat added in v0.3.0

func (c *Client) ArchiveChat(chatID uint) error

ArchiveChat sends chat to archive

https://dev.pachca.com/chats/update-archive

func (*Client) CurrentUser added in v0.7.0

func (c *Client) CurrentUser() (*User, error)

CurrentUser returns info about current user

https://dev.pachca.com/profile/profile

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(messageID uint) error

DeleteMessage deletes message with given ID

https://dev.pachca.com/messages/delete

func (*Client) DeleteMessageButtons added in v0.16.0

func (c *Client) DeleteMessageButtons(messageID uint) error

DeleteMessageButtons is a helper for deleting buttons from a message

func (*Client) DeleteReaction

func (c *Client) DeleteReaction(messageID uint, reaction string) error

DeleteReaction removes given emoji reaction from the message

https://dev.pachca.com/reactions/remove-reactions

func (*Client) DeleteTag

func (c *Client) DeleteTag(groupTagID uint) error

DeleteTag removes group tag

https://dev.pachca.com/group-tags/delete

func (*Client) DeleteUser

func (c *Client) DeleteUser(userID uint) error

DeleteUser deletes an existing user

https://dev.pachca.com/users/delete

func (*Client) DeleteWebhookEvent added in v0.20.0

func (c *Client) DeleteWebhookEvent(eventID string) error

DeleteWebhookEvent deletes webhook event with given ID

https://dev.pachca.com/bots/remove-event

func (*Client) EditChat

func (c *Client) EditChat(chatID uint, chat *ChatRequest) (*Chat, error)

EditChat modifies chat

https://dev.pachca.com/chats/update

func (*Client) EditMessage

func (c *Client) EditMessage(messageID uint, message *MessageRequest) (*Message, error)

EditMessage modifies message

https://dev.pachca.com/messages/update

func (*Client) EditTag

func (c *Client) EditTag(groupTagID uint, groupTagName string) (*Tag, error)

EditTag changes name of given group tag

http://dev.pachca.com/group-tags/update

func (*Client) EditUser

func (c *Client) EditUser(userID uint, user *UserRequest) (*User, error)

EditUser modifies an existing user

https://dev.pachca.com/users/update

func (*Client) Engine

func (c *Client) Engine() *req.Engine

Engine returns pointer to request engine used for all HTTP requests to API

func (*Client) ExcludeChatTag

func (c *Client) ExcludeChatTag(chatID, tagID uint) error

ExcludeChatTag excludes the group tag from the chat

https://dev.pachca.com/members/remove-group-tag

func (*Client) ExcludeChatUser

func (c *Client) ExcludeChatUser(chatID, userID uint) error

ExcludeChatUser excludes the user from the chat

https://dev.pachca.com/members/remove-member

func (*Client) GetChat

func (c *Client) GetChat(chatID uint) (*Chat, error)

GetChat returns info about specific channel

https://dev.pachca.com/chats/get

func (*Client) GetChatUsers added in v0.10.0

func (c *Client) GetChatUsers(chatID uint, memberRole ChatRole) (Users, error)

GetChatUsers returns all users of given chat

https://dev.pachca.com/members/list-members

func (*Client) GetChats

func (c *Client) GetChats(filter ...ChatFilter) (Chats, error)

GetChats returns all chats and conversations

https://dev.pachca.com/chats/list

func (*Client) GetMessage

func (c *Client) GetMessage(messageID uint) (*Message, error)

GetMessage returns info about message

https://dev.pachca.com/messages/get

func (*Client) GetMessageReads added in v0.4.0

func (c *Client) GetMessageReads(messageID uint) ([]uint, error)

GetMessageReads returns a slice with IDs of users who have read the message

https://dev.pachca.com/read-member/list-read-member-ids

func (*Client) GetMessages added in v0.8.0

func (c *Client) GetMessages(chatID uint, limit int) (Messages, error)

GetMessages returns messages from given chat

https://dev.pachca.com/messages/list

func (*Client) GetProperties

func (c *Client) GetProperties() (Properties, error)

GetProperties returns custom properties

https://dev.pachca.com/common/list

func (*Client) GetReactions

func (c *Client) GetReactions(messageID uint) (Reactions, error)

GetReactions returns slice with reactions added to given message

https://dev.pachca.com/reactions/list-reactions

func (*Client) GetTag

func (c *Client) GetTag(groupTagID uint) (*Tag, error)

GetTag returns info about group tag with given ID

https://dev.pachca.com/group-tags/get

func (*Client) GetTagUsers

func (c *Client) GetTagUsers(groupTagID uint) (Users, error)

GetTagUsers returns slice with users with given tag

https://dev.pachca.com/group-tags/list-users

func (*Client) GetTags

func (c *Client) GetTags(names ...string) (Tags, error)

GetTags returns all group tags

https://dev.pachca.com/group-tags/list

func (*Client) GetThread

func (c *Client) GetThread(threadID uint) (*Thread, error)

GetThread returns info about thread

https://dev.pachca.com/thread/get

func (*Client) GetUser

func (c *Client) GetUser(userID uint) (*User, error)

GetUser returns info about specific user

https://dev.pachca.com/users/get

func (*Client) GetUsers

func (c *Client) GetUsers(searchQuery ...string) (Users, error)

GetUsers returns info about all users

https://dev.pachca.com/users/list

func (*Client) GetWebhookEvents added in v0.20.0

func (c *Client) GetWebhookEvents(maxPages int) ([]*WebhookEvent, error)

GetWebhookEvents returns webhook events. Each event's Payload field contains raw JSON that must be decoded using webhook.DecodeJSON to extract the specific webhook type (Message, Reaction, etc.).

Example:

events, _ := client.GetWebhookEvents(10)
for _, ev := range events {
    wh, _ := webhook.DecodeJSON(ev.Payload)
    // Handle webhook based on type
}

https://dev.pachca.com/bots/list-events

func (*Client) NewThread

func (c *Client) NewThread(messageID uint) (*Thread, error)

NewThread creates a new tread

https://dev.pachca.com/thread/add-thread

func (*Client) OpenView added in v0.13.0

func (c *Client) OpenView(view *ViewRequest) error

OpenView opens view with form

https://dev.pachca.com/views/create-open

func (*Client) PinMessage

func (c *Client) PinMessage(messageID uint) error

PinMessage pins message to chat

https://dev.pachca.com/messages/pin

func (*Client) SendMessageToChat

func (c *Client) SendMessageToChat(chatID uint, text string) (*Message, error)

SendMessageToChat helper to send message to chat with given ID

func (*Client) SendMessageToThread

func (c *Client) SendMessageToThread(threadID uint, text string) (*Message, error)

SendMessageToThread helper to send message to thread with given ID

func (*Client) SendMessageToUser

func (c *Client) SendMessageToUser(userID uint, text string) (*Message, error)

SendMessageToUser helper to send message to user with given ID

func (*Client) SetChatUserRole added in v0.4.0

func (c *Client) SetChatUserRole(chatID, userID uint, role ChatRole) error

SetChatUserRole sets user role in given chat

https://dev.pachca.com/members/update-members

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(app, ver string)

SetUserAgent sets user-agent info

func (*Client) UnarchiveChat added in v0.3.0

func (c *Client) UnarchiveChat(chatID uint) error

UnarchiveChat restores chat from archive

https://dev.pachca.com/chats/update-unarchive

func (*Client) UnpinMessage

func (c *Client) UnpinMessage(messageID uint) error

UnpinMessage unpins message from chat

https://dev.pachca.com/messages/unpin

func (*Client) UpdateBot added in v0.15.0

func (c *Client) UpdateBot(botID uint, webhookURL string) error

UpdateBot updates bot webhook URL

https://dev.pachca.com/bots/update

func (*Client) UpdateMessage added in v0.6.0

func (c *Client) UpdateMessage(messageID uint, text string) (*Message, error)

UpdateMessage helper to change message text

func (*Client) UploadFile

func (c *Client) UploadFile(file string) (*File, error)

UploadFile uploads new file and returns key of it

https://dev.pachca.com/common/direct-url

type Date

type Date struct {
	time.Time
}

Date is JSON date

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON parses JSON date

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,omitempty"`
	URL    string   `json:"url,omitempty"`
	Size   int64    `json:"size"`
	Width  int      `json:"width,omitzero"`
	Height int      `json:"height,omitzero"`
}

File contains info about message attachment

type FileType

type FileType string

FileType is type for file type

const (
	FILE_TYPE_FILE  FileType = "file"
	FILE_TYPE_IMAGE FileType = "image"
)

type Files

type Files []*File

Files is a slice of attachments

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 LinkPreview added in v0.5.0

type LinkPreview struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	ImageURL    string `json:"image_url,omitempty"`
	Image       *File  `json:"image,omitempty"`
}

LinkPreview contains link preview data

type LinkPreviews added in v0.5.0

type LinkPreviews map[string]*LinkPreview

LinkPreviews is map (url → preview data) with link previews

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

func (*Message) URL

func (m *Message) URL() string

URL returns message URL

type MessageRequest

type MessageRequest struct {
	EntityType         EntityType `json:"entity_type,omitempty"`
	EntityID           uint       `json:"entity_id,omitempty"`
	ParentMessageID    uint       `json:"parent_message_id,omitempty"`
	Content            string     `json:"content"`
	DisplayAvatarURL   string     `json:"display_avatar_url,omitempty"`
	DisplayName        string     `json:"display_name,omitempty"`
	Files              Files      `json:"files,omitzero"`
	Buttons            Buttons    `json:"buttons,omitzero"`
	SkipInviteMentions bool       `json:"skip_invite_mentions,omitempty"`
}

MessageRequest is a struct with information needed to create or modify a message

type Messages added in v0.8.0

type Messages []*Message

Messages is a slice of messages

type Metadata added in v0.10.0

type Metadata struct {
	Paginate *Paginate `json:"paginate"`
}

Metadata is listing metadata

type Paginate added in v0.10.0

type Paginate struct {
	NextPage string `json:"next_page"`
}

Paginate contains cursor to the next page

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

func (*Property) Date added in v0.0.2

func (p *Property) Date() time.Time

Date returns property value as date

func (*Property) Int added in v0.0.2

func (p *Property) Int() int

Int returns property value as int

func (*Property) IsDate added in v0.0.2

func (p *Property) IsDate() bool

IsDate returns true if property has date type

func (p *Property) IsLink() bool

IsLink returns true if property has URL type

func (*Property) IsNumber added in v0.0.2

func (p *Property) IsNumber() bool

IsNumber returns true if property has number type

func (*Property) IsSet added in v0.2.0

func (p *Property) IsSet() bool

IsSet returns true if property has a value

func (*Property) IsText added in v0.0.2

func (p *Property) IsText() bool

IsText returns true if property has text type

func (*Property) String added in v0.0.2

func (p *Property) String() string

String returns property value

func (*Property) ToDate added in v0.0.2

func (p *Property) ToDate() (time.Time, error)

ToDate tries to convert property value to date

func (*Property) ToInt added in v0.0.2

func (p *Property) ToInt() (int, error)

ToInt tries to convert property value to int

type PropertyRequest added in v0.1.1

type PropertyRequest struct {
	ID    uint   `json:"id"`
	Value string `json:"value"`
}

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"`
	Name      string `json:"name"`
}

Reaction contains reaction info

type ReactionRequest added in v0.12.0

type ReactionRequest struct {
	Code string `json:"code"`
	Name string `json:"name,omitempty"`
}

ReactionRequest is a payload for message reaction

type Reactions

type Reactions []*Reaction

Reactions is a slice of reactions

type S3Error added in v0.5.3

type S3Error struct {
	Message string
	Full    string
}

S3Error represents S3 error

func (*S3Error) Error added in v0.5.3

func (e *S3Error) Error() string

Error returns error message

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

func (Tags) Find added in v0.1.1

func (t Tags) Find(name string) *Tag

Find returns tag with given name

func (Tags) Get added in v0.1.0

func (t Tags) Get(id uint) *Tag

Get returns tag with given ID

func (Tags) InChat added in v0.1.0

func (t Tags) InChat(chat *Chat) Tags

InChat only returns tags that are present in the given chat

func (Tags) Names added in v0.1.1

func (t Tags) Names() []string

Names returns names of all 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

func (*Thread) URL

func (t *Thread) URL() string

URL returns thread URL

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"`
	LastActivityAt Date         `json:"last_activity_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"`
	IsSSO          bool         `json:"sso"`
}

User contains info about user

func (*User) FullName

func (u *User) FullName() string

FullName returns user full name

func (*User) HasAvatar added in v0.1.0

func (u *User) HasAvatar() bool

HasAvatar returns true if user has custom avatar

func (*User) HasTag added in v0.18.0

func (u *User) HasTag(tag string) bool

HasTag returns true if user has given tag

func (*User) IsActive added in v0.1.0

func (u *User) IsActive() bool

IsActive returns true if user is active

func (*User) IsAdmin added in v0.1.0

func (u *User) IsAdmin() bool

IsAdmin returns true if user is admin

func (*User) IsGuest added in v0.1.0

func (u *User) IsGuest() bool

IsGuest returns true if user is guest or multi-guest

func (*User) IsInvited added in v0.1.0

func (u *User) IsInvited() bool

IsInvited returns true if user is invited

func (*User) IsMultiGuest added in v0.10.2

func (u *User) IsMultiGuest() bool

IsMultiGuest returns true if user is multi-guest

func (*User) IsPaid added in v0.10.2

func (u *User) IsPaid() bool

IsPaid returns true if user is paid (not bot or guest)

func (*User) IsRegular added in v0.1.0

func (u *User) IsRegular() bool

IsRegular returns true if user just regular user

func (*User) URL

func (u *User) URL() string

URL returns URL of user profile

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 UserRole

type UserRole string

UserRole is type of user role

const (
	ROLE_ADMIN       UserRole = "admin"
	ROLE_REGULAR     UserRole = "user"
	ROLE_MULTI_GUEST UserRole = "multi_guest"
	ROLE_GUEST       UserRole = "guest"
)

type Users

type Users []*User

Users is a slice of users

func (Users) Active

func (u Users) Active() Users

Active returns slice with active users

func (Users) Admins

func (u Users) Admins() Users

Admins returns slice with admins

func (Users) Bots

func (u Users) Bots() Users

Bots returns slice with bots

func (Users) Find added in v0.1.0

func (u Users) Find(nicknameOrEmail string) *User

Find returns user with given nickname or email

func (Users) Get added in v0.1.0

func (u Users) Get(id uint) *User

Get returns user with given ID or nil

func (Users) Guests

func (u Users) Guests() Users

Guests returns slice with guests or multi-guests

func (Users) InChat added in v0.1.0

func (u Users) InChat(chat *Chat) Users

InChat only returns users that are present in the given chat

func (Users) Invited

func (u Users) Invited() Users

Invited returns all invited users

func (Users) MultiGuests added in v0.10.2

func (u Users) MultiGuests() Users

MultiGuests returns slice with multi-guests

func (Users) Paid added in v0.10.2

func (u Users) Paid() Users

Paid returns slice with paid users

func (Users) People added in v0.2.1

func (u Users) People() Users

People returns slice with non-bot users

func (Users) Regular

func (u Users) Regular() Users

Regular returns slice with regular users

func (Users) Suspended added in v0.0.3

func (u Users) Suspended() Users

Suspended returns slice with inactive users

func (Users) WithTag added in v0.18.0

func (u Users) WithTag(tag string) Users

WithTag returns users with given tag

func (Users) WithoutGuests added in v0.5.1

func (u Users) WithoutGuests() Users

WithoutGuests returns slice with users without guests

type View added in v0.13.0

type View struct {
	Title      string        `json:"title"`
	CloseText  string        `json:"close_text,omitempty"`
	SubmitText string        `json:"submit_text,omitempty"`
	Blocks     []block.Block `json:"blocks"`
}

View contains form view

func (*View) AddBlocks added in v0.13.0

func (v *View) AddBlocks(blocks ...block.Block) *View

AddBlocks adds new blocks to the view

func (*View) AddBlocksIf added in v0.19.0

func (v *View) AddBlocksIf(cond bool, blocks ...block.Block) *View

AddBlocksIf conditionally adds new blocks to the view

type ViewErrors added in v0.13.0

type ViewErrors map[string]string

ViewErrors is a map with view errors

type ViewRequest added in v0.13.0

type ViewRequest struct {
	Type       ViewType `json:"type"`
	TriggerID  string   `json:"trigger_id"`
	Metadata   string   `json:"private_metadata,omitempty"`
	CallbackID string   `json:"callback_id,omitempty"`
	View       *View    `json:"view"`
}

ViewRequest is a payload for open a view

type ViewType added in v0.13.0

type ViewType string

ViewType is type for view

const (
	VIEW_MODAL ViewType = "modal"
)

type WebhookEvent

type WebhookEvent struct {
	ID        string          `json:"id"`
	EventType string          `json:"event_type"`
	Payload   json.RawMessage `json:"payload"`
}

WebhookEvent contains webhook event data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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