twilio/request/
list_usage_trigger.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 ListUsageTriggerRequest<'a> {
9    pub(crate) http_client: &'a TwilioClient,
10    pub account_sid: String,
11    pub page: Option<i64>,
12    pub page_size: Option<i64>,
13    pub page_token: Option<String>,
14    pub recurring: Option<String>,
15    pub trigger_by: Option<String>,
16    pub usage_category: Option<String>,
17}
18impl<'a> ListUsageTriggerRequest<'a> {
19    pub async fn send(self) -> ::httpclient::InMemoryResult<serde_json::Value> {
20        let mut r = self
21            .http_client
22            .client
23            .get(
24                &format!(
25                    "/2010-04-01/Accounts/{account_sid}/Usage/Triggers.json", account_sid
26                    = self.account_sid
27                ),
28            );
29        if let Some(ref unwrapped) = self.page {
30            r = r.query("Page", &unwrapped.to_string());
31        }
32        if let Some(ref unwrapped) = self.page_size {
33            r = r.query("PageSize", &unwrapped.to_string());
34        }
35        if let Some(ref unwrapped) = self.page_token {
36            r = r.query("PageToken", &unwrapped.to_string());
37        }
38        if let Some(ref unwrapped) = self.recurring {
39            r = r.query("Recurring", &unwrapped.to_string());
40        }
41        if let Some(ref unwrapped) = self.trigger_by {
42            r = r.query("TriggerBy", &unwrapped.to_string());
43        }
44        if let Some(ref unwrapped) = self.usage_category {
45            r = r.query("UsageCategory", &unwrapped.to_string());
46        }
47        r = self.http_client.authenticate(r);
48        let res = r.send_awaiting_body().await?;
49        res.json()
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 recurring(mut self, recurring: &str) -> Self {
64        self.recurring = Some(recurring.to_owned());
65        self
66    }
67    pub fn trigger_by(mut self, trigger_by: &str) -> Self {
68        self.trigger_by = Some(trigger_by.to_owned());
69        self
70    }
71    pub fn usage_category(mut self, usage_category: &str) -> Self {
72        self.usage_category = Some(usage_category.to_owned());
73        self
74    }
75}
76impl<'a> ::std::future::IntoFuture for ListUsageTriggerRequest<'a> {
77    type Output = httpclient::InMemoryResult<serde_json::Value>;
78    type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
79    fn into_future(self) -> Self::IntoFuture {
80        Box::pin(self.send())
81    }
82}