Struct mattermost_api::client::Mattermost [−][src]
pub struct Mattermost { /* fields omitted */ }
Expand description
Struct to interact with a Mattermost instance API.
Implementations
Create a new instance of the struct to interact with the instance API.
The instance_url
variable should be the root URL of your Mattermost
instance.
Get a session token from the stored login_id and password. Required when using login_id and password authentication, before making any calls to the instance API.
Does nothing if the AuthenticationData
this struct instance
was created with used a personal access token.
Make a query to the Mattermost instance API.
This method is “raw” in that the calling code must
supply the method, query parameters, body, and
a struct for the shape of the data returned (or
serde_json::Value
for “dynamic” data).
Callers are encouraged to look for a specific endpoint function that is for the API endpoint that is desired, but this function is exposed to calling code so that this library can be more flexible.
pub async fn connect_to_websocket<H: WebsocketHandler + 'static>(
&mut self,
handler: H
) -> Result<(), ApiError>
pub async fn connect_to_websocket<H: WebsocketHandler + 'static>(
&mut self,
handler: H
) -> Result<(), ApiError>
Connect to the websocket API on the instance.
This method loops, sending messages received from the websocket connection to the passed handler. The authentication handshake is handled with the connection is made, but otherwise no handling of messages is currently implemented.
This function is likely to experience a great deal of change soon.
Example
use async_trait::async_trait;
use async_tungstenite::tungstenite::Message;
use mattermost_api::prelude::*;
struct Handler {}
#[async_trait]
impl WebsocketHandler for Handler {
async fn callback(&self, message: Message) {
println!("{}", message);
}
}
let auth = AuthenticationData::from_password("you@example.com", "password");
let mut api = Mattermost::new("https://your-mattermost-instance.com", auth);
api.store_session_token().await.unwrap();
api.connect_to_websocket(Handler {}).await.unwrap();
Get a team’s information.
Get information for a team by its name,
List teams that are open or, if the user has the “manage_system” permission, exist.
pub async fn get_team_unreads_for(
&self,
user_id: &str
) -> Result<Vec<TeamsUnreadInformation>, ApiError>
pub async fn get_team_unreads_for(
&self,
user_id: &str
) -> Result<Vec<TeamsUnreadInformation>, ApiError>
Get the number of unread messages and mentions for all member teams of the user.
pub async fn get_team_unreads_for_in(
&self,
user_id: &str,
team_id: &str
) -> Result<TeamsUnreadInformation, ApiError>
pub async fn get_team_unreads_for_in(
&self,
user_id: &str,
team_id: &str
) -> Result<TeamsUnreadInformation, ApiError>
Get the number of unread messages and mentions for the specific team the user is in.
Requires either the “read_channel” or “edit_other_users” permission.
Get all channels on the instance.
Requires the “manage_system” permission.
Get a channel’s information.
Requires the “read_channel” permission for that channel.
pub async fn get_public_channels(
&self,
team_id: &str
) -> Result<Vec<ChannelInformation>, ApiError>
pub async fn get_public_channels(
&self,
team_id: &str
) -> Result<Vec<ChannelInformation>, ApiError>
Get public channels’ information.
Requires the “list_team_channels” permission.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Mattermost
impl Send for Mattermost
impl Sync for Mattermost
impl Unpin for Mattermost
impl !UnwindSafe for Mattermost
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more