vapi_client/apis/
squads_api.rs

1/*
2 * Vapi API
3 *
4 * Voice AI for developers.
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`squad_controller_create`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum SquadControllerCreateError {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`squad_controller_find_all`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum SquadControllerFindAllError {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`squad_controller_find_one`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum SquadControllerFindOneError {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`squad_controller_remove`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum SquadControllerRemoveError {
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`squad_controller_update`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum SquadControllerUpdateError {
48    UnknownValue(serde_json::Value),
49}
50
51pub async fn squad_controller_create(
52    configuration: &configuration::Configuration,
53    create_squad_dto: models::CreateSquadDto,
54) -> Result<models::Squad, Error<SquadControllerCreateError>> {
55    // add a prefix to parameters to efficiently prevent name collisions
56    let p_create_squad_dto = create_squad_dto;
57
58    let uri_str = format!("{}/squad", 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_squad_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::Squad`"))),
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::Squad`")))),
88        }
89    } else {
90        let content = resp.text().await?;
91        let entity: Option<SquadControllerCreateError> = serde_json::from_str(&content).ok();
92        Err(Error::ResponseError(ResponseContent {
93            status,
94            content,
95            entity,
96        }))
97    }
98}
99
100pub async fn squad_controller_find_all(
101    configuration: &configuration::Configuration,
102    limit: Option<f64>,
103    created_at_gt: Option<String>,
104    created_at_lt: Option<String>,
105    created_at_ge: Option<String>,
106    created_at_le: Option<String>,
107    updated_at_gt: Option<String>,
108    updated_at_lt: Option<String>,
109    updated_at_ge: Option<String>,
110    updated_at_le: Option<String>,
111) -> Result<Vec<models::Squad>, Error<SquadControllerFindAllError>> {
112    // add a prefix to parameters to efficiently prevent name collisions
113    let p_limit = limit;
114    let p_created_at_gt = created_at_gt;
115    let p_created_at_lt = created_at_lt;
116    let p_created_at_ge = created_at_ge;
117    let p_created_at_le = created_at_le;
118    let p_updated_at_gt = updated_at_gt;
119    let p_updated_at_lt = updated_at_lt;
120    let p_updated_at_ge = updated_at_ge;
121    let p_updated_at_le = updated_at_le;
122
123    let uri_str = format!("{}/squad", configuration.base_path);
124    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
125
126    if let Some(ref param_value) = p_limit {
127        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
128    }
129    if let Some(ref param_value) = p_created_at_gt {
130        req_builder = req_builder.query(&[("createdAtGt", &param_value.to_string())]);
131    }
132    if let Some(ref param_value) = p_created_at_lt {
133        req_builder = req_builder.query(&[("createdAtLt", &param_value.to_string())]);
134    }
135    if let Some(ref param_value) = p_created_at_ge {
136        req_builder = req_builder.query(&[("createdAtGe", &param_value.to_string())]);
137    }
138    if let Some(ref param_value) = p_created_at_le {
139        req_builder = req_builder.query(&[("createdAtLe", &param_value.to_string())]);
140    }
141    if let Some(ref param_value) = p_updated_at_gt {
142        req_builder = req_builder.query(&[("updatedAtGt", &param_value.to_string())]);
143    }
144    if let Some(ref param_value) = p_updated_at_lt {
145        req_builder = req_builder.query(&[("updatedAtLt", &param_value.to_string())]);
146    }
147    if let Some(ref param_value) = p_updated_at_ge {
148        req_builder = req_builder.query(&[("updatedAtGe", &param_value.to_string())]);
149    }
150    if let Some(ref param_value) = p_updated_at_le {
151        req_builder = req_builder.query(&[("updatedAtLe", &param_value.to_string())]);
152    }
153    if let Some(ref user_agent) = configuration.user_agent {
154        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155    }
156    if let Some(ref token) = configuration.bearer_access_token {
157        req_builder = req_builder.bearer_auth(token.to_owned());
158    };
159
160    let req = req_builder.build()?;
161    let resp = configuration.client.execute(req).await?;
162
163    let status = resp.status();
164    let content_type = resp
165        .headers()
166        .get("content-type")
167        .and_then(|v| v.to_str().ok())
168        .unwrap_or("application/octet-stream");
169    let content_type = super::ContentType::from(content_type);
170
171    if !status.is_client_error() && !status.is_server_error() {
172        let content = resp.text().await?;
173        match content_type {
174            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
175            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Squad&gt;`"))),
176            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&lt;models::Squad&gt;`")))),
177        }
178    } else {
179        let content = resp.text().await?;
180        let entity: Option<SquadControllerFindAllError> = serde_json::from_str(&content).ok();
181        Err(Error::ResponseError(ResponseContent {
182            status,
183            content,
184            entity,
185        }))
186    }
187}
188
189pub async fn squad_controller_find_one(
190    configuration: &configuration::Configuration,
191    id: &str,
192) -> Result<models::Squad, Error<SquadControllerFindOneError>> {
193    // add a prefix to parameters to efficiently prevent name collisions
194    let p_id = id;
195
196    let uri_str = format!(
197        "{}/squad/{id}",
198        configuration.base_path,
199        id = crate::apis::urlencode(p_id)
200    );
201    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
202
203    if let Some(ref user_agent) = configuration.user_agent {
204        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
205    }
206    if let Some(ref token) = configuration.bearer_access_token {
207        req_builder = req_builder.bearer_auth(token.to_owned());
208    };
209
210    let req = req_builder.build()?;
211    let resp = configuration.client.execute(req).await?;
212
213    let status = resp.status();
214    let content_type = resp
215        .headers()
216        .get("content-type")
217        .and_then(|v| v.to_str().ok())
218        .unwrap_or("application/octet-stream");
219    let content_type = super::ContentType::from(content_type);
220
221    if !status.is_client_error() && !status.is_server_error() {
222        let content = resp.text().await?;
223        match content_type {
224            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
225            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Squad`"))),
226            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::Squad`")))),
227        }
228    } else {
229        let content = resp.text().await?;
230        let entity: Option<SquadControllerFindOneError> = serde_json::from_str(&content).ok();
231        Err(Error::ResponseError(ResponseContent {
232            status,
233            content,
234            entity,
235        }))
236    }
237}
238
239pub async fn squad_controller_remove(
240    configuration: &configuration::Configuration,
241    id: &str,
242) -> Result<models::Squad, Error<SquadControllerRemoveError>> {
243    // add a prefix to parameters to efficiently prevent name collisions
244    let p_id = id;
245
246    let uri_str = format!(
247        "{}/squad/{id}",
248        configuration.base_path,
249        id = crate::apis::urlencode(p_id)
250    );
251    let mut req_builder = configuration
252        .client
253        .request(reqwest::Method::DELETE, &uri_str);
254
255    if let Some(ref user_agent) = configuration.user_agent {
256        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
257    }
258    if let Some(ref token) = configuration.bearer_access_token {
259        req_builder = req_builder.bearer_auth(token.to_owned());
260    };
261
262    let req = req_builder.build()?;
263    let resp = configuration.client.execute(req).await?;
264
265    let status = resp.status();
266    let content_type = resp
267        .headers()
268        .get("content-type")
269        .and_then(|v| v.to_str().ok())
270        .unwrap_or("application/octet-stream");
271    let content_type = super::ContentType::from(content_type);
272
273    if !status.is_client_error() && !status.is_server_error() {
274        let content = resp.text().await?;
275        match content_type {
276            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
277            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Squad`"))),
278            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::Squad`")))),
279        }
280    } else {
281        let content = resp.text().await?;
282        let entity: Option<SquadControllerRemoveError> = serde_json::from_str(&content).ok();
283        Err(Error::ResponseError(ResponseContent {
284            status,
285            content,
286            entity,
287        }))
288    }
289}
290
291pub async fn squad_controller_update(
292    configuration: &configuration::Configuration,
293    id: &str,
294    update_squad_dto: models::UpdateSquadDto,
295) -> Result<models::Squad, Error<SquadControllerUpdateError>> {
296    // add a prefix to parameters to efficiently prevent name collisions
297    let p_id = id;
298    let p_update_squad_dto = update_squad_dto;
299
300    let uri_str = format!(
301        "{}/squad/{id}",
302        configuration.base_path,
303        id = crate::apis::urlencode(p_id)
304    );
305    let mut req_builder = configuration
306        .client
307        .request(reqwest::Method::PATCH, &uri_str);
308
309    if let Some(ref user_agent) = configuration.user_agent {
310        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
311    }
312    if let Some(ref token) = configuration.bearer_access_token {
313        req_builder = req_builder.bearer_auth(token.to_owned());
314    };
315    req_builder = req_builder.json(&p_update_squad_dto);
316
317    let req = req_builder.build()?;
318    let resp = configuration.client.execute(req).await?;
319
320    let status = resp.status();
321    let content_type = resp
322        .headers()
323        .get("content-type")
324        .and_then(|v| v.to_str().ok())
325        .unwrap_or("application/octet-stream");
326    let content_type = super::ContentType::from(content_type);
327
328    if !status.is_client_error() && !status.is_server_error() {
329        let content = resp.text().await?;
330        match content_type {
331            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
332            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Squad`"))),
333            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::Squad`")))),
334        }
335    } else {
336        let content = resp.text().await?;
337        let entity: Option<SquadControllerUpdateError> = serde_json::from_str(&content).ok();
338        Err(Error::ResponseError(ResponseContent {
339            status,
340            content,
341            entity,
342        }))
343    }
344}