twilio_rust_openapi/apis/
api20100401_recording_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 [`create_call_recording`]
18#[derive(Clone, Debug)]
19pub struct CreateCallRecordingParams {
20    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource.
21    pub account_sid: String,
22    /// The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) to associate the resource with.
23    pub call_sid: String,
24    /// The recording status events on which we should call the `recording_status_callback` URL. Can be: `in-progress`, `completed` and `absent` and the default is `completed`. Separate multiple event values with a space.
25    pub recording_status_callback_event: Option<Vec<String>>,
26    /// The URL we should call using the `recording_status_callback_method` on each recording event specified in  `recording_status_callback_event`. For more information, see [RecordingStatusCallback parameters](https://www.twilio.com/docs/voice/api/recording#recordingstatuscallback).
27    pub recording_status_callback: Option<String>,
28    /// The HTTP method we should use to call `recording_status_callback`. Can be: `GET` or `POST` and the default is `POST`.
29    pub recording_status_callback_method: Option<String>,
30    /// Whether to trim any leading and trailing silence in the recording. Can be: `trim-silence` or `do-not-trim` and the default is `do-not-trim`. `trim-silence` trims the silence from the beginning and end of the recording and `do-not-trim` does not.
31    pub trim: Option<String>,
32    /// The number of channels used in the recording. Can be: `mono` or `dual` and the default is `mono`. `mono` records all parties of the call into one channel. `dual` records each party of a 2-party call into separate channels.
33    pub recording_channels: Option<String>,
34    /// The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio.
35    pub recording_track: Option<String>
36}
37
38/// struct for passing parameters to the method [`delete_call_recording`]
39#[derive(Clone, Debug)]
40pub struct DeleteCallRecordingParams {
41    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resources to delete.
42    pub account_sid: String,
43    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to delete.
44    pub call_sid: String,
45    /// The Twilio-provided string that uniquely identifies the Recording resource to delete.
46    pub sid: String
47}
48
49/// struct for passing parameters to the method [`delete_conference_recording`]
50#[derive(Clone, Debug)]
51pub struct DeleteConferenceRecordingParams {
52    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resources to delete.
53    pub account_sid: String,
54    /// The Conference SID that identifies the conference associated with the recording to delete.
55    pub conference_sid: String,
56    /// The Twilio-provided string that uniquely identifies the Conference Recording resource to delete.
57    pub sid: String
58}
59
60/// struct for passing parameters to the method [`delete_recording`]
61#[derive(Clone, Debug)]
62pub struct DeleteRecordingParams {
63    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resources to delete.
64    pub account_sid: String,
65    /// The Twilio-provided string that uniquely identifies the Recording resource to delete.
66    pub sid: String
67}
68
69/// struct for passing parameters to the method [`fetch_call_recording`]
70#[derive(Clone, Debug)]
71pub struct FetchCallRecordingParams {
72    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource to fetch.
73    pub account_sid: String,
74    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resource to fetch.
75    pub call_sid: String,
76    /// The Twilio-provided string that uniquely identifies the Recording resource to fetch.
77    pub sid: String
78}
79
80/// struct for passing parameters to the method [`fetch_conference_recording`]
81#[derive(Clone, Debug)]
82pub struct FetchConferenceRecordingParams {
83    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resource to fetch.
84    pub account_sid: String,
85    /// The Conference SID that identifies the conference associated with the recording to fetch.
86    pub conference_sid: String,
87    /// The Twilio-provided string that uniquely identifies the Conference Recording resource to fetch.
88    pub sid: String
89}
90
91/// struct for passing parameters to the method [`fetch_recording`]
92#[derive(Clone, Debug)]
93pub struct FetchRecordingParams {
94    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource to fetch.
95    pub account_sid: String,
96    /// The Twilio-provided string that uniquely identifies the Recording resource to fetch.
97    pub sid: String,
98    /// A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
99    pub include_soft_deleted: Option<bool>
100}
101
102/// struct for passing parameters to the method [`list_call_recording`]
103#[derive(Clone, Debug)]
104pub struct ListCallRecordingParams {
105    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resources to read.
106    pub account_sid: String,
107    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
108    pub call_sid: String,
109    /// The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
110    pub date_created: Option<String>,
111    /// The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
112    pub date_created_less_than: Option<String>,
113    /// The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
114    pub date_created_greater_than: Option<String>,
115    /// How many resources to return in each list page. The default is 50, and the maximum is 1000.
116    pub page_size: Option<i32>,
117    /// The page index. This value is simply for client state.
118    pub page: Option<i32>,
119    /// The page token. This is provided by the API.
120    pub page_token: Option<String>
121}
122
123/// struct for passing parameters to the method [`list_conference_recording`]
124#[derive(Clone, Debug)]
125pub struct ListConferenceRecordingParams {
126    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resources to read.
127    pub account_sid: String,
128    /// The Conference SID that identifies the conference associated with the recording to read.
129    pub conference_sid: String,
130    /// The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
131    pub date_created: Option<String>,
132    /// The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
133    pub date_created_less_than: Option<String>,
134    /// The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
135    pub date_created_greater_than: Option<String>,
136    /// How many resources to return in each list page. The default is 50, and the maximum is 1000.
137    pub page_size: Option<i32>,
138    /// The page index. This value is simply for client state.
139    pub page: Option<i32>,
140    /// The page token. This is provided by the API.
141    pub page_token: Option<String>
142}
143
144/// struct for passing parameters to the method [`list_recording`]
145#[derive(Clone, Debug)]
146pub struct ListRecordingParams {
147    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resources to read.
148    pub account_sid: String,
149    /// Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
150    pub date_created: Option<String>,
151    /// Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
152    pub date_created_less_than: Option<String>,
153    /// Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
154    pub date_created_greater_than: Option<String>,
155    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
156    pub call_sid: Option<String>,
157    /// The Conference SID that identifies the conference associated with the recording to read.
158    pub conference_sid: Option<String>,
159    /// A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
160    pub include_soft_deleted: Option<bool>,
161    /// How many resources to return in each list page. The default is 50, and the maximum is 1000.
162    pub page_size: Option<i32>,
163    /// The page index. This value is simply for client state.
164    pub page: Option<i32>,
165    /// The page token. This is provided by the API.
166    pub page_token: Option<String>
167}
168
169/// struct for passing parameters to the method [`update_call_recording`]
170#[derive(Clone, Debug)]
171pub struct UpdateCallRecordingParams {
172    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource to update.
173    pub account_sid: String,
174    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resource to update.
175    pub call_sid: String,
176    /// The Twilio-provided string that uniquely identifies the Recording resource to update.
177    pub sid: String,
178    pub status: String,
179    /// Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
180    pub pause_behavior: Option<String>
181}
182
183/// struct for passing parameters to the method [`update_conference_recording`]
184#[derive(Clone, Debug)]
185pub struct UpdateConferenceRecordingParams {
186    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resource to update.
187    pub account_sid: String,
188    /// The Conference SID that identifies the conference associated with the recording to update.
189    pub conference_sid: String,
190    /// The Twilio-provided string that uniquely identifies the Conference Recording resource to update. Use `Twilio.CURRENT` to reference the current active recording.
191    pub sid: String,
192    pub status: String,
193    /// Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
194    pub pause_behavior: Option<String>
195}
196
197
198/// struct for typed errors of method [`create_call_recording`]
199#[derive(Debug, Clone, Serialize, Deserialize)]
200#[serde(untagged)]
201pub enum CreateCallRecordingError {
202    UnknownValue(serde_json::Value),
203}
204
205/// struct for typed errors of method [`delete_call_recording`]
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum DeleteCallRecordingError {
209    UnknownValue(serde_json::Value),
210}
211
212/// struct for typed errors of method [`delete_conference_recording`]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum DeleteConferenceRecordingError {
216    UnknownValue(serde_json::Value),
217}
218
219/// struct for typed errors of method [`delete_recording`]
220#[derive(Debug, Clone, Serialize, Deserialize)]
221#[serde(untagged)]
222pub enum DeleteRecordingError {
223    UnknownValue(serde_json::Value),
224}
225
226/// struct for typed errors of method [`fetch_call_recording`]
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum FetchCallRecordingError {
230    UnknownValue(serde_json::Value),
231}
232
233/// struct for typed errors of method [`fetch_conference_recording`]
234#[derive(Debug, Clone, Serialize, Deserialize)]
235#[serde(untagged)]
236pub enum FetchConferenceRecordingError {
237    UnknownValue(serde_json::Value),
238}
239
240/// struct for typed errors of method [`fetch_recording`]
241#[derive(Debug, Clone, Serialize, Deserialize)]
242#[serde(untagged)]
243pub enum FetchRecordingError {
244    UnknownValue(serde_json::Value),
245}
246
247/// struct for typed errors of method [`list_call_recording`]
248#[derive(Debug, Clone, Serialize, Deserialize)]
249#[serde(untagged)]
250pub enum ListCallRecordingError {
251    UnknownValue(serde_json::Value),
252}
253
254/// struct for typed errors of method [`list_conference_recording`]
255#[derive(Debug, Clone, Serialize, Deserialize)]
256#[serde(untagged)]
257pub enum ListConferenceRecordingError {
258    UnknownValue(serde_json::Value),
259}
260
261/// struct for typed errors of method [`list_recording`]
262#[derive(Debug, Clone, Serialize, Deserialize)]
263#[serde(untagged)]
264pub enum ListRecordingError {
265    UnknownValue(serde_json::Value),
266}
267
268/// struct for typed errors of method [`update_call_recording`]
269#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum UpdateCallRecordingError {
272    UnknownValue(serde_json::Value),
273}
274
275/// struct for typed errors of method [`update_conference_recording`]
276#[derive(Debug, Clone, Serialize, Deserialize)]
277#[serde(untagged)]
278pub enum UpdateConferenceRecordingError {
279    UnknownValue(serde_json::Value),
280}
281
282
283/// Create a recording for the call
284pub async fn create_call_recording(configuration: &configuration::Configuration, params: CreateCallRecordingParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodCallPeriodCallRecording, Error<CreateCallRecordingError>> {
285    let local_var_configuration = configuration;
286
287    // unbox the parameters
288    let account_sid = params.account_sid;
289    let call_sid = params.call_sid;
290    let recording_status_callback_event = params.recording_status_callback_event;
291    let recording_status_callback = params.recording_status_callback;
292    let recording_status_callback_method = params.recording_status_callback_method;
293    let trim = params.trim;
294    let recording_channels = params.recording_channels;
295    let recording_track = params.recording_track;
296
297
298    let local_var_client = &local_var_configuration.client;
299
300    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Recordings.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), CallSid=crate::apis::urlencode(call_sid));
301    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
302
303    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
304        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
305    }
306    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
307        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
308    };
309    let mut local_var_form_params = std::collections::HashMap::new();
310    if let Some(local_var_param_value) = recording_status_callback_event {
311        local_var_form_params.insert("RecordingStatusCallbackEvent", local_var_param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
312    }
313    if let Some(local_var_param_value) = recording_status_callback {
314        local_var_form_params.insert("RecordingStatusCallback", local_var_param_value.to_string());
315    }
316    if let Some(local_var_param_value) = recording_status_callback_method {
317        local_var_form_params.insert("RecordingStatusCallbackMethod", local_var_param_value.to_string());
318    }
319    if let Some(local_var_param_value) = trim {
320        local_var_form_params.insert("Trim", local_var_param_value.to_string());
321    }
322    if let Some(local_var_param_value) = recording_channels {
323        local_var_form_params.insert("RecordingChannels", local_var_param_value.to_string());
324    }
325    if let Some(local_var_param_value) = recording_track {
326        local_var_form_params.insert("RecordingTrack", local_var_param_value.to_string());
327    }
328    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
329
330    let local_var_req = local_var_req_builder.build()?;
331    let local_var_resp = local_var_client.execute(local_var_req).await?;
332
333    let local_var_status = local_var_resp.status();
334    let local_var_content = local_var_resp.text().await?;
335
336    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
337        serde_json::from_str(&local_var_content).map_err(Error::from)
338    } else {
339        let local_var_entity: Option<CreateCallRecordingError> = serde_json::from_str(&local_var_content).ok();
340        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
341        Err(Error::ResponseError(local_var_error))
342    }
343}
344
345/// Delete a recording from your account
346pub async fn delete_call_recording(configuration: &configuration::Configuration, params: DeleteCallRecordingParams) -> Result<(), Error<DeleteCallRecordingError>> {
347    let local_var_configuration = configuration;
348
349    // unbox the parameters
350    let account_sid = params.account_sid;
351    let call_sid = params.call_sid;
352    let sid = params.sid;
353
354
355    let local_var_client = &local_var_configuration.client;
356
357    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), CallSid=crate::apis::urlencode(call_sid), Sid=crate::apis::urlencode(sid));
358    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
359
360    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
361        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
362    }
363    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
364        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
365    };
366
367    let local_var_req = local_var_req_builder.build()?;
368    let local_var_resp = local_var_client.execute(local_var_req).await?;
369
370    let local_var_status = local_var_resp.status();
371    let local_var_content = local_var_resp.text().await?;
372
373    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
374        Ok(())
375    } else {
376        let local_var_entity: Option<DeleteCallRecordingError> = serde_json::from_str(&local_var_content).ok();
377        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
378        Err(Error::ResponseError(local_var_error))
379    }
380}
381
382/// Delete a recording from your account
383pub async fn delete_conference_recording(configuration: &configuration::Configuration, params: DeleteConferenceRecordingParams) -> Result<(), Error<DeleteConferenceRecordingError>> {
384    let local_var_configuration = configuration;
385
386    // unbox the parameters
387    let account_sid = params.account_sid;
388    let conference_sid = params.conference_sid;
389    let sid = params.sid;
390
391
392    let local_var_client = &local_var_configuration.client;
393
394    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid), Sid=crate::apis::urlencode(sid));
395    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
396
397    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
398        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
399    }
400    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
401        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
402    };
403
404    let local_var_req = local_var_req_builder.build()?;
405    let local_var_resp = local_var_client.execute(local_var_req).await?;
406
407    let local_var_status = local_var_resp.status();
408    let local_var_content = local_var_resp.text().await?;
409
410    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
411        Ok(())
412    } else {
413        let local_var_entity: Option<DeleteConferenceRecordingError> = serde_json::from_str(&local_var_content).ok();
414        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
415        Err(Error::ResponseError(local_var_error))
416    }
417}
418
419/// Delete a recording from your account
420pub async fn delete_recording(configuration: &configuration::Configuration, params: DeleteRecordingParams) -> Result<(), Error<DeleteRecordingError>> {
421    let local_var_configuration = configuration;
422
423    // unbox the parameters
424    let account_sid = params.account_sid;
425    let sid = params.sid;
426
427
428    let local_var_client = &local_var_configuration.client;
429
430    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), Sid=crate::apis::urlencode(sid));
431    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
432
433    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
434        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
435    }
436    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
437        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
438    };
439
440    let local_var_req = local_var_req_builder.build()?;
441    let local_var_resp = local_var_client.execute(local_var_req).await?;
442
443    let local_var_status = local_var_resp.status();
444    let local_var_content = local_var_resp.text().await?;
445
446    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
447        Ok(())
448    } else {
449        let local_var_entity: Option<DeleteRecordingError> = serde_json::from_str(&local_var_content).ok();
450        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
451        Err(Error::ResponseError(local_var_error))
452    }
453}
454
455/// Fetch an instance of a recording for a call
456pub async fn fetch_call_recording(configuration: &configuration::Configuration, params: FetchCallRecordingParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodCallPeriodCallRecording, Error<FetchCallRecordingError>> {
457    let local_var_configuration = configuration;
458
459    // unbox the parameters
460    let account_sid = params.account_sid;
461    let call_sid = params.call_sid;
462    let sid = params.sid;
463
464
465    let local_var_client = &local_var_configuration.client;
466
467    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), CallSid=crate::apis::urlencode(call_sid), Sid=crate::apis::urlencode(sid));
468    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
469
470    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
471        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
472    }
473    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
474        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
475    };
476
477    let local_var_req = local_var_req_builder.build()?;
478    let local_var_resp = local_var_client.execute(local_var_req).await?;
479
480    let local_var_status = local_var_resp.status();
481    let local_var_content = local_var_resp.text().await?;
482
483    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
484        serde_json::from_str(&local_var_content).map_err(Error::from)
485    } else {
486        let local_var_entity: Option<FetchCallRecordingError> = serde_json::from_str(&local_var_content).ok();
487        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
488        Err(Error::ResponseError(local_var_error))
489    }
490}
491
492/// Fetch an instance of a recording for a call
493pub async fn fetch_conference_recording(configuration: &configuration::Configuration, params: FetchConferenceRecordingParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodConferencePeriodConferenceRecording, Error<FetchConferenceRecordingError>> {
494    let local_var_configuration = configuration;
495
496    // unbox the parameters
497    let account_sid = params.account_sid;
498    let conference_sid = params.conference_sid;
499    let sid = params.sid;
500
501
502    let local_var_client = &local_var_configuration.client;
503
504    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid), Sid=crate::apis::urlencode(sid));
505    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
506
507    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
508        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
509    }
510    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
511        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
512    };
513
514    let local_var_req = local_var_req_builder.build()?;
515    let local_var_resp = local_var_client.execute(local_var_req).await?;
516
517    let local_var_status = local_var_resp.status();
518    let local_var_content = local_var_resp.text().await?;
519
520    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
521        serde_json::from_str(&local_var_content).map_err(Error::from)
522    } else {
523        let local_var_entity: Option<FetchConferenceRecordingError> = serde_json::from_str(&local_var_content).ok();
524        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
525        Err(Error::ResponseError(local_var_error))
526    }
527}
528
529/// Fetch an instance of a recording
530pub async fn fetch_recording(configuration: &configuration::Configuration, params: FetchRecordingParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodRecording, Error<FetchRecordingError>> {
531    let local_var_configuration = configuration;
532
533    // unbox the parameters
534    let account_sid = params.account_sid;
535    let sid = params.sid;
536    let include_soft_deleted = params.include_soft_deleted;
537
538
539    let local_var_client = &local_var_configuration.client;
540
541    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), Sid=crate::apis::urlencode(sid));
542    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
543
544    if let Some(ref local_var_str) = include_soft_deleted {
545        local_var_req_builder = local_var_req_builder.query(&[("IncludeSoftDeleted", &local_var_str.to_string())]);
546    }
547    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
548        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
549    }
550    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
551        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
552    };
553
554    let local_var_req = local_var_req_builder.build()?;
555    let local_var_resp = local_var_client.execute(local_var_req).await?;
556
557    let local_var_status = local_var_resp.status();
558    let local_var_content = local_var_resp.text().await?;
559
560    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
561        serde_json::from_str(&local_var_content).map_err(Error::from)
562    } else {
563        let local_var_entity: Option<FetchRecordingError> = serde_json::from_str(&local_var_content).ok();
564        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
565        Err(Error::ResponseError(local_var_error))
566    }
567}
568
569/// Retrieve a list of recordings belonging to the call used to make the request
570pub async fn list_call_recording(configuration: &configuration::Configuration, params: ListCallRecordingParams) -> Result<models::ListCallRecordingResponse, Error<ListCallRecordingError>> {
571    let local_var_configuration = configuration;
572
573    // unbox the parameters
574    let account_sid = params.account_sid;
575    let call_sid = params.call_sid;
576    let date_created = params.date_created;
577    let date_created_less_than = params.date_created_less_than;
578    let date_created_greater_than = params.date_created_greater_than;
579    let page_size = params.page_size;
580    let page = params.page;
581    let page_token = params.page_token;
582
583
584    let local_var_client = &local_var_configuration.client;
585
586    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Recordings.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), CallSid=crate::apis::urlencode(call_sid));
587    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
588
589    if let Some(ref local_var_str) = date_created {
590        local_var_req_builder = local_var_req_builder.query(&[("DateCreated", &local_var_str.to_string())]);
591    }
592    if let Some(ref local_var_str) = date_created_less_than {
593        local_var_req_builder = local_var_req_builder.query(&[("DateCreated<", &local_var_str.to_string())]);
594    }
595    if let Some(ref local_var_str) = date_created_greater_than {
596        local_var_req_builder = local_var_req_builder.query(&[("DateCreated>", &local_var_str.to_string())]);
597    }
598    if let Some(ref local_var_str) = page_size {
599        local_var_req_builder = local_var_req_builder.query(&[("PageSize", &local_var_str.to_string())]);
600    }
601    if let Some(ref local_var_str) = page {
602        local_var_req_builder = local_var_req_builder.query(&[("Page", &local_var_str.to_string())]);
603    }
604    if let Some(ref local_var_str) = page_token {
605        local_var_req_builder = local_var_req_builder.query(&[("PageToken", &local_var_str.to_string())]);
606    }
607    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
608        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
609    }
610    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
611        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
612    };
613
614    let local_var_req = local_var_req_builder.build()?;
615    let local_var_resp = local_var_client.execute(local_var_req).await?;
616
617    let local_var_status = local_var_resp.status();
618    let local_var_content = local_var_resp.text().await?;
619
620    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
621        serde_json::from_str(&local_var_content).map_err(Error::from)
622    } else {
623        let local_var_entity: Option<ListCallRecordingError> = serde_json::from_str(&local_var_content).ok();
624        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
625        Err(Error::ResponseError(local_var_error))
626    }
627}
628
629/// Retrieve a list of recordings belonging to the call used to make the request
630pub async fn list_conference_recording(configuration: &configuration::Configuration, params: ListConferenceRecordingParams) -> Result<models::ListConferenceRecordingResponse, Error<ListConferenceRecordingError>> {
631    let local_var_configuration = configuration;
632
633    // unbox the parameters
634    let account_sid = params.account_sid;
635    let conference_sid = params.conference_sid;
636    let date_created = params.date_created;
637    let date_created_less_than = params.date_created_less_than;
638    let date_created_greater_than = params.date_created_greater_than;
639    let page_size = params.page_size;
640    let page = params.page;
641    let page_token = params.page_token;
642
643
644    let local_var_client = &local_var_configuration.client;
645
646    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Recordings.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid));
647    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
648
649    if let Some(ref local_var_str) = date_created {
650        local_var_req_builder = local_var_req_builder.query(&[("DateCreated", &local_var_str.to_string())]);
651    }
652    if let Some(ref local_var_str) = date_created_less_than {
653        local_var_req_builder = local_var_req_builder.query(&[("DateCreated<", &local_var_str.to_string())]);
654    }
655    if let Some(ref local_var_str) = date_created_greater_than {
656        local_var_req_builder = local_var_req_builder.query(&[("DateCreated>", &local_var_str.to_string())]);
657    }
658    if let Some(ref local_var_str) = page_size {
659        local_var_req_builder = local_var_req_builder.query(&[("PageSize", &local_var_str.to_string())]);
660    }
661    if let Some(ref local_var_str) = page {
662        local_var_req_builder = local_var_req_builder.query(&[("Page", &local_var_str.to_string())]);
663    }
664    if let Some(ref local_var_str) = page_token {
665        local_var_req_builder = local_var_req_builder.query(&[("PageToken", &local_var_str.to_string())]);
666    }
667    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
668        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
669    }
670    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
671        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
672    };
673
674    let local_var_req = local_var_req_builder.build()?;
675    let local_var_resp = local_var_client.execute(local_var_req).await?;
676
677    let local_var_status = local_var_resp.status();
678    let local_var_content = local_var_resp.text().await?;
679
680    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
681        serde_json::from_str(&local_var_content).map_err(Error::from)
682    } else {
683        let local_var_entity: Option<ListConferenceRecordingError> = serde_json::from_str(&local_var_content).ok();
684        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
685        Err(Error::ResponseError(local_var_error))
686    }
687}
688
689/// Retrieve a list of recordings belonging to the account used to make the request
690pub async fn list_recording(configuration: &configuration::Configuration, params: ListRecordingParams) -> Result<models::ListRecordingResponse, Error<ListRecordingError>> {
691    let local_var_configuration = configuration;
692
693    // unbox the parameters
694    let account_sid = params.account_sid;
695    let date_created = params.date_created;
696    let date_created_less_than = params.date_created_less_than;
697    let date_created_greater_than = params.date_created_greater_than;
698    let call_sid = params.call_sid;
699    let conference_sid = params.conference_sid;
700    let include_soft_deleted = params.include_soft_deleted;
701    let page_size = params.page_size;
702    let page = params.page;
703    let page_token = params.page_token;
704
705
706    let local_var_client = &local_var_configuration.client;
707
708    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Recordings.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid));
709    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
710
711    if let Some(ref local_var_str) = date_created {
712        local_var_req_builder = local_var_req_builder.query(&[("DateCreated", &local_var_str.to_string())]);
713    }
714    if let Some(ref local_var_str) = date_created_less_than {
715        local_var_req_builder = local_var_req_builder.query(&[("DateCreated<", &local_var_str.to_string())]);
716    }
717    if let Some(ref local_var_str) = date_created_greater_than {
718        local_var_req_builder = local_var_req_builder.query(&[("DateCreated>", &local_var_str.to_string())]);
719    }
720    if let Some(ref local_var_str) = call_sid {
721        local_var_req_builder = local_var_req_builder.query(&[("CallSid", &local_var_str.to_string())]);
722    }
723    if let Some(ref local_var_str) = conference_sid {
724        local_var_req_builder = local_var_req_builder.query(&[("ConferenceSid", &local_var_str.to_string())]);
725    }
726    if let Some(ref local_var_str) = include_soft_deleted {
727        local_var_req_builder = local_var_req_builder.query(&[("IncludeSoftDeleted", &local_var_str.to_string())]);
728    }
729    if let Some(ref local_var_str) = page_size {
730        local_var_req_builder = local_var_req_builder.query(&[("PageSize", &local_var_str.to_string())]);
731    }
732    if let Some(ref local_var_str) = page {
733        local_var_req_builder = local_var_req_builder.query(&[("Page", &local_var_str.to_string())]);
734    }
735    if let Some(ref local_var_str) = page_token {
736        local_var_req_builder = local_var_req_builder.query(&[("PageToken", &local_var_str.to_string())]);
737    }
738    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
739        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
740    }
741    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
742        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
743    };
744
745    let local_var_req = local_var_req_builder.build()?;
746    let local_var_resp = local_var_client.execute(local_var_req).await?;
747
748    let local_var_status = local_var_resp.status();
749    let local_var_content = local_var_resp.text().await?;
750
751    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
752        serde_json::from_str(&local_var_content).map_err(Error::from)
753    } else {
754        let local_var_entity: Option<ListRecordingError> = serde_json::from_str(&local_var_content).ok();
755        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
756        Err(Error::ResponseError(local_var_error))
757    }
758}
759
760/// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of recording sid to reference current active recording.
761pub async fn update_call_recording(configuration: &configuration::Configuration, params: UpdateCallRecordingParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodCallPeriodCallRecording, Error<UpdateCallRecordingError>> {
762    let local_var_configuration = configuration;
763
764    // unbox the parameters
765    let account_sid = params.account_sid;
766    let call_sid = params.call_sid;
767    let sid = params.sid;
768    let status = params.status;
769    let pause_behavior = params.pause_behavior;
770
771
772    let local_var_client = &local_var_configuration.client;
773
774    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), CallSid=crate::apis::urlencode(call_sid), Sid=crate::apis::urlencode(sid));
775    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
776
777    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
778        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
779    }
780    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
781        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
782    };
783    let mut local_var_form_params = std::collections::HashMap::new();
784    local_var_form_params.insert("Status", status.to_string());
785    if let Some(local_var_param_value) = pause_behavior {
786        local_var_form_params.insert("PauseBehavior", local_var_param_value.to_string());
787    }
788    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
789
790    let local_var_req = local_var_req_builder.build()?;
791    let local_var_resp = local_var_client.execute(local_var_req).await?;
792
793    let local_var_status = local_var_resp.status();
794    let local_var_content = local_var_resp.text().await?;
795
796    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
797        serde_json::from_str(&local_var_content).map_err(Error::from)
798    } else {
799        let local_var_entity: Option<UpdateCallRecordingError> = serde_json::from_str(&local_var_content).ok();
800        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
801        Err(Error::ResponseError(local_var_error))
802    }
803}
804
805/// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as recording sid.
806pub async fn update_conference_recording(configuration: &configuration::Configuration, params: UpdateConferenceRecordingParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodConferencePeriodConferenceRecording, Error<UpdateConferenceRecordingError>> {
807    let local_var_configuration = configuration;
808
809    // unbox the parameters
810    let account_sid = params.account_sid;
811    let conference_sid = params.conference_sid;
812    let sid = params.sid;
813    let status = params.status;
814    let pause_behavior = params.pause_behavior;
815
816
817    let local_var_client = &local_var_configuration.client;
818
819    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Recordings/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid), Sid=crate::apis::urlencode(sid));
820    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
821
822    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
823        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
824    }
825    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
826        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
827    };
828    let mut local_var_form_params = std::collections::HashMap::new();
829    local_var_form_params.insert("Status", status.to_string());
830    if let Some(local_var_param_value) = pause_behavior {
831        local_var_form_params.insert("PauseBehavior", local_var_param_value.to_string());
832    }
833    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
834
835    let local_var_req = local_var_req_builder.build()?;
836    let local_var_resp = local_var_client.execute(local_var_req).await?;
837
838    let local_var_status = local_var_resp.status();
839    let local_var_content = local_var_resp.text().await?;
840
841    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
842        serde_json::from_str(&local_var_content).map_err(Error::from)
843    } else {
844        let local_var_entity: Option<UpdateConferenceRecordingError> = serde_json::from_str(&local_var_content).ok();
845        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
846        Err(Error::ResponseError(local_var_error))
847    }
848}
849