termii_rust/blocking/rest/switch/mod.rs
1//! Send messages globally.
2
3//! # Examples
4//!
5//!
6//! Fetch Phonebooks.
7//!
8//! ```rust
9//! use termii_rust::{blocking::rest::termii, common::switch::campaign::PhoneBookItem};
10//!
11//! let client = termii::Termii::new("Your API key");
12//!
13//! let phonebooks: Vec<PhoneBookItem> = client.switch.campaign.get(Some(1)).unwrap();
14//!
15//! println!("{:?}", phonebooks);
16//! ```
17//! ### The above code is limited by termii's pagination. You can get all your phonebooks with the **all** function like such
18//!
19//! ```rust
20//! let phonebooks: Vec<PhoneBookItem> = client.switch.campaign.all().unwrap();
21//! ```
22//!
23//!
24//! ## Send a message to a recipient.
25//!
26//! ```rust
27//! use termii_rust::{
28//! blocking::rest::termii,
29//! common::switch::messaging::{Channel, MessageRequest, MessageType},
30//! };
31//!
32//! let client = termii::Termii::new("Your API key");
33//!
34//! let message_payload = MessageRequest::new(
35//! "234XXXXXXXXXX".to_string(),
36//! "Your org sender id".to_string(),
37//! "Your message".to_string(),
38//! MessageType::Plain,
39//! Channel::Generic,
40//! );
41//!
42//! let message_response = client.switch.messaging.send(message_payload).unwrap();
43//!
44//! println!("{:?}", message_response);
45//! ```
46//!
47//!
48//! ## Send a message to a recipient using termii's auto generated number.
49//!
50//! ```rust
51//! use termii_rust::{blocking::rest::termii, common::switch::number::NumberMessageRequest};
52//!
53//! let client = termii::Termii::new("Your API key");
54//!
55//! let message_payload =
56//! NumberMessageRequest::new("234XXXXXXXXXX".to_string(), "Your message".to_string());
57//!
58//! let message_response = client.switch.number.send(message_payload).unwrap();
59//!
60//! println!("{:?}", message_response);
61//! ```
62//!
63//!
64//! ## Fetch your organization's sender ID's.
65//!
66//! ```rust
67//! use termii_rust::blocking::rest::termii;
68//!
69//! let client = termii::Termii::new("Your API key");
70//!
71//! let sender_id = client.switch.sender_id.get(Some("1")).unwrap();
72//!
73//! println!("{:?}", sender_id);
74//! ```
75//! ### The above code is limited by termii's pagination. You can get all your sender ID's with the **all** function like such
76//!
77//! ```rust
78//! let sender_ids = client.switch.sender_id.all().unwrap();
79//! ```
80//!
81//!
82//! ## Set a template for your org's one time pin.
83//!
84//! ```rust
85//! use termii_rust::{
86//! blocking::rest::termii,
87//! common::switch::templates::{TemplatesData, TemplatesRequest},
88//! };
89//!
90//! let client = termii::Termii::new("Your API key");
91//!
92//! let templates_data =
93//! TemplatesData::new("Termii", "325821".to_string(), "10 minutes".to_string());
94//!
95//! let templates_payload = TemplatesRequest::new(
96//! "+234XXXXXXXXXX".to_string(),
97//! "talert".to_string(),
98//! "1493-csdn3-ns34w-sd3434-dfdf".to_string(),
99//! templates_data,
100//! );
101//!
102//! let templates_response = client.switch.templates.send(templates_payload).unwrap();
103//!
104//! println!("{:?}", templates_response);
105//! ```
106pub mod switch;
107pub use switch::*;
108
109pub mod templates;
110pub use templates::*;
111
112pub mod sender_id;
113pub use sender_id::*;
114
115pub mod campaign;
116pub use campaign::*;
117
118pub mod number;
119pub use number::*;
120
121pub mod messaging;
122pub use messaging::*;