Documentation
¶
Overview ¶
profile.go
Index ¶
- Constants
- Variables
- type AccessTokenInfo
- type Chat
- type ChatMessagesOptions
- type ChatResponse
- type ChatResponseRaw
- type Chats
- func (c *Chats) AddTags(ctx context.Context, chatID int, groupTagsIDs []int) (*resty.Response, error)
- func (c *Chats) AddUsers(ctx context.Context, chatID int, membersIDs []int, silent bool) (*resty.Response, error)
- func (c *Chats) Archive(ctx context.Context, chatID int) (*resty.Response, error)
- func (c *Chats) EditRole(ctx context.Context, chatID, memberID int, role string) (*resty.Response, error)
- func (c *Chats) Find(ctx context.Context, name string) (chat ChatResponse, resp *resty.Response, err error)
- func (c *Chats) Get(ctx context.Context, chatID int) (*ChatResponse, *resty.Response, error)
- func (c *Chats) Leave(ctx context.Context, chatID int) (*resty.Response, error)
- func (c *Chats) List(ctx context.Context, options *ListChatsOptions) (allChats []ChatResponse, resp *resty.Response, err error)
- func (c *Chats) New(ctx context.Context, chat Chat) (*ChatResponse, *resty.Response, error)
- func (c *Chats) RemoveTags(ctx context.Context, chatID int, groupTagID int) (*resty.Response, error)
- func (c *Chats) RemoveUsers(ctx context.Context, chatID, userID int) (*resty.Response, error)
- func (c *Chats) Unarchive(ctx context.Context, chatID int) (*resty.Response, error)
- func (c *Chats) Update(ctx context.Context, chatID int, chat Chat) (*ChatResponse, *resty.Response, error)
- type ChatsResponseRaw
- type Client
- type ClientOptions
- type CustomProperty
- type Files
- type ListChatsOptions
- type ListTagsOptions
- type ListUsersOptions
- type Message
- type MessageButton
- type MessageFile
- type MessageResponse
- type Messages
- func (m *Messages) Delete(ctx context.Context, messageID int) (*resty.Response, error)
- func (m *Messages) Edit(ctx context.Context, messageID int, msg *Message) (*MessageResponse, *resty.Response, error)
- func (m *Messages) Get(ctx context.Context, messageID int) (*MessageResponse, *resty.Response, error)
- func (m *Messages) ListChatMessages(ctx context.Context, opts *ChatMessagesOptions) ([]MessageResponse, string, *resty.Response, error)
- func (m *Messages) ListChatMessagesAll(ctx context.Context, chatID int) ([]MessageResponse, error)
- func (m *Messages) Pin(ctx context.Context, messageID int) (*resty.Response, error)
- func (m *Messages) Send(ctx context.Context, msg *Message, linkPreview bool) (*MessageResponse, *resty.Response, error)
- func (m *Messages) Unpin(ctx context.Context, messageID int) (*resty.Response, error)
- type OutgoingMessage
- type PaginationOptions
- type Profile
- type ReactionOutgoing
- type ReactionResponse
- type ReactionResponseRaw
- type Reactions
- func (r *Reactions) Add(ctx context.Context, messageID int, code string) (*resty.Response, error)
- func (r *Reactions) AddCustom(ctx context.Context, messageID int, code, name string) (*resty.Response, error)
- func (r *Reactions) Del(ctx context.Context, messageID int, code string) (*resty.Response, error)
- func (r *Reactions) DelCustom(ctx context.Context, messageID int, code, name string) (*resty.Response, error)
- func (r *Reactions) List(ctx context.Context, messageID int, options *PaginationOptions) ([]ReactionResponse, *resty.Response, error)
- type RetryMeta
- type RetryObserver
- type Tag
- type TagResponse
- type TagResponseRaw
- type TagUsersOptions
- type Tags
- func (t *Tags) Delete(ctx context.Context, tagID int) (*resty.Response, error)
- func (t *Tags) Edit(ctx context.Context, tagID int, object *Tag) (*TagResponse, *resty.Response, error)
- func (t *Tags) Find(ctx context.Context, name string) (tag *TagResponse, resp *resty.Response, err error)
- func (t *Tags) Get(ctx context.Context, tagID int) (TagResponse, *resty.Response, error)
- func (t *Tags) List(ctx context.Context, options *ListTagsOptions) (allTags []TagResponse, resp *resty.Response, err error)
- func (t *Tags) New(ctx context.Context, object *Tag) (*TagResponse, *resty.Response, error)
- func (t *Tags) Users(ctx context.Context, tagID int) (allUsers []UserResponse, resp *resty.Response, err error)
- type TagsResponseRaw
- type Thread
- type ThreadResponseRaw
- type Threads
- type User
- type UserResponse
- type UserResponseRaw
- type UserStatus
- type UserStatusAwayMessage
- type Users
- func (u *Users) Find(ctx context.Context, query string) (users []UserResponse, resp *resty.Response, err error)
- func (u *Users) Get(ctx context.Context, userID int) (*UserResponse, *resty.Response, error)
- func (u *Users) List(ctx context.Context, options *ListUsersOptions) (users []UserResponse, resp *resty.Response, err error)
- func (u *Users) New(ctx context.Context, user *User) (*UserResponse, *resty.Response, error)
- func (u *Users) Update(ctx context.Context, userID int, user *User) (*UserResponse, *resty.Response, error)
- type UsersResponseRaw
- type View
- type ViewBlock
- type ViewOption
- type ViewRequest
- type Views
- type WebhookButton
- type WebhookMessage
- type WebhookReaction
- type WebhookType
- type WebhookView
Constants ¶
const ( ViewTypeModal = "modal" BlockHeader = "header" BlockPlainText = "plain_text" BlockMarkdown = "markdown" BlockDivider = "divider" BlockInput = "input" BlockSelect = "select" BlockRadio = "radio" BlockCheckbox = "checkbox" BlockDate = "date" BlockTime = "time" BlockFileInput = "file_input" )
Variables ¶
var ( ErrResponseCode = fmt.Errorf("unexpected response code") ErrResponseDecode = fmt.Errorf("error json decoding body") ErrInvalidInput = fmt.Errorf("invalid input data") ErrNoClientOptions = fmt.Errorf("client options cannot be nil") ErrNoAccessToken = fmt.Errorf("access token cannot be empty") )
Functions ¶
This section is empty.
Types ¶
type AccessTokenInfo ¶ added in v1.4.2
type AccessTokenInfo struct {
ID int64 `json:"id"` // идентификатор токена
Token string `json:"token"` // маскированный токен (первые 8 и последние 4 символа)
Name *string `json:"name"` // пользовательское имя токена
UserID int64 `json:"user_id"` // идентификатор владельца токена
Scopes []string `json:"scopes"` // список скоупов токена
CreatedAt time.Time `json:"created_at"` // дата создания токена
RevokedAt *time.Time `json:"revoked_at"` // дата отзыва токена (null, если не отозван)
ExpiresIn *int32 `json:"expires_in"` // время жизни токена в секундах (null для бессрочных)
LastUsedAt *time.Time `json:"last_used_at"` // дата последнего использования
}
AccessTokenInfo информация о токене доступа
type Chat ¶
type Chat struct {
Name string `json:"name"` // Название
MemberIDs []int `json:"member_ids"` // Массив идентификаторов пользователей, которые станут участниками
GroupTagIDs []int `json:"group_tag_ids"` // Массив идентификаторов тегов, которые станут участниками
Channel bool `json:"channel"` // Тип: беседа (по умолчанию, false) или канал (true)
Public bool `json:"public"` // Доступ: закрытый (по умолчанию, false) или открытый (true)
}
Chat Объект описывающий чат
type ChatMessagesOptions ¶ added in v1.2.0
ChatMessagesOptions параметры для получения сообщений чата
type ChatResponse ¶
type ChatResponse struct {
ID int `json:"id"`
CreatedAt time.Time `json:"created_at"`
OwnerID int `json:"owner_id"`
LastMessageAt time.Time `json:"last_message_at"`
MeetRoomURL string `json:"meet_room_url"`
Chat
}
ChatResponse Объект получаемый в ответах API описывающий чат с дополнительными неизменяемыми параметрами
type ChatResponseRaw ¶
type ChatResponseRaw struct {
Data ChatResponse `json:"data"`
}
ChatResponseRaw Объект для хранения сырого ответа с чатом из pachca API
type Chats ¶
type Chats struct {
// contains filtered or unexported fields
}
Chats Объект для работы с чатами
func (*Chats) AddTags ¶
func (c *Chats) AddTags(ctx context.Context, chatID int, groupTagsIDs []int) (*resty.Response, error)
AddTags Метод для добавления тегов в состав участников беседы или канала.
func (*Chats) AddUsers ¶
func (c *Chats) AddUsers(ctx context.Context, chatID int, membersIDs []int, silent bool) (*resty.Response, error)
AddUsers Метод для добавления пользователей в состав участников беседы или канала.
func (*Chats) EditRole ¶
func (c *Chats) EditRole(ctx context.Context, chatID, memberID int, role string) (*resty.Response, error)
EditRole Метод для редактирования роли пользователя или бота в беседе или канале. Владельцу чата роль изменить нельзя. Он всегда имеет права Админа в чате.
func (*Chats) Find ¶
func (c *Chats) Find(ctx context.Context, name string) (chat ChatResponse, resp *resty.Response, err error)
Find Поиск чата по имени
func (*Chats) List ¶
func (c *Chats) List(ctx context.Context, options *ListChatsOptions) (allChats []ChatResponse, resp *resty.Response, err error)
List Получение списка всех бесед и каналов
func (*Chats) New ¶
New Метод для создания новой беседы или нового канала. Для создания личной переписки 1 на 1 с пользователем воспользуйтесь методом Новое сообщение. При создании беседы или канала вы автоматически становитесь участником.
func (*Chats) RemoveTags ¶
func (c *Chats) RemoveTags(ctx context.Context, chatID int, groupTagID int) (*resty.Response, error)
RemoveTags Метод для исключения тега из состава участников беседы или канала.
func (*Chats) RemoveUsers ¶
RemoveUsers Метод для исключения пользователя из состава участников беседы или канала. Если пользователь является владельцем чата, то исключить его нельзя. Он может только самостоятельно выйти из чата, воспользовавшись методом Выход из беседы или канала.
type ChatsResponseRaw ¶
type ChatsResponseRaw struct {
Data []ChatResponse `json:"data"`
}
ChatsResponseRaw Объект для хранения сырого ответа со списком чатов из pachca API
type Client ¶
type Client struct {
Messages *Messages
Threads *Threads
Users *Users
Chats *Chats
Tags *Tags
Reactions *Reactions
Files *Files
Views *Views
Profile *Profile
// contains filtered or unexported fields
}
Client Клиент для работы с мессенджером pachca
func NewClient ¶
func NewClient(options *ClientOptions) (*Client, error)
NewClient Конструктор клиента для мессенджера pachca
type ClientOptions ¶ added in v1.1.0
type CustomProperty ¶ added in v1.4.2
type CustomProperty struct {
ID int `json:"id"`
Name string `json:"name"`
DataType string `json:"data_type"` // string, number, date, link
Value string `json:"value"`
}
CustomProperty дополнительное поле сотрудника
type Files ¶ added in v1.3.0
type Files struct {
// contains filtered or unexported fields
}
Files Объект для работы с файлами
type ListChatsOptions ¶
type ListChatsOptions struct {
Sort string
Availability string
LastMessageAtAfter string
LastMessageAtBefore string
PaginationOptions
}
ListChatsOptions Опции для поиска чатов
type ListTagsOptions ¶
type ListTagsOptions struct {
PaginationOptions
}
ListTagsOptions Опции для запросов тегов с пагинацией
type ListUsersOptions ¶
type ListUsersOptions struct {
Query string
PaginationOptions
}
type Message ¶
type Message struct {
EntityType string `json:"entity_type,omitempty"` // "discussion", "thread", "user"
EntityID int `json:"entity_id"` // ID чата/треда/пользователя
Content string `json:"content"` // текст сообщения
Files []MessageFile `json:"files"` // вложения
Buttons [][]MessageButton `json:"buttons"` // кнопки
ParentMessageID *int `json:"parent_message_id,omitempty"` // ответ на сообщение
DisplayAvatarURL string `json:"display_avatar_url,omitempty"` // кастомная аватарка (только для ботов)
DisplayName string `json:"display_name,omitempty"` // кастомное имя (только для ботов)
SkipInviteMentions bool `json:"skip_invite_mentions,omitempty"` // не добавлять упомянутых в тред
}
Message основная структура для отправки/редактирования
type MessageButton ¶
type MessageButton struct {
Text string `json:"text"`
Data string `json:"data,omitempty"` // данные для вебхука
URL string `json:"url,omitempty"` // ссылка
}
MessageButton кнопка
type MessageFile ¶
type MessageFile struct {
Key string `json:"key"` // путь от /uploads
Name string `json:"name"` // имя файла с расширением
FileType string `json:"file_type"` // "file" или "image"
Size int `json:"size"` // размер в байтах
Width int `json:"width,omitempty"` // для изображений
Height int `json:"height,omitempty"` // для изображений
}
MessageFile вложение
type MessageResponse ¶
type MessageResponse struct {
ID int `json:"id"`
EntityType string `json:"entity_type"`
EntityID int `json:"entity_id"`
ChatID int `json:"chat_id"`
RootChatID int `json:"root_chat_id"`
Content string `json:"content"`
UserID int `json:"user_id"`
CreatedAt time.Time `json:"created_at"`
ChangedAt *time.Time `json:"changed_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
URL string `json:"url"`
DisplayAvatarURL *string `json:"display_avatar_url,omitempty"`
DisplayName *string `json:"display_name,omitempty"`
Files []struct {
ID int `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
FileType string `json:"file_type"`
URL string `json:"url"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
} `json:"files"`
Buttons [][]MessageButton `json:"buttons,omitempty"`
Thread *struct {
ID int `json:"id"`
ChatID int `json:"chat_id"`
} `json:"thread,omitempty"`
Forwarding *struct {
OriginalMessageID int `json:"original_message_id"`
OriginalChatID int `json:"original_chat_id"`
AuthorID int `json:"author_id"`
OriginalCreatedAt time.Time `json:"original_created_at"`
OriginalThreadID *int `json:"original_thread_id,omitempty"`
OriginalThreadMessageID *int `json:"original_thread_message_id,omitempty"`
OriginalThreadParentChatID *int `json:"original_thread_parent_chat_id,omitempty"`
} `json:"forwarding,omitempty"`
ParentMessageID *int `json:"parent_message_id,omitempty"`
}
MessageResponse структура ответа API
type Messages ¶
type Messages struct {
// contains filtered or unexported fields
}
func NewMessages ¶ added in v1.4.1
NewMessages создаёт новый объект для работы с сообщениями
func (*Messages) Edit ¶
func (m *Messages) Edit(ctx context.Context, messageID int, msg *Message) (*MessageResponse, *resty.Response, error)
Edit редактирует существующее сообщение
func (*Messages) Get ¶
func (m *Messages) Get(ctx context.Context, messageID int) (*MessageResponse, *resty.Response, error)
Get возвращает одно сообщение по ID
func (*Messages) ListChatMessages ¶ added in v1.4.1
func (m *Messages) ListChatMessages(ctx context.Context, opts *ChatMessagesOptions) ([]MessageResponse, string, *resty.Response, error)
ListChatMessages возвращает список сообщений чата с пагинацией по курсору
func (*Messages) ListChatMessagesAll ¶ added in v1.4.1
ListChatMessagesAll автоматически обходит все страницы и возвращает все сообщения чата
type OutgoingMessage ¶
type OutgoingMessage struct {
Message *Message `json:"message"`
LinkPreview bool `json:"link_preview,omitempty"` // показывать превью ссылки
}
OutgoingMessage обёртка для POST/PUT запросов
type PaginationOptions ¶
type Profile ¶ added in v1.4.2
type Profile struct {
// contains filtered or unexported fields
}
func NewProfile ¶ added in v1.4.2
NewProfile создаёт новый объект для работы с профилем и токеном
func (*Profile) GetProfile ¶ added in v1.4.2
GetProfile возвращает информацию о профиле пользователя, которому принадлежит токен
func (*Profile) GetTokenInfo ¶ added in v1.4.2
GetTokenInfo возвращает информацию о текущем OAuth токене
type ReactionOutgoing ¶ added in v1.2.0
type ReactionResponse ¶ added in v1.2.0
type ReactionResponseRaw ¶ added in v1.2.0
type ReactionResponseRaw struct {
Data []ReactionResponse `json:"data"`
}
type Reactions ¶ added in v1.2.0
type Reactions struct {
// contains filtered or unexported fields
}
type RetryObserver ¶ added in v1.1.0
type RetryObserver func(meta RetryMeta)
type TagResponse ¶
TagResponse Объект тега обогащенный информацией из API
type TagResponseRaw ¶
type TagResponseRaw struct {
Data TagResponse `json:"data"`
}
TagResponseRaw Объект для хранения ответа от API которые возвращают один тег
type TagUsersOptions ¶
type TagUsersOptions struct {
PaginationOptions
}
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags Объект для работы с тегами
func (*Tags) Delete ¶
Delete Метод для удаления тега. Данный метод доступен для работы только с access_token администратора пространства.
func (*Tags) Edit ¶
func (t *Tags) Edit(ctx context.Context, tagID int, object *Tag) (*TagResponse, *resty.Response, error)
Edit Метод для редактирования тега. Данный метод доступен для работы только с access_token администратора пространства.
func (*Tags) Find ¶
func (t *Tags) Find(ctx context.Context, name string) (tag *TagResponse, resp *resty.Response, err error)
Find Метод для поиска тега по его имени
func (*Tags) Get ¶
Get Метод для получения информации о теге. Названия тегов являются уникальными в компании.
func (*Tags) List ¶
func (t *Tags) List(ctx context.Context, options *ListTagsOptions) (allTags []TagResponse, resp *resty.Response, err error)
List Метод для получения актуального списка тегов сотрудников. Названия тегов являются уникальными в компании. Опции не обязательны
type TagsResponseRaw ¶
type TagsResponseRaw struct {
Data []TagResponse `json:"data"`
}
TagsResponseRaw Объект для хранения ответа от API которые возвращают список тегов
type Thread ¶
type Thread struct {
ID int `json:"id"`
ChatID int `json:"chat_id"`
MessageID int `json:"message_id"`
MessageChatID int `json:"message_chat_id"`
UpdatedAt time.Time `json:"updated_at"`
}
Thread Объект описывающий тред
type ThreadResponseRaw ¶
type ThreadResponseRaw struct {
Data Thread `json:"data"`
}
ThreadResponseRaw Объект для хранения ответов от API с описанием треда
type Threads ¶
type Threads struct {
// contains filtered or unexported fields
}
Threads Объект для работы с обсуждениями (тредами)
type User ¶
type User struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Nickname string `json:"nickname"`
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
Department string `json:"department"`
Title string `json:"title"`
Role string `json:"role"` // admin, user, multi_guest, guest
Suspended bool `json:"suspended"`
InviteStatus string `json:"invite_status"` // confirmed, sent
ListTags []string `json:"list_tags"`
CustomProperties []CustomProperty `json:"custom_properties"`
UserStatus *UserStatus `json:"user_status"` // может быть null
Bot bool `json:"bot"`
Sso bool `json:"sso"`
CreatedAt time.Time `json:"created_at"`
LastActivityAt time.Time `json:"last_activity_at"`
TimeZone string `json:"time_zone"`
ImageURL *string `json:"image_url"` // ссылка на аватарку
}
User модель сотрудника / профиля
type UserResponse ¶
type UserResponse struct {
ID int `json:"id"`
InviteStatus string `json:"invite_status"`
UserStatus *UserStatus `json:"user_status"`
Bot bool `json:"bot"`
CreatedAt string `json:"created_at"`
LastActivityAt string `json:"last_activity_at"`
TimeZone string `json:"time_zone"`
ImageURL string `json:"image_url"`
User
}
type UserResponseRaw ¶
type UserResponseRaw struct {
Data UserResponse `json:"data"`
}
type UserStatus ¶
type UserStatus struct {
Emoji string `json:"emoji"`
Title string `json:"title"`
ExpiresAt *time.Time `json:"expires_at"`
IsAway bool `json:"is_away"`
AwayMessage *UserStatusAwayMessage `json:"away_message"`
}
UserStatus статус пользователя
type UserStatusAwayMessage ¶ added in v1.4.2
type UserStatusAwayMessage struct {
Text string `json:"text"`
}
UserStatusAwayMessage сообщение при режиме «Нет на месте»
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
Users Объект для работы с пользователями
func (*Users) Find ¶
func (u *Users) Find(ctx context.Context, query string) (users []UserResponse, resp *resty.Response, err error)
Find Метод для поиска пользователей. Упрощенная версия метода List. Позволяет передать фильтрующий запрос и получить результаты. Поисковая фраза для фильтрации результатов (поиск идет по полям first_name (имя), last_name (фамилия), email (электронная почта), phone_number (телефон) и nickname (никнейм))
func (*Users) List ¶
func (u *Users) List(ctx context.Context, options *ListUsersOptions) (users []UserResponse, resp *resty.Response, err error)
List Метод для получения актуального списка сотрудников вашей компании. Все параметры передаются через опции. В случае отсутствия опций будут возвращены все сотрудники.
type UsersResponseRaw ¶
type UsersResponseRaw struct {
Data []UserResponse `json:"data"`
}
type ViewBlock ¶ added in v1.4.1
type ViewBlock struct {
Type string `json:"type"`
// common
Text string `json:"text,omitempty"`
// input / select / radio / checkbox / date / time / file_input
Name string `json:"name,omitempty"`
Label string `json:"label,omitempty"`
Required bool `json:"required,omitempty"`
Hint string `json:"hint,omitempty"`
// input
Placeholder string `json:"placeholder,omitempty"`
Multiline bool `json:"multiline,omitempty"`
InitialValue string `json:"initial_value,omitempty"`
MinLength int `json:"min_length,omitempty"`
MaxLength int `json:"max_length,omitempty"`
// select / radio / checkbox
Options []ViewOption `json:"options,omitempty"`
// date
InitialDate string `json:"initial_date,omitempty"`
// time
InitialTime string `json:"initial_time,omitempty"`
// file_input
Filetypes []string `json:"filetypes,omitempty"`
MaxFiles int `json:"max_files,omitempty"`
}
type ViewOption ¶ added in v1.4.1
type ViewRequest ¶ added in v1.4.1
type WebhookButton ¶
type WebhookMessage ¶
type WebhookMessage struct {
Type string `json:"type"`
Event string `json:"event"`
ChatID int `json:"chat_id"`
Content string `json:"content"`
UserID int `json:"user_id"`
ID int `json:"id"`
CreatedAt time.Time `json:"created_at"`
ParentMessageID *int `json:"parent_message_id"`
EntityType string `json:"entity_type"`
EntityID int `json:"entity_id"`
URL string `json:"url"`
Thread *struct {
MessageID int `json:"message_id"`
MessageChatID int `json:"message_chat_id"`
} `json:"thread"`
WebhookTimestamp int `json:"webhook_timestamp"`
}
type WebhookReaction ¶
type WebhookType ¶
type WebhookType struct {
Type string `json:"type"`
}