twilio/request/
list_notification.rs

1use serde_json::json;
2use crate::model::*;
3use crate::TwilioClient;
4/**Create this with the associated client method.
5
6That method takes required values as arguments. Set optional values using builder methods on this struct.*/
7#[derive(Clone)]
8pub struct ListNotificationRequest<'a> {
9    pub(crate) http_client: &'a TwilioClient,
10    pub account_sid: String,
11    pub log: Option<i64>,
12    pub message_date: Option<chrono::NaiveDate>,
13    pub message_date_gt: Option<chrono::NaiveDate>,
14    pub message_date_lt: Option<chrono::NaiveDate>,
15    pub page: Option<i64>,
16    pub page_size: Option<i64>,
17    pub page_token: Option<String>,
18}
19impl<'a> ListNotificationRequest<'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}/Notifications.json", account_sid
27                    = self.account_sid
28                ),
29            );
30        if let Some(ref unwrapped) = self.log {
31            r = r.query("Log", &unwrapped.to_string());
32        }
33        if let Some(ref unwrapped) = self.message_date {
34            r = r.query("MessageDate", &unwrapped.to_string());
35        }
36        if let Some(ref unwrapped) = self.message_date_gt {
37            r = r.query("MessageDate_gt", &unwrapped.to_string());
38        }
39        if let Some(ref unwrapped) = self.message_date_lt {
40            r = r.query("MessageDate_lt", &unwrapped.to_string());
41        }
42        if let Some(ref unwrapped) = self.page {
43            r = r.query("Page", &unwrapped.to_string());
44        }
45        if let Some(ref unwrapped) = self.page_size {
46            r = r.query("PageSize", &unwrapped.to_string());
47        }
48        if let Some(ref unwrapped) = self.page_token {
49            r = r.query("PageToken", &unwrapped.to_string());
50        }
51        r = self.http_client.authenticate(r);
52        let res = r.send_awaiting_body().await?;
53        res.json()
54    }
55    pub fn log(mut self, log: i64) -> Self {
56        self.log = Some(log);
57        self
58    }
59    pub fn message_date(mut self, message_date: chrono::NaiveDate) -> Self {
60        self.message_date = Some(message_date);
61        self
62    }
63    pub fn message_date_gt(mut self, message_date_gt: chrono::NaiveDate) -> Self {
64        self.message_date_gt = Some(message_date_gt);
65        self
66    }
67    pub fn message_date_lt(mut self, message_date_lt: chrono::NaiveDate) -> Self {
68        self.message_date_lt = Some(message_date_lt);
69        self
70    }
71    pub fn page(mut self, page: i64) -> Self {
72        self.page = Some(page);
73        self
74    }
75    pub fn page_size(mut self, page_size: i64) -> Self {
76        self.page_size = Some(page_size);
77        self
78    }
79    pub fn page_token(mut self, page_token: &str) -> Self {
80        self.page_token = Some(page_token.to_owned());
81        self
82    }
83}
84impl<'a> ::std::future::IntoFuture for ListNotificationRequest<'a> {
85    type Output = httpclient::InMemoryResult<serde_json::Value>;
86    type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
87    fn into_future(self) -> Self::IntoFuture {
88        Box::pin(self.send())
89    }
90}