twilio/request/
list_short_code.rs1use serde_json::json;
2use crate::model::*;
3use crate::TwilioClient;
4#[derive(Clone)]
8pub struct ListShortCodeRequest<'a> {
9 pub(crate) http_client: &'a TwilioClient,
10 pub account_sid: String,
11 pub friendly_name: Option<String>,
12 pub page: Option<i64>,
13 pub page_size: Option<i64>,
14 pub page_token: Option<String>,
15 pub short_code: Option<String>,
16}
17impl<'a> ListShortCodeRequest<'a> {
18 pub async fn send(self) -> ::httpclient::InMemoryResult<serde_json::Value> {
19 let mut r = self
20 .http_client
21 .client
22 .get(
23 &format!(
24 "/2010-04-01/Accounts/{account_sid}/SMS/ShortCodes.json", account_sid
25 = self.account_sid
26 ),
27 );
28 if let Some(ref unwrapped) = self.friendly_name {
29 r = r.query("FriendlyName", &unwrapped.to_string());
30 }
31 if let Some(ref unwrapped) = self.page {
32 r = r.query("Page", &unwrapped.to_string());
33 }
34 if let Some(ref unwrapped) = self.page_size {
35 r = r.query("PageSize", &unwrapped.to_string());
36 }
37 if let Some(ref unwrapped) = self.page_token {
38 r = r.query("PageToken", &unwrapped.to_string());
39 }
40 if let Some(ref unwrapped) = self.short_code {
41 r = r.query("ShortCode", &unwrapped.to_string());
42 }
43 r = self.http_client.authenticate(r);
44 let res = r.send_awaiting_body().await?;
45 res.json()
46 }
47 pub fn friendly_name(mut self, friendly_name: &str) -> Self {
48 self.friendly_name = Some(friendly_name.to_owned());
49 self
50 }
51 pub fn page(mut self, page: i64) -> Self {
52 self.page = Some(page);
53 self
54 }
55 pub fn page_size(mut self, page_size: i64) -> Self {
56 self.page_size = Some(page_size);
57 self
58 }
59 pub fn page_token(mut self, page_token: &str) -> Self {
60 self.page_token = Some(page_token.to_owned());
61 self
62 }
63 pub fn short_code(mut self, short_code: &str) -> Self {
64 self.short_code = Some(short_code.to_owned());
65 self
66 }
67}
68impl<'a> ::std::future::IntoFuture for ListShortCodeRequest<'a> {
69 type Output = httpclient::InMemoryResult<serde_json::Value>;
70 type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
71 fn into_future(self) -> Self::IntoFuture {
72 Box::pin(self.send())
73 }
74}