1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteBookingsIdError {
22 Status400(models::Problem),
23 Status401(models::Problem),
24 Status403(models::Problem),
25 Status404(models::Problem),
26 Status406(models::Problem),
27 Status409(models::Problem),
28 Status415(models::Problem),
29 Status500(models::Problem),
30 Status501(models::Problem),
31 Status503(models::Problem),
32 DefaultResponse(models::Problem),
33 UnknownValue(serde_json::Value),
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum GetBookingsIdError {
40 Status400(models::Problem),
41 Status401(models::Problem),
42 Status403(models::Problem),
43 Status404(models::Problem),
44 Status406(models::Problem),
45 Status415(models::Problem),
46 Status500(models::Problem),
47 Status501(models::Problem),
48 Status503(models::Problem),
49 DefaultResponse(models::Problem),
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetBookingsIdHistoryError {
57 Status400(models::Problem),
58 Status401(models::Problem),
59 Status403(models::Problem),
60 Status404(models::Problem),
61 Status406(models::Problem),
62 Status415(models::Problem),
63 Status500(models::Problem),
64 Status501(models::Problem),
65 Status503(models::Problem),
66 DefaultResponse(models::Problem),
67 UnknownValue(serde_json::Value),
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum PostBookingCleanupError {
74 Status400(models::Problem),
75 Status401(models::Problem),
76 Status403(models::Problem),
77 Status404(models::Problem),
78 Status406(models::Problem),
79 Status415(models::Problem),
80 Status500(models::Problem),
81 Status501(models::Problem),
82 Status503(models::Problem),
83 DefaultResponse(models::Problem),
84 UnknownValue(serde_json::Value),
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
89#[serde(untagged)]
90pub enum PostBookingsError {
91 Status400(models::Problem),
92 Status401(models::Problem),
93 Status403(models::Problem),
94 Status404(models::Problem),
95 Status406(models::Problem),
96 Status415(models::Problem),
97 Status500(models::Problem),
98 Status501(models::Problem),
99 Status503(models::Problem),
100 DefaultResponse(models::Problem),
101 UnknownValue(serde_json::Value),
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum UpdateBookingError {
108 Status400(models::Problem),
109 Status401(models::Problem),
110 Status403(models::Problem),
111 Status404(models::Problem),
112 Status406(models::Problem),
113 Status409(models::Problem),
114 Status415(models::Problem),
115 Status500(models::Problem),
116 Status501(models::Problem),
117 Status503(models::Problem),
118 DefaultResponse(models::Problem),
119 UnknownValue(serde_json::Value),
120}
121
122
123pub async fn delete_bookings_id(configuration: &configuration::Configuration, booking_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>) -> Result<(), Error<DeleteBookingsIdError>> {
125 let p_path_booking_id = booking_id;
127 let p_header_requestor = requestor;
128 let p_header_accept_language = accept_language;
129 let p_header_traceparent = traceparent;
130 let p_header_tracestate = tracestate;
131
132 let uri_str = format!("{}/bookings/{bookingId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
133 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
134
135 if let Some(ref user_agent) = configuration.user_agent {
136 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
137 }
138 if let Some(param_value) = p_header_requestor {
139 req_builder = req_builder.header("Requestor", param_value.to_string());
140 }
141 if let Some(param_value) = p_header_accept_language {
142 req_builder = req_builder.header("Accept-Language", param_value.to_string());
143 }
144 if let Some(param_value) = p_header_traceparent {
145 req_builder = req_builder.header("traceparent", param_value.to_string());
146 }
147 if let Some(param_value) = p_header_tracestate {
148 req_builder = req_builder.header("tracestate", param_value.to_string());
149 }
150 if let Some(ref token) = configuration.oauth_access_token {
151 req_builder = req_builder.bearer_auth(token.to_owned());
152 };
153
154 let req = req_builder.build()?;
155 let resp = configuration.client.execute(req).await?;
156
157 let status = resp.status();
158
159 if !status.is_client_error() && !status.is_server_error() {
160 Ok(())
161 } else {
162 let content = resp.text().await?;
163 let entity: Option<DeleteBookingsIdError> = serde_json::from_str(&content).ok();
164 Err(Error::ResponseError(ResponseContent { status, content, entity }))
165 }
166}
167
168pub async fn get_bookings_id(configuration: &configuration::Configuration, booking_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>, embed: Option<Vec<models::BookingResponseContent>>) -> Result<models::BookingResponse, Error<GetBookingsIdError>> {
169 let p_path_booking_id = booking_id;
171 let p_header_requestor = requestor;
172 let p_header_accept_language = accept_language;
173 let p_header_traceparent = traceparent;
174 let p_header_tracestate = tracestate;
175 let p_header_x_accept_namespace = x_accept_namespace;
176 let p_query_embed = embed;
177
178 let uri_str = format!("{}/bookings/{bookingId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
179 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
180
181 if let Some(ref param_value) = p_query_embed {
182 req_builder = match "multi" {
183 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("embed".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
184 _ => req_builder.query(&[("embed", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
185 };
186 }
187 if let Some(ref user_agent) = configuration.user_agent {
188 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
189 }
190 if let Some(param_value) = p_header_requestor {
191 req_builder = req_builder.header("Requestor", param_value.to_string());
192 }
193 if let Some(param_value) = p_header_accept_language {
194 req_builder = req_builder.header("Accept-Language", param_value.to_string());
195 }
196 if let Some(param_value) = p_header_traceparent {
197 req_builder = req_builder.header("traceparent", param_value.to_string());
198 }
199 if let Some(param_value) = p_header_tracestate {
200 req_builder = req_builder.header("tracestate", param_value.to_string());
201 }
202 if let Some(param_value) = p_header_x_accept_namespace {
203 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
204 }
205 if let Some(ref token) = configuration.oauth_access_token {
206 req_builder = req_builder.bearer_auth(token.to_owned());
207 };
208
209 let req = req_builder.build()?;
210 let resp = configuration.client.execute(req).await?;
211
212 let status = resp.status();
213 let content_type = resp
214 .headers()
215 .get("content-type")
216 .and_then(|v| v.to_str().ok())
217 .unwrap_or("application/octet-stream");
218 let content_type = super::ContentType::from(content_type);
219
220 if !status.is_client_error() && !status.is_server_error() {
221 let content = resp.text().await?;
222 match content_type {
223 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
224 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BookingResponse`"))),
225 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::BookingResponse`")))),
226 }
227 } else {
228 let content = resp.text().await?;
229 let entity: Option<GetBookingsIdError> = serde_json::from_str(&content).ok();
230 Err(Error::ResponseError(ResponseContent { status, content, entity }))
231 }
232}
233
234pub async fn get_bookings_id_history(configuration: &configuration::Configuration, booking_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>) -> Result<models::BookingHistoryResponse, Error<GetBookingsIdHistoryError>> {
235 let p_path_booking_id = booking_id;
237 let p_header_requestor = requestor;
238 let p_header_accept_language = accept_language;
239 let p_header_traceparent = traceparent;
240 let p_header_tracestate = tracestate;
241
242 let uri_str = format!("{}/bookings/{bookingId}/history", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
243 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
244
245 if let Some(ref user_agent) = configuration.user_agent {
246 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
247 }
248 if let Some(param_value) = p_header_requestor {
249 req_builder = req_builder.header("Requestor", param_value.to_string());
250 }
251 if let Some(param_value) = p_header_accept_language {
252 req_builder = req_builder.header("Accept-Language", param_value.to_string());
253 }
254 if let Some(param_value) = p_header_traceparent {
255 req_builder = req_builder.header("traceparent", param_value.to_string());
256 }
257 if let Some(param_value) = p_header_tracestate {
258 req_builder = req_builder.header("tracestate", param_value.to_string());
259 }
260 if let Some(ref token) = configuration.oauth_access_token {
261 req_builder = req_builder.bearer_auth(token.to_owned());
262 };
263
264 let req = req_builder.build()?;
265 let resp = configuration.client.execute(req).await?;
266
267 let status = resp.status();
268 let content_type = resp
269 .headers()
270 .get("content-type")
271 .and_then(|v| v.to_str().ok())
272 .unwrap_or("application/octet-stream");
273 let content_type = super::ContentType::from(content_type);
274
275 if !status.is_client_error() && !status.is_server_error() {
276 let content = resp.text().await?;
277 match content_type {
278 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
279 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BookingHistoryResponse`"))),
280 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::BookingHistoryResponse`")))),
281 }
282 } else {
283 let content = resp.text().await?;
284 let entity: Option<GetBookingsIdHistoryError> = serde_json::from_str(&content).ok();
285 Err(Error::ResponseError(ResponseContent { status, content, entity }))
286 }
287}
288
289pub async fn post_booking_cleanup(configuration: &configuration::Configuration, booking_id: &str, booking_cleanup_request: models::BookingCleanupRequest, requestor: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>) -> Result<models::WarningCollection, Error<PostBookingCleanupError>> {
291 let p_path_booking_id = booking_id;
293 let p_body_booking_cleanup_request = booking_cleanup_request;
294 let p_header_requestor = requestor;
295 let p_header_traceparent = traceparent;
296 let p_header_tracestate = tracestate;
297 let p_header_idempotency_key = idempotency_key;
298
299 let uri_str = format!("{}/bookings/{bookingId}/cleanup", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
300 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
301
302 if let Some(ref user_agent) = configuration.user_agent {
303 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
304 }
305 if let Some(param_value) = p_header_requestor {
306 req_builder = req_builder.header("Requestor", param_value.to_string());
307 }
308 if let Some(param_value) = p_header_traceparent {
309 req_builder = req_builder.header("traceparent", param_value.to_string());
310 }
311 if let Some(param_value) = p_header_tracestate {
312 req_builder = req_builder.header("tracestate", param_value.to_string());
313 }
314 if let Some(param_value) = p_header_idempotency_key {
315 req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
316 }
317 if let Some(ref token) = configuration.oauth_access_token {
318 req_builder = req_builder.bearer_auth(token.to_owned());
319 };
320 req_builder = req_builder.json(&p_body_booking_cleanup_request);
321
322 let req = req_builder.build()?;
323 let resp = configuration.client.execute(req).await?;
324
325 let status = resp.status();
326 let content_type = resp
327 .headers()
328 .get("content-type")
329 .and_then(|v| v.to_str().ok())
330 .unwrap_or("application/octet-stream");
331 let content_type = super::ContentType::from(content_type);
332
333 if !status.is_client_error() && !status.is_server_error() {
334 let content = resp.text().await?;
335 match content_type {
336 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
337 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WarningCollection`"))),
338 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::WarningCollection`")))),
339 }
340 } else {
341 let content = resp.text().await?;
342 let entity: Option<PostBookingCleanupError> = serde_json::from_str(&content).ok();
343 Err(Error::ResponseError(ResponseContent { status, content, entity }))
344 }
345}
346
347pub async fn post_bookings(configuration: &configuration::Configuration, booking_request: models::BookingRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::BookingResponse, Error<PostBookingsError>> {
348 let p_body_booking_request = booking_request;
350 let p_header_requestor = requestor;
351 let p_header_accept_language = accept_language;
352 let p_header_traceparent = traceparent;
353 let p_header_tracestate = tracestate;
354 let p_header_idempotency_key = idempotency_key;
355 let p_header_x_accept_namespace = x_accept_namespace;
356
357 let uri_str = format!("{}/bookings", configuration.base_path);
358 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
359
360 if let Some(ref user_agent) = configuration.user_agent {
361 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
362 }
363 if let Some(param_value) = p_header_requestor {
364 req_builder = req_builder.header("Requestor", param_value.to_string());
365 }
366 if let Some(param_value) = p_header_accept_language {
367 req_builder = req_builder.header("Accept-Language", param_value.to_string());
368 }
369 if let Some(param_value) = p_header_traceparent {
370 req_builder = req_builder.header("traceparent", param_value.to_string());
371 }
372 if let Some(param_value) = p_header_tracestate {
373 req_builder = req_builder.header("tracestate", param_value.to_string());
374 }
375 if let Some(param_value) = p_header_idempotency_key {
376 req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
377 }
378 if let Some(param_value) = p_header_x_accept_namespace {
379 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
380 }
381 if let Some(ref token) = configuration.oauth_access_token {
382 req_builder = req_builder.bearer_auth(token.to_owned());
383 };
384 req_builder = req_builder.json(&p_body_booking_request);
385
386 let req = req_builder.build()?;
387 let resp = configuration.client.execute(req).await?;
388
389 let status = resp.status();
390 let content_type = resp
391 .headers()
392 .get("content-type")
393 .and_then(|v| v.to_str().ok())
394 .unwrap_or("application/octet-stream");
395 let content_type = super::ContentType::from(content_type);
396
397 if !status.is_client_error() && !status.is_server_error() {
398 let content = resp.text().await?;
399 match content_type {
400 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
401 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BookingResponse`"))),
402 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::BookingResponse`")))),
403 }
404 } else {
405 let content = resp.text().await?;
406 let entity: Option<PostBookingsError> = serde_json::from_str(&content).ok();
407 Err(Error::ResponseError(ResponseContent { status, content, entity }))
408 }
409}
410
411pub async fn update_booking(configuration: &configuration::Configuration, booking_id: &str, booking_patch_request: models::BookingPatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::BookingResponse, Error<UpdateBookingError>> {
413 let p_path_booking_id = booking_id;
415 let p_body_booking_patch_request = booking_patch_request;
416 let p_header_requestor = requestor;
417 let p_header_accept_language = accept_language;
418 let p_header_traceparent = traceparent;
419 let p_header_tracestate = tracestate;
420 let p_header_x_accept_namespace = x_accept_namespace;
421
422 let uri_str = format!("{}/bookings/{bookingId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
423 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
424
425 if let Some(ref user_agent) = configuration.user_agent {
426 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
427 }
428 if let Some(param_value) = p_header_requestor {
429 req_builder = req_builder.header("Requestor", param_value.to_string());
430 }
431 if let Some(param_value) = p_header_accept_language {
432 req_builder = req_builder.header("Accept-Language", param_value.to_string());
433 }
434 if let Some(param_value) = p_header_traceparent {
435 req_builder = req_builder.header("traceparent", param_value.to_string());
436 }
437 if let Some(param_value) = p_header_tracestate {
438 req_builder = req_builder.header("tracestate", param_value.to_string());
439 }
440 if let Some(param_value) = p_header_x_accept_namespace {
441 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
442 }
443 if let Some(ref token) = configuration.oauth_access_token {
444 req_builder = req_builder.bearer_auth(token.to_owned());
445 };
446 req_builder = req_builder.json(&p_body_booking_patch_request);
447
448 let req = req_builder.build()?;
449 let resp = configuration.client.execute(req).await?;
450
451 let status = resp.status();
452 let content_type = resp
453 .headers()
454 .get("content-type")
455 .and_then(|v| v.to_str().ok())
456 .unwrap_or("application/octet-stream");
457 let content_type = super::ContentType::from(content_type);
458
459 if !status.is_client_error() && !status.is_server_error() {
460 let content = resp.text().await?;
461 match content_type {
462 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
463 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BookingResponse`"))),
464 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::BookingResponse`")))),
465 }
466 } else {
467 let content = resp.text().await?;
468 let entity: Option<UpdateBookingError> = serde_json::from_str(&content).ok();
469 Err(Error::ResponseError(ResponseContent { status, content, entity }))
470 }
471}
472