osdm_sys/apis/
booked_offers_api.rs

1/*
2 * UIC 90918-10 - OSDM
3 *
4 * Specifications for the OSDM API standard. The OSDM specification supports two modes of operation: Retailer Mode and Distributor Mode. The API works identically in both modes, except that in distributor mode the API also returns fare information.  The following resources are key to get started:    -  [Processes](https://osdm.io/spec/processes/)   -  [Models](https://osdm.io/spec/models/)   -  [Getting started](https://osdm.io/spec/getting-started/) 
5 *
6 * The version of the OpenAPI document: 3.7.0
7 * Contact: osdm@uic.org
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 [`delete_booking_booked_offers_id`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteBookingBookedOffersIdError {
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/// struct for typed errors of method [`delete_booking_booked_offers_id_passenger_id`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum DeleteBookingBookedOffersIdPassengerIdError {
40    Status400(models::Problem),
41    Status401(models::Problem),
42    Status403(models::Problem),
43    Status404(models::Problem),
44    Status406(models::Problem),
45    Status409(models::Problem),
46    Status415(models::Problem),
47    Status500(models::Problem),
48    Status501(models::Problem),
49    Status503(models::Problem),
50    DefaultResponse(models::Problem),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`get_booking_booked_offers_id`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetBookingBookedOffersIdError {
58    Status400(models::Problem),
59    Status401(models::Problem),
60    Status403(models::Problem),
61    Status404(models::Problem),
62    Status406(models::Problem),
63    Status415(models::Problem),
64    Status500(models::Problem),
65    Status501(models::Problem),
66    Status503(models::Problem),
67    DefaultResponse(models::Problem),
68    UnknownValue(serde_json::Value),
69}
70
71/// struct for typed errors of method [`post_booking_booked_offers`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum PostBookingBookedOffersError {
75    Status400(models::Problem),
76    Status401(models::Problem),
77    Status403(models::Problem),
78    Status404(models::Problem),
79    Status406(models::Problem),
80    Status415(models::Problem),
81    Status500(models::Problem),
82    Status501(models::Problem),
83    Status503(models::Problem),
84    DefaultResponse(models::Problem),
85    UnknownValue(serde_json::Value),
86}
87
88
89pub async fn delete_booking_booked_offers_id(configuration: &configuration::Configuration, booking_id: &str, booked_offer_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>) -> Result<(), Error<DeleteBookingBookedOffersIdError>> {
90    // add a prefix to parameters to efficiently prevent name collisions
91    let p_path_booking_id = booking_id;
92    let p_path_booked_offer_id = booked_offer_id;
93    let p_header_requestor = requestor;
94    let p_header_accept_language = accept_language;
95    let p_header_traceparent = traceparent;
96    let p_header_tracestate = tracestate;
97
98    let uri_str = format!("{}/bookings/{bookingId}/booked-offers/{bookedOfferId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id), bookedOfferId=crate::apis::urlencode(p_path_booked_offer_id));
99    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
100
101    if let Some(ref user_agent) = configuration.user_agent {
102        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
103    }
104    if let Some(param_value) = p_header_requestor {
105        req_builder = req_builder.header("Requestor", param_value.to_string());
106    }
107    if let Some(param_value) = p_header_accept_language {
108        req_builder = req_builder.header("Accept-Language", param_value.to_string());
109    }
110    if let Some(param_value) = p_header_traceparent {
111        req_builder = req_builder.header("traceparent", param_value.to_string());
112    }
113    if let Some(param_value) = p_header_tracestate {
114        req_builder = req_builder.header("tracestate", param_value.to_string());
115    }
116    if let Some(ref token) = configuration.oauth_access_token {
117        req_builder = req_builder.bearer_auth(token.to_owned());
118    };
119
120    let req = req_builder.build()?;
121    let resp = configuration.client.execute(req).await?;
122
123    let status = resp.status();
124
125    if !status.is_client_error() && !status.is_server_error() {
126        Ok(())
127    } else {
128        let content = resp.text().await?;
129        let entity: Option<DeleteBookingBookedOffersIdError> = serde_json::from_str(&content).ok();
130        Err(Error::ResponseError(ResponseContent { status, content, entity }))
131    }
132}
133
134/// Deletes all booked offer parts of the passenger only if this valid from a tariff point of view. This implies that the offer part are sufficiently partitioned and no repricing is needed. 
135pub async fn delete_booking_booked_offers_id_passenger_id(configuration: &configuration::Configuration, booking_id: &str, offer_id: &str, passenger_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>) -> Result<(), Error<DeleteBookingBookedOffersIdPassengerIdError>> {
136    // add a prefix to parameters to efficiently prevent name collisions
137    let p_path_booking_id = booking_id;
138    let p_path_offer_id = offer_id;
139    let p_path_passenger_id = passenger_id;
140    let p_header_requestor = requestor;
141    let p_header_accept_language = accept_language;
142    let p_header_traceparent = traceparent;
143    let p_header_tracestate = tracestate;
144
145    let uri_str = format!("{}/bookings/{bookingId}/booked-offers/{offerId}/passengers/{passengerId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id), offerId=crate::apis::urlencode(p_path_offer_id), passengerId=crate::apis::urlencode(p_path_passenger_id));
146    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
147
148    if let Some(ref user_agent) = configuration.user_agent {
149        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
150    }
151    if let Some(param_value) = p_header_requestor {
152        req_builder = req_builder.header("Requestor", param_value.to_string());
153    }
154    if let Some(param_value) = p_header_accept_language {
155        req_builder = req_builder.header("Accept-Language", param_value.to_string());
156    }
157    if let Some(param_value) = p_header_traceparent {
158        req_builder = req_builder.header("traceparent", param_value.to_string());
159    }
160    if let Some(param_value) = p_header_tracestate {
161        req_builder = req_builder.header("tracestate", param_value.to_string());
162    }
163    if let Some(ref token) = configuration.oauth_access_token {
164        req_builder = req_builder.bearer_auth(token.to_owned());
165    };
166
167    let req = req_builder.build()?;
168    let resp = configuration.client.execute(req).await?;
169
170    let status = resp.status();
171
172    if !status.is_client_error() && !status.is_server_error() {
173        Ok(())
174    } else {
175        let content = resp.text().await?;
176        let entity: Option<DeleteBookingBookedOffersIdPassengerIdError> = serde_json::from_str(&content).ok();
177        Err(Error::ResponseError(ResponseContent { status, content, entity }))
178    }
179}
180
181pub async fn get_booking_booked_offers_id(configuration: &configuration::Configuration, booking_id: &str, booked_offer_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::BookedOfferResponse, Error<GetBookingBookedOffersIdError>> {
182    // add a prefix to parameters to efficiently prevent name collisions
183    let p_path_booking_id = booking_id;
184    let p_path_booked_offer_id = booked_offer_id;
185    let p_header_requestor = requestor;
186    let p_header_accept_language = accept_language;
187    let p_header_traceparent = traceparent;
188    let p_header_tracestate = tracestate;
189    let p_header_x_accept_namespace = x_accept_namespace;
190
191    let uri_str = format!("{}/bookings/{bookingId}/booked-offers/{bookedOfferId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id), bookedOfferId=crate::apis::urlencode(p_path_booked_offer_id));
192    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
193
194    if let Some(ref user_agent) = configuration.user_agent {
195        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
196    }
197    if let Some(param_value) = p_header_requestor {
198        req_builder = req_builder.header("Requestor", param_value.to_string());
199    }
200    if let Some(param_value) = p_header_accept_language {
201        req_builder = req_builder.header("Accept-Language", param_value.to_string());
202    }
203    if let Some(param_value) = p_header_traceparent {
204        req_builder = req_builder.header("traceparent", param_value.to_string());
205    }
206    if let Some(param_value) = p_header_tracestate {
207        req_builder = req_builder.header("tracestate", param_value.to_string());
208    }
209    if let Some(param_value) = p_header_x_accept_namespace {
210        req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
211    }
212    if let Some(ref token) = configuration.oauth_access_token {
213        req_builder = req_builder.bearer_auth(token.to_owned());
214    };
215
216    let req = req_builder.build()?;
217    let resp = configuration.client.execute(req).await?;
218
219    let status = resp.status();
220    let content_type = resp
221        .headers()
222        .get("content-type")
223        .and_then(|v| v.to_str().ok())
224        .unwrap_or("application/octet-stream");
225    let content_type = super::ContentType::from(content_type);
226
227    if !status.is_client_error() && !status.is_server_error() {
228        let content = resp.text().await?;
229        match content_type {
230            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
231            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BookedOfferResponse`"))),
232            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::BookedOfferResponse`")))),
233        }
234    } else {
235        let content = resp.text().await?;
236        let entity: Option<GetBookingBookedOffersIdError> = serde_json::from_str(&content).ok();
237        Err(Error::ResponseError(ResponseContent { status, content, entity }))
238    }
239}
240
241pub async fn post_booking_booked_offers(configuration: &configuration::Configuration, booking_id: &str, booked_offer_request: models::BookedOfferRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::BookedOfferResponse, Error<PostBookingBookedOffersError>> {
242    // add a prefix to parameters to efficiently prevent name collisions
243    let p_path_booking_id = booking_id;
244    let p_body_booked_offer_request = booked_offer_request;
245    let p_header_requestor = requestor;
246    let p_header_accept_language = accept_language;
247    let p_header_traceparent = traceparent;
248    let p_header_tracestate = tracestate;
249    let p_header_idempotency_key = idempotency_key;
250    let p_header_x_accept_namespace = x_accept_namespace;
251
252    let uri_str = format!("{}/bookings/{bookingId}/booked-offers", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
253    let mut req_builder = configuration.client.request(reqwest::Method::POST, &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(param_value) = p_header_requestor {
259        req_builder = req_builder.header("Requestor", param_value.to_string());
260    }
261    if let Some(param_value) = p_header_accept_language {
262        req_builder = req_builder.header("Accept-Language", param_value.to_string());
263    }
264    if let Some(param_value) = p_header_traceparent {
265        req_builder = req_builder.header("traceparent", param_value.to_string());
266    }
267    if let Some(param_value) = p_header_tracestate {
268        req_builder = req_builder.header("tracestate", param_value.to_string());
269    }
270    if let Some(param_value) = p_header_idempotency_key {
271        req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
272    }
273    if let Some(param_value) = p_header_x_accept_namespace {
274        req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
275    }
276    if let Some(ref token) = configuration.oauth_access_token {
277        req_builder = req_builder.bearer_auth(token.to_owned());
278    };
279    req_builder = req_builder.json(&p_body_booked_offer_request);
280
281    let req = req_builder.build()?;
282    let resp = configuration.client.execute(req).await?;
283
284    let status = resp.status();
285    let content_type = resp
286        .headers()
287        .get("content-type")
288        .and_then(|v| v.to_str().ok())
289        .unwrap_or("application/octet-stream");
290    let content_type = super::ContentType::from(content_type);
291
292    if !status.is_client_error() && !status.is_server_error() {
293        let content = resp.text().await?;
294        match content_type {
295            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
296            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BookedOfferResponse`"))),
297            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::BookedOfferResponse`")))),
298        }
299    } else {
300        let content = resp.text().await?;
301        let entity: Option<PostBookingBookedOffersError> = serde_json::from_str(&content).ok();
302        Err(Error::ResponseError(ResponseContent { status, content, entity }))
303    }
304}
305