osdm_sys/apis/
refund_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_refund_offers`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteRefundOffersError {
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 [`get_refund_offers`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum GetRefundOffersError {
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/// struct for typed errors of method [`patch_refund_offers`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PatchRefundOffersError {
57    Status400(models::Problem),
58    Status401(models::Problem),
59    Status403(models::Problem),
60    Status404(models::Problem),
61    Status406(models::Problem),
62    Status409(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_prepare_refund_offers`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum PostPrepareRefundOffersError {
75    Status400(models::Problem),
76    Status401(models::Problem),
77    Status403(models::Problem),
78    Status404(models::Problem),
79    Status406(models::Problem),
80    Status409(models::Problem),
81    Status415(models::Problem),
82    Status500(models::Problem),
83    Status501(models::Problem),
84    Status503(models::Problem),
85    DefaultResponse(models::Problem),
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`post_refund_offers`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum PostRefundOffersError {
93    Status400(models::Problem),
94    Status401(models::Problem),
95    Status403(models::Problem),
96    Status404(models::Problem),
97    Status406(models::Problem),
98    Status415(models::Problem),
99    Status500(models::Problem),
100    Status501(models::Problem),
101    Status503(models::Problem),
102    DefaultResponse(models::Problem),
103    UnknownValue(serde_json::Value),
104}
105
106
107/// In case the unconfimed refund offer is not sored in the booking  object the delete request must return an ok (http 204). In case the  refund offer is already confirmed and can not be deleted the reply  must be an error (http 409 conflict). 
108pub async fn delete_refund_offers(configuration: &configuration::Configuration, booking_id: &str, refund_offer_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>) -> Result<(), Error<DeleteRefundOffersError>> {
109    // add a prefix to parameters to efficiently prevent name collisions
110    let p_path_booking_id = booking_id;
111    let p_path_refund_offer_id = refund_offer_id;
112    let p_header_requestor = requestor;
113    let p_header_accept_language = accept_language;
114    let p_header_traceparent = traceparent;
115    let p_header_tracestate = tracestate;
116
117    let uri_str = format!("{}/bookings/{bookingId}/refund-offers/{refundOfferId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id), refundOfferId=crate::apis::urlencode(p_path_refund_offer_id));
118    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
119
120    if let Some(ref user_agent) = configuration.user_agent {
121        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
122    }
123    if let Some(param_value) = p_header_requestor {
124        req_builder = req_builder.header("Requestor", param_value.to_string());
125    }
126    if let Some(param_value) = p_header_accept_language {
127        req_builder = req_builder.header("Accept-Language", param_value.to_string());
128    }
129    if let Some(param_value) = p_header_traceparent {
130        req_builder = req_builder.header("traceparent", param_value.to_string());
131    }
132    if let Some(param_value) = p_header_tracestate {
133        req_builder = req_builder.header("tracestate", param_value.to_string());
134    }
135    if let Some(ref token) = configuration.oauth_access_token {
136        req_builder = req_builder.bearer_auth(token.to_owned());
137    };
138
139    let req = req_builder.build()?;
140    let resp = configuration.client.execute(req).await?;
141
142    let status = resp.status();
143
144    if !status.is_client_error() && !status.is_server_error() {
145        Ok(())
146    } else {
147        let content = resp.text().await?;
148        let entity: Option<DeleteRefundOffersError> = serde_json::from_str(&content).ok();
149        Err(Error::ResponseError(ResponseContent { status, content, entity }))
150    }
151}
152
153pub async fn get_refund_offers(configuration: &configuration::Configuration, booking_id: &str, refund_offer_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::RefundOfferResponse, Error<GetRefundOffersError>> {
154    // add a prefix to parameters to efficiently prevent name collisions
155    let p_path_booking_id = booking_id;
156    let p_path_refund_offer_id = refund_offer_id;
157    let p_header_requestor = requestor;
158    let p_header_accept_language = accept_language;
159    let p_header_traceparent = traceparent;
160    let p_header_tracestate = tracestate;
161    let p_header_x_accept_namespace = x_accept_namespace;
162
163    let uri_str = format!("{}/bookings/{bookingId}/refund-offers/{refundOfferId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id), refundOfferId=crate::apis::urlencode(p_path_refund_offer_id));
164    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
165
166    if let Some(ref user_agent) = configuration.user_agent {
167        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
168    }
169    if let Some(param_value) = p_header_requestor {
170        req_builder = req_builder.header("Requestor", param_value.to_string());
171    }
172    if let Some(param_value) = p_header_accept_language {
173        req_builder = req_builder.header("Accept-Language", param_value.to_string());
174    }
175    if let Some(param_value) = p_header_traceparent {
176        req_builder = req_builder.header("traceparent", param_value.to_string());
177    }
178    if let Some(param_value) = p_header_tracestate {
179        req_builder = req_builder.header("tracestate", param_value.to_string());
180    }
181    if let Some(param_value) = p_header_x_accept_namespace {
182        req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
183    }
184    if let Some(ref token) = configuration.oauth_access_token {
185        req_builder = req_builder.bearer_auth(token.to_owned());
186    };
187
188    let req = req_builder.build()?;
189    let resp = configuration.client.execute(req).await?;
190
191    let status = resp.status();
192    let content_type = resp
193        .headers()
194        .get("content-type")
195        .and_then(|v| v.to_str().ok())
196        .unwrap_or("application/octet-stream");
197    let content_type = super::ContentType::from(content_type);
198
199    if !status.is_client_error() && !status.is_server_error() {
200        let content = resp.text().await?;
201        match content_type {
202            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
203            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RefundOfferResponse`"))),
204            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::RefundOfferResponse`")))),
205        }
206    } else {
207        let content = resp.text().await?;
208        let entity: Option<GetRefundOffersError> = serde_json::from_str(&content).ok();
209        Err(Error::ResponseError(ResponseContent { status, content, entity }))
210    }
211}
212
213pub async fn patch_refund_offers(configuration: &configuration::Configuration, booking_id: &str, refund_offer_id: &str, refund_offer_patch_request: models::RefundOfferPatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::RefundOfferResponse, Error<PatchRefundOffersError>> {
214    // add a prefix to parameters to efficiently prevent name collisions
215    let p_path_booking_id = booking_id;
216    let p_path_refund_offer_id = refund_offer_id;
217    let p_body_refund_offer_patch_request = refund_offer_patch_request;
218    let p_header_requestor = requestor;
219    let p_header_accept_language = accept_language;
220    let p_header_traceparent = traceparent;
221    let p_header_tracestate = tracestate;
222    let p_header_idempotency_key = idempotency_key;
223    let p_header_x_accept_namespace = x_accept_namespace;
224
225    let uri_str = format!("{}/bookings/{bookingId}/refund-offers/{refundOfferId}", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id), refundOfferId=crate::apis::urlencode(p_path_refund_offer_id));
226    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
227
228    if let Some(ref user_agent) = configuration.user_agent {
229        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
230    }
231    if let Some(param_value) = p_header_requestor {
232        req_builder = req_builder.header("Requestor", param_value.to_string());
233    }
234    if let Some(param_value) = p_header_accept_language {
235        req_builder = req_builder.header("Accept-Language", param_value.to_string());
236    }
237    if let Some(param_value) = p_header_traceparent {
238        req_builder = req_builder.header("traceparent", param_value.to_string());
239    }
240    if let Some(param_value) = p_header_tracestate {
241        req_builder = req_builder.header("tracestate", param_value.to_string());
242    }
243    if let Some(param_value) = p_header_idempotency_key {
244        req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
245    }
246    if let Some(param_value) = p_header_x_accept_namespace {
247        req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
248    }
249    if let Some(ref token) = configuration.oauth_access_token {
250        req_builder = req_builder.bearer_auth(token.to_owned());
251    };
252    req_builder = req_builder.json(&p_body_refund_offer_patch_request);
253
254    let req = req_builder.build()?;
255    let resp = configuration.client.execute(req).await?;
256
257    let status = resp.status();
258    let content_type = resp
259        .headers()
260        .get("content-type")
261        .and_then(|v| v.to_str().ok())
262        .unwrap_or("application/octet-stream");
263    let content_type = super::ContentType::from(content_type);
264
265    if !status.is_client_error() && !status.is_server_error() {
266        let content = resp.text().await?;
267        match content_type {
268            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
269            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RefundOfferResponse`"))),
270            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::RefundOfferResponse`")))),
271        }
272    } else {
273        let content = resp.text().await?;
274        let entity: Option<PatchRefundOffersError> = serde_json::from_str(&content).ok();
275        Err(Error::ResponseError(ResponseContent { status, content, entity }))
276    }
277}
278
279/// Step 1 in a two phase commit process. An aggregator can use this to secure that all underlaying provider systems are up and running and the provider booking is ready to be refunded. 
280pub async fn post_prepare_refund_offers(configuration: &configuration::Configuration, booking_id: &str, refund_offer_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<(), Error<PostPrepareRefundOffersError>> {
281    // add a prefix to parameters to efficiently prevent name collisions
282    let p_path_booking_id = booking_id;
283    let p_path_refund_offer_id = refund_offer_id;
284    let p_header_requestor = requestor;
285    let p_header_accept_language = accept_language;
286    let p_header_traceparent = traceparent;
287    let p_header_tracestate = tracestate;
288    let p_header_idempotency_key = idempotency_key;
289    let p_header_x_accept_namespace = x_accept_namespace;
290
291    let uri_str = format!("{}/bookings/{bookingId}/refund-offers/{refundOfferId}/confirmation-check", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id), refundOfferId=crate::apis::urlencode(p_path_refund_offer_id));
292    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
293
294    if let Some(ref user_agent) = configuration.user_agent {
295        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
296    }
297    if let Some(param_value) = p_header_requestor {
298        req_builder = req_builder.header("Requestor", param_value.to_string());
299    }
300    if let Some(param_value) = p_header_accept_language {
301        req_builder = req_builder.header("Accept-Language", param_value.to_string());
302    }
303    if let Some(param_value) = p_header_traceparent {
304        req_builder = req_builder.header("traceparent", param_value.to_string());
305    }
306    if let Some(param_value) = p_header_tracestate {
307        req_builder = req_builder.header("tracestate", param_value.to_string());
308    }
309    if let Some(param_value) = p_header_idempotency_key {
310        req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
311    }
312    if let Some(param_value) = p_header_x_accept_namespace {
313        req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
314    }
315    if let Some(ref token) = configuration.oauth_access_token {
316        req_builder = req_builder.bearer_auth(token.to_owned());
317    };
318
319    let req = req_builder.build()?;
320    let resp = configuration.client.execute(req).await?;
321
322    let status = resp.status();
323
324    if !status.is_client_error() && !status.is_server_error() {
325        Ok(())
326    } else {
327        let content = resp.text().await?;
328        let entity: Option<PostPrepareRefundOffersError> = serde_json::from_str(&content).ok();
329        Err(Error::ResponseError(ResponseContent { status, content, entity }))
330    }
331}
332
333/// The RefundOffer contains the required information on the potential operation. One refund offer can then be accepted via a PATCH, deleted or left to die at the end of its lifetime. 
334pub async fn post_refund_offers(configuration: &configuration::Configuration, booking_id: &str, refund_offer_request: models::RefundOfferRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::RefundOfferCollectionResponse, Error<PostRefundOffersError>> {
335    // add a prefix to parameters to efficiently prevent name collisions
336    let p_path_booking_id = booking_id;
337    let p_body_refund_offer_request = refund_offer_request;
338    let p_header_requestor = requestor;
339    let p_header_accept_language = accept_language;
340    let p_header_traceparent = traceparent;
341    let p_header_tracestate = tracestate;
342    let p_header_idempotency_key = idempotency_key;
343    let p_header_x_accept_namespace = x_accept_namespace;
344
345    let uri_str = format!("{}/bookings/{bookingId}/refund-offers", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
346    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
347
348    if let Some(ref user_agent) = configuration.user_agent {
349        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
350    }
351    if let Some(param_value) = p_header_requestor {
352        req_builder = req_builder.header("Requestor", param_value.to_string());
353    }
354    if let Some(param_value) = p_header_accept_language {
355        req_builder = req_builder.header("Accept-Language", param_value.to_string());
356    }
357    if let Some(param_value) = p_header_traceparent {
358        req_builder = req_builder.header("traceparent", param_value.to_string());
359    }
360    if let Some(param_value) = p_header_tracestate {
361        req_builder = req_builder.header("tracestate", param_value.to_string());
362    }
363    if let Some(param_value) = p_header_idempotency_key {
364        req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
365    }
366    if let Some(param_value) = p_header_x_accept_namespace {
367        req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
368    }
369    if let Some(ref token) = configuration.oauth_access_token {
370        req_builder = req_builder.bearer_auth(token.to_owned());
371    };
372    req_builder = req_builder.json(&p_body_refund_offer_request);
373
374    let req = req_builder.build()?;
375    let resp = configuration.client.execute(req).await?;
376
377    let status = resp.status();
378    let content_type = resp
379        .headers()
380        .get("content-type")
381        .and_then(|v| v.to_str().ok())
382        .unwrap_or("application/octet-stream");
383    let content_type = super::ContentType::from(content_type);
384
385    if !status.is_client_error() && !status.is_server_error() {
386        let content = resp.text().await?;
387        match content_type {
388            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
389            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RefundOfferCollectionResponse`"))),
390            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::RefundOfferCollectionResponse`")))),
391        }
392    } else {
393        let content = resp.text().await?;
394        let entity: Option<PostRefundOffersError> = serde_json::from_str(&content).ok();
395        Err(Error::ResponseError(ResponseContent { status, content, entity }))
396    }
397}
398