termii_rust/async_impl/mod.rs
1//! An asynchronous messaging client API.
2//!
3//! This module provides an async interface to the termii API. Yow will need a runtime to use this module.
4//! If you want to use this module within a blocking runtime, use the [`blocking::rest`][crate::blocking::rest] module.
5//!
6//! ## Sending a quick message
7//!
8//! ```rust
9//! use termii_rust::{
10//! async_impl::rest::termii,
11//! common::switch::messaging::{Channel, MessageRequest, MessageType},
12//! }
13//!
14//! let client = termii::Termii::new("Your API key");
15//!
16//! let _message = MessageRequest::new(
17//! "234XXXXXXXXXX".to_string(),
18//! "FromYourOrg".to_string(),
19//! "Hello from Rust Termii. 😎".to_string(),
20//! MessageType::Plain,
21//! Channel::Dnd,
22//! );
23//!
24//! let message = client.switch.messaging.send(_message).await.unwrap();
25//!
26//! println!("{:?}", message);
27//! ```
28//!
29//! ## Sending a one time token
30//!
31//! We can use the [`token`](crate::async_impl::rest::token) module of the Token api to send a one time token.
32//!
33//! ```rust
34//! use termii_rust::{
35//! async_impl::rest::termii,
36//! common::token::request::{
37//! RequestTokenChannel, RequestTokenMessageType, RequestTokenPinType, RequestTokenRequest,
38//! },
39//! };
40//!
41//! let client = termii::Termii::new("Your API key");
42//!
43//! let payload = RequestTokenRequest::new(
44//! RequestTokenMessageType::ALPHANUMERIC,
45//! String::from("234XXXXXXXXXX"),
46//! String::from("FromYourOrg"),
47//! RequestTokenChannel::Generic,
48//! 3 as u8,
49//! 50 as usize,
50//! 6 as u8,
51//! String::from("< 1234 >"),
52//! String::from("Your pin is < 1234 >"),
53//! RequestTokenPinType::ALPHANUMERIC,
54//! );
55//!
56//! let response = client.token.request_token.send(otp_payload).await.unwrap();
57//!
58//! println!("{:#?}", response);
59//! ```
60
61pub mod http;
62pub mod rest;