6 releases (3 breaking)

0.4.1 Nov 1, 2022
0.4.0 Oct 30, 2022
0.3.1 Oct 22, 2022
0.2.0 Oct 20, 2022
0.1.0 Oct 17, 2022

#21 in #auth-token

Download history 1/week @ 2024-02-21 61/week @ 2024-02-28 13/week @ 2024-03-06

75 downloads per month

MIT license

13KB
289 lines

rocketchat

Rust API wrapper for the RocketChat API

crates.io MIT

Example

The library uses asynchronous HTTP client reqwest, so your Cargo.toml could look like this:

rocketchat = "0.4.0"
tokio = { version = "1", features = ["full"] }

When calling methods, you need to pass settings that can be created as follows:

Using username and password

use rocketchat::{LoginSettings, Settings};

let settings = Settings::Login(LoginSettings {
    username: "chuck_norris".to_string(),
    password: "supersecret".to_string(),
    domain: "https://mydomain.com".to_string(),
});

Using auth token and user ID

use rocketchat::{AuthSettings, Settings};

let settings = Settings::Auth(AuthSettings {
    auth_token: "some_auth_token".to_string(),
    user_id: "some_user_id".to_string(),
    domain: "https://mydomain.com".to_string(),
});

Available API methods

Post Message

use rocketchat::methods::PostMessageMethod;

let result = PostMessageMethod {
    settings: &settings,
    room_id: "#channel".to_string(),
    text: Some("Some message with star emoji :star:".to_string()),
    ..Default::default()
}.call().await;

Channel Create

use rocketchat::methods::ChannelCreateMethod;

let result = ChannelCreateMethod {
    settings: &settings,
    name: "some-channel".to_string(),
    members: Some(vec!["rocket.cat".to_string()]),
    ..Default::default()
}.call().await;

License

MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Dependencies

~4–17MB
~250K SLoC