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