1 unstable release

0.1.0 Jun 24, 2020

#10 in #ms

Download history 37/week @ 2024-03-13 98/week @ 2024-03-20 37/week @ 2024-03-27 34/week @ 2024-04-03 21/week @ 2024-04-10 21/week @ 2024-04-17 14/week @ 2024-04-24 7/week @ 2024-05-01 31/week @ 2024-05-08 47/week @ 2024-05-15 18/week @ 2024-05-22 5/week @ 2024-05-29 13/week @ 2024-06-05 39/week @ 2024-06-12 70/week @ 2024-06-19 27/week @ 2024-06-26

149 downloads per month

Apache-2.0

22KB
188 lines

MHteams

Crates.io latest version Crates.io downloads GitHub license

MHteams provides an easy and idiomatic way of creating and sending messages to MS Teams webhooks.

Based on official documentation for message cards.

See crate documentation.

Changelog

v0.1.0

* Initial release

lib.rs:

Idiomatic building of MS Teams messages.

Most documentation in this module are from microsoft docs.

Goal

Provide easy building of a MS Teams messages, through the Message object. The Message object is serializable, using Serde, allowing it to be converted to JSON and sent to a Teams webhook.

Example

extern crate mhteams;
extern crate reqwest;

use mhteams::{Message, Section, Image};
use reqwest::blocking::Client;

let msg = Message::new()
    .title("My title 😉")
    .text("TL;DR: it's awesome 👍")
    .sections(vec![
        Section::new()
            .title("The **Section**")
            .activity_title("_Check this out_")
            .activity_subtitle("It's awesome")
            .activity_image("https://sweet.image/cute.png")
            .activity_text("Lorum ipsum!")
            .hero_image(Image::new("MyImage", "https://sweet.image/bigasscar.png")),
        Section::new()
            .title("Layin down some facts ✅")
            .facts(vec![
                Fact::new("Name", "John Smith"),
                Fact::new("Language", "Rust. What else?"),
            ]),
    ]);

let client = Client::new();
let resp = client
    .post(URL)
    .json(&msg)
    .send()?;

Dependencies

~0.4–1MB
~22K SLoC