Skip to main content

Crate mhteams

Crate mhteams 

Source
Expand description

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()?;
 

Structsยง

Fact
A fact (title-value pair) used in sections.
Image
An image, referenced by a url.
Message
Main object representing a teams message.
Section
A section in a message.