1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum AuthRequestsAdminRequestPostError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum AuthRequestsGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum AuthRequestsIdGetError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum AuthRequestsIdPutError {
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum AuthRequestsIdResponseGetError {
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum AuthRequestsPostError {
56 UnknownValue(serde_json::Value),
57}
58
59pub async fn auth_requests_admin_request_post(
60 configuration: &configuration::Configuration,
61 auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
62) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsAdminRequestPostError>> {
63 let p_auth_request_create_request_model = auth_request_create_request_model;
65
66 let uri_str = format!("{}/auth-requests/admin-request", configuration.base_path);
67 let mut req_builder = configuration
68 .client
69 .request(reqwest::Method::POST, &uri_str);
70
71 if let Some(ref user_agent) = configuration.user_agent {
72 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
73 }
74 if let Some(ref token) = configuration.oauth_access_token {
75 req_builder = req_builder.bearer_auth(token.to_owned());
76 };
77 req_builder = req_builder.json(&p_auth_request_create_request_model);
78
79 let req = req_builder.build()?;
80 let resp = configuration.client.execute(req).await?;
81
82 let status = resp.status();
83 let content_type = resp
84 .headers()
85 .get("content-type")
86 .and_then(|v| v.to_str().ok())
87 .unwrap_or("application/octet-stream");
88 let content_type = super::ContentType::from(content_type);
89
90 if !status.is_client_error() && !status.is_server_error() {
91 let content = resp.text().await?;
92 match content_type {
93 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
94 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
95 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::AuthRequestResponseModel`")))),
96 }
97 } else {
98 let content = resp.text().await?;
99 let entity: Option<AuthRequestsAdminRequestPostError> = serde_json::from_str(&content).ok();
100 Err(Error::ResponseError(ResponseContent {
101 status,
102 content,
103 entity,
104 }))
105 }
106}
107
108pub async fn auth_requests_get(
109 configuration: &configuration::Configuration,
110) -> Result<models::AuthRequestResponseModelListResponseModel, Error<AuthRequestsGetError>> {
111 let uri_str = format!("{}/auth-requests", configuration.base_path);
112 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
113
114 if let Some(ref user_agent) = configuration.user_agent {
115 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116 }
117 if let Some(ref token) = configuration.oauth_access_token {
118 req_builder = req_builder.bearer_auth(token.to_owned());
119 };
120
121 let req = req_builder.build()?;
122 let resp = configuration.client.execute(req).await?;
123
124 let status = resp.status();
125 let content_type = resp
126 .headers()
127 .get("content-type")
128 .and_then(|v| v.to_str().ok())
129 .unwrap_or("application/octet-stream");
130 let content_type = super::ContentType::from(content_type);
131
132 if !status.is_client_error() && !status.is_server_error() {
133 let content = resp.text().await?;
134 match content_type {
135 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
136 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModelListResponseModel`"))),
137 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::AuthRequestResponseModelListResponseModel`")))),
138 }
139 } else {
140 let content = resp.text().await?;
141 let entity: Option<AuthRequestsGetError> = serde_json::from_str(&content).ok();
142 Err(Error::ResponseError(ResponseContent {
143 status,
144 content,
145 entity,
146 }))
147 }
148}
149
150pub async fn auth_requests_id_get(
151 configuration: &configuration::Configuration,
152 id: uuid::Uuid,
153) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdGetError>> {
154 let p_id = id;
156
157 let uri_str = format!(
158 "{}/auth-requests/{id}",
159 configuration.base_path,
160 id = crate::apis::urlencode(p_id.to_string())
161 );
162 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
163
164 if let Some(ref user_agent) = configuration.user_agent {
165 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
166 }
167 if let Some(ref token) = configuration.oauth_access_token {
168 req_builder = req_builder.bearer_auth(token.to_owned());
169 };
170
171 let req = req_builder.build()?;
172 let resp = configuration.client.execute(req).await?;
173
174 let status = resp.status();
175 let content_type = resp
176 .headers()
177 .get("content-type")
178 .and_then(|v| v.to_str().ok())
179 .unwrap_or("application/octet-stream");
180 let content_type = super::ContentType::from(content_type);
181
182 if !status.is_client_error() && !status.is_server_error() {
183 let content = resp.text().await?;
184 match content_type {
185 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
187 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::AuthRequestResponseModel`")))),
188 }
189 } else {
190 let content = resp.text().await?;
191 let entity: Option<AuthRequestsIdGetError> = serde_json::from_str(&content).ok();
192 Err(Error::ResponseError(ResponseContent {
193 status,
194 content,
195 entity,
196 }))
197 }
198}
199
200pub async fn auth_requests_id_put(
201 configuration: &configuration::Configuration,
202 id: uuid::Uuid,
203 auth_request_update_request_model: Option<models::AuthRequestUpdateRequestModel>,
204) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdPutError>> {
205 let p_id = id;
207 let p_auth_request_update_request_model = auth_request_update_request_model;
208
209 let uri_str = format!(
210 "{}/auth-requests/{id}",
211 configuration.base_path,
212 id = crate::apis::urlencode(p_id.to_string())
213 );
214 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
215
216 if let Some(ref user_agent) = configuration.user_agent {
217 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
218 }
219 if let Some(ref token) = configuration.oauth_access_token {
220 req_builder = req_builder.bearer_auth(token.to_owned());
221 };
222 req_builder = req_builder.json(&p_auth_request_update_request_model);
223
224 let req = req_builder.build()?;
225 let resp = configuration.client.execute(req).await?;
226
227 let status = resp.status();
228 let content_type = resp
229 .headers()
230 .get("content-type")
231 .and_then(|v| v.to_str().ok())
232 .unwrap_or("application/octet-stream");
233 let content_type = super::ContentType::from(content_type);
234
235 if !status.is_client_error() && !status.is_server_error() {
236 let content = resp.text().await?;
237 match content_type {
238 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
239 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
240 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::AuthRequestResponseModel`")))),
241 }
242 } else {
243 let content = resp.text().await?;
244 let entity: Option<AuthRequestsIdPutError> = serde_json::from_str(&content).ok();
245 Err(Error::ResponseError(ResponseContent {
246 status,
247 content,
248 entity,
249 }))
250 }
251}
252
253pub async fn auth_requests_id_response_get(
254 configuration: &configuration::Configuration,
255 id: uuid::Uuid,
256 code: Option<&str>,
257) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdResponseGetError>> {
258 let p_id = id;
260 let p_code = code;
261
262 let uri_str = format!(
263 "{}/auth-requests/{id}/response",
264 configuration.base_path,
265 id = crate::apis::urlencode(p_id.to_string())
266 );
267 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
268
269 if let Some(ref param_value) = p_code {
270 req_builder = req_builder.query(&[("code", ¶m_value.to_string())]);
271 }
272 if let Some(ref user_agent) = configuration.user_agent {
273 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
274 }
275 if let Some(ref token) = configuration.oauth_access_token {
276 req_builder = req_builder.bearer_auth(token.to_owned());
277 };
278
279 let req = req_builder.build()?;
280 let resp = configuration.client.execute(req).await?;
281
282 let status = resp.status();
283 let content_type = resp
284 .headers()
285 .get("content-type")
286 .and_then(|v| v.to_str().ok())
287 .unwrap_or("application/octet-stream");
288 let content_type = super::ContentType::from(content_type);
289
290 if !status.is_client_error() && !status.is_server_error() {
291 let content = resp.text().await?;
292 match content_type {
293 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
294 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
295 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::AuthRequestResponseModel`")))),
296 }
297 } else {
298 let content = resp.text().await?;
299 let entity: Option<AuthRequestsIdResponseGetError> = serde_json::from_str(&content).ok();
300 Err(Error::ResponseError(ResponseContent {
301 status,
302 content,
303 entity,
304 }))
305 }
306}
307
308pub async fn auth_requests_post(
309 configuration: &configuration::Configuration,
310 auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
311) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsPostError>> {
312 let p_auth_request_create_request_model = auth_request_create_request_model;
314
315 let uri_str = format!("{}/auth-requests", configuration.base_path);
316 let mut req_builder = configuration
317 .client
318 .request(reqwest::Method::POST, &uri_str);
319
320 if let Some(ref user_agent) = configuration.user_agent {
321 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
322 }
323 if let Some(ref token) = configuration.oauth_access_token {
324 req_builder = req_builder.bearer_auth(token.to_owned());
325 };
326 req_builder = req_builder.json(&p_auth_request_create_request_model);
327
328 let req = req_builder.build()?;
329 let resp = configuration.client.execute(req).await?;
330
331 let status = resp.status();
332 let content_type = resp
333 .headers()
334 .get("content-type")
335 .and_then(|v| v.to_str().ok())
336 .unwrap_or("application/octet-stream");
337 let content_type = super::ContentType::from(content_type);
338
339 if !status.is_client_error() && !status.is_server_error() {
340 let content = resp.text().await?;
341 match content_type {
342 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
343 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
344 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::AuthRequestResponseModel`")))),
345 }
346 } else {
347 let content = resp.text().await?;
348 let entity: Option<AuthRequestsPostError> = serde_json::from_str(&content).ok();
349 Err(Error::ResponseError(ResponseContent {
350 status,
351 content,
352 entity,
353 }))
354 }
355}