twilio_rust_openapi/apis/
api20100401_add_on_result_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 [`delete_recording_add_on_result`]
18#[derive(Clone, Debug)]
19pub struct DeleteRecordingAddOnResultParams {
20    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording AddOnResult resources to delete.
21    pub account_sid: String,
22    /// The SID of the recording to which the result to delete belongs.
23    pub reference_sid: String,
24    /// The Twilio-provided string that uniquely identifies the Recording AddOnResult resource to delete.
25    pub sid: String
26}
27
28/// struct for passing parameters to the method [`fetch_recording_add_on_result`]
29#[derive(Clone, Debug)]
30pub struct FetchRecordingAddOnResultParams {
31    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording AddOnResult resource to fetch.
32    pub account_sid: String,
33    /// The SID of the recording to which the result to fetch belongs.
34    pub reference_sid: String,
35    /// The Twilio-provided string that uniquely identifies the Recording AddOnResult resource to fetch.
36    pub sid: String
37}
38
39/// struct for passing parameters to the method [`list_recording_add_on_result`]
40#[derive(Clone, Debug)]
41pub struct ListRecordingAddOnResultParams {
42    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording AddOnResult resources to read.
43    pub account_sid: String,
44    /// The SID of the recording to which the result to read belongs.
45    pub reference_sid: String,
46    /// How many resources to return in each list page. The default is 50, and the maximum is 1000.
47    pub page_size: Option<i32>,
48    /// The page index. This value is simply for client state.
49    pub page: Option<i32>,
50    /// The page token. This is provided by the API.
51    pub page_token: Option<String>
52}
53
54
55/// struct for typed errors of method [`delete_recording_add_on_result`]
56#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum DeleteRecordingAddOnResultError {
59    UnknownValue(serde_json::Value),
60}
61
62/// struct for typed errors of method [`fetch_recording_add_on_result`]
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum FetchRecordingAddOnResultError {
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`list_recording_add_on_result`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum ListRecordingAddOnResultError {
73    UnknownValue(serde_json::Value),
74}
75
76
77/// Delete a result and purge all associated Payloads
78pub async fn delete_recording_add_on_result(configuration: &configuration::Configuration, params: DeleteRecordingAddOnResultParams) -> Result<(), Error<DeleteRecordingAddOnResultError>> {
79    let local_var_configuration = configuration;
80
81    // unbox the parameters
82    let account_sid = params.account_sid;
83    let reference_sid = params.reference_sid;
84    let sid = params.sid;
85
86
87    let local_var_client = &local_var_configuration.client;
88
89    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Recordings/{ReferenceSid}/AddOnResults/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ReferenceSid=crate::apis::urlencode(reference_sid), Sid=crate::apis::urlencode(sid));
90    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
91
92    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
93        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
94    }
95    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
96        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
97    };
98
99    let local_var_req = local_var_req_builder.build()?;
100    let local_var_resp = local_var_client.execute(local_var_req).await?;
101
102    let local_var_status = local_var_resp.status();
103    let local_var_content = local_var_resp.text().await?;
104
105    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
106        Ok(())
107    } else {
108        let local_var_entity: Option<DeleteRecordingAddOnResultError> = serde_json::from_str(&local_var_content).ok();
109        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
110        Err(Error::ResponseError(local_var_error))
111    }
112}
113
114/// Fetch an instance of an AddOnResult
115pub async fn fetch_recording_add_on_result(configuration: &configuration::Configuration, params: FetchRecordingAddOnResultParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodRecordingPeriodRecordingAddOnResult, Error<FetchRecordingAddOnResultError>> {
116    let local_var_configuration = configuration;
117
118    // unbox the parameters
119    let account_sid = params.account_sid;
120    let reference_sid = params.reference_sid;
121    let sid = params.sid;
122
123
124    let local_var_client = &local_var_configuration.client;
125
126    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Recordings/{ReferenceSid}/AddOnResults/{Sid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ReferenceSid=crate::apis::urlencode(reference_sid), Sid=crate::apis::urlencode(sid));
127    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
128
129    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
130        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
131    }
132    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
133        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
134    };
135
136    let local_var_req = local_var_req_builder.build()?;
137    let local_var_resp = local_var_client.execute(local_var_req).await?;
138
139    let local_var_status = local_var_resp.status();
140    let local_var_content = local_var_resp.text().await?;
141
142    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
143        serde_json::from_str(&local_var_content).map_err(Error::from)
144    } else {
145        let local_var_entity: Option<FetchRecordingAddOnResultError> = serde_json::from_str(&local_var_content).ok();
146        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
147        Err(Error::ResponseError(local_var_error))
148    }
149}
150
151/// Retrieve a list of results belonging to the recording
152pub async fn list_recording_add_on_result(configuration: &configuration::Configuration, params: ListRecordingAddOnResultParams) -> Result<models::ListRecordingAddOnResultResponse, Error<ListRecordingAddOnResultError>> {
153    let local_var_configuration = configuration;
154
155    // unbox the parameters
156    let account_sid = params.account_sid;
157    let reference_sid = params.reference_sid;
158    let page_size = params.page_size;
159    let page = params.page;
160    let page_token = params.page_token;
161
162
163    let local_var_client = &local_var_configuration.client;
164
165    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Recordings/{ReferenceSid}/AddOnResults.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ReferenceSid=crate::apis::urlencode(reference_sid));
166    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
167
168    if let Some(ref local_var_str) = page_size {
169        local_var_req_builder = local_var_req_builder.query(&[("PageSize", &local_var_str.to_string())]);
170    }
171    if let Some(ref local_var_str) = page {
172        local_var_req_builder = local_var_req_builder.query(&[("Page", &local_var_str.to_string())]);
173    }
174    if let Some(ref local_var_str) = page_token {
175        local_var_req_builder = local_var_req_builder.query(&[("PageToken", &local_var_str.to_string())]);
176    }
177    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
178        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
179    }
180    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
181        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
182    };
183
184    let local_var_req = local_var_req_builder.build()?;
185    let local_var_resp = local_var_client.execute(local_var_req).await?;
186
187    let local_var_status = local_var_resp.status();
188    let local_var_content = local_var_resp.text().await?;
189
190    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
191        serde_json::from_str(&local_var_content).map_err(Error::from)
192    } else {
193        let local_var_entity: Option<ListRecordingAddOnResultError> = serde_json::from_str(&local_var_content).ok();
194        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
195        Err(Error::ResponseError(local_var_error))
196    }
197}
198