google_qpxexpress1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11// ########
12// HUB ###
13// ######
14
15/// Central instance to access all QPXExpress related resource activities
16///
17/// # Examples
18///
19/// Instantiate a new hub
20///
21/// ```test_harness,no_run
22/// extern crate hyper;
23/// extern crate hyper_rustls;
24/// extern crate google_qpxexpress1 as qpxexpress1;
25/// use qpxexpress1::api::TripsSearchRequest;
26/// use qpxexpress1::{Result, Error};
27/// # async fn dox() {
28/// use qpxexpress1::{QPXExpress, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29///
30/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
31/// // `client_secret`, among other things.
32/// let secret: yup_oauth2::ApplicationSecret = Default::default();
33/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
34/// // unless you replace `None` with the desired Flow.
35/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
36/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
37/// // retrieve them from storage.
38/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
39/// .with_native_roots()
40/// .unwrap()
41/// .https_only()
42/// .enable_http2()
43/// .build();
44///
45/// let executor = hyper_util::rt::TokioExecutor::new();
46/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
47/// secret,
48/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
49/// yup_oauth2::client::CustomHyperClientBuilder::from(
50/// hyper_util::client::legacy::Client::builder(executor).build(connector),
51/// ),
52/// ).build().await.unwrap();
53///
54/// let client = hyper_util::client::legacy::Client::builder(
55/// hyper_util::rt::TokioExecutor::new()
56/// )
57/// .build(
58/// hyper_rustls::HttpsConnectorBuilder::new()
59/// .with_native_roots()
60/// .unwrap()
61/// .https_or_http()
62/// .enable_http2()
63/// .build()
64/// );
65/// let mut hub = QPXExpress::new(client, auth);
66/// // As the method needs a request, you would usually fill it with the desired information
67/// // into the respective structure. Some of the parts shown here might not be applicable !
68/// // Values shown here are possibly random and not representative !
69/// let mut req = TripsSearchRequest::default();
70///
71/// // You can configure optional parameters by calling the respective setters at will, and
72/// // execute the final call using `doit()`.
73/// // Values shown here are possibly random and not representative !
74/// let result = hub.trips().search(req)
75/// .doit().await;
76///
77/// match result {
78/// Err(e) => match e {
79/// // The Error enum provides details about what exactly happened.
80/// // You can also just use its `Debug`, `Display` or `Error` traits
81/// Error::HttpError(_)
82/// |Error::Io(_)
83/// |Error::MissingAPIKey
84/// |Error::MissingToken(_)
85/// |Error::Cancelled
86/// |Error::UploadSizeLimitExceeded(_, _)
87/// |Error::Failure(_)
88/// |Error::BadRequest(_)
89/// |Error::FieldClash(_)
90/// |Error::JsonDecodeError(_, _) => println!("{}", e),
91/// },
92/// Ok(res) => println!("Success: {:?}", res),
93/// }
94/// # }
95/// ```
96#[derive(Clone)]
97pub struct QPXExpress<C> {
98 pub client: common::Client<C>,
99 pub auth: Box<dyn common::GetToken>,
100 _user_agent: String,
101 _base_url: String,
102 _root_url: String,
103}
104
105impl<C> common::Hub for QPXExpress<C> {}
106
107impl<'a, C> QPXExpress<C> {
108 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> QPXExpress<C> {
109 QPXExpress {
110 client,
111 auth: Box::new(auth),
112 _user_agent: "google-api-rust-client/7.0.0".to_string(),
113 _base_url: "https://www.googleapis.com/qpxExpress/v1/trips/".to_string(),
114 _root_url: "https://www.googleapis.com/".to_string(),
115 }
116 }
117
118 pub fn trips(&'a self) -> TripMethods<'a, C> {
119 TripMethods { hub: self }
120 }
121
122 /// Set the user-agent header field to use in all requests to the server.
123 /// It defaults to `google-api-rust-client/7.0.0`.
124 ///
125 /// Returns the previously set user-agent.
126 pub fn user_agent(&mut self, agent_name: String) -> String {
127 std::mem::replace(&mut self._user_agent, agent_name)
128 }
129
130 /// Set the base url to use in all requests to the server.
131 /// It defaults to `https://www.googleapis.com/qpxExpress/v1/trips/`.
132 ///
133 /// Returns the previously set base url.
134 pub fn base_url(&mut self, new_base_url: String) -> String {
135 std::mem::replace(&mut self._base_url, new_base_url)
136 }
137
138 /// Set the root url to use in all requests to the server.
139 /// It defaults to `https://www.googleapis.com/`.
140 ///
141 /// Returns the previously set root url.
142 pub fn root_url(&mut self, new_root_url: String) -> String {
143 std::mem::replace(&mut self._root_url, new_root_url)
144 }
145}
146
147// ############
148// SCHEMAS ###
149// ##########
150/// The make, model, and type of an aircraft.
151///
152/// This type is not used in any activity, and only used as *part* of another schema.
153///
154#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
155#[serde_with::serde_as]
156#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
157pub struct AircraftData {
158 /// The aircraft code. For example, for a Boeing 777 the code would be 777.
159 pub code: Option<String>,
160 /// Identifies this as an aircraftData object. Value: the fixed string qpxexpress#aircraftData
161 pub kind: Option<String>,
162 /// The name of an aircraft, for example Boeing 777.
163 pub name: Option<String>,
164}
165
166impl common::Part for AircraftData {}
167
168/// An airport.
169///
170/// This type is not used in any activity, and only used as *part* of another schema.
171///
172#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
173#[serde_with::serde_as]
174#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
175pub struct AirportData {
176 /// The city code an airport is located in. For example, for JFK airport, this is NYC.
177 pub city: Option<String>,
178 /// An airport's code. For example, for Boston Logan airport, this is BOS.
179 pub code: Option<String>,
180 /// Identifies this as an airport object. Value: the fixed string qpxexpress#airportData.
181 pub kind: Option<String>,
182 /// The name of an airport. For example, for airport BOS the name is "Boston Logan International".
183 pub name: Option<String>,
184}
185
186impl common::Part for AirportData {}
187
188/// Information about an item of baggage.
189///
190/// This type is not used in any activity, and only used as *part* of another schema.
191///
192#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
193#[serde_with::serde_as]
194#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
195pub struct BagDescriptor {
196 /// Provides the commercial name for an optional service.
197 #[serde(rename = "commercialName")]
198 pub commercial_name: Option<String>,
199 /// How many of this type of bag will be checked on this flight.
200 pub count: Option<i32>,
201 /// A description of the baggage.
202 pub description: Option<Vec<String>>,
203 /// Identifies this as a baggage object. Value: the fixed string qpxexpress#bagDescriptor.
204 pub kind: Option<String>,
205 /// The standard IATA subcode used to identify this optional service.
206 pub subcode: Option<String>,
207}
208
209impl common::Part for BagDescriptor {}
210
211/// Information about a carrier (ie. an airline, bus line, railroad, etc) that might be useful to display to an end-user.
212///
213/// This type is not used in any activity, and only used as *part* of another schema.
214///
215#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
216#[serde_with::serde_as]
217#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
218pub struct CarrierData {
219 /// The IATA designator of a carrier (airline, etc). For example, for American Airlines, the code is AA.
220 pub code: Option<String>,
221 /// Identifies this as a kind of carrier (ie. an airline, bus line, railroad, etc). Value: the fixed string qpxexpress#carrierData.
222 pub kind: Option<String>,
223 /// The long, full name of a carrier. For example: American Airlines.
224 pub name: Option<String>,
225}
226
227impl common::Part for CarrierData {}
228
229/// Information about a city that might be useful to an end-user; typically the city of an airport.
230///
231/// This type is not used in any activity, and only used as *part* of another schema.
232///
233#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
234#[serde_with::serde_as]
235#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
236pub struct CityData {
237 /// The IATA character ID of a city. For example, for Boston this is BOS.
238 pub code: Option<String>,
239 /// The two-character country code of the country the city is located in. For example, US for the United States of America.
240 pub country: Option<String>,
241 /// Identifies this as a city, typically with one or more airports. Value: the fixed string qpxexpress#cityData.
242 pub kind: Option<String>,
243 /// The full name of a city. An example would be: New York.
244 pub name: Option<String>,
245}
246
247impl common::Part for CityData {}
248
249/// Detailed information about components found in the solutions of this response, including a trip's airport, city, taxes, airline, and aircraft.
250///
251/// This type is not used in any activity, and only used as *part* of another schema.
252///
253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
254#[serde_with::serde_as]
255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
256pub struct Data {
257 /// The aircraft that is flying between an origin and destination.
258 pub aircraft: Option<Vec<AircraftData>>,
259 /// The airport of an origin or destination.
260 pub airport: Option<Vec<AirportData>>,
261 /// The airline carrier of the aircraft flying between an origin and destination. Allowed values are IATA carrier codes.
262 pub carrier: Option<Vec<CarrierData>>,
263 /// The city that is either the origin or destination of part of a trip.
264 pub city: Option<Vec<CityData>>,
265 /// Identifies this as QPX Express response resource, including a trip's airport, city, taxes, airline, and aircraft. Value: the fixed string qpxexpress#data.
266 pub kind: Option<String>,
267 /// The taxes due for flying between an origin and a destination.
268 pub tax: Option<Vec<TaxData>>,
269}
270
271impl common::Part for Data {}
272
273/// Complete information about a fare used in the solution to a low-fare search query. In the airline industry a fare is a price an airline charges for one-way travel between two points. A fare typically contains a carrier code, two city codes, a price, and a fare basis. (A fare basis is a one-to-eight character alphanumeric code used to identify a fare.)
274///
275/// This type is not used in any activity, and only used as *part* of another schema.
276///
277#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
278#[serde_with::serde_as]
279#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
280pub struct FareInfo {
281 /// no description provided
282 #[serde(rename = "basisCode")]
283 pub basis_code: Option<String>,
284 /// The carrier of the aircraft or other vehicle commuting between two points.
285 pub carrier: Option<String>,
286 /// The city code of the city the trip ends at.
287 pub destination: Option<String>,
288 /// A unique identifier of the fare.
289 pub id: Option<String>,
290 /// Identifies this as a fare object. Value: the fixed string qpxexpress#fareInfo.
291 pub kind: Option<String>,
292 /// The city code of the city the trip begins at.
293 pub origin: Option<String>,
294 /// Whether this is a private fare, for example one offered only to select customers rather than the general public.
295 pub private: Option<bool>,
296}
297
298impl common::Part for FareInfo {}
299
300/// A flight is a sequence of legs with the same airline carrier and flight number. (A leg is the smallest unit of travel, in the case of a flight a takeoff immediately followed by a landing at two set points on a particular carrier with a particular flight number.) The naive view is that a flight is scheduled travel of an aircraft between two points, with possibly intermediate stops, but carriers will frequently list flights that require a change of aircraft between legs.
301///
302/// This type is not used in any activity, and only used as *part* of another schema.
303///
304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
305#[serde_with::serde_as]
306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
307pub struct FlightInfo {
308 /// no description provided
309 pub carrier: Option<String>,
310 /// The flight number.
311 pub number: Option<String>,
312}
313
314impl common::Part for FlightInfo {}
315
316/// Information about free baggage allowed on one segment of a trip.
317///
318/// This type is not used in any activity, and only used as *part* of another schema.
319///
320#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
321#[serde_with::serde_as]
322#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
323pub struct FreeBaggageAllowance {
324 /// A representation of a type of bag, such as an ATPCo subcode, Commercial Name, or other description.
325 #[serde(rename = "bagDescriptor")]
326 pub bag_descriptor: Option<Vec<BagDescriptor>>,
327 /// The maximum number of kilos all the free baggage together may weigh.
328 pub kilos: Option<i32>,
329 /// The maximum number of kilos any one piece of baggage may weigh.
330 #[serde(rename = "kilosPerPiece")]
331 pub kilos_per_piece: Option<i32>,
332 /// Identifies this as free baggage object, allowed on one segment of a trip. Value: the fixed string qpxexpress#freeBaggageAllowance.
333 pub kind: Option<String>,
334 /// The number of free pieces of baggage allowed.
335 pub pieces: Option<i32>,
336 /// The number of pounds of free baggage allowed.
337 pub pounds: Option<i32>,
338}
339
340impl common::Part for FreeBaggageAllowance {}
341
342/// Information about a leg. (A leg is the smallest unit of travel, in the case of a flight a takeoff immediately followed by a landing at two set points on a particular carrier with a particular flight number.)
343///
344/// This type is not used in any activity, and only used as *part* of another schema.
345///
346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
347#[serde_with::serde_as]
348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
349pub struct LegInfo {
350 /// The aircraft (or bus, ferry, railcar, etc) travelling between the two points of this leg.
351 pub aircraft: Option<String>,
352 /// The scheduled time of arrival at the destination of the leg, local to the point of arrival.
353 #[serde(rename = "arrivalTime")]
354 pub arrival_time: Option<String>,
355 /// Whether you have to change planes following this leg. Only applies to the next leg.
356 #[serde(rename = "changePlane")]
357 pub change_plane: Option<bool>,
358 /// Duration of a connection following this leg, in minutes.
359 #[serde(rename = "connectionDuration")]
360 pub connection_duration: Option<i32>,
361 /// The scheduled departure time of the leg, local to the point of departure.
362 #[serde(rename = "departureTime")]
363 pub departure_time: Option<String>,
364 /// The leg destination as a city and airport.
365 pub destination: Option<String>,
366 /// The terminal the flight is scheduled to arrive at.
367 #[serde(rename = "destinationTerminal")]
368 pub destination_terminal: Option<String>,
369 /// The scheduled travelling time from the origin to the destination.
370 pub duration: Option<i32>,
371 /// An identifier that uniquely identifies this leg in the solution.
372 pub id: Option<String>,
373 /// Identifies this as a leg object. A leg is the smallest unit of travel, in the case of a flight a takeoff immediately followed by a landing at two set points on a particular carrier with a particular flight number. Value: the fixed string qpxexpress#legInfo.
374 pub kind: Option<String>,
375 /// A simple, general description of the meal(s) served on the flight, for example: "Hot meal".
376 pub meal: Option<String>,
377 /// The number of miles in this leg.
378 pub mileage: Option<i32>,
379 /// In percent, the published on time performance on this leg.
380 #[serde(rename = "onTimePerformance")]
381 pub on_time_performance: Option<i32>,
382 /// Department of Transportation disclosure information on the actual operator of a flight in a code share. (A code share refers to a marketing agreement between two carriers, where one carrier will list in its schedules (and take bookings for) flights that are actually operated by another carrier.)
383 #[serde(rename = "operatingDisclosure")]
384 pub operating_disclosure: Option<String>,
385 /// The leg origin as a city and airport.
386 pub origin: Option<String>,
387 /// The terminal the flight is scheduled to depart from.
388 #[serde(rename = "originTerminal")]
389 pub origin_terminal: Option<String>,
390 /// Whether passenger information must be furnished to the United States Transportation Security Administration (TSA) prior to departure.
391 pub secure: Option<bool>,
392}
393
394impl common::Part for LegInfo {}
395
396/// The number and type of passengers. Unfortunately the definition of an infant, child, adult, and senior citizen varies across carriers and reservation systems.
397///
398/// This type is not used in any activity, and only used as *part* of another schema.
399///
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct PassengerCounts {
404 /// The number of passengers that are adults.
405 #[serde(rename = "adultCount")]
406 pub adult_count: Option<i32>,
407 /// The number of passengers that are children.
408 #[serde(rename = "childCount")]
409 pub child_count: Option<i32>,
410 /// The number of passengers that are infants travelling in the lap of an adult.
411 #[serde(rename = "infantInLapCount")]
412 pub infant_in_lap_count: Option<i32>,
413 /// The number of passengers that are infants each assigned a seat.
414 #[serde(rename = "infantInSeatCount")]
415 pub infant_in_seat_count: Option<i32>,
416 /// Identifies this as a passenger count object, representing the number of passengers. Value: the fixed string qpxexpress#passengerCounts.
417 pub kind: Option<String>,
418 /// The number of passengers that are senior citizens.
419 #[serde(rename = "seniorCount")]
420 pub senior_count: Option<i32>,
421}
422
423impl common::Part for PassengerCounts {}
424
425/// The price of one or more travel segments. The currency used to purchase tickets is usually determined by the sale/ticketing city or the sale/ticketing country, unless none are specified, in which case it defaults to that of the journey origin country.
426///
427/// This type is not used in any activity, and only used as *part* of another schema.
428///
429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
430#[serde_with::serde_as]
431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
432pub struct PricingInfo {
433 /// The total fare in the base fare currency (the currency of the country of origin). This element is only present when the sales currency and the currency of the country of commencement are different.
434 #[serde(rename = "baseFareTotal")]
435 pub base_fare_total: Option<String>,
436 /// The fare used to price one or more segments.
437 pub fare: Option<Vec<FareInfo>>,
438 /// The horizontal fare calculation. This is a field on a ticket that displays all of the relevant items that go into the calculation of the fare.
439 #[serde(rename = "fareCalculation")]
440 pub fare_calculation: Option<String>,
441 /// Identifies this as a pricing object, representing the price of one or more travel segments. Value: the fixed string qpxexpress#pricingInfo.
442 pub kind: Option<String>,
443 /// The latest ticketing time for this pricing assuming the reservation occurs at ticketing time and there is no change in fares/rules. The time is local to the point of sale (POS).
444 #[serde(rename = "latestTicketingTime")]
445 pub latest_ticketing_time: Option<String>,
446 /// The number of passengers to which this price applies.
447 pub passengers: Option<PassengerCounts>,
448 /// The passenger type code for this pricing. An alphanumeric code used by a carrier to restrict fares to certain categories of passenger. For instance, a fare might be valid only for senior citizens.
449 pub ptc: Option<String>,
450 /// Whether the fares on this pricing are refundable.
451 pub refundable: Option<bool>,
452 /// The total fare in the sale or equivalent currency.
453 #[serde(rename = "saleFareTotal")]
454 pub sale_fare_total: Option<String>,
455 /// The taxes in the sale or equivalent currency.
456 #[serde(rename = "saleTaxTotal")]
457 pub sale_tax_total: Option<String>,
458 /// Total per-passenger price (fare and tax) in the sale or equivalent currency.
459 #[serde(rename = "saleTotal")]
460 pub sale_total: Option<String>,
461 /// The per-segment price and baggage information.
462 #[serde(rename = "segmentPricing")]
463 pub segment_pricing: Option<Vec<SegmentPricing>>,
464 /// The taxes used to calculate the tax total per ticket.
465 pub tax: Option<Vec<TaxInfo>>,
466}
467
468impl common::Part for PricingInfo {}
469
470/// Details of a segment of a flight; a segment is one or more consecutive legs on the same flight. For example a hypothetical flight ZZ001, from DFW to OGG, would have one segment with two legs: DFW to HNL (leg 1), HNL to OGG (leg 2), and DFW to OGG (legs 1 and 2).
471///
472/// This type is not used in any activity, and only used as *part* of another schema.
473///
474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
475#[serde_with::serde_as]
476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
477pub struct SegmentInfo {
478 /// The booking code or class for this segment.
479 #[serde(rename = "bookingCode")]
480 pub booking_code: Option<String>,
481 /// The number of seats available in this booking code on this segment.
482 #[serde(rename = "bookingCodeCount")]
483 pub booking_code_count: Option<i32>,
484 /// The cabin booked for this segment.
485 pub cabin: Option<String>,
486 /// In minutes, the duration of the connection following this segment.
487 #[serde(rename = "connectionDuration")]
488 pub connection_duration: Option<i32>,
489 /// The duration of the flight segment in minutes.
490 pub duration: Option<i32>,
491 /// The flight this is a segment of.
492 pub flight: Option<FlightInfo>,
493 /// An id uniquely identifying the segment in the solution.
494 pub id: Option<String>,
495 /// Identifies this as a segment object. A segment is one or more consecutive legs on the same flight. For example a hypothetical flight ZZ001, from DFW to OGG, could have one segment with two legs: DFW to HNL (leg 1), HNL to OGG (leg 2). Value: the fixed string qpxexpress#segmentInfo.
496 pub kind: Option<String>,
497 /// The legs composing this segment.
498 pub leg: Option<Vec<LegInfo>>,
499 /// The solution-based index of a segment in a married segment group. Married segments can only be booked together. For example, an airline might report a certain booking code as sold out from Boston to Pittsburgh, but as available as part of two married segments Boston to Chicago connecting through Pittsburgh. For example content of this field, consider the round-trip flight ZZ1 PHX-PHL ZZ2 PHL-CLT ZZ3 CLT-PHX. This has three segments, with the two outbound ones (ZZ1 ZZ2) married. In this case, the two outbound segments belong to married segment group 0, and the return segment belongs to married segment group 1.
500 #[serde(rename = "marriedSegmentGroup")]
501 pub married_segment_group: Option<String>,
502 /// Whether the operation of this segment remains subject to government approval.
503 #[serde(rename = "subjectToGovernmentApproval")]
504 pub subject_to_government_approval: Option<bool>,
505}
506
507impl common::Part for SegmentInfo {}
508
509/// The price of this segment.
510///
511/// This type is not used in any activity, and only used as *part* of another schema.
512///
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct SegmentPricing {
517 /// A segment identifier unique within a single solution. It is used to refer to different parts of the same solution.
518 #[serde(rename = "fareId")]
519 pub fare_id: Option<String>,
520 /// Details of the free baggage allowance on this segment.
521 #[serde(rename = "freeBaggageOption")]
522 pub free_baggage_option: Option<Vec<FreeBaggageAllowance>>,
523 /// Identifies this as a segment pricing object, representing the price of this segment. Value: the fixed string qpxexpress#segmentPricing.
524 pub kind: Option<String>,
525 /// Unique identifier in the response of this segment.
526 #[serde(rename = "segmentId")]
527 pub segment_id: Option<String>,
528}
529
530impl common::Part for SegmentPricing {}
531
532/// Information about a slice. A slice represents a traveller's intent, the portion of a low-fare search corresponding to a traveler's request to get between two points. One-way journeys are generally expressed using 1 slice, round-trips using 2. For example, if a traveler specifies the following trip in a user interface:
533/// | Origin | Destination | Departure Date | | BOS | LAX | March 10, 2007 | | LAX | SYD | March 17, 2007 | | SYD | BOS | March 22, 2007 |
534/// then this is a three slice trip.
535///
536/// This type is not used in any activity, and only used as *part* of another schema.
537///
538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
539#[serde_with::serde_as]
540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
541pub struct SliceInfo {
542 /// The duration of the slice in minutes.
543 pub duration: Option<i32>,
544 /// Identifies this as a slice object. A slice represents a traveller's intent, the portion of a low-fare search corresponding to a traveler's request to get between two points. One-way journeys are generally expressed using 1 slice, round-trips using 2. Value: the fixed string qpxexpress#sliceInfo.
545 pub kind: Option<String>,
546 /// The segment(s) constituting the slice.
547 pub segment: Option<Vec<SegmentInfo>>,
548}
549
550impl common::Part for SliceInfo {}
551
552/// Criteria a desired slice must satisfy.
553///
554/// This type is not used in any activity, and only used as *part* of another schema.
555///
556#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
557#[serde_with::serde_as]
558#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
559pub struct SliceInput {
560 /// Slices with only the carriers in this alliance should be returned; do not use this field with permittedCarrier. Allowed values are ONEWORLD, SKYTEAM, and STAR.
561 pub alliance: Option<String>,
562 /// Departure date in YYYY-MM-DD format.
563 pub date: Option<String>,
564 /// Airport or city IATA designator of the destination.
565 pub destination: Option<String>,
566 /// Identifies this as a slice input object, representing the criteria a desired slice must satisfy. Value: the fixed string qpxexpress#sliceInput.
567 pub kind: Option<String>,
568 /// The longest connection between two legs, in minutes, you are willing to accept.
569 #[serde(rename = "maxConnectionDuration")]
570 pub max_connection_duration: Option<i32>,
571 /// The maximum number of stops you are willing to accept in this slice.
572 #[serde(rename = "maxStops")]
573 pub max_stops: Option<i32>,
574 /// Airport or city IATA designator of the origin.
575 pub origin: Option<String>,
576 /// A list of 2-letter IATA airline designators. Slices with only these carriers should be returned.
577 #[serde(rename = "permittedCarrier")]
578 pub permitted_carrier: Option<Vec<String>>,
579 /// Slices must depart in this time of day range, local to the point of departure.
580 #[serde(rename = "permittedDepartureTime")]
581 pub permitted_departure_time: Option<TimeOfDayRange>,
582 /// Prefer solutions that book in this cabin for this slice. Allowed values are COACH, PREMIUM_COACH, BUSINESS, and FIRST.
583 #[serde(rename = "preferredCabin")]
584 pub preferred_cabin: Option<String>,
585 /// A list of 2-letter IATA airline designators. Exclude slices that use these carriers.
586 #[serde(rename = "prohibitedCarrier")]
587 pub prohibited_carrier: Option<Vec<String>>,
588}
589
590impl common::Part for SliceInput {}
591
592/// Tax data.
593///
594/// This type is not used in any activity, and only used as *part* of another schema.
595///
596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
597#[serde_with::serde_as]
598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
599pub struct TaxData {
600 /// An identifier uniquely identifying a tax in a response.
601 pub id: Option<String>,
602 /// Identifies this as a tax data object, representing some tax. Value: the fixed string qpxexpress#taxData.
603 pub kind: Option<String>,
604 /// The name of a tax.
605 pub name: Option<String>,
606}
607
608impl common::Part for TaxData {}
609
610/// Tax information.
611///
612/// This type is not used in any activity, and only used as *part* of another schema.
613///
614#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
615#[serde_with::serde_as]
616#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
617pub struct TaxInfo {
618 /// Whether this is a government charge or a carrier surcharge.
619 #[serde(rename = "chargeType")]
620 pub charge_type: Option<String>,
621 /// The code to enter in the ticket's tax box.
622 pub code: Option<String>,
623 /// For government charges, the country levying the charge.
624 pub country: Option<String>,
625 /// Identifier uniquely identifying this tax in a response. Not present for unnamed carrier surcharges.
626 pub id: Option<String>,
627 /// Identifies this as a tax information object. Value: the fixed string qpxexpress#taxInfo.
628 pub kind: Option<String>,
629 /// The price of the tax in the sales or equivalent currency.
630 #[serde(rename = "salePrice")]
631 pub sale_price: Option<String>,
632}
633
634impl common::Part for TaxInfo {}
635
636/// Two times in a single day defining a time range.
637///
638/// This type is not used in any activity, and only used as *part* of another schema.
639///
640#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
641#[serde_with::serde_as]
642#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
643pub struct TimeOfDayRange {
644 /// The earliest time of day in HH:MM format.
645 #[serde(rename = "earliestTime")]
646 pub earliest_time: Option<String>,
647 /// Identifies this as a time of day range object, representing two times in a single day defining a time range. Value: the fixed string qpxexpress#timeOfDayRange.
648 pub kind: Option<String>,
649 /// The latest time of day in HH:MM format.
650 #[serde(rename = "latestTime")]
651 pub latest_time: Option<String>,
652}
653
654impl common::Part for TimeOfDayRange {}
655
656/// Trip information.
657///
658/// This type is not used in any activity, and only used as *part* of another schema.
659///
660#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
661#[serde_with::serde_as]
662#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
663pub struct TripOption {
664 /// Identifier uniquely identifying this trip in a response.
665 pub id: Option<String>,
666 /// Identifies this as a trip information object. Value: the fixed string qpxexpress#tripOption.
667 pub kind: Option<String>,
668 /// Per passenger pricing information.
669 pub pricing: Option<Vec<PricingInfo>>,
670 /// The total price for all passengers on the trip, in the form of a currency followed by an amount, e.g. USD253.35.
671 #[serde(rename = "saleTotal")]
672 pub sale_total: Option<String>,
673 /// The slices that make up this trip's itinerary.
674 pub slice: Option<Vec<SliceInfo>>,
675}
676
677impl common::Part for TripOption {}
678
679/// A QPX Express search request, which will yield one or more solutions.
680///
681/// This type is not used in any activity, and only used as *part* of another schema.
682///
683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
684#[serde_with::serde_as]
685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
686pub struct TripOptionsRequest {
687 /// Do not return solutions that cost more than this price. The alphabetical part of the price is in ISO 4217. The format, in regex, is [A-Z]{3}\d+(\.\d+)? Example: $102.07
688 #[serde(rename = "maxPrice")]
689 pub max_price: Option<String>,
690 /// Counts for each passenger type in the request.
691 pub passengers: Option<PassengerCounts>,
692 /// Return only solutions with refundable fares.
693 pub refundable: Option<bool>,
694 /// IATA country code representing the point of sale. This determines the "equivalent amount paid" currency for the ticket.
695 #[serde(rename = "saleCountry")]
696 pub sale_country: Option<String>,
697 /// The slices that make up the itinerary of this trip. A slice represents a traveler's intent, the portion of a low-fare search corresponding to a traveler's request to get between two points. One-way journeys are generally expressed using one slice, round-trips using two. An example of a one slice trip with three segments might be BOS-SYD, SYD-LAX, LAX-BOS if the traveler only stopped in SYD and LAX just long enough to change planes.
698 pub slice: Option<Vec<SliceInput>>,
699 /// The number of solutions to return, maximum 500.
700 pub solutions: Option<i32>,
701 /// IATA country code representing the point of ticketing.
702 #[serde(rename = "ticketingCountry")]
703 pub ticketing_country: Option<String>,
704}
705
706impl common::Part for TripOptionsRequest {}
707
708/// A QPX Express search response.
709///
710/// This type is not used in any activity, and only used as *part* of another schema.
711///
712#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
713#[serde_with::serde_as]
714#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
715pub struct TripOptionsResponse {
716 /// Informational data global to list of solutions.
717 pub data: Option<Data>,
718 /// Identifies this as a QPX Express trip response object, which consists of zero or more solutions. Value: the fixed string qpxexpress#tripOptions.
719 pub kind: Option<String>,
720 /// An identifier uniquely identifying this response.
721 #[serde(rename = "requestId")]
722 pub request_id: Option<String>,
723 /// A list of priced itinerary solutions to the QPX Express query.
724 #[serde(rename = "tripOption")]
725 pub trip_option: Option<Vec<TripOption>>,
726}
727
728impl common::Part for TripOptionsResponse {}
729
730/// A QPX Express search request.
731///
732/// # Activities
733///
734/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
735/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
736///
737/// * [search trips](TripSearchCall) (request)
738#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
739#[serde_with::serde_as]
740#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
741pub struct TripsSearchRequest {
742 /// A QPX Express search request. Required values are at least one adult or senior passenger, an origin, a destination, and a date.
743 pub request: Option<TripOptionsRequest>,
744}
745
746impl common::RequestValue for TripsSearchRequest {}
747
748/// A QPX Express search response.
749///
750/// # Activities
751///
752/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
753/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
754///
755/// * [search trips](TripSearchCall) (response)
756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
757#[serde_with::serde_as]
758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
759pub struct TripsSearchResponse {
760 /// Identifies this as a QPX Express API search response resource. Value: the fixed string qpxExpress#tripsSearch.
761 pub kind: Option<String>,
762 /// All possible solutions to the QPX Express search request.
763 pub trips: Option<TripOptionsResponse>,
764}
765
766impl common::ResponseResult for TripsSearchResponse {}
767
768// ###################
769// MethodBuilders ###
770// #################
771
772/// A builder providing access to all methods supported on *trip* resources.
773/// It is not used directly, but through the [`QPXExpress`] hub.
774///
775/// # Example
776///
777/// Instantiate a resource builder
778///
779/// ```test_harness,no_run
780/// extern crate hyper;
781/// extern crate hyper_rustls;
782/// extern crate google_qpxexpress1 as qpxexpress1;
783///
784/// # async fn dox() {
785/// use qpxexpress1::{QPXExpress, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
786///
787/// let secret: yup_oauth2::ApplicationSecret = Default::default();
788/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
789/// .with_native_roots()
790/// .unwrap()
791/// .https_only()
792/// .enable_http2()
793/// .build();
794///
795/// let executor = hyper_util::rt::TokioExecutor::new();
796/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
797/// secret,
798/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
799/// yup_oauth2::client::CustomHyperClientBuilder::from(
800/// hyper_util::client::legacy::Client::builder(executor).build(connector),
801/// ),
802/// ).build().await.unwrap();
803///
804/// let client = hyper_util::client::legacy::Client::builder(
805/// hyper_util::rt::TokioExecutor::new()
806/// )
807/// .build(
808/// hyper_rustls::HttpsConnectorBuilder::new()
809/// .with_native_roots()
810/// .unwrap()
811/// .https_or_http()
812/// .enable_http2()
813/// .build()
814/// );
815/// let mut hub = QPXExpress::new(client, auth);
816/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
817/// // like `search(...)`
818/// // to build up your call.
819/// let rb = hub.trips();
820/// # }
821/// ```
822pub struct TripMethods<'a, C>
823where
824 C: 'a,
825{
826 hub: &'a QPXExpress<C>,
827}
828
829impl<'a, C> common::MethodsBuilder for TripMethods<'a, C> {}
830
831impl<'a, C> TripMethods<'a, C> {
832 /// Create a builder to help you perform the following task:
833 ///
834 /// Returns a list of flights.
835 ///
836 /// # Arguments
837 ///
838 /// * `request` - No description provided.
839 pub fn search(&self, request: TripsSearchRequest) -> TripSearchCall<'a, C> {
840 TripSearchCall {
841 hub: self.hub,
842 _request: request,
843 _delegate: Default::default(),
844 _additional_params: Default::default(),
845 }
846 }
847}
848
849// ###################
850// CallBuilders ###
851// #################
852
853/// Returns a list of flights.
854///
855/// A builder for the *search* method supported by a *trip* resource.
856/// It is not used directly, but through a [`TripMethods`] instance.
857///
858/// # Example
859///
860/// Instantiate a resource method builder
861///
862/// ```test_harness,no_run
863/// # extern crate hyper;
864/// # extern crate hyper_rustls;
865/// # extern crate google_qpxexpress1 as qpxexpress1;
866/// use qpxexpress1::api::TripsSearchRequest;
867/// # async fn dox() {
868/// # use qpxexpress1::{QPXExpress, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
869///
870/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
871/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
872/// # .with_native_roots()
873/// # .unwrap()
874/// # .https_only()
875/// # .enable_http2()
876/// # .build();
877///
878/// # let executor = hyper_util::rt::TokioExecutor::new();
879/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
880/// # secret,
881/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
882/// # yup_oauth2::client::CustomHyperClientBuilder::from(
883/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
884/// # ),
885/// # ).build().await.unwrap();
886///
887/// # let client = hyper_util::client::legacy::Client::builder(
888/// # hyper_util::rt::TokioExecutor::new()
889/// # )
890/// # .build(
891/// # hyper_rustls::HttpsConnectorBuilder::new()
892/// # .with_native_roots()
893/// # .unwrap()
894/// # .https_or_http()
895/// # .enable_http2()
896/// # .build()
897/// # );
898/// # let mut hub = QPXExpress::new(client, auth);
899/// // As the method needs a request, you would usually fill it with the desired information
900/// // into the respective structure. Some of the parts shown here might not be applicable !
901/// // Values shown here are possibly random and not representative !
902/// let mut req = TripsSearchRequest::default();
903///
904/// // You can configure optional parameters by calling the respective setters at will, and
905/// // execute the final call using `doit()`.
906/// // Values shown here are possibly random and not representative !
907/// let result = hub.trips().search(req)
908/// .doit().await;
909/// # }
910/// ```
911pub struct TripSearchCall<'a, C>
912where
913 C: 'a,
914{
915 hub: &'a QPXExpress<C>,
916 _request: TripsSearchRequest,
917 _delegate: Option<&'a mut dyn common::Delegate>,
918 _additional_params: HashMap<String, String>,
919}
920
921impl<'a, C> common::CallBuilder for TripSearchCall<'a, C> {}
922
923impl<'a, C> TripSearchCall<'a, C>
924where
925 C: common::Connector,
926{
927 /// Perform the operation you have build so far.
928 pub async fn doit(mut self) -> common::Result<(common::Response, TripsSearchResponse)> {
929 use std::borrow::Cow;
930 use std::io::{Read, Seek};
931
932 use common::{url::Params, ToParts};
933 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
934
935 let mut dd = common::DefaultDelegate;
936 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
937 dlg.begin(common::MethodInfo {
938 id: "qpxExpress.trips.search",
939 http_method: hyper::Method::POST,
940 });
941
942 for &field in ["alt"].iter() {
943 if self._additional_params.contains_key(field) {
944 dlg.finished(false);
945 return Err(common::Error::FieldClash(field));
946 }
947 }
948
949 let mut params = Params::with_capacity(3 + self._additional_params.len());
950
951 params.extend(self._additional_params.iter());
952
953 params.push("alt", "json");
954 let mut url = self.hub._base_url.clone() + "search";
955
956 match dlg.api_key() {
957 Some(value) => params.push("key", value),
958 None => {
959 dlg.finished(false);
960 return Err(common::Error::MissingAPIKey);
961 }
962 }
963
964 let url = params.parse_with_url(&url);
965
966 let mut json_mime_type = mime::APPLICATION_JSON;
967 let mut request_value_reader = {
968 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
969 common::remove_json_null_values(&mut value);
970 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
971 serde_json::to_writer(&mut dst, &value).unwrap();
972 dst
973 };
974 let request_size = request_value_reader
975 .seek(std::io::SeekFrom::End(0))
976 .unwrap();
977 request_value_reader
978 .seek(std::io::SeekFrom::Start(0))
979 .unwrap();
980
981 loop {
982 request_value_reader
983 .seek(std::io::SeekFrom::Start(0))
984 .unwrap();
985 let mut req_result = {
986 let client = &self.hub.client;
987 dlg.pre_request();
988 let mut req_builder = hyper::Request::builder()
989 .method(hyper::Method::POST)
990 .uri(url.as_str())
991 .header(USER_AGENT, self.hub._user_agent.clone());
992
993 let request = req_builder
994 .header(CONTENT_TYPE, json_mime_type.to_string())
995 .header(CONTENT_LENGTH, request_size as u64)
996 .body(common::to_body(
997 request_value_reader.get_ref().clone().into(),
998 ));
999
1000 client.request(request.unwrap()).await
1001 };
1002
1003 match req_result {
1004 Err(err) => {
1005 if let common::Retry::After(d) = dlg.http_error(&err) {
1006 sleep(d).await;
1007 continue;
1008 }
1009 dlg.finished(false);
1010 return Err(common::Error::HttpError(err));
1011 }
1012 Ok(res) => {
1013 let (mut parts, body) = res.into_parts();
1014 let mut body = common::Body::new(body);
1015 if !parts.status.is_success() {
1016 let bytes = common::to_bytes(body).await.unwrap_or_default();
1017 let error = serde_json::from_str(&common::to_string(&bytes));
1018 let response = common::to_response(parts, bytes.into());
1019
1020 if let common::Retry::After(d) =
1021 dlg.http_failure(&response, error.as_ref().ok())
1022 {
1023 sleep(d).await;
1024 continue;
1025 }
1026
1027 dlg.finished(false);
1028
1029 return Err(match error {
1030 Ok(value) => common::Error::BadRequest(value),
1031 _ => common::Error::Failure(response),
1032 });
1033 }
1034 let response = {
1035 let bytes = common::to_bytes(body).await.unwrap_or_default();
1036 let encoded = common::to_string(&bytes);
1037 match serde_json::from_str(&encoded) {
1038 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1039 Err(error) => {
1040 dlg.response_json_decode_error(&encoded, &error);
1041 return Err(common::Error::JsonDecodeError(
1042 encoded.to_string(),
1043 error,
1044 ));
1045 }
1046 }
1047 };
1048
1049 dlg.finished(true);
1050 return Ok(response);
1051 }
1052 }
1053 }
1054 }
1055
1056 ///
1057 /// Sets the *request* property to the given value.
1058 ///
1059 /// Even though the property as already been set when instantiating this call,
1060 /// we provide this method for API completeness.
1061 pub fn request(mut self, new_value: TripsSearchRequest) -> TripSearchCall<'a, C> {
1062 self._request = new_value;
1063 self
1064 }
1065 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1066 /// while executing the actual API request.
1067 ///
1068 /// ````text
1069 /// It should be used to handle progress information, and to implement a certain level of resilience.
1070 /// ````
1071 ///
1072 /// Sets the *delegate* property to the given value.
1073 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TripSearchCall<'a, C> {
1074 self._delegate = Some(new_value);
1075 self
1076 }
1077
1078 /// Set any additional parameter of the query string used in the request.
1079 /// It should be used to set parameters which are not yet available through their own
1080 /// setters.
1081 ///
1082 /// Please note that this method must not be used to set any of the known parameters
1083 /// which have their own setter method. If done anyway, the request will fail.
1084 ///
1085 /// # Additional Parameters
1086 ///
1087 /// * *alt* (query-string) - Data format for the response.
1088 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1089 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1090 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1091 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1092 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1093 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1094 pub fn param<T>(mut self, name: T, value: T) -> TripSearchCall<'a, C>
1095 where
1096 T: AsRef<str>,
1097 {
1098 self._additional_params
1099 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1100 self
1101 }
1102}