twilio_rust_openapi/apis/
api20100401_conference_api.rs

1/*
2 * Twilio - Api
3 *
4 * This is the public Twilio REST API.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * Contact: support@twilio.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`fetch_conference`]
18#[derive(Clone, Debug)]
19pub struct FetchConferenceParams {
20    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference resource(s) to fetch.
21    pub account_sid: String,
22    /// The Twilio-provided string that uniquely identifies the Conference resource to fetch
23    pub sid: String
24}
25
26/// struct for passing parameters to the method [`list_conference`]
27#[derive(Clone, Debug)]
28pub struct ListConferenceParams {
29    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference resource(s) to read.
30    pub account_sid: String,
31    /// Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date.
32    pub date_created: Option<String>,
33    /// Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date.
34    pub date_created_less_than: Option<String>,
35    /// Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date.
36    pub date_created_greater_than: Option<String>,
37    /// Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date.
38    pub date_updated: Option<String>,
39    /// Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date.
40    pub date_updated_less_than: Option<String>,
41    /// Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date.
42    pub date_updated_greater_than: Option<String>,
43    /// The string that identifies the Conference resources to read.
44    pub friendly_name: Option<String>,
45    /// The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
46    pub status: Option<String>,
47    /// How many resources to return in each list page. The default is 50, and the maximum is 1000.
48    pub page_size: Option<i32>,
49    /// The page index. This value is simply for client state.
50    pub page: Option<i32>,
51    /// The page token. This is provided by the API.
52    pub page_token: Option<String>
53}
54
55/// struct for passing parameters to the method [`update_conference`]
56#[derive(Clone, Debug)]
57pub struct UpdateConferenceParams {
58    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference resource(s) to update.
59    pub account_sid: String,
60    /// The Twilio-provided string that uniquely identifies the Conference resource to update
61    pub sid: String,
62    pub status: Option<String>,
63    /// The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
64    pub announce_url: Option<String>,
65    /// The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
66    pub announce_method: Option<String>
67}
68
69
70/// struct for typed errors of method [`fetch_conference`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum FetchConferenceError {
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method [`list_conference`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum ListConferenceError {
81    UnknownValue(serde_json::Value),
82}
83
84/// struct for typed errors of method [`update_conference`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum UpdateConferenceError {
88    UnknownValue(serde_json::Value),
89}
90
91
92/// Fetch an instance of a conference
93pub async fn fetch_conference(configuration: &configuration::Configuration, params: FetchConferenceParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodConference, Error<FetchConferenceError>> {
94    let local_var_configuration = configuration;
95
96    // unbox the parameters
97    let account_sid = params.account_sid;
98    let sid = params.sid;
99
100
101    let local_var_client = &local_var_configuration.client;
102
103    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), Sid=crate::apis::urlencode(sid));
104    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
105
106    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
107        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
108    }
109    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
110        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
111    };
112
113    let local_var_req = local_var_req_builder.build()?;
114    let local_var_resp = local_var_client.execute(local_var_req).await?;
115
116    let local_var_status = local_var_resp.status();
117    let local_var_content = local_var_resp.text().await?;
118
119    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
120        serde_json::from_str(&local_var_content).map_err(Error::from)
121    } else {
122        let local_var_entity: Option<FetchConferenceError> = serde_json::from_str(&local_var_content).ok();
123        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
124        Err(Error::ResponseError(local_var_error))
125    }
126}
127
128/// Retrieve a list of conferences belonging to the account used to make the request
129pub async fn list_conference(configuration: &configuration::Configuration, params: ListConferenceParams) -> Result<models::ListConferenceResponse, Error<ListConferenceError>> {
130    let local_var_configuration = configuration;
131
132    // unbox the parameters
133    let account_sid = params.account_sid;
134    let date_created = params.date_created;
135    let date_created_less_than = params.date_created_less_than;
136    let date_created_greater_than = params.date_created_greater_than;
137    let date_updated = params.date_updated;
138    let date_updated_less_than = params.date_updated_less_than;
139    let date_updated_greater_than = params.date_updated_greater_than;
140    let friendly_name = params.friendly_name;
141    let status = params.status;
142    let page_size = params.page_size;
143    let page = params.page;
144    let page_token = params.page_token;
145
146
147    let local_var_client = &local_var_configuration.client;
148
149    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid));
150    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
151
152    if let Some(ref local_var_str) = date_created {
153        local_var_req_builder = local_var_req_builder.query(&[("DateCreated", &local_var_str.to_string())]);
154    }
155    if let Some(ref local_var_str) = date_created_less_than {
156        local_var_req_builder = local_var_req_builder.query(&[("DateCreated<", &local_var_str.to_string())]);
157    }
158    if let Some(ref local_var_str) = date_created_greater_than {
159        local_var_req_builder = local_var_req_builder.query(&[("DateCreated>", &local_var_str.to_string())]);
160    }
161    if let Some(ref local_var_str) = date_updated {
162        local_var_req_builder = local_var_req_builder.query(&[("DateUpdated", &local_var_str.to_string())]);
163    }
164    if let Some(ref local_var_str) = date_updated_less_than {
165        local_var_req_builder = local_var_req_builder.query(&[("DateUpdated<", &local_var_str.to_string())]);
166    }
167    if let Some(ref local_var_str) = date_updated_greater_than {
168        local_var_req_builder = local_var_req_builder.query(&[("DateUpdated>", &local_var_str.to_string())]);
169    }
170    if let Some(ref local_var_str) = friendly_name {
171        local_var_req_builder = local_var_req_builder.query(&[("FriendlyName", &local_var_str.to_string())]);
172    }
173    if let Some(ref local_var_str) = status {
174        local_var_req_builder = local_var_req_builder.query(&[("Status", &local_var_str.to_string())]);
175    }
176    if let Some(ref local_var_str) = page_size {
177        local_var_req_builder = local_var_req_builder.query(&[("PageSize", &local_var_str.to_string())]);
178    }
179    if let Some(ref local_var_str) = page {
180        local_var_req_builder = local_var_req_builder.query(&[("Page", &local_var_str.to_string())]);
181    }
182    if let Some(ref local_var_str) = page_token {
183        local_var_req_builder = local_var_req_builder.query(&[("PageToken", &local_var_str.to_string())]);
184    }
185    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
186        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
187    }
188    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
189        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
190    };
191
192    let local_var_req = local_var_req_builder.build()?;
193    let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195    let local_var_status = local_var_resp.status();
196    let local_var_content = local_var_resp.text().await?;
197
198    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199        serde_json::from_str(&local_var_content).map_err(Error::from)
200    } else {
201        let local_var_entity: Option<ListConferenceError> = serde_json::from_str(&local_var_content).ok();
202        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
203        Err(Error::ResponseError(local_var_error))
204    }
205}
206
207/// 
208pub async fn update_conference(configuration: &configuration::Configuration, params: UpdateConferenceParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodConference, Error<UpdateConferenceError>> {
209    let local_var_configuration = configuration;
210
211    // unbox the parameters
212    let account_sid = params.account_sid;
213    let sid = params.sid;
214    let status = params.status;
215    let announce_url = params.announce_url;
216    let announce_method = params.announce_method;
217
218
219    let local_var_client = &local_var_configuration.client;
220
221    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), Sid=crate::apis::urlencode(sid));
222    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
223
224    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
225        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
226    }
227    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
228        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
229    };
230    let mut local_var_form_params = std::collections::HashMap::new();
231    if let Some(local_var_param_value) = status {
232        local_var_form_params.insert("Status", local_var_param_value.to_string());
233    }
234    if let Some(local_var_param_value) = announce_url {
235        local_var_form_params.insert("AnnounceUrl", local_var_param_value.to_string());
236    }
237    if let Some(local_var_param_value) = announce_method {
238        local_var_form_params.insert("AnnounceMethod", local_var_param_value.to_string());
239    }
240    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
241
242    let local_var_req = local_var_req_builder.build()?;
243    let local_var_resp = local_var_client.execute(local_var_req).await?;
244
245    let local_var_status = local_var_resp.status();
246    let local_var_content = local_var_resp.text().await?;
247
248    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
249        serde_json::from_str(&local_var_content).map_err(Error::from)
250    } else {
251        let local_var_entity: Option<UpdateConferenceError> = serde_json::from_str(&local_var_content).ok();
252        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
253        Err(Error::ResponseError(local_var_error))
254    }
255}
256