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 FinalizeFulfillmentsError {
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 GetCheckFulfillmentsError {
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 GetContinuousServiceUsageIdError {
57 Status400(models::Problem),
58 Status401(models::Problem),
59 Status403(models::Problem),
60 Status404(models::Problem),
61 Status415(models::Problem),
62 Status500(models::Problem),
63 Status501(models::Problem),
64 Status503(models::Problem),
65 DefaultResponse(models::Problem),
66 UnknownValue(serde_json::Value),
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetFulfillmentIdError {
73 Status400(models::Problem),
74 Status401(models::Problem),
75 Status403(models::Problem),
76 Status404(models::Problem),
77 Status406(models::Problem),
78 Status415(models::Problem),
79 Status500(models::Problem),
80 Status501(models::Problem),
81 Status503(models::Problem),
82 DefaultResponse(models::Problem),
83 UnknownValue(serde_json::Value),
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum PatchContinuousServiceUsageIdError {
90 Status400(models::Problem),
91 Status401(models::Problem),
92 Status403(models::Problem),
93 Status404(models::Problem),
94 Status409(models::Problem),
95 Status415(models::Problem),
96 Status500(models::Problem),
97 Status501(models::Problem),
98 Status503(models::Problem),
99 DefaultResponse(models::Problem),
100 UnknownValue(serde_json::Value),
101}
102
103#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum PatchFulfillmentIdError {
107 Status400(models::Problem),
108 Status401(models::Problem),
109 Status403(models::Problem),
110 Status404(models::Problem),
111 Status406(models::Problem),
112 Status409(models::Problem),
113 Status415(models::Problem),
114 Status500(models::Problem),
115 Status501(models::Problem),
116 Status503(models::Problem),
117 DefaultResponse(models::Problem),
118 UnknownValue(serde_json::Value),
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum PostFulfillmentsError {
125 Status400(models::Problem),
126 Status401(models::Problem),
127 Status403(models::Problem),
128 Status404(models::Problem),
129 Status406(models::Problem),
130 Status415(models::Problem),
131 Status500(models::Problem),
132 Status501(models::Problem),
133 Status503(models::Problem),
134 DefaultResponse(models::Problem),
135 UnknownValue(serde_json::Value),
136}
137
138
139pub async fn finalize_fulfillments(configuration: &configuration::Configuration, booking_id: &str, fulfillment_patch_request: models::FulfillmentPatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentCollectionResponse, Error<FinalizeFulfillmentsError>> {
141 let p_path_booking_id = booking_id;
143 let p_body_fulfillment_patch_request = fulfillment_patch_request;
144 let p_header_requestor = requestor;
145 let p_header_accept_language = accept_language;
146 let p_header_traceparent = traceparent;
147 let p_header_tracestate = tracestate;
148 let p_header_idempotency_key = idempotency_key;
149 let p_header_x_accept_namespace = x_accept_namespace;
150
151 let uri_str = format!("{}/bookings/{bookingId}/fulfillments", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
152 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
153
154 if let Some(ref user_agent) = configuration.user_agent {
155 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156 }
157 if let Some(param_value) = p_header_requestor {
158 req_builder = req_builder.header("Requestor", param_value.to_string());
159 }
160 if let Some(param_value) = p_header_accept_language {
161 req_builder = req_builder.header("Accept-Language", param_value.to_string());
162 }
163 if let Some(param_value) = p_header_traceparent {
164 req_builder = req_builder.header("traceparent", param_value.to_string());
165 }
166 if let Some(param_value) = p_header_tracestate {
167 req_builder = req_builder.header("tracestate", param_value.to_string());
168 }
169 if let Some(param_value) = p_header_idempotency_key {
170 req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
171 }
172 if let Some(param_value) = p_header_x_accept_namespace {
173 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
174 }
175 if let Some(ref token) = configuration.oauth_access_token {
176 req_builder = req_builder.bearer_auth(token.to_owned());
177 };
178 req_builder = req_builder.json(&p_body_fulfillment_patch_request);
179
180 let req = req_builder.build()?;
181 let resp = configuration.client.execute(req).await?;
182
183 let status = resp.status();
184 let content_type = resp
185 .headers()
186 .get("content-type")
187 .and_then(|v| v.to_str().ok())
188 .unwrap_or("application/octet-stream");
189 let content_type = super::ContentType::from(content_type);
190
191 if !status.is_client_error() && !status.is_server_error() {
192 let content = resp.text().await?;
193 match content_type {
194 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
195 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FulfillmentCollectionResponse`"))),
196 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::FulfillmentCollectionResponse`")))),
197 }
198 } else {
199 let content = resp.text().await?;
200 let entity: Option<FinalizeFulfillmentsError> = serde_json::from_str(&content).ok();
201 Err(Error::ResponseError(ResponseContent { status, content, entity }))
202 }
203}
204
205pub async fn get_check_fulfillments(configuration: &configuration::Configuration, booking_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<GetCheckFulfillmentsError>> {
207 let p_path_booking_id = booking_id;
209 let p_header_requestor = requestor;
210 let p_header_accept_language = accept_language;
211 let p_header_traceparent = traceparent;
212 let p_header_tracestate = tracestate;
213 let p_header_idempotency_key = idempotency_key;
214 let p_header_x_accept_namespace = x_accept_namespace;
215
216 let uri_str = format!("{}/bookings/{bookingId}/fulfillment-check", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
217 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
218
219 if let Some(ref user_agent) = configuration.user_agent {
220 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
221 }
222 if let Some(param_value) = p_header_requestor {
223 req_builder = req_builder.header("Requestor", param_value.to_string());
224 }
225 if let Some(param_value) = p_header_accept_language {
226 req_builder = req_builder.header("Accept-Language", param_value.to_string());
227 }
228 if let Some(param_value) = p_header_traceparent {
229 req_builder = req_builder.header("traceparent", param_value.to_string());
230 }
231 if let Some(param_value) = p_header_tracestate {
232 req_builder = req_builder.header("tracestate", param_value.to_string());
233 }
234 if let Some(param_value) = p_header_idempotency_key {
235 req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
236 }
237 if let Some(param_value) = p_header_x_accept_namespace {
238 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
239 }
240 if let Some(ref token) = configuration.oauth_access_token {
241 req_builder = req_builder.bearer_auth(token.to_owned());
242 };
243
244 let req = req_builder.build()?;
245 let resp = configuration.client.execute(req).await?;
246
247 let status = resp.status();
248
249 if !status.is_client_error() && !status.is_server_error() {
250 Ok(())
251 } else {
252 let content = resp.text().await?;
253 let entity: Option<GetCheckFulfillmentsError> = serde_json::from_str(&content).ok();
254 Err(Error::ResponseError(ResponseContent { status, content, entity }))
255 }
256}
257
258pub async fn get_continuous_service_usage_id(configuration: &configuration::Configuration, fulfillment_id: &str, continuous_service_usage_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::ContinuousServiceUsage, Error<GetContinuousServiceUsageIdError>> {
259 let p_path_fulfillment_id = fulfillment_id;
261 let p_path_continuous_service_usage_id = continuous_service_usage_id;
262 let p_header_requestor = requestor;
263 let p_header_accept_language = accept_language;
264 let p_header_traceparent = traceparent;
265 let p_header_tracestate = tracestate;
266 let p_header_x_accept_namespace = x_accept_namespace;
267
268 let uri_str = format!("{}/fulfillments/{fulfillmentId}/continuous-service-usage/{continuousServiceUsageId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_id), continuousServiceUsageId=crate::apis::urlencode(p_path_continuous_service_usage_id));
269 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
270
271 if let Some(ref user_agent) = configuration.user_agent {
272 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
273 }
274 if let Some(param_value) = p_header_requestor {
275 req_builder = req_builder.header("Requestor", param_value.to_string());
276 }
277 if let Some(param_value) = p_header_accept_language {
278 req_builder = req_builder.header("Accept-Language", param_value.to_string());
279 }
280 if let Some(param_value) = p_header_traceparent {
281 req_builder = req_builder.header("traceparent", param_value.to_string());
282 }
283 if let Some(param_value) = p_header_tracestate {
284 req_builder = req_builder.header("tracestate", param_value.to_string());
285 }
286 if let Some(param_value) = p_header_x_accept_namespace {
287 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
288 }
289 if let Some(ref token) = configuration.oauth_access_token {
290 req_builder = req_builder.bearer_auth(token.to_owned());
291 };
292
293 let req = req_builder.build()?;
294 let resp = configuration.client.execute(req).await?;
295
296 let status = resp.status();
297 let content_type = resp
298 .headers()
299 .get("content-type")
300 .and_then(|v| v.to_str().ok())
301 .unwrap_or("application/octet-stream");
302 let content_type = super::ContentType::from(content_type);
303
304 if !status.is_client_error() && !status.is_server_error() {
305 let content = resp.text().await?;
306 match content_type {
307 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
308 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContinuousServiceUsage`"))),
309 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::ContinuousServiceUsage`")))),
310 }
311 } else {
312 let content = resp.text().await?;
313 let entity: Option<GetContinuousServiceUsageIdError> = serde_json::from_str(&content).ok();
314 Err(Error::ResponseError(ResponseContent { status, content, entity }))
315 }
316}
317
318pub async fn get_fulfillment_id(configuration: &configuration::Configuration, fulfillment_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentResponse, Error<GetFulfillmentIdError>> {
319 let p_path_fulfillment_id = fulfillment_id;
321 let p_header_requestor = requestor;
322 let p_header_accept_language = accept_language;
323 let p_header_traceparent = traceparent;
324 let p_header_tracestate = tracestate;
325 let p_header_x_accept_namespace = x_accept_namespace;
326
327 let uri_str = format!("{}/fulfillments/{fulfillmentId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_id));
328 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
329
330 if let Some(ref user_agent) = configuration.user_agent {
331 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
332 }
333 if let Some(param_value) = p_header_requestor {
334 req_builder = req_builder.header("Requestor", param_value.to_string());
335 }
336 if let Some(param_value) = p_header_accept_language {
337 req_builder = req_builder.header("Accept-Language", param_value.to_string());
338 }
339 if let Some(param_value) = p_header_traceparent {
340 req_builder = req_builder.header("traceparent", param_value.to_string());
341 }
342 if let Some(param_value) = p_header_tracestate {
343 req_builder = req_builder.header("tracestate", param_value.to_string());
344 }
345 if let Some(param_value) = p_header_x_accept_namespace {
346 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
347 }
348 if let Some(ref token) = configuration.oauth_access_token {
349 req_builder = req_builder.bearer_auth(token.to_owned());
350 };
351
352 let req = req_builder.build()?;
353 let resp = configuration.client.execute(req).await?;
354
355 let status = resp.status();
356 let content_type = resp
357 .headers()
358 .get("content-type")
359 .and_then(|v| v.to_str().ok())
360 .unwrap_or("application/octet-stream");
361 let content_type = super::ContentType::from(content_type);
362
363 if !status.is_client_error() && !status.is_server_error() {
364 let content = resp.text().await?;
365 match content_type {
366 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
367 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FulfillmentResponse`"))),
368 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::FulfillmentResponse`")))),
369 }
370 } else {
371 let content = resp.text().await?;
372 let entity: Option<GetFulfillmentIdError> = serde_json::from_str(&content).ok();
373 Err(Error::ResponseError(ResponseContent { status, content, entity }))
374 }
375}
376
377pub async fn patch_continuous_service_usage_id(configuration: &configuration::Configuration, fulfillment_id: &str, continuous_service_usage_id: &str, continuous_service_usage_patch_request: models::ContinuousServiceUsagePatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::ContinuousServiceUsage, Error<PatchContinuousServiceUsageIdError>> {
379 let p_path_fulfillment_id = fulfillment_id;
381 let p_path_continuous_service_usage_id = continuous_service_usage_id;
382 let p_body_continuous_service_usage_patch_request = continuous_service_usage_patch_request;
383 let p_header_requestor = requestor;
384 let p_header_accept_language = accept_language;
385 let p_header_traceparent = traceparent;
386 let p_header_tracestate = tracestate;
387 let p_header_idempotency_key = idempotency_key;
388 let p_header_x_accept_namespace = x_accept_namespace;
389
390 let uri_str = format!("{}/fulfillments/{fulfillmentId}/continuous-service-usage/{continuousServiceUsageId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_id), continuousServiceUsageId=crate::apis::urlencode(p_path_continuous_service_usage_id));
391 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
392
393 if let Some(ref user_agent) = configuration.user_agent {
394 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
395 }
396 if let Some(param_value) = p_header_requestor {
397 req_builder = req_builder.header("Requestor", param_value.to_string());
398 }
399 if let Some(param_value) = p_header_accept_language {
400 req_builder = req_builder.header("Accept-Language", param_value.to_string());
401 }
402 if let Some(param_value) = p_header_traceparent {
403 req_builder = req_builder.header("traceparent", param_value.to_string());
404 }
405 if let Some(param_value) = p_header_tracestate {
406 req_builder = req_builder.header("tracestate", param_value.to_string());
407 }
408 if let Some(param_value) = p_header_idempotency_key {
409 req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
410 }
411 if let Some(param_value) = p_header_x_accept_namespace {
412 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
413 }
414 if let Some(ref token) = configuration.oauth_access_token {
415 req_builder = req_builder.bearer_auth(token.to_owned());
416 };
417 req_builder = req_builder.json(&p_body_continuous_service_usage_patch_request);
418
419 let req = req_builder.build()?;
420 let resp = configuration.client.execute(req).await?;
421
422 let status = resp.status();
423 let content_type = resp
424 .headers()
425 .get("content-type")
426 .and_then(|v| v.to_str().ok())
427 .unwrap_or("application/octet-stream");
428 let content_type = super::ContentType::from(content_type);
429
430 if !status.is_client_error() && !status.is_server_error() {
431 let content = resp.text().await?;
432 match content_type {
433 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
434 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContinuousServiceUsage`"))),
435 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::ContinuousServiceUsage`")))),
436 }
437 } else {
438 let content = resp.text().await?;
439 let entity: Option<PatchContinuousServiceUsageIdError> = serde_json::from_str(&content).ok();
440 Err(Error::ResponseError(ResponseContent { status, content, entity }))
441 }
442}
443
444pub async fn patch_fulfillment_id(configuration: &configuration::Configuration, fulfillment_id: &str, fulfillment_activation_patch_request: models::FulfillmentActivationPatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentResponse, Error<PatchFulfillmentIdError>> {
446 let p_path_fulfillment_id = fulfillment_id;
448 let p_body_fulfillment_activation_patch_request = fulfillment_activation_patch_request;
449 let p_header_requestor = requestor;
450 let p_header_accept_language = accept_language;
451 let p_header_traceparent = traceparent;
452 let p_header_tracestate = tracestate;
453 let p_header_idempotency_key = idempotency_key;
454 let p_header_x_accept_namespace = x_accept_namespace;
455
456 let uri_str = format!("{}/fulfillments/{fulfillmentId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_id));
457 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
458
459 if let Some(ref user_agent) = configuration.user_agent {
460 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
461 }
462 if let Some(param_value) = p_header_requestor {
463 req_builder = req_builder.header("Requestor", param_value.to_string());
464 }
465 if let Some(param_value) = p_header_accept_language {
466 req_builder = req_builder.header("Accept-Language", param_value.to_string());
467 }
468 if let Some(param_value) = p_header_traceparent {
469 req_builder = req_builder.header("traceparent", param_value.to_string());
470 }
471 if let Some(param_value) = p_header_tracestate {
472 req_builder = req_builder.header("tracestate", param_value.to_string());
473 }
474 if let Some(param_value) = p_header_idempotency_key {
475 req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
476 }
477 if let Some(param_value) = p_header_x_accept_namespace {
478 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
479 }
480 if let Some(ref token) = configuration.oauth_access_token {
481 req_builder = req_builder.bearer_auth(token.to_owned());
482 };
483 req_builder = req_builder.json(&p_body_fulfillment_activation_patch_request);
484
485 let req = req_builder.build()?;
486 let resp = configuration.client.execute(req).await?;
487
488 let status = resp.status();
489 let content_type = resp
490 .headers()
491 .get("content-type")
492 .and_then(|v| v.to_str().ok())
493 .unwrap_or("application/octet-stream");
494 let content_type = super::ContentType::from(content_type);
495
496 if !status.is_client_error() && !status.is_server_error() {
497 let content = resp.text().await?;
498 match content_type {
499 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
500 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FulfillmentResponse`"))),
501 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::FulfillmentResponse`")))),
502 }
503 } else {
504 let content = resp.text().await?;
505 let entity: Option<PatchFulfillmentIdError> = serde_json::from_str(&content).ok();
506 Err(Error::ResponseError(ResponseContent { status, content, entity }))
507 }
508}
509
510pub async fn post_fulfillments(configuration: &configuration::Configuration, booking_id: &str, fulfillment_post_request: models::FulfillmentPostRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentCollectionResponse, Error<PostFulfillmentsError>> {
512 let p_path_booking_id = booking_id;
514 let p_body_fulfillment_post_request = fulfillment_post_request;
515 let p_header_requestor = requestor;
516 let p_header_accept_language = accept_language;
517 let p_header_traceparent = traceparent;
518 let p_header_tracestate = tracestate;
519 let p_header_idempotency_key = idempotency_key;
520 let p_header_x_accept_namespace = x_accept_namespace;
521
522 let uri_str = format!("{}/bookings/{bookingId}/fulfillments", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
523 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
524
525 if let Some(ref user_agent) = configuration.user_agent {
526 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
527 }
528 if let Some(param_value) = p_header_requestor {
529 req_builder = req_builder.header("Requestor", param_value.to_string());
530 }
531 if let Some(param_value) = p_header_accept_language {
532 req_builder = req_builder.header("Accept-Language", param_value.to_string());
533 }
534 if let Some(param_value) = p_header_traceparent {
535 req_builder = req_builder.header("traceparent", param_value.to_string());
536 }
537 if let Some(param_value) = p_header_tracestate {
538 req_builder = req_builder.header("tracestate", param_value.to_string());
539 }
540 if let Some(param_value) = p_header_idempotency_key {
541 req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
542 }
543 if let Some(param_value) = p_header_x_accept_namespace {
544 req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
545 }
546 if let Some(ref token) = configuration.oauth_access_token {
547 req_builder = req_builder.bearer_auth(token.to_owned());
548 };
549 req_builder = req_builder.json(&p_body_fulfillment_post_request);
550
551 let req = req_builder.build()?;
552 let resp = configuration.client.execute(req).await?;
553
554 let status = resp.status();
555 let content_type = resp
556 .headers()
557 .get("content-type")
558 .and_then(|v| v.to_str().ok())
559 .unwrap_or("application/octet-stream");
560 let content_type = super::ContentType::from(content_type);
561
562 if !status.is_client_error() && !status.is_server_error() {
563 let content = resp.text().await?;
564 match content_type {
565 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
566 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FulfillmentCollectionResponse`"))),
567 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::FulfillmentCollectionResponse`")))),
568 }
569 } else {
570 let content = resp.text().await?;
571 let entity: Option<PostFulfillmentsError> = serde_json::from_str(&content).ok();
572 Err(Error::ResponseError(ResponseContent { status, content, entity }))
573 }
574}
575