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