1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CallControllerCreateError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum CallControllerDeleteCallDataError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum CallControllerFindAllError {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum CallControllerFindOneError {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum CallControllerUpdateError {
48 UnknownValue(serde_json::Value),
49}
50
51pub async fn call_controller_create(
52 configuration: &configuration::Configuration,
53 create_call_dto: models::CreateCallDto,
54) -> Result<models::CallControllerCreate201Response, Error<CallControllerCreateError>> {
55 let p_create_call_dto = create_call_dto;
57
58 let uri_str = format!("{}/call", configuration.base_path);
59 let mut req_builder = configuration
60 .client
61 .request(reqwest::Method::POST, &uri_str);
62
63 if let Some(ref user_agent) = configuration.user_agent {
64 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
65 }
66 if let Some(ref token) = configuration.bearer_access_token {
67 req_builder = req_builder.bearer_auth(token.to_owned());
68 };
69 req_builder = req_builder.json(&p_create_call_dto);
70
71 let req = req_builder.build()?;
72 let resp = configuration.client.execute(req).await?;
73
74 let status = resp.status();
75 let content_type = resp
76 .headers()
77 .get("content-type")
78 .and_then(|v| v.to_str().ok())
79 .unwrap_or("application/octet-stream");
80 let content_type = super::ContentType::from(content_type);
81
82 if !status.is_client_error() && !status.is_server_error() {
83 let content = resp.text().await?;
84 match content_type {
85 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
86 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CallControllerCreate201Response`"))),
87 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CallControllerCreate201Response`")))),
88 }
89 } else {
90 let content = resp.text().await?;
91 let entity: Option<CallControllerCreateError> = serde_json::from_str(&content).ok();
92 Err(Error::ResponseError(ResponseContent {
93 status,
94 content,
95 entity,
96 }))
97 }
98}
99
100pub async fn call_controller_delete_call_data(
101 configuration: &configuration::Configuration,
102 id: &str,
103) -> Result<models::Call, Error<CallControllerDeleteCallDataError>> {
104 let p_id = id;
106
107 let uri_str = format!(
108 "{}/call/{id}",
109 configuration.base_path,
110 id = crate::apis::urlencode(p_id)
111 );
112 let mut req_builder = configuration
113 .client
114 .request(reqwest::Method::DELETE, &uri_str);
115
116 if let Some(ref user_agent) = configuration.user_agent {
117 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
118 }
119 if let Some(ref token) = configuration.bearer_access_token {
120 req_builder = req_builder.bearer_auth(token.to_owned());
121 };
122
123 let req = req_builder.build()?;
124 let resp = configuration.client.execute(req).await?;
125
126 let status = resp.status();
127 let content_type = resp
128 .headers()
129 .get("content-type")
130 .and_then(|v| v.to_str().ok())
131 .unwrap_or("application/octet-stream");
132 let content_type = super::ContentType::from(content_type);
133
134 if !status.is_client_error() && !status.is_server_error() {
135 let content = resp.text().await?;
136 match content_type {
137 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
138 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Call`"))),
139 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Call`")))),
140 }
141 } else {
142 let content = resp.text().await?;
143 let entity: Option<CallControllerDeleteCallDataError> = serde_json::from_str(&content).ok();
144 Err(Error::ResponseError(ResponseContent {
145 status,
146 content,
147 entity,
148 }))
149 }
150}
151
152pub async fn call_controller_find_all(
153 configuration: &configuration::Configuration,
154 id: Option<&str>,
155 assistant_id: Option<&str>,
156 phone_number_id: Option<&str>,
157 limit: Option<f64>,
158 created_at_gt: Option<String>,
159 created_at_lt: Option<String>,
160 created_at_ge: Option<String>,
161 created_at_le: Option<String>,
162 updated_at_gt: Option<String>,
163 updated_at_lt: Option<String>,
164 updated_at_ge: Option<String>,
165 updated_at_le: Option<String>,
166) -> Result<Vec<models::Call>, Error<CallControllerFindAllError>> {
167 let p_id = id;
169 let p_assistant_id = assistant_id;
170 let p_phone_number_id = phone_number_id;
171 let p_limit = limit;
172 let p_created_at_gt = created_at_gt;
173 let p_created_at_lt = created_at_lt;
174 let p_created_at_ge = created_at_ge;
175 let p_created_at_le = created_at_le;
176 let p_updated_at_gt = updated_at_gt;
177 let p_updated_at_lt = updated_at_lt;
178 let p_updated_at_ge = updated_at_ge;
179 let p_updated_at_le = updated_at_le;
180
181 let uri_str = format!("{}/call", configuration.base_path);
182 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
183
184 if let Some(ref param_value) = p_id {
185 req_builder = req_builder.query(&[("id", ¶m_value.to_string())]);
186 }
187 if let Some(ref param_value) = p_assistant_id {
188 req_builder = req_builder.query(&[("assistantId", ¶m_value.to_string())]);
189 }
190 if let Some(ref param_value) = p_phone_number_id {
191 req_builder = req_builder.query(&[("phoneNumberId", ¶m_value.to_string())]);
192 }
193 if let Some(ref param_value) = p_limit {
194 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
195 }
196 if let Some(ref param_value) = p_created_at_gt {
197 req_builder = req_builder.query(&[("createdAtGt", ¶m_value.to_string())]);
198 }
199 if let Some(ref param_value) = p_created_at_lt {
200 req_builder = req_builder.query(&[("createdAtLt", ¶m_value.to_string())]);
201 }
202 if let Some(ref param_value) = p_created_at_ge {
203 req_builder = req_builder.query(&[("createdAtGe", ¶m_value.to_string())]);
204 }
205 if let Some(ref param_value) = p_created_at_le {
206 req_builder = req_builder.query(&[("createdAtLe", ¶m_value.to_string())]);
207 }
208 if let Some(ref param_value) = p_updated_at_gt {
209 req_builder = req_builder.query(&[("updatedAtGt", ¶m_value.to_string())]);
210 }
211 if let Some(ref param_value) = p_updated_at_lt {
212 req_builder = req_builder.query(&[("updatedAtLt", ¶m_value.to_string())]);
213 }
214 if let Some(ref param_value) = p_updated_at_ge {
215 req_builder = req_builder.query(&[("updatedAtGe", ¶m_value.to_string())]);
216 }
217 if let Some(ref param_value) = p_updated_at_le {
218 req_builder = req_builder.query(&[("updatedAtLe", ¶m_value.to_string())]);
219 }
220 if let Some(ref user_agent) = configuration.user_agent {
221 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
222 }
223 if let Some(ref token) = configuration.bearer_access_token {
224 req_builder = req_builder.bearer_auth(token.to_owned());
225 };
226
227 let req = req_builder.build()?;
228 let resp = configuration.client.execute(req).await?;
229
230 let status = resp.status();
231 let content_type = resp
232 .headers()
233 .get("content-type")
234 .and_then(|v| v.to_str().ok())
235 .unwrap_or("application/octet-stream");
236 let content_type = super::ContentType::from(content_type);
237
238 if !status.is_client_error() && !status.is_server_error() {
239 let content = resp.text().await?;
240 match content_type {
241 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
242 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Call>`"))),
243 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Call>`")))),
244 }
245 } else {
246 let content = resp.text().await?;
247 let entity: Option<CallControllerFindAllError> = serde_json::from_str(&content).ok();
248 Err(Error::ResponseError(ResponseContent {
249 status,
250 content,
251 entity,
252 }))
253 }
254}
255
256pub async fn call_controller_find_one(
257 configuration: &configuration::Configuration,
258 id: &str,
259) -> Result<models::Call, Error<CallControllerFindOneError>> {
260 let p_id = id;
262
263 let uri_str = format!(
264 "{}/call/{id}",
265 configuration.base_path,
266 id = crate::apis::urlencode(p_id)
267 );
268 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
269
270 if let Some(ref user_agent) = configuration.user_agent {
271 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
272 }
273 if let Some(ref token) = configuration.bearer_access_token {
274 req_builder = req_builder.bearer_auth(token.to_owned());
275 };
276
277 let req = req_builder.build()?;
278 let resp = configuration.client.execute(req).await?;
279
280 let status = resp.status();
281 let content_type = resp
282 .headers()
283 .get("content-type")
284 .and_then(|v| v.to_str().ok())
285 .unwrap_or("application/octet-stream");
286 let content_type = super::ContentType::from(content_type);
287
288 if !status.is_client_error() && !status.is_server_error() {
289 let content = resp.text().await?;
290 match content_type {
291 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
292 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Call`"))),
293 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Call`")))),
294 }
295 } else {
296 let content = resp.text().await?;
297 let entity: Option<CallControllerFindOneError> = serde_json::from_str(&content).ok();
298 Err(Error::ResponseError(ResponseContent {
299 status,
300 content,
301 entity,
302 }))
303 }
304}
305
306pub async fn call_controller_update(
307 configuration: &configuration::Configuration,
308 id: &str,
309 update_call_dto: models::UpdateCallDto,
310) -> Result<models::Call, Error<CallControllerUpdateError>> {
311 let p_id = id;
313 let p_update_call_dto = update_call_dto;
314
315 let uri_str = format!(
316 "{}/call/{id}",
317 configuration.base_path,
318 id = crate::apis::urlencode(p_id)
319 );
320 let mut req_builder = configuration
321 .client
322 .request(reqwest::Method::PATCH, &uri_str);
323
324 if let Some(ref user_agent) = configuration.user_agent {
325 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
326 }
327 if let Some(ref token) = configuration.bearer_access_token {
328 req_builder = req_builder.bearer_auth(token.to_owned());
329 };
330 req_builder = req_builder.json(&p_update_call_dto);
331
332 let req = req_builder.build()?;
333 let resp = configuration.client.execute(req).await?;
334
335 let status = resp.status();
336 let content_type = resp
337 .headers()
338 .get("content-type")
339 .and_then(|v| v.to_str().ok())
340 .unwrap_or("application/octet-stream");
341 let content_type = super::ContentType::from(content_type);
342
343 if !status.is_client_error() && !status.is_server_error() {
344 let content = resp.text().await?;
345 match content_type {
346 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
347 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Call`"))),
348 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Call`")))),
349 }
350 } else {
351 let content = resp.text().await?;
352 let entity: Option<CallControllerUpdateError> = serde_json::from_str(&content).ok();
353 Err(Error::ResponseError(ResponseContent {
354 status,
355 content,
356 entity,
357 }))
358 }
359}