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
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`squad_controller_create`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum SquadControllerCreateError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`squad_controller_find_all`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum SquadControllerFindAllError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`squad_controller_find_one`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum SquadControllerFindOneError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`squad_controller_remove`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum SquadControllerRemoveError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`squad_controller_update`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum SquadControllerUpdateError {
50    UnknownValue(serde_json::Value),
51}
52
53
54pub async fn squad_controller_create(configuration: &configuration::Configuration, create_squad_dto: models::CreateSquadDto) -> 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.client.request(reqwest::Method::POST, &uri_str);
60
61    if let Some(ref user_agent) = configuration.user_agent {
62        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
63    }
64    if let Some(ref token) = configuration.bearer_access_token {
65        req_builder = req_builder.bearer_auth(token.to_owned());
66    };
67    req_builder = req_builder.json(&p_create_squad_dto);
68
69    let req = req_builder.build()?;
70    let resp = configuration.client.execute(req).await?;
71
72    let status = resp.status();
73    let content_type = resp
74        .headers()
75        .get("content-type")
76        .and_then(|v| v.to_str().ok())
77        .unwrap_or("application/octet-stream");
78    let content_type = super::ContentType::from(content_type);
79
80    if !status.is_client_error() && !status.is_server_error() {
81        let content = resp.text().await?;
82        match content_type {
83            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
84            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Squad`"))),
85            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`")))),
86        }
87    } else {
88        let content = resp.text().await?;
89        let entity: Option<SquadControllerCreateError> = serde_json::from_str(&content).ok();
90        Err(Error::ResponseError(ResponseContent { status, content, entity }))
91    }
92}
93
94pub async fn squad_controller_find_all(configuration: &configuration::Configuration, limit: Option<f64>, created_at_gt: Option<String>, created_at_lt: Option<String>, created_at_ge: Option<String>, created_at_le: Option<String>, updated_at_gt: Option<String>, updated_at_lt: Option<String>, updated_at_ge: Option<String>, updated_at_le: Option<String>) -> Result<Vec<models::Squad>, Error<SquadControllerFindAllError>> {
95    // add a prefix to parameters to efficiently prevent name collisions
96    let p_limit = limit;
97    let p_created_at_gt = created_at_gt;
98    let p_created_at_lt = created_at_lt;
99    let p_created_at_ge = created_at_ge;
100    let p_created_at_le = created_at_le;
101    let p_updated_at_gt = updated_at_gt;
102    let p_updated_at_lt = updated_at_lt;
103    let p_updated_at_ge = updated_at_ge;
104    let p_updated_at_le = updated_at_le;
105
106    let uri_str = format!("{}/squad", configuration.base_path);
107    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
108
109    if let Some(ref param_value) = p_limit {
110        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
111    }
112    if let Some(ref param_value) = p_created_at_gt {
113        req_builder = req_builder.query(&[("createdAtGt", &param_value.to_string())]);
114    }
115    if let Some(ref param_value) = p_created_at_lt {
116        req_builder = req_builder.query(&[("createdAtLt", &param_value.to_string())]);
117    }
118    if let Some(ref param_value) = p_created_at_ge {
119        req_builder = req_builder.query(&[("createdAtGe", &param_value.to_string())]);
120    }
121    if let Some(ref param_value) = p_created_at_le {
122        req_builder = req_builder.query(&[("createdAtLe", &param_value.to_string())]);
123    }
124    if let Some(ref param_value) = p_updated_at_gt {
125        req_builder = req_builder.query(&[("updatedAtGt", &param_value.to_string())]);
126    }
127    if let Some(ref param_value) = p_updated_at_lt {
128        req_builder = req_builder.query(&[("updatedAtLt", &param_value.to_string())]);
129    }
130    if let Some(ref param_value) = p_updated_at_ge {
131        req_builder = req_builder.query(&[("updatedAtGe", &param_value.to_string())]);
132    }
133    if let Some(ref param_value) = p_updated_at_le {
134        req_builder = req_builder.query(&[("updatedAtLe", &param_value.to_string())]);
135    }
136    if let Some(ref user_agent) = configuration.user_agent {
137        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
138    }
139    if let Some(ref token) = configuration.bearer_access_token {
140        req_builder = req_builder.bearer_auth(token.to_owned());
141    };
142
143    let req = req_builder.build()?;
144    let resp = configuration.client.execute(req).await?;
145
146    let status = resp.status();
147    let content_type = resp
148        .headers()
149        .get("content-type")
150        .and_then(|v| v.to_str().ok())
151        .unwrap_or("application/octet-stream");
152    let content_type = super::ContentType::from(content_type);
153
154    if !status.is_client_error() && !status.is_server_error() {
155        let content = resp.text().await?;
156        match content_type {
157            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
158            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;`"))),
159            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;`")))),
160        }
161    } else {
162        let content = resp.text().await?;
163        let entity: Option<SquadControllerFindAllError> = serde_json::from_str(&content).ok();
164        Err(Error::ResponseError(ResponseContent { status, content, entity }))
165    }
166}
167
168pub async fn squad_controller_find_one(configuration: &configuration::Configuration, id: &str) -> Result<models::Squad, Error<SquadControllerFindOneError>> {
169    // add a prefix to parameters to efficiently prevent name collisions
170    let p_id = id;
171
172    let uri_str = format!("{}/squad/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
173    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
174
175    if let Some(ref user_agent) = configuration.user_agent {
176        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177    }
178    if let Some(ref token) = configuration.bearer_access_token {
179        req_builder = req_builder.bearer_auth(token.to_owned());
180    };
181
182    let req = req_builder.build()?;
183    let resp = configuration.client.execute(req).await?;
184
185    let status = resp.status();
186    let content_type = resp
187        .headers()
188        .get("content-type")
189        .and_then(|v| v.to_str().ok())
190        .unwrap_or("application/octet-stream");
191    let content_type = super::ContentType::from(content_type);
192
193    if !status.is_client_error() && !status.is_server_error() {
194        let content = resp.text().await?;
195        match content_type {
196            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
197            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Squad`"))),
198            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`")))),
199        }
200    } else {
201        let content = resp.text().await?;
202        let entity: Option<SquadControllerFindOneError> = serde_json::from_str(&content).ok();
203        Err(Error::ResponseError(ResponseContent { status, content, entity }))
204    }
205}
206
207pub async fn squad_controller_remove(configuration: &configuration::Configuration, id: &str) -> Result<models::Squad, Error<SquadControllerRemoveError>> {
208    // add a prefix to parameters to efficiently prevent name collisions
209    let p_id = id;
210
211    let uri_str = format!("{}/squad/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
212    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
213
214    if let Some(ref user_agent) = configuration.user_agent {
215        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
216    }
217    if let Some(ref token) = configuration.bearer_access_token {
218        req_builder = req_builder.bearer_auth(token.to_owned());
219    };
220
221    let req = req_builder.build()?;
222    let resp = configuration.client.execute(req).await?;
223
224    let status = resp.status();
225    let content_type = resp
226        .headers()
227        .get("content-type")
228        .and_then(|v| v.to_str().ok())
229        .unwrap_or("application/octet-stream");
230    let content_type = super::ContentType::from(content_type);
231
232    if !status.is_client_error() && !status.is_server_error() {
233        let content = resp.text().await?;
234        match content_type {
235            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
236            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Squad`"))),
237            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`")))),
238        }
239    } else {
240        let content = resp.text().await?;
241        let entity: Option<SquadControllerRemoveError> = serde_json::from_str(&content).ok();
242        Err(Error::ResponseError(ResponseContent { status, content, entity }))
243    }
244}
245
246pub async fn squad_controller_update(configuration: &configuration::Configuration, id: &str, update_squad_dto: models::UpdateSquadDto) -> Result<models::Squad, Error<SquadControllerUpdateError>> {
247    // add a prefix to parameters to efficiently prevent name collisions
248    let p_id = id;
249    let p_update_squad_dto = update_squad_dto;
250
251    let uri_str = format!("{}/squad/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
252    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
253
254    if let Some(ref user_agent) = configuration.user_agent {
255        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
256    }
257    if let Some(ref token) = configuration.bearer_access_token {
258        req_builder = req_builder.bearer_auth(token.to_owned());
259    };
260    req_builder = req_builder.json(&p_update_squad_dto);
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<SquadControllerUpdateError> = serde_json::from_str(&content).ok();
283        Err(Error::ResponseError(ResponseContent { status, content, entity }))
284    }
285}
286