Documentation ¶
Overview ¶
Package rest provides a RocketChat rest client.
Index ¶
- Variables
- type ChannelResponse
- type ChannelsResponse
- type Client
- func (c *Client) ChannelHistory(channel *models.Channel, inclusive bool, fromDate time.Time, ...) ([]models.Message, error)
- func (c *Client) CreateDirectMessage(username string) (*Room, error)
- func (c *Client) CreateToken(userID, username string) (*models.UserCredentials, error)
- func (c *Client) CreateUser(req *models.CreateUserRequest) (*CreateUserResponse, error)
- func (c *Client) DMHistory(channel *models.Channel, inclusive bool, fromDate time.Time, ...) ([]models.Message, error)
- func (c *Client) DeleteMessage(msg *models.DeleteMessage) (*DeleteMessageResponse, error)
- func (c *Client) ExecuteSlashCommand(channel *models.ChannelSubscription, command string, params string) (ExecuteSlashCommandResponse, error)
- func (c *Client) Get(api string, params url.Values, response Response) error
- func (c *Client) GetChannelInfo(channel *models.Channel) (*models.Channel, error)
- func (c *Client) GetDirectory(params url.Values) (*models.Directory, error)
- func (c *Client) GetGroupInfo(channel *models.Channel) (*models.Channel, error)
- func (c *Client) GetGroupMembers(channel *models.Channel) ([]models.User, error)
- func (c *Client) GetJoinedChannels(params url.Values) (*ChannelsResponse, error)
- func (c *Client) GetMentionedMessages(channel *models.Channel, page *models.Pagination) ([]models.Message, error)
- func (c *Client) GetMessage(msgId string) (models.Message, error)
- func (c *Client) GetMessages(channel *models.Channel, page *models.Pagination) ([]models.Message, error)
- func (c *Client) GetPrivateGroups() (*GroupsResponse, error)
- func (c *Client) GetPublicChannels() (*ChannelsResponse, error)
- func (c *Client) GetServerInfo() (*models.Info, error)
- func (c *Client) GetSlashCommandsList(params url.Values) ([]models.SlashCommand, error)
- func (c *Client) GetSpotlight(params url.Values) (*models.Spotlight, error)
- func (c *Client) GetStatistics() (*models.StatisticsInfo, error)
- func (c *Client) GetStatisticsList(params url.Values) (*models.StatisticsList, error)
- func (c *Client) GetUserStatus(username string) (*UserStatusResponse, error)
- func (c *Client) GroupHistory(channel *models.Channel, inclusive bool, fromDate time.Time, ...) ([]models.Message, error)
- func (c *Client) LeaveChannel(channel *models.Channel) error
- func (c *Client) Login(credentials *models.UserCredentials) error
- func (c *Client) Logout() (string, error)
- func (c *Client) Post(api string, body io.Reader, response Response) error
- func (c *Client) PostForm(api string, params url.Values, response Response) error
- func (c *Client) PostMessage(msg *models.PostMessage) (*MessageResponse, error)
- func (c *Client) SearchMessages(channel *models.Channel, searchText string) ([]models.Message, error)
- func (c *Client) SearchUsersOrRooms(query string) (*SearchUsersOrRoomsResponse, error)
- func (c *Client) Send(channel *models.Channel, msg string) error
- func (c *Client) SetUserAvatar(userID, username, avatarURL string) (*Status, error)
- func (c *Client) UpdateMessage(msg *models.UpdateMessage) (*MessageResponse, error)
- func (c *Client) UpdatePermissions(req *UpdatePermissionsRequest) (*UpdatePermissionsResponse, error)
- func (c *Client) UpdateUser(req *models.UpdateUserRequest) (*CreateUserResponse, error)
- type CreateUserResponse
- type DeleteMessageResponse
- type DirectMessageResponse
- type DirectoryResponse
- type ExecuteSlashCommandResponse
- type GroupMembersResponse
- type GroupResponse
- type GroupsResponse
- type InfoResponse
- type MessageResponse
- type MessagesResponse
- type Response
- type Room
- type SearchUsersOrRoomsResponse
- type SlashCommandsResponse
- type SpotlightResponse
- type StatisticsListResponse
- type StatisticsResponse
- type Status
- type StatusResponse
- type UpdatePermissionsRequest
- type UpdatePermissionsResponse
- type UserStatusResponse
Constants ¶
This section is empty.
Variables ¶
var (
ResponseErr = fmt.Errorf("got false response")
)
Functions ¶
This section is empty.
Types ¶
type ChannelResponse ¶
type ChannelsResponse ¶
type ChannelsResponse struct { Status models.Pagination Channels []models.Channel `json:"channels"` }
type Client ¶
type Client struct { Protocol string Host string Path string Port string Version string // Use this switch to see all network communication. Debug bool // contains filtered or unexported fields }
func (*Client) ChannelHistory ¶
func (c *Client) ChannelHistory(channel *models.Channel, inclusive bool, fromDate time.Time, page *models.Pagination) ([]models.Message, error)
Get messages from a channel. The channel id has to be not nil. Optionally a count can be specified to limit the size of the returned messages.
https://rocket.chat/docs/developer-guides/rest-api/channels/history
func (*Client) CreateDirectMessage ¶
Creates a DirectMessage
https://developer.rocket.chat/api/rest-api/methods/im/create
func (*Client) CreateToken ¶
func (c *Client) CreateToken(userID, username string) (*models.UserCredentials, error)
CreateToken creates an access token for a user
https://rocket.chat/docs/developer-guides/rest-api/users/createtoken/
func (*Client) CreateUser ¶
func (c *Client) CreateUser(req *models.CreateUserRequest) (*CreateUserResponse, error)
CreateUser being logged in with a user that has permission to do so.
https://rocket.chat/docs/developer-guides/rest-api/users/create
func (*Client) DMHistory ¶
func (c *Client) DMHistory(channel *models.Channel, inclusive bool, fromDate time.Time, page *models.Pagination) ([]models.Message, error)
Get messages from a dm. The channel id has to be not nil. Optionally a count can be specified to limit the size of the returned messages.
https://rocket.chat/docs/developer-guides/rest-api/channels/history
func (*Client) DeleteMessage ¶
func (c *Client) DeleteMessage(msg *models.DeleteMessage) (*DeleteMessageResponse, error)
DeleteMessage deletes a specific message.
https://developer.rocket.chat/reference/api/rest-api/endpoints/core-endpoints/chat-endpoints/delete
func (*Client) ExecuteSlashCommand ¶
func (c *Client) ExecuteSlashCommand(channel *models.ChannelSubscription, command string, params string) (ExecuteSlashCommandResponse, error)
ExecuteSlashCommand Execute a slash command in a room in the Rocket.Chat server command and roomId are required params is optional it depends upon command
func (*Client) GetChannelInfo ¶
GetChannelInfo get information about a channel. That might be useful to update the usernames.
https://rocket.chat/docs/developer-guides/rest-api/channels/info
func (*Client) GetDirectory ¶
GetDirectory a method, that searches by users or channels on all users and channels available on server. It supports the Offset, Count, and Sort Query Parameters along with Query and Fields Query Parameters.
https://rocket.chat/docs/developer-guides/rest-api/miscellaneous/directory
func (*Client) GetGroupInfo ¶
GetGroupInfo get information about a group. That might be useful to update the usernames.
https://rocket.chat/docs/developer-guides/rest-api/groups/info
func (*Client) GetGroupMembers ¶
GetChannelMembers lists all channel users.
func (*Client) GetJoinedChannels ¶
func (c *Client) GetJoinedChannels(params url.Values) (*ChannelsResponse, error)
GetJoinedChannels returns all channels that the user has joined.
https://rocket.chat/docs/developer-guides/rest-api/channels/list-joined
func (*Client) GetMentionedMessages ¶
func (c *Client) GetMentionedMessages(channel *models.Channel, page *models.Pagination) ([]models.Message, error)
GetMentionedMessages retrieves mentioned messages. It supports the Offset and Count Query Parameters.
func (*Client) GetMessages ¶
func (c *Client) GetMessages(channel *models.Channel, page *models.Pagination) ([]models.Message, error)
Get messages from a channel. The channel id has to be not nil. Optionally a count can be specified to limit the size of the returned messages.
https://rocket.chat/docs/developer-guides/rest-api/channels/history
func (*Client) GetPrivateGroups ¶
func (c *Client) GetPrivateGroups() (*GroupsResponse, error)
GetPrivateGroups returns all channels that can be seen by the logged in user.
https://rocket.chat/docs/developer-guides/rest-api/groups/list
func (*Client) GetPublicChannels ¶
func (c *Client) GetPublicChannels() (*ChannelsResponse, error)
GetPublicChannels returns all channels that can be seen by the logged in user.
https://rocket.chat/docs/developer-guides/rest-api/channels/list
func (*Client) GetServerInfo ¶
GetServerInfo a simple method, requires no authentication, that returns information about the server including version information.
https://rocket.chat/docs/developer-guides/rest-api/miscellaneous/info
func (*Client) GetSlashCommandsList ¶
GetSlashCommandsList Slash Commands available in the Rocket.Chat server. It supports the offset, count and Sort Query Parameters along with just the Fields and Query Parameters.
func (*Client) GetSpotlight ¶
GetSpotlight searches for users or rooms that are visible to the user. WARNING: It will only return rooms that user didn’t join yet.
https://rocket.chat/docs/developer-guides/rest-api/miscellaneous/spotlight
func (*Client) GetStatistics ¶
func (c *Client) GetStatistics() (*models.StatisticsInfo, error)
GetStatistics Statistics about the Rocket.Chat server.
https://rocket.chat/docs/developer-guides/rest-api/miscellaneous/statistics
func (*Client) GetStatisticsList ¶
GetStatisticsList Selectable statistics about the Rocket.Chat server. It supports the Offset, Count and Sort Query Parameters along with just the Fields and Query Parameters.
https://rocket.chat/docs/developer-guides/rest-api/miscellaneous/statistics.list
func (*Client) GetUserStatus ¶
func (c *Client) GetUserStatus(username string) (*UserStatusResponse, error)
func (*Client) GroupHistory ¶
func (c *Client) GroupHistory(channel *models.Channel, inclusive bool, fromDate time.Time, page *models.Pagination) ([]models.Message, error)
Get messages from a dm. The channel id has to be not nil. Optionally a count can be specified to limit the size of the returned messages.
https://rocket.chat/docs/developer-guides/rest-api/channels/history
func (*Client) LeaveChannel ¶
LeaveChannel leaves a channel. The id of the channel has to be not nil.
https://rocket.chat/docs/developer-guides/rest-api/channels/leave
func (*Client) Login ¶
func (c *Client) Login(credentials *models.UserCredentials) error
Login a user. The Email and the Password are mandatory. The auth token of the user is stored in the Client instance.
https://rocket.chat/docs/developer-guides/rest-api/authentication/login
func (*Client) Logout ¶
Logout a user. The function returns the response message of the server.
https://rocket.chat/docs/developer-guides/rest-api/authentication/logout
func (*Client) PostMessage ¶
func (c *Client) PostMessage(msg *models.PostMessage) (*MessageResponse, error)
PostMessage send a message to a channel. The channel or roomId has to be not nil. The message will be json encode.
https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage
func (*Client) SearchMessages ¶
func (*Client) SearchUsersOrRooms ¶
func (c *Client) SearchUsersOrRooms(query string) (*SearchUsersOrRoomsResponse, error)
Searches for users or rooms that are visible to the user. WARNING: It will only return rooms that user didn't join yet.
func (*Client) Send ¶
Sends a message to a channel. The name of the channel has to be not nil. The message will be html escaped.
https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage
func (*Client) SetUserAvatar ¶
SetUserAvatar updates a user's avatar being logged in with a user that has permission to do so. Currently only passing an URL is possible.
https://rocket.chat/docs/developer-guides/rest-api/users/setavatar/
func (*Client) UpdateMessage ¶
func (c *Client) UpdateMessage(msg *models.UpdateMessage) (*MessageResponse, error)
UpdateMessage updates a specific message.
func (*Client) UpdatePermissions ¶
func (c *Client) UpdatePermissions(req *UpdatePermissionsRequest) (*UpdatePermissionsResponse, error)
UpdatePermissions updates permissions
https://rocket.chat/docs/developer-guides/rest-api/permissions/update/
func (*Client) UpdateUser ¶
func (c *Client) UpdateUser(req *models.UpdateUserRequest) (*CreateUserResponse, error)
UpdateUser updates a user's data being logged in with a user that has permission to do so.
https://rocket.chat/docs/developer-guides/rest-api/users/update/
type CreateUserResponse ¶
type CreateUserResponse struct { Status User struct { ID string `json:"_id"` CreatedAt time.Time `json:"createdAt"` Services struct { Password struct { Bcrypt string `json:"bcrypt"` } `json:"password"` } `json:"services"` Username string `json:"username"` Emails []struct { Address string `json:"address"` Verified bool `json:"verified"` } `json:"emails"` Type string `json:"type"` Status string `json:"status"` Active bool `json:"active"` Roles []string `json:"roles"` UpdatedAt time.Time `json:"_updatedAt"` Name string `json:"name"` CustomFields map[string]string `json:"customFields"` } `json:"user"` }
type DeleteMessageResponse ¶
type DirectMessageResponse ¶
type DirectoryResponse ¶
type ExecuteSlashCommandResponse ¶
type ExecuteSlashCommandResponse struct {
Status
}
type GroupMembersResponse ¶
type GroupMembersResponse struct { Status models.Pagination Members []models.User `json:"members"` }
type GroupResponse ¶
type GroupsResponse ¶
type GroupsResponse struct { Status models.Pagination Groups []models.Channel `json:"groups"` }
type InfoResponse ¶
type MessageResponse ¶
type MessagesResponse ¶
type SearchUsersOrRoomsResponse ¶
type SearchUsersOrRoomsResponse struct { Users []models.SearchUsers `json:"users"` Rooms []models.SearchRooms `json:"rooms"` Status }
type SlashCommandsResponse ¶
type SlashCommandsResponse struct { Status Commands []models.SlashCommand `json:"commands"` }
type SpotlightResponse ¶
type StatisticsListResponse ¶
type StatisticsListResponse struct { Status models.StatisticsList }
type StatisticsResponse ¶
type StatisticsResponse struct { Status models.StatisticsInfo }
type Status ¶
type StatusResponse ¶
StatusResponse The base for the most of the json responses
type UpdatePermissionsRequest ¶
type UpdatePermissionsRequest struct {
Permissions []models.Permission `json:"permissions"`
}
type UpdatePermissionsResponse ¶
type UpdatePermissionsResponse struct { Status Permissions []models.Permission `json:"permissions"` }
type UserStatusResponse ¶
type UserStatusResponse struct { ID string `json:"_id"` ConnectionStatus string `json:"connectionStatus"` Message string `json:"message"` Status string `json:"status"` Error string `json:"error"` Success bool `json:"success"` }
func (UserStatusResponse) OK ¶
func (s UserStatusResponse) OK() error