Documentation
¶
Index ¶
- Variables
- 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 ListChatsOptions
- type ListTagsOptions
- type ListUsersOptions
- type Message
- type MessageButton
- type MessageFile
- type MessageResponse
- type MessageResponseRaw
- type Messages
- func (m *Messages) Delete(ctx context.Context, messageID int) (*resty.Response, error)
- func (m *Messages) Edit(ctx context.Context, messageID int, newMessage *Message) (*MessageResponse, *resty.Response, error)
- func (m *Messages) Get(ctx context.Context, messageID int) (*MessageResponse, *resty.Response, error)
- func (m *Messages) GetAll(ctx context.Context, chatID int) ([]MessageResponse, *resty.Response, error)
- func (m *Messages) GetChatMessages(ctx context.Context, opts *ChatMessagesOptions) ([]MessageResponse, *resty.Response, error)
- func (m *Messages) Pin(ctx context.Context, messageID int) (*resty.Response, error)
- func (m *Messages) Send(ctx context.Context, msg *Message) (*MessageResponse, *resty.Response, error)
- func (m *Messages) Unpin(ctx context.Context, messageID int) (*resty.Response, error)
- type MessagesResponseRaw
- type OutgoingMessage
- type PaginationOptions
- type ReactionOutgoing
- type ReactionResponse
- type ReactionResponseRaw
- type Reactions
- func (r *Reactions) Add(ctx context.Context, messageID int, reactionCode string) (*resty.Response, error)
- func (r *Reactions) Del(ctx context.Context, messageID int, reactionCode 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 UserCustomProperty
- type UserResponse
- type UserResponseRaw
- type UserStatus
- 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 WebhookButton
- type WebhookMessage
- type WebhookReaction
- type WebhookType
Constants ¶
This section is empty.
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 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
type ChatMessagesOptions struct {
ChatID int
PaginationOptions
}
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
// 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 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"`
EntityID int `json:"entity_id,omitempty"`
Content string `json:"content,omitempty"`
Files []MessageFile `json:"files,omitempty"`
Buttons [][]MessageButton `json:"buttons,omitempty"`
ParentMessageID *int `json:"parent_message_id,omitempty"`
DisplayAvatarURL string `json:"display_avatar_url"`
DisplayName string `json:"display_name,omitempty"`
SkipInviteMentions bool `json:"skip_invite_mentions,omitempty"`
LinkPreview bool `json:"link_preview,omitempty"`
}
Message Объект для сообщения pachca
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"`
Name string `json:"name"`
FileType string `json:"file_type"`
Size int `json:"size"`
}
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"`
Content string `json:"content"`
UserID int `json:"user_id"`
CreatedAt time.Time `json:"created_at"`
URL string `json:"url"`
Files []struct {
ID int `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
FileType string `json:"file_type"`
URL string `json:"url"`
} `json:"files"`
Buttons [][]MessageButton
Thread *struct {
ID int `json:"id"`
ChatID int `json:"chat_id"`
} `json:"thread"`
Forwarding *struct {
OriginalMessageID int `json:"original_message_id"`
OriginalChatID int `json:"original_chat_id"`
AuthorID int `json:"author_id"`
OriginalCreatedAt int `json:"original_created_at"`
OriginalThreadID *int `json:"original_thread_id"`
OriginalThreadMessageID *int `json:"original_thread_message_id"`
OriginalThreadParentChatID *int `json:"original_thread_parent_chat_id"`
} `json:"forwarding"`
ParentMessageID *int `json:"parent_message_id"`
}
type MessageResponseRaw ¶
type MessageResponseRaw struct {
Data MessageResponse `json:"data"`
}
MessageResponseRaw Объект для хранения ответа от API возвращающих одно сообщение
type Messages ¶
type Messages struct {
// contains filtered or unexported fields
}
Messages Объект для работы с сообщениями
func (*Messages) GetChatMessages ¶ added in v1.2.0
func (m *Messages) GetChatMessages(ctx context.Context, opts *ChatMessagesOptions) ([]MessageResponse, *resty.Response, error)
type MessagesResponseRaw ¶
type MessagesResponseRaw struct {
Data []MessageResponse `json:"data"`
}
MessagesResponseRaw Объект для хранения ответа от API возвращающий список сообщений
type OutgoingMessage ¶
type OutgoingMessage struct {
Message *Message `json:"message"`
}
OutgoingMessage Объект для исходящего сообщения в pachca
type PaginationOptions ¶
type ReactionOutgoing ¶ added in v1.2.0
type ReactionOutgoing struct {
Code string `json:"code"`
}
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 {
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Nickname string `json:"nickname,omitempty"`
Email string `json:"email,omitempty"`
PhoneNumber string `json:"phone_number,omitempty"`
Department string `json:"department,omitempty"`
Title string `json:"title,omitempty"`
Role string `json:"role,omitempty"`
Suspended bool `json:"suspended,omitempty"`
ListTags []string `json:"list_tags"`
CustomProperties []UserCustomProperty `json:"custom_properties,omitempty"`
}
type UserCustomProperty ¶
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 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 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"`
Thread *struct {
MessageID int `json:"message_id"`
MessageChatID int `json:"message_chat_id"`
} `json:"thread"`
}
type WebhookReaction ¶
type WebhookType ¶
type WebhookType struct {
Type string `json:"type"`
}