1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::sync::Arc;
use crate::{
async_impl::http::client,
common::{
errors,
switch::number::{NumberMessageRequest, NumberMessageResponse},
},
};
#[derive(Debug)]
pub struct Number<'a> {
api_key: &'a str,
client: Arc<client::HttpClient>,
}
impl<'a> Number<'a> {
pub(crate) fn new(api_key: &'a str, client: Arc<client::HttpClient>) -> Number<'a> {
Number { api_key, client }
}
pub async fn send(
&self,
mut message: NumberMessageRequest,
) -> Result<NumberMessageResponse, errors::HttpError> {
message.set_api_key(self.api_key);
let response = self
.client
.post("sms/number/send", None, None, Some(message))
.await?;
let message_response = response_or_error_text_async!(response, NumberMessageResponse);
Ok(message_response)
}
}