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