google_content2_sandbox/
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/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// Manage your product listings and accounts for Google Shopping
17    Full,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::Full => "https://www.googleapis.com/auth/content",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::Full
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all ShoppingContent related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_content2_sandbox as content2_sandbox;
49/// use content2_sandbox::{Result, Error};
50/// # async fn dox() {
51/// use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace  `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62///     .with_native_roots()
63///     .unwrap()
64///     .https_only()
65///     .enable_http2()
66///     .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70///     secret,
71///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72///     yup_oauth2::client::CustomHyperClientBuilder::from(
73///         hyper_util::client::legacy::Client::builder(executor).build(connector),
74///     ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78///     hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81///     hyper_rustls::HttpsConnectorBuilder::new()
82///         .with_native_roots()
83///         .unwrap()
84///         .https_or_http()
85///         .enable_http2()
86///         .build()
87/// );
88/// let mut hub = ShoppingContent::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.orders().list(97)
93///              .add_statuses("ea")
94///              .placed_date_start("ipsum")
95///              .placed_date_end("invidunt")
96///              .page_token("amet")
97///              .order_by("duo")
98///              .max_results(51)
99///              .acknowledged(false)
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct ShoppingContent<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for ShoppingContent<C> {}
131
132impl<'a, C> ShoppingContent<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> ShoppingContent<C> {
137        ShoppingContent {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://www.googleapis.com/content/v2sandbox/".to_string(),
142            _root_url: "https://www.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn orderinvoices(&'a self) -> OrderinvoiceMethods<'a, C> {
147        OrderinvoiceMethods { hub: self }
148    }
149    pub fn orderpayments(&'a self) -> OrderpaymentMethods<'a, C> {
150        OrderpaymentMethods { hub: self }
151    }
152    pub fn orderreturns(&'a self) -> OrderreturnMethods<'a, C> {
153        OrderreturnMethods { hub: self }
154    }
155    pub fn orders(&'a self) -> OrderMethods<'a, C> {
156        OrderMethods { hub: self }
157    }
158
159    /// Set the user-agent header field to use in all requests to the server.
160    /// It defaults to `google-api-rust-client/7.0.0`.
161    ///
162    /// Returns the previously set user-agent.
163    pub fn user_agent(&mut self, agent_name: String) -> String {
164        std::mem::replace(&mut self._user_agent, agent_name)
165    }
166
167    /// Set the base url to use in all requests to the server.
168    /// It defaults to `https://www.googleapis.com/content/v2sandbox/`.
169    ///
170    /// Returns the previously set base url.
171    pub fn base_url(&mut self, new_base_url: String) -> String {
172        std::mem::replace(&mut self._base_url, new_base_url)
173    }
174
175    /// Set the root url to use in all requests to the server.
176    /// It defaults to `https://www.googleapis.com/`.
177    ///
178    /// Returns the previously set root url.
179    pub fn root_url(&mut self, new_root_url: String) -> String {
180        std::mem::replace(&mut self._root_url, new_root_url)
181    }
182}
183
184// ############
185// SCHEMAS ###
186// ##########
187/// There is no detailed description.
188///
189/// This type is not used in any activity, and only used as *part* of another schema.
190///
191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
192#[serde_with::serde_as]
193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
194pub struct Amount {
195    /// [required] Value before taxes.
196    pub pretax: Option<Price>,
197    /// [required] Tax value.
198    pub tax: Option<Price>,
199}
200
201impl common::Part for Amount {}
202
203/// There is no detailed description.
204///
205/// This type is not used in any activity, and only used as *part* of another schema.
206///
207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
208#[serde_with::serde_as]
209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
210pub struct CustomerReturnReason {
211    /// no description provided
212    pub description: Option<String>,
213    /// no description provided
214    #[serde(rename = "reasonCode")]
215    pub reason_code: Option<String>,
216}
217
218impl common::Part for CustomerReturnReason {}
219
220/// An error returned by the API.
221///
222/// This type is not used in any activity, and only used as *part* of another schema.
223///
224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
225#[serde_with::serde_as]
226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
227pub struct Error {
228    /// The domain of the error.
229    pub domain: Option<String>,
230    /// A description of the error.
231    pub message: Option<String>,
232    /// The error code.
233    pub reason: Option<String>,
234}
235
236impl common::Part for Error {}
237
238/// A list of errors returned by a failed batch entry.
239///
240/// This type is not used in any activity, and only used as *part* of another schema.
241///
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct Errors {
246    /// The HTTP status of the first error in errors.
247    pub code: Option<u32>,
248    /// A list of errors.
249    pub errors: Option<Vec<Error>>,
250    /// The message of the first error in errors.
251    pub message: Option<String>,
252}
253
254impl common::Part for Errors {}
255
256/// There is no detailed description.
257///
258/// This type is not used in any activity, and only used as *part* of another schema.
259///
260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
261#[serde_with::serde_as]
262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
263pub struct InvoiceSummary {
264    /// Summary of the total amounts of the additional charges.
265    #[serde(rename = "additionalChargeSummaries")]
266    pub additional_charge_summaries: Option<Vec<InvoiceSummaryAdditionalChargeSummary>>,
267    /// [required] Customer balance on this invoice. A negative amount means the customer is paying, a positive one means the customer is receiving money. Note: the sum of merchant_balance, customer_balance and google_balance must always be zero.
268    ///
269    /// Furthermore the absolute value of this amount is expected to be equal to the sum of product amount and additional charges, minus promotions.
270    #[serde(rename = "customerBalance")]
271    pub customer_balance: Option<Amount>,
272    /// [required] Google balance on this invoice. A negative amount means Google is paying, a positive one means Google is receiving money. Note: the sum of merchant_balance, customer_balance and google_balance must always be zero.
273    #[serde(rename = "googleBalance")]
274    pub google_balance: Option<Amount>,
275    /// [required] Merchant balance on this invoice. A negative amount means the merchant is paying, a positive one means the merchant is receiving money. Note: the sum of merchant_balance, customer_balance and google_balance must always be zero.
276    #[serde(rename = "merchantBalance")]
277    pub merchant_balance: Option<Amount>,
278    /// [required] Total price for the product.
279    #[serde(rename = "productTotal")]
280    pub product_total: Option<Amount>,
281    /// Summary for each promotion.
282    #[serde(rename = "promotionSummaries")]
283    pub promotion_summaries: Option<Vec<Promotion>>,
284}
285
286impl common::Part for InvoiceSummary {}
287
288/// There is no detailed description.
289///
290/// This type is not used in any activity, and only used as *part* of another schema.
291///
292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
293#[serde_with::serde_as]
294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
295pub struct InvoiceSummaryAdditionalChargeSummary {
296    /// [required] Total additional charge for this type.
297    #[serde(rename = "totalAmount")]
298    pub total_amount: Option<Amount>,
299    /// [required] Type of the additional charge.
300    #[serde(rename = "type")]
301    pub type_: Option<String>,
302}
303
304impl common::Part for InvoiceSummaryAdditionalChargeSummary {}
305
306/// There is no detailed description.
307///
308/// # Activities
309///
310/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
311/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
312///
313/// * [get orderreturns](OrderreturnGetCall) (response)
314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
315#[serde_with::serde_as]
316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
317pub struct MerchantOrderReturn {
318    /// no description provided
319    #[serde(rename = "creationDate")]
320    pub creation_date: Option<String>,
321    /// no description provided
322    #[serde(rename = "merchantOrderId")]
323    pub merchant_order_id: Option<String>,
324    /// no description provided
325    #[serde(rename = "orderId")]
326    pub order_id: Option<String>,
327    /// no description provided
328    #[serde(rename = "orderReturnId")]
329    pub order_return_id: Option<String>,
330    /// no description provided
331    #[serde(rename = "returnItems")]
332    pub return_items: Option<Vec<MerchantOrderReturnItem>>,
333    /// no description provided
334    #[serde(rename = "returnShipments")]
335    pub return_shipments: Option<Vec<ReturnShipment>>,
336}
337
338impl common::ResponseResult for MerchantOrderReturn {}
339
340/// There is no detailed description.
341///
342/// This type is not used in any activity, and only used as *part* of another schema.
343///
344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
345#[serde_with::serde_as]
346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
347pub struct MerchantOrderReturnItem {
348    /// no description provided
349    #[serde(rename = "customerReturnReason")]
350    pub customer_return_reason: Option<CustomerReturnReason>,
351    /// no description provided
352    #[serde(rename = "itemId")]
353    pub item_id: Option<String>,
354    /// no description provided
355    #[serde(rename = "merchantReturnReason")]
356    pub merchant_return_reason: Option<RefundReason>,
357    /// no description provided
358    pub product: Option<OrderLineItemProduct>,
359    /// no description provided
360    #[serde(rename = "returnShipmentIds")]
361    pub return_shipment_ids: Option<Vec<String>>,
362    /// no description provided
363    pub state: Option<String>,
364}
365
366impl common::Part for MerchantOrderReturnItem {}
367
368/// There is no detailed description.
369///
370/// # Activities
371///
372/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
373/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
374///
375/// * [acknowledge orders](OrderAcknowledgeCall) (none)
376/// * [advancetestorder orders](OrderAdvancetestorderCall) (none)
377/// * [cancel orders](OrderCancelCall) (none)
378/// * [cancellineitem orders](OrderCancellineitemCall) (none)
379/// * [canceltestorderbycustomer orders](OrderCanceltestorderbycustomerCall) (none)
380/// * [createtestorder orders](OrderCreatetestorderCall) (none)
381/// * [createtestreturn orders](OrderCreatetestreturnCall) (none)
382/// * [custombatch orders](OrderCustombatchCall) (none)
383/// * [get orders](OrderGetCall) (response)
384/// * [getbymerchantorderid orders](OrderGetbymerchantorderidCall) (none)
385/// * [gettestordertemplate orders](OrderGettestordertemplateCall) (none)
386/// * [instorerefundlineitem orders](OrderInstorerefundlineitemCall) (none)
387/// * [list orders](OrderListCall) (none)
388/// * [refund orders](OrderRefundCall) (none)
389/// * [rejectreturnlineitem orders](OrderRejectreturnlineitemCall) (none)
390/// * [returnlineitem orders](OrderReturnlineitemCall) (none)
391/// * [returnrefundlineitem orders](OrderReturnrefundlineitemCall) (none)
392/// * [setlineitemmetadata orders](OrderSetlineitemmetadataCall) (none)
393/// * [shiplineitems orders](OrderShiplineitemCall) (none)
394/// * [updatelineitemshippingdetails orders](OrderUpdatelineitemshippingdetailCall) (none)
395/// * [updatemerchantorderid orders](OrderUpdatemerchantorderidCall) (none)
396/// * [updateshipment orders](OrderUpdateshipmentCall) (none)
397#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
398#[serde_with::serde_as]
399#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
400pub struct Order {
401    /// Whether the order was acknowledged.
402    pub acknowledged: Option<bool>,
403    /// The channel type of the order: "purchaseOnGoogle" or "googleExpress".
404    #[serde(rename = "channelType")]
405    pub channel_type: Option<String>,
406    /// The details of the customer who placed the order.
407    pub customer: Option<OrderCustomer>,
408    /// The details for the delivery.
409    #[serde(rename = "deliveryDetails")]
410    pub delivery_details: Option<OrderDeliveryDetails>,
411    /// The REST id of the order. Globally unique.
412    pub id: Option<String>,
413    /// Identifies what kind of resource this is. Value: the fixed string "content#order".
414    pub kind: Option<String>,
415    /// Line items that are ordered.
416    #[serde(rename = "lineItems")]
417    pub line_items: Option<Vec<OrderLineItem>>,
418    /// no description provided
419    #[serde(rename = "merchantId")]
420    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
421    pub merchant_id: Option<u64>,
422    /// Merchant-provided id of the order.
423    #[serde(rename = "merchantOrderId")]
424    pub merchant_order_id: Option<String>,
425    /// The net amount for the order. For example, if an order was originally for a grand total of $100 and a refund was issued for $20, the net amount will be $80.
426    #[serde(rename = "netAmount")]
427    pub net_amount: Option<Price>,
428    /// The details of the payment method.
429    #[serde(rename = "paymentMethod")]
430    pub payment_method: Option<OrderPaymentMethod>,
431    /// The status of the payment.
432    #[serde(rename = "paymentStatus")]
433    pub payment_status: Option<String>,
434    /// The date when the order was placed, in ISO 8601 format.
435    #[serde(rename = "placedDate")]
436    pub placed_date: Option<String>,
437    /// Deprecated. The details of the merchant provided promotions applied to the order. More details about the program are here.
438    pub promotions: Option<Vec<OrderLegacyPromotion>>,
439    /// Refunds for the order.
440    pub refunds: Option<Vec<OrderRefund>>,
441    /// Shipments of the order.
442    pub shipments: Option<Vec<OrderShipment>>,
443    /// The total cost of shipping for all items.
444    #[serde(rename = "shippingCost")]
445    pub shipping_cost: Option<Price>,
446    /// The tax for the total shipping cost.
447    #[serde(rename = "shippingCostTax")]
448    pub shipping_cost_tax: Option<Price>,
449    /// The requested shipping option.
450    #[serde(rename = "shippingOption")]
451    pub shipping_option: Option<String>,
452    /// The status of the order.
453    pub status: Option<String>,
454}
455
456impl common::Resource for Order {}
457impl common::ResponseResult for Order {}
458
459/// There is no detailed description.
460///
461/// This type is not used in any activity, and only used as *part* of another schema.
462///
463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
464#[serde_with::serde_as]
465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
466pub struct OrderAddress {
467    /// CLDR country code (e.g. "US").
468    pub country: Option<String>,
469    /// Strings representing the lines of the printed label for mailing the order, for example:
470    /// John Smith
471    /// 1600 Amphitheatre Parkway
472    /// Mountain View, CA, 94043
473    /// United States
474    #[serde(rename = "fullAddress")]
475    pub full_address: Option<Vec<String>>,
476    /// Whether the address is a post office box.
477    #[serde(rename = "isPostOfficeBox")]
478    pub is_post_office_box: Option<bool>,
479    /// City, town or commune. May also include dependent localities or sublocalities (e.g. neighborhoods or suburbs).
480    pub locality: Option<String>,
481    /// Postal Code or ZIP (e.g. "94043").
482    #[serde(rename = "postalCode")]
483    pub postal_code: Option<String>,
484    /// Name of the recipient.
485    #[serde(rename = "recipientName")]
486    pub recipient_name: Option<String>,
487    /// Top-level administrative subdivision of the country. For example, a state like California ("CA") or a province like Quebec ("QC").
488    pub region: Option<String>,
489    /// Street-level part of the address.
490    #[serde(rename = "streetAddress")]
491    pub street_address: Option<Vec<String>>,
492}
493
494impl common::Part for OrderAddress {}
495
496/// There is no detailed description.
497///
498/// This type is not used in any activity, and only used as *part* of another schema.
499///
500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
501#[serde_with::serde_as]
502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
503pub struct OrderCancellation {
504    /// The actor that created the cancellation.
505    pub actor: Option<String>,
506    /// Date on which the cancellation has been created, in ISO 8601 format.
507    #[serde(rename = "creationDate")]
508    pub creation_date: Option<String>,
509    /// The quantity that was canceled.
510    pub quantity: Option<u32>,
511    /// The reason for the cancellation. Orders that are cancelled with a noInventory reason will lead to the removal of the product from Shopping Actions until you make an update to that product. This will not affect your Shopping ads.
512    pub reason: Option<String>,
513    /// The explanation of the reason.
514    #[serde(rename = "reasonText")]
515    pub reason_text: Option<String>,
516}
517
518impl common::Part for OrderCancellation {}
519
520/// There is no detailed description.
521///
522/// This type is not used in any activity, and only used as *part* of another schema.
523///
524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
525#[serde_with::serde_as]
526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
527pub struct OrderCustomer {
528    /// Deprecated.
529    pub email: Option<String>,
530    /// Deprecated. Please use marketingRightsInfo instead.
531    #[serde(rename = "explicitMarketingPreference")]
532    pub explicit_marketing_preference: Option<bool>,
533    /// Full name of the customer.
534    #[serde(rename = "fullName")]
535    pub full_name: Option<String>,
536    /// Customer's marketing preferences.
537    #[serde(rename = "marketingRightsInfo")]
538    pub marketing_rights_info: Option<OrderCustomerMarketingRightsInfo>,
539}
540
541impl common::Part for OrderCustomer {}
542
543/// There is no detailed description.
544///
545/// This type is not used in any activity, and only used as *part* of another schema.
546///
547#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
548#[serde_with::serde_as]
549#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
550pub struct OrderCustomerMarketingRightsInfo {
551    /// Last known user selection regarding marketing preferences. In certain cases this selection might not be known, so this field would be empty.
552    #[serde(rename = "explicitMarketingPreference")]
553    pub explicit_marketing_preference: Option<String>,
554    /// Timestamp when last time marketing preference was updated. Could be empty, if user wasn't offered a selection yet.
555    #[serde(rename = "lastUpdatedTimestamp")]
556    pub last_updated_timestamp: Option<String>,
557    /// Email address that can be used for marketing purposes. This field is only filled when explicitMarketingPreference is equal to 'granted'.
558    #[serde(rename = "marketingEmailAddress")]
559    pub marketing_email_address: Option<String>,
560}
561
562impl common::Part for OrderCustomerMarketingRightsInfo {}
563
564/// There is no detailed description.
565///
566/// This type is not used in any activity, and only used as *part* of another schema.
567///
568#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
569#[serde_with::serde_as]
570#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
571pub struct OrderDeliveryDetails {
572    /// The delivery address
573    pub address: Option<OrderAddress>,
574    /// The phone number of the person receiving the delivery.
575    #[serde(rename = "phoneNumber")]
576    pub phone_number: Option<String>,
577}
578
579impl common::Part for OrderDeliveryDetails {}
580
581/// There is no detailed description.
582///
583/// This type is not used in any activity, and only used as *part* of another schema.
584///
585#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
586#[serde_with::serde_as]
587#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
588pub struct OrderLegacyPromotion {
589    /// no description provided
590    pub benefits: Option<Vec<OrderLegacyPromotionBenefit>>,
591    /// The date and time frame when the promotion is active and ready for validation review. Note that the promotion live time may be delayed for a few hours due to the validation review.
592    /// Start date and end date are separated by a forward slash (/). The start date is specified by the format (YYYY-MM-DD), followed by the letter ?T?, the time of the day when the sale starts (in Greenwich Mean Time, GMT), followed by an expression of the time zone for the sale. The end date is in the same format.
593    #[serde(rename = "effectiveDates")]
594    pub effective_dates: Option<String>,
595    /// Optional. The text code that corresponds to the promotion when applied on the retailer?s website.
596    #[serde(rename = "genericRedemptionCode")]
597    pub generic_redemption_code: Option<String>,
598    /// The unique ID of the promotion.
599    pub id: Option<String>,
600    /// The full title of the promotion.
601    #[serde(rename = "longTitle")]
602    pub long_title: Option<String>,
603    /// Whether the promotion is applicable to all products or only specific products.
604    #[serde(rename = "productApplicability")]
605    pub product_applicability: Option<String>,
606    /// Indicates that the promotion is valid online.
607    #[serde(rename = "redemptionChannel")]
608    pub redemption_channel: Option<String>,
609}
610
611impl common::Part for OrderLegacyPromotion {}
612
613/// There is no detailed description.
614///
615/// This type is not used in any activity, and only used as *part* of another schema.
616///
617#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
618#[serde_with::serde_as]
619#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
620pub struct OrderLegacyPromotionBenefit {
621    /// The discount in the order price when the promotion is applied.
622    pub discount: Option<Price>,
623    /// The OfferId(s) that were purchased in this order and map to this specific benefit of the promotion.
624    #[serde(rename = "offerIds")]
625    pub offer_ids: Option<Vec<String>>,
626    /// Further describes the benefit of the promotion. Note that we will expand on this enumeration as we support new promotion sub-types.
627    #[serde(rename = "subType")]
628    pub sub_type: Option<String>,
629    /// The impact on tax when the promotion is applied.
630    #[serde(rename = "taxImpact")]
631    pub tax_impact: Option<Price>,
632    /// Describes whether the promotion applies to products (e.g. 20% off) or to shipping (e.g. Free Shipping).
633    #[serde(rename = "type")]
634    pub type_: Option<String>,
635}
636
637impl common::Part for OrderLegacyPromotionBenefit {}
638
639/// There is no detailed description.
640///
641/// This type is not used in any activity, and only used as *part* of another schema.
642///
643#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
644#[serde_with::serde_as]
645#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
646pub struct OrderLineItem {
647    /// Annotations that are attached to the line item.
648    pub annotations: Option<Vec<OrderMerchantProvidedAnnotation>>,
649    /// Cancellations of the line item.
650    pub cancellations: Option<Vec<OrderCancellation>>,
651    /// The id of the line item.
652    pub id: Option<String>,
653    /// Total price for the line item. For example, if two items for $10 are purchased, the total price will be $20.
654    pub price: Option<Price>,
655    /// Product data from the time of the order placement.
656    pub product: Option<OrderLineItemProduct>,
657    /// Number of items canceled.
658    #[serde(rename = "quantityCanceled")]
659    pub quantity_canceled: Option<u32>,
660    /// Number of items delivered.
661    #[serde(rename = "quantityDelivered")]
662    pub quantity_delivered: Option<u32>,
663    /// Number of items ordered.
664    #[serde(rename = "quantityOrdered")]
665    pub quantity_ordered: Option<u32>,
666    /// Number of items pending.
667    #[serde(rename = "quantityPending")]
668    pub quantity_pending: Option<u32>,
669    /// Number of items returned.
670    #[serde(rename = "quantityReturned")]
671    pub quantity_returned: Option<u32>,
672    /// Number of items shipped.
673    #[serde(rename = "quantityShipped")]
674    pub quantity_shipped: Option<u32>,
675    /// Details of the return policy for the line item.
676    #[serde(rename = "returnInfo")]
677    pub return_info: Option<OrderLineItemReturnInfo>,
678    /// Returns of the line item.
679    pub returns: Option<Vec<OrderReturn>>,
680    /// Details of the requested shipping for the line item.
681    #[serde(rename = "shippingDetails")]
682    pub shipping_details: Option<OrderLineItemShippingDetails>,
683    /// Total tax amount for the line item. For example, if two items are purchased, and each have a cost tax of $2, the total tax amount will be $4.
684    pub tax: Option<Price>,
685}
686
687impl common::Part for OrderLineItem {}
688
689/// There is no detailed description.
690///
691/// This type is not used in any activity, and only used as *part* of another schema.
692///
693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
694#[serde_with::serde_as]
695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
696pub struct OrderLineItemProduct {
697    /// Brand of the item.
698    pub brand: Option<String>,
699    /// The item's channel (online or local).
700    pub channel: Option<String>,
701    /// Condition or state of the item.
702    pub condition: Option<String>,
703    /// The two-letter ISO 639-1 language code for the item.
704    #[serde(rename = "contentLanguage")]
705    pub content_language: Option<String>,
706    /// Global Trade Item Number (GTIN) of the item.
707    pub gtin: Option<String>,
708    /// The REST id of the product.
709    pub id: Option<String>,
710    /// URL of an image of the item.
711    #[serde(rename = "imageLink")]
712    pub image_link: Option<String>,
713    /// Shared identifier for all variants of the same product.
714    #[serde(rename = "itemGroupId")]
715    pub item_group_id: Option<String>,
716    /// Manufacturer Part Number (MPN) of the item.
717    pub mpn: Option<String>,
718    /// An identifier of the item.
719    #[serde(rename = "offerId")]
720    pub offer_id: Option<String>,
721    /// Price of the item.
722    pub price: Option<Price>,
723    /// URL to the cached image shown to the user when order was placed.
724    #[serde(rename = "shownImage")]
725    pub shown_image: Option<String>,
726    /// The CLDR territory code of the target country of the product.
727    #[serde(rename = "targetCountry")]
728    pub target_country: Option<String>,
729    /// The title of the product.
730    pub title: Option<String>,
731    /// Variant attributes for the item. These are dimensions of the product, such as color, gender, material, pattern, and size. You can find a comprehensive list of variant attributes here.
732    #[serde(rename = "variantAttributes")]
733    pub variant_attributes: Option<Vec<OrderLineItemProductVariantAttribute>>,
734}
735
736impl common::Part for OrderLineItemProduct {}
737
738/// There is no detailed description.
739///
740/// This type is not used in any activity, and only used as *part* of another schema.
741///
742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
743#[serde_with::serde_as]
744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
745pub struct OrderLineItemProductVariantAttribute {
746    /// The dimension of the variant.
747    pub dimension: Option<String>,
748    /// The value for the dimension.
749    pub value: Option<String>,
750}
751
752impl common::Part for OrderLineItemProductVariantAttribute {}
753
754/// There is no detailed description.
755///
756/// This type is not used in any activity, and only used as *part* of another schema.
757///
758#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
759#[serde_with::serde_as]
760#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
761pub struct OrderLineItemReturnInfo {
762    /// How many days later the item can be returned.
763    #[serde(rename = "daysToReturn")]
764    pub days_to_return: Option<i32>,
765    /// Whether the item is returnable.
766    #[serde(rename = "isReturnable")]
767    pub is_returnable: Option<bool>,
768    /// URL of the item return policy.
769    #[serde(rename = "policyUrl")]
770    pub policy_url: Option<String>,
771}
772
773impl common::Part for OrderLineItemReturnInfo {}
774
775/// There is no detailed description.
776///
777/// This type is not used in any activity, and only used as *part* of another schema.
778///
779#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
780#[serde_with::serde_as]
781#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
782pub struct OrderLineItemShippingDetails {
783    /// The delivery by date, in ISO 8601 format.
784    #[serde(rename = "deliverByDate")]
785    pub deliver_by_date: Option<String>,
786    /// Details of the shipping method.
787    pub method: Option<OrderLineItemShippingDetailsMethod>,
788    /// The ship by date, in ISO 8601 format.
789    #[serde(rename = "shipByDate")]
790    pub ship_by_date: Option<String>,
791}
792
793impl common::Part for OrderLineItemShippingDetails {}
794
795/// There is no detailed description.
796///
797/// This type is not used in any activity, and only used as *part* of another schema.
798///
799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
800#[serde_with::serde_as]
801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
802pub struct OrderLineItemShippingDetailsMethod {
803    /// The carrier for the shipping. Optional. See shipments[].carrier for a list of acceptable values.
804    pub carrier: Option<String>,
805    /// Maximum transit time.
806    #[serde(rename = "maxDaysInTransit")]
807    pub max_days_in_transit: Option<u32>,
808    /// The name of the shipping method.
809    #[serde(rename = "methodName")]
810    pub method_name: Option<String>,
811    /// Minimum transit time.
812    #[serde(rename = "minDaysInTransit")]
813    pub min_days_in_transit: Option<u32>,
814}
815
816impl common::Part for OrderLineItemShippingDetailsMethod {}
817
818/// There is no detailed description.
819///
820/// This type is not used in any activity, and only used as *part* of another schema.
821///
822#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
823#[serde_with::serde_as]
824#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
825pub struct OrderMerchantProvidedAnnotation {
826    /// Key for additional merchant provided (as key-value pairs) annotation about the line item.
827    pub key: Option<String>,
828    /// Value for additional merchant provided (as key-value pairs) annotation about the line item.
829    pub value: Option<String>,
830}
831
832impl common::Part for OrderMerchantProvidedAnnotation {}
833
834/// There is no detailed description.
835///
836/// This type is not used in any activity, and only used as *part* of another schema.
837///
838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
839#[serde_with::serde_as]
840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
841pub struct OrderPaymentMethod {
842    /// The billing address.
843    #[serde(rename = "billingAddress")]
844    pub billing_address: Option<OrderAddress>,
845    /// The card expiration month (January = 1, February = 2 etc.).
846    #[serde(rename = "expirationMonth")]
847    pub expiration_month: Option<i32>,
848    /// The card expiration year (4-digit, e.g. 2015).
849    #[serde(rename = "expirationYear")]
850    pub expiration_year: Option<i32>,
851    /// The last four digits of the card number.
852    #[serde(rename = "lastFourDigits")]
853    pub last_four_digits: Option<String>,
854    /// The billing phone number.
855    #[serde(rename = "phoneNumber")]
856    pub phone_number: Option<String>,
857    /// The type of instrument.
858    ///
859    /// Acceptable values are:  
860    /// - "AMEX"
861    /// - "DISCOVER"
862    /// - "JCB"
863    /// - "MASTERCARD"
864    /// - "UNIONPAY"
865    /// - "VISA"
866    /// - ""
867    #[serde(rename = "type")]
868    pub type_: Option<String>,
869}
870
871impl common::Part for OrderPaymentMethod {}
872
873/// There is no detailed description.
874///
875/// This type is not used in any activity, and only used as *part* of another schema.
876///
877#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
878#[serde_with::serde_as]
879#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
880pub struct OrderRefund {
881    /// The actor that created the refund.
882    pub actor: Option<String>,
883    /// The amount that is refunded.
884    pub amount: Option<Price>,
885    /// Date on which the item has been created, in ISO 8601 format.
886    #[serde(rename = "creationDate")]
887    pub creation_date: Option<String>,
888    /// The reason for the refund.
889    pub reason: Option<String>,
890    /// The explanation of the reason.
891    #[serde(rename = "reasonText")]
892    pub reason_text: Option<String>,
893}
894
895impl common::Part for OrderRefund {}
896
897/// There is no detailed description.
898///
899/// This type is not used in any activity, and only used as *part* of another schema.
900///
901#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
902#[serde_with::serde_as]
903#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
904pub struct OrderReturn {
905    /// The actor that created the refund.
906    pub actor: Option<String>,
907    /// Date on which the item has been created, in ISO 8601 format.
908    #[serde(rename = "creationDate")]
909    pub creation_date: Option<String>,
910    /// Quantity that is returned.
911    pub quantity: Option<u32>,
912    /// The reason for the return.
913    pub reason: Option<String>,
914    /// The explanation of the reason.
915    #[serde(rename = "reasonText")]
916    pub reason_text: Option<String>,
917}
918
919impl common::Part for OrderReturn {}
920
921/// There is no detailed description.
922///
923/// This type is not used in any activity, and only used as *part* of another schema.
924///
925#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
926#[serde_with::serde_as]
927#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
928pub struct OrderShipment {
929    /// The carrier handling the shipment.
930    ///
931    /// Acceptable values are:  
932    /// - "gsx"
933    /// - "ups"
934    /// - "usps"
935    /// - "fedex"
936    /// - "dhl"
937    /// - "ecourier"
938    /// - "cxt"
939    /// - "google"
940    /// - "ontrac"
941    /// - "emsy"
942    /// - "ont"
943    /// - "deliv"
944    /// - "dynamex"
945    /// - "lasership"
946    /// - "mpx"
947    /// - "uds"
948    pub carrier: Option<String>,
949    /// Date on which the shipment has been created, in ISO 8601 format.
950    #[serde(rename = "creationDate")]
951    pub creation_date: Option<String>,
952    /// Date on which the shipment has been delivered, in ISO 8601 format. Present only if status is delivered
953    #[serde(rename = "deliveryDate")]
954    pub delivery_date: Option<String>,
955    /// The id of the shipment.
956    pub id: Option<String>,
957    /// The line items that are shipped.
958    #[serde(rename = "lineItems")]
959    pub line_items: Option<Vec<OrderShipmentLineItemShipment>>,
960    /// The status of the shipment.
961    pub status: Option<String>,
962    /// The tracking id for the shipment.
963    #[serde(rename = "trackingId")]
964    pub tracking_id: Option<String>,
965}
966
967impl common::Part for OrderShipment {}
968
969/// There is no detailed description.
970///
971/// This type is not used in any activity, and only used as *part* of another schema.
972///
973#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
974#[serde_with::serde_as]
975#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
976pub struct OrderShipmentLineItemShipment {
977    /// The id of the line item that is shipped. Either lineItemId or productId is required.
978    #[serde(rename = "lineItemId")]
979    pub line_item_id: Option<String>,
980    /// The ID of the product to ship. This is the REST ID used in the products service. Either lineItemId or productId is required.
981    #[serde(rename = "productId")]
982    pub product_id: Option<String>,
983    /// The quantity that is shipped.
984    pub quantity: Option<u32>,
985}
986
987impl common::Part for OrderShipmentLineItemShipment {}
988
989/// There is no detailed description.
990///
991/// # Activities
992///
993/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
994/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
995///
996/// * [createchargeinvoice orderinvoices](OrderinvoiceCreatechargeinvoiceCall) (request)
997#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
998#[serde_with::serde_as]
999#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1000pub struct OrderinvoicesCreateChargeInvoiceRequest {
1001    /// [required] The ID of the invoice.
1002    #[serde(rename = "invoiceId")]
1003    pub invoice_id: Option<String>,
1004    /// [required] Invoice summary.
1005    #[serde(rename = "invoiceSummary")]
1006    pub invoice_summary: Option<InvoiceSummary>,
1007    /// [required] Invoice details per line item.
1008    #[serde(rename = "lineItemInvoices")]
1009    pub line_item_invoices: Option<Vec<ShipmentInvoiceLineItemInvoice>>,
1010    /// [required] The ID of the operation, unique across all operations for a given order.
1011    #[serde(rename = "operationId")]
1012    pub operation_id: Option<String>,
1013    /// [required] ID of the shipment group.
1014    #[serde(rename = "shipmentGroupId")]
1015    pub shipment_group_id: Option<String>,
1016}
1017
1018impl common::RequestValue for OrderinvoicesCreateChargeInvoiceRequest {}
1019
1020/// There is no detailed description.
1021///
1022/// # Activities
1023///
1024/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1025/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1026///
1027/// * [createchargeinvoice orderinvoices](OrderinvoiceCreatechargeinvoiceCall) (response)
1028#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1029#[serde_with::serde_as]
1030#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1031pub struct OrderinvoicesCreateChargeInvoiceResponse {
1032    /// The status of the execution.
1033    #[serde(rename = "executionStatus")]
1034    pub execution_status: Option<String>,
1035    /// Identifies what kind of resource this is. Value: the fixed string "content#orderinvoicesCreateChargeInvoiceResponse".
1036    pub kind: Option<String>,
1037}
1038
1039impl common::ResponseResult for OrderinvoicesCreateChargeInvoiceResponse {}
1040
1041/// There is no detailed description.
1042///
1043/// # Activities
1044///
1045/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1046/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1047///
1048/// * [createrefundinvoice orderinvoices](OrderinvoiceCreaterefundinvoiceCall) (request)
1049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1050#[serde_with::serde_as]
1051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1052pub struct OrderinvoicesCreateRefundInvoiceRequest {
1053    /// [required] The ID of the invoice.
1054    #[serde(rename = "invoiceId")]
1055    pub invoice_id: Option<String>,
1056    /// [required] The ID of the operation, unique across all operations for a given order.
1057    #[serde(rename = "operationId")]
1058    pub operation_id: Option<String>,
1059    /// Option to create a refund-only invoice. Exactly one of refundOnlyOption or returnOption must be provided.
1060    #[serde(rename = "refundOnlyOption")]
1061    pub refund_only_option:
1062        Option<OrderinvoicesCustomBatchRequestEntryCreateRefundInvoiceRefundOption>,
1063    /// Option to create an invoice for a refund and mark all items within the invoice as returned. Exactly one of refundOnlyOption or returnOption must be provided.
1064    #[serde(rename = "returnOption")]
1065    pub return_option: Option<OrderinvoicesCustomBatchRequestEntryCreateRefundInvoiceReturnOption>,
1066    /// Invoice details for different shipment groups.
1067    #[serde(rename = "shipmentInvoices")]
1068    pub shipment_invoices: Option<Vec<ShipmentInvoice>>,
1069}
1070
1071impl common::RequestValue for OrderinvoicesCreateRefundInvoiceRequest {}
1072
1073/// There is no detailed description.
1074///
1075/// # Activities
1076///
1077/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1078/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1079///
1080/// * [createrefundinvoice orderinvoices](OrderinvoiceCreaterefundinvoiceCall) (response)
1081#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1082#[serde_with::serde_as]
1083#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1084pub struct OrderinvoicesCreateRefundInvoiceResponse {
1085    /// The status of the execution.
1086    #[serde(rename = "executionStatus")]
1087    pub execution_status: Option<String>,
1088    /// Identifies what kind of resource this is. Value: the fixed string "content#orderinvoicesCreateRefundInvoiceResponse".
1089    pub kind: Option<String>,
1090}
1091
1092impl common::ResponseResult for OrderinvoicesCreateRefundInvoiceResponse {}
1093
1094/// There is no detailed description.
1095///
1096/// This type is not used in any activity, and only used as *part* of another schema.
1097///
1098#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1099#[serde_with::serde_as]
1100#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1101pub struct OrderinvoicesCustomBatchRequestEntryCreateRefundInvoiceRefundOption {
1102    /// Optional description of the refund reason.
1103    pub description: Option<String>,
1104    /// [required] Reason for the refund.
1105    pub reason: Option<String>,
1106}
1107
1108impl common::Part for OrderinvoicesCustomBatchRequestEntryCreateRefundInvoiceRefundOption {}
1109
1110/// There is no detailed description.
1111///
1112/// This type is not used in any activity, and only used as *part* of another schema.
1113///
1114#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1115#[serde_with::serde_as]
1116#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1117pub struct OrderinvoicesCustomBatchRequestEntryCreateRefundInvoiceReturnOption {
1118    /// Optional description of the return reason.
1119    pub description: Option<String>,
1120    /// [required] Reason for the return.
1121    pub reason: Option<String>,
1122}
1123
1124impl common::Part for OrderinvoicesCustomBatchRequestEntryCreateRefundInvoiceReturnOption {}
1125
1126/// There is no detailed description.
1127///
1128/// # Activities
1129///
1130/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1131/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1132///
1133/// * [notifyauthapproved orderpayments](OrderpaymentNotifyauthapprovedCall) (request)
1134#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1135#[serde_with::serde_as]
1136#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1137pub struct OrderpaymentsNotifyAuthApprovedRequest {
1138    /// no description provided
1139    #[serde(rename = "authAmountPretax")]
1140    pub auth_amount_pretax: Option<Price>,
1141    /// no description provided
1142    #[serde(rename = "authAmountTax")]
1143    pub auth_amount_tax: Option<Price>,
1144}
1145
1146impl common::RequestValue for OrderpaymentsNotifyAuthApprovedRequest {}
1147
1148/// There is no detailed description.
1149///
1150/// # Activities
1151///
1152/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1153/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1154///
1155/// * [notifyauthapproved orderpayments](OrderpaymentNotifyauthapprovedCall) (response)
1156#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1157#[serde_with::serde_as]
1158#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1159pub struct OrderpaymentsNotifyAuthApprovedResponse {
1160    /// The status of the execution.
1161    #[serde(rename = "executionStatus")]
1162    pub execution_status: Option<String>,
1163    /// Identifies what kind of resource this is. Value: the fixed string "content#orderpaymentsNotifyAuthApprovedResponse".
1164    pub kind: Option<String>,
1165}
1166
1167impl common::ResponseResult for OrderpaymentsNotifyAuthApprovedResponse {}
1168
1169/// There is no detailed description.
1170///
1171/// # Activities
1172///
1173/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1174/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1175///
1176/// * [notifyauthdeclined orderpayments](OrderpaymentNotifyauthdeclinedCall) (request)
1177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1178#[serde_with::serde_as]
1179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1180pub struct OrderpaymentsNotifyAuthDeclinedRequest {
1181    /// Reason why payment authorization was declined.
1182    #[serde(rename = "declineReason")]
1183    pub decline_reason: Option<String>,
1184}
1185
1186impl common::RequestValue for OrderpaymentsNotifyAuthDeclinedRequest {}
1187
1188/// There is no detailed description.
1189///
1190/// # Activities
1191///
1192/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1193/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1194///
1195/// * [notifyauthdeclined orderpayments](OrderpaymentNotifyauthdeclinedCall) (response)
1196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1197#[serde_with::serde_as]
1198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1199pub struct OrderpaymentsNotifyAuthDeclinedResponse {
1200    /// The status of the execution.
1201    #[serde(rename = "executionStatus")]
1202    pub execution_status: Option<String>,
1203    /// Identifies what kind of resource this is. Value: the fixed string "content#orderpaymentsNotifyAuthDeclinedResponse".
1204    pub kind: Option<String>,
1205}
1206
1207impl common::ResponseResult for OrderpaymentsNotifyAuthDeclinedResponse {}
1208
1209/// There is no detailed description.
1210///
1211/// # Activities
1212///
1213/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1214/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1215///
1216/// * [notifycharge orderpayments](OrderpaymentNotifychargeCall) (request)
1217#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1218#[serde_with::serde_as]
1219#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1220pub struct OrderpaymentsNotifyChargeRequest {
1221    /// Whether charge was successful.
1222    #[serde(rename = "chargeState")]
1223    pub charge_state: Option<String>,
1224    /// Deprecated. Please use invoiceIds instead.
1225    #[serde(rename = "invoiceId")]
1226    pub invoice_id: Option<String>,
1227    /// Invoice IDs from the orderinvoices service that correspond to the charge.
1228    #[serde(rename = "invoiceIds")]
1229    pub invoice_ids: Option<Vec<String>>,
1230}
1231
1232impl common::RequestValue for OrderpaymentsNotifyChargeRequest {}
1233
1234/// There is no detailed description.
1235///
1236/// # Activities
1237///
1238/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1239/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1240///
1241/// * [notifycharge orderpayments](OrderpaymentNotifychargeCall) (response)
1242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1243#[serde_with::serde_as]
1244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1245pub struct OrderpaymentsNotifyChargeResponse {
1246    /// The status of the execution.
1247    #[serde(rename = "executionStatus")]
1248    pub execution_status: Option<String>,
1249    /// Identifies what kind of resource this is. Value: the fixed string "content#orderpaymentsNotifyChargeResponse".
1250    pub kind: Option<String>,
1251}
1252
1253impl common::ResponseResult for OrderpaymentsNotifyChargeResponse {}
1254
1255/// There is no detailed description.
1256///
1257/// # Activities
1258///
1259/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1260/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1261///
1262/// * [notifyrefund orderpayments](OrderpaymentNotifyrefundCall) (request)
1263#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1264#[serde_with::serde_as]
1265#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1266pub struct OrderpaymentsNotifyRefundRequest {
1267    /// Deprecated. Please use invoiceIds instead.
1268    #[serde(rename = "invoiceId")]
1269    pub invoice_id: Option<String>,
1270    /// Invoice IDs from the orderinvoices service that correspond to the refund.
1271    #[serde(rename = "invoiceIds")]
1272    pub invoice_ids: Option<Vec<String>>,
1273    /// Whether refund was successful.
1274    #[serde(rename = "refundState")]
1275    pub refund_state: Option<String>,
1276}
1277
1278impl common::RequestValue for OrderpaymentsNotifyRefundRequest {}
1279
1280/// There is no detailed description.
1281///
1282/// # Activities
1283///
1284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1286///
1287/// * [notifyrefund orderpayments](OrderpaymentNotifyrefundCall) (response)
1288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1289#[serde_with::serde_as]
1290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1291pub struct OrderpaymentsNotifyRefundResponse {
1292    /// The status of the execution.
1293    #[serde(rename = "executionStatus")]
1294    pub execution_status: Option<String>,
1295    /// Identifies what kind of resource this is. Value: the fixed string "content#orderpaymentsNotifyRefundResponse".
1296    pub kind: Option<String>,
1297}
1298
1299impl common::ResponseResult for OrderpaymentsNotifyRefundResponse {}
1300
1301/// There is no detailed description.
1302///
1303/// # Activities
1304///
1305/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1306/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1307///
1308/// * [list orderreturns](OrderreturnListCall) (response)
1309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1310#[serde_with::serde_as]
1311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1312pub struct OrderreturnsListResponse {
1313    /// Identifies what kind of resource this is. Value: the fixed string "content#orderreturnsListResponse".
1314    pub kind: Option<String>,
1315    /// The token for the retrieval of the next page of returns.
1316    #[serde(rename = "nextPageToken")]
1317    pub next_page_token: Option<String>,
1318    /// no description provided
1319    pub resources: Option<Vec<MerchantOrderReturn>>,
1320}
1321
1322impl common::ResponseResult for OrderreturnsListResponse {}
1323
1324/// There is no detailed description.
1325///
1326/// # Activities
1327///
1328/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1329/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1330///
1331/// * [acknowledge orders](OrderAcknowledgeCall) (request)
1332#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1333#[serde_with::serde_as]
1334#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1335pub struct OrdersAcknowledgeRequest {
1336    /// The ID of the operation. Unique across all operations for a given order.
1337    #[serde(rename = "operationId")]
1338    pub operation_id: Option<String>,
1339}
1340
1341impl common::RequestValue for OrdersAcknowledgeRequest {}
1342
1343/// There is no detailed description.
1344///
1345/// # Activities
1346///
1347/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1348/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1349///
1350/// * [acknowledge orders](OrderAcknowledgeCall) (response)
1351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1352#[serde_with::serde_as]
1353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1354pub struct OrdersAcknowledgeResponse {
1355    /// The status of the execution.
1356    #[serde(rename = "executionStatus")]
1357    pub execution_status: Option<String>,
1358    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersAcknowledgeResponse".
1359    pub kind: Option<String>,
1360}
1361
1362impl common::ResponseResult for OrdersAcknowledgeResponse {}
1363
1364/// There is no detailed description.
1365///
1366/// # Activities
1367///
1368/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1369/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1370///
1371/// * [advancetestorder orders](OrderAdvancetestorderCall) (response)
1372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1373#[serde_with::serde_as]
1374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1375pub struct OrdersAdvanceTestOrderResponse {
1376    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersAdvanceTestOrderResponse".
1377    pub kind: Option<String>,
1378}
1379
1380impl common::ResponseResult for OrdersAdvanceTestOrderResponse {}
1381
1382/// There is no detailed description.
1383///
1384/// # Activities
1385///
1386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1388///
1389/// * [cancellineitem orders](OrderCancellineitemCall) (request)
1390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1391#[serde_with::serde_as]
1392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1393pub struct OrdersCancelLineItemRequest {
1394    /// Deprecated. Please use amountPretax and amountTax instead.
1395    pub amount: Option<Price>,
1396    /// Amount to refund for the cancelation. Optional. If not set, Google will calculate the default based on the price and tax of the items involved. The amount must not be larger than the net amount left on the order.
1397    #[serde(rename = "amountPretax")]
1398    pub amount_pretax: Option<Price>,
1399    /// Tax amount that correspond to cancellation amount in amountPretax.
1400    #[serde(rename = "amountTax")]
1401    pub amount_tax: Option<Price>,
1402    /// The ID of the line item to cancel. Either lineItemId or productId is required.
1403    #[serde(rename = "lineItemId")]
1404    pub line_item_id: Option<String>,
1405    /// The ID of the operation. Unique across all operations for a given order.
1406    #[serde(rename = "operationId")]
1407    pub operation_id: Option<String>,
1408    /// The ID of the product to cancel. This is the REST ID used in the products service. Either lineItemId or productId is required.
1409    #[serde(rename = "productId")]
1410    pub product_id: Option<String>,
1411    /// The quantity to cancel.
1412    pub quantity: Option<u32>,
1413    /// The reason for the cancellation.
1414    pub reason: Option<String>,
1415    /// The explanation of the reason.
1416    #[serde(rename = "reasonText")]
1417    pub reason_text: Option<String>,
1418}
1419
1420impl common::RequestValue for OrdersCancelLineItemRequest {}
1421
1422/// There is no detailed description.
1423///
1424/// # Activities
1425///
1426/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1427/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1428///
1429/// * [cancellineitem orders](OrderCancellineitemCall) (response)
1430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1431#[serde_with::serde_as]
1432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1433pub struct OrdersCancelLineItemResponse {
1434    /// The status of the execution.
1435    #[serde(rename = "executionStatus")]
1436    pub execution_status: Option<String>,
1437    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCancelLineItemResponse".
1438    pub kind: Option<String>,
1439}
1440
1441impl common::ResponseResult for OrdersCancelLineItemResponse {}
1442
1443/// There is no detailed description.
1444///
1445/// # Activities
1446///
1447/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1448/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1449///
1450/// * [cancel orders](OrderCancelCall) (request)
1451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1452#[serde_with::serde_as]
1453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1454pub struct OrdersCancelRequest {
1455    /// The ID of the operation. Unique across all operations for a given order.
1456    #[serde(rename = "operationId")]
1457    pub operation_id: Option<String>,
1458    /// The reason for the cancellation.
1459    pub reason: Option<String>,
1460    /// The explanation of the reason.
1461    #[serde(rename = "reasonText")]
1462    pub reason_text: Option<String>,
1463}
1464
1465impl common::RequestValue for OrdersCancelRequest {}
1466
1467/// There is no detailed description.
1468///
1469/// # Activities
1470///
1471/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1472/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1473///
1474/// * [cancel orders](OrderCancelCall) (response)
1475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1476#[serde_with::serde_as]
1477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1478pub struct OrdersCancelResponse {
1479    /// The status of the execution.
1480    #[serde(rename = "executionStatus")]
1481    pub execution_status: Option<String>,
1482    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCancelResponse".
1483    pub kind: Option<String>,
1484}
1485
1486impl common::ResponseResult for OrdersCancelResponse {}
1487
1488/// There is no detailed description.
1489///
1490/// # Activities
1491///
1492/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1494///
1495/// * [canceltestorderbycustomer orders](OrderCanceltestorderbycustomerCall) (request)
1496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1497#[serde_with::serde_as]
1498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1499pub struct OrdersCancelTestOrderByCustomerRequest {
1500    /// The reason for the cancellation.
1501    pub reason: Option<String>,
1502}
1503
1504impl common::RequestValue for OrdersCancelTestOrderByCustomerRequest {}
1505
1506/// There is no detailed description.
1507///
1508/// # Activities
1509///
1510/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1511/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1512///
1513/// * [canceltestorderbycustomer orders](OrderCanceltestorderbycustomerCall) (response)
1514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1515#[serde_with::serde_as]
1516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1517pub struct OrdersCancelTestOrderByCustomerResponse {
1518    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCancelTestOrderByCustomerResponse".
1519    pub kind: Option<String>,
1520}
1521
1522impl common::ResponseResult for OrdersCancelTestOrderByCustomerResponse {}
1523
1524/// There is no detailed description.
1525///
1526/// # Activities
1527///
1528/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1529/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1530///
1531/// * [createtestorder orders](OrderCreatetestorderCall) (request)
1532#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1533#[serde_with::serde_as]
1534#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1535pub struct OrdersCreateTestOrderRequest {
1536    /// The  CLDR territory code of the country of the test order to create. Affects the currency and addresses of orders created via template_name, or the addresses of orders created via test_order.
1537    ///
1538    /// Acceptable values are:  
1539    /// - "US"
1540    /// - "FR"  Defaults to US.
1541    pub country: Option<String>,
1542    /// The test order template to use. Specify as an alternative to testOrder as a shortcut for retrieving a template and then creating an order using that template.
1543    #[serde(rename = "templateName")]
1544    pub template_name: Option<String>,
1545    /// The test order to create.
1546    #[serde(rename = "testOrder")]
1547    pub test_order: Option<TestOrder>,
1548}
1549
1550impl common::RequestValue for OrdersCreateTestOrderRequest {}
1551
1552/// There is no detailed description.
1553///
1554/// # Activities
1555///
1556/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1557/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1558///
1559/// * [createtestorder orders](OrderCreatetestorderCall) (response)
1560#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1561#[serde_with::serde_as]
1562#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1563pub struct OrdersCreateTestOrderResponse {
1564    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCreateTestOrderResponse".
1565    pub kind: Option<String>,
1566    /// The ID of the newly created test order.
1567    #[serde(rename = "orderId")]
1568    pub order_id: Option<String>,
1569}
1570
1571impl common::ResponseResult for OrdersCreateTestOrderResponse {}
1572
1573/// There is no detailed description.
1574///
1575/// # Activities
1576///
1577/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1578/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1579///
1580/// * [createtestreturn orders](OrderCreatetestreturnCall) (request)
1581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1582#[serde_with::serde_as]
1583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1584pub struct OrdersCreateTestReturnRequest {
1585    /// Returned items.
1586    pub items: Option<Vec<OrdersCustomBatchRequestEntryCreateTestReturnReturnItem>>,
1587}
1588
1589impl common::RequestValue for OrdersCreateTestReturnRequest {}
1590
1591/// There is no detailed description.
1592///
1593/// # Activities
1594///
1595/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1596/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1597///
1598/// * [createtestreturn orders](OrderCreatetestreturnCall) (response)
1599#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1600#[serde_with::serde_as]
1601#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1602pub struct OrdersCreateTestReturnResponse {
1603    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCreateTestReturnResponse".
1604    pub kind: Option<String>,
1605    /// The ID of the newly created test order return.
1606    #[serde(rename = "returnId")]
1607    pub return_id: Option<String>,
1608}
1609
1610impl common::ResponseResult for OrdersCreateTestReturnResponse {}
1611
1612/// There is no detailed description.
1613///
1614/// # Activities
1615///
1616/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1617/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1618///
1619/// * [custombatch orders](OrderCustombatchCall) (request)
1620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1621#[serde_with::serde_as]
1622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1623pub struct OrdersCustomBatchRequest {
1624    /// The request entries to be processed in the batch.
1625    pub entries: Option<Vec<OrdersCustomBatchRequestEntry>>,
1626}
1627
1628impl common::RequestValue for OrdersCustomBatchRequest {}
1629
1630/// There is no detailed description.
1631///
1632/// This type is not used in any activity, and only used as *part* of another schema.
1633///
1634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1635#[serde_with::serde_as]
1636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1637pub struct OrdersCustomBatchRequestEntry {
1638    /// An entry ID, unique within the batch request.
1639    #[serde(rename = "batchId")]
1640    pub batch_id: Option<u32>,
1641    /// Required for cancel method.
1642    pub cancel: Option<OrdersCustomBatchRequestEntryCancel>,
1643    /// Required for cancelLineItem method.
1644    #[serde(rename = "cancelLineItem")]
1645    pub cancel_line_item: Option<OrdersCustomBatchRequestEntryCancelLineItem>,
1646    /// Required for inStoreReturnLineItem method.
1647    #[serde(rename = "inStoreRefundLineItem")]
1648    pub in_store_refund_line_item: Option<OrdersCustomBatchRequestEntryInStoreRefundLineItem>,
1649    /// The ID of the managing account.
1650    #[serde(rename = "merchantId")]
1651    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1652    pub merchant_id: Option<u64>,
1653    /// The merchant order id. Required for updateMerchantOrderId and getByMerchantOrderId methods.
1654    #[serde(rename = "merchantOrderId")]
1655    pub merchant_order_id: Option<String>,
1656    /// The method to apply.
1657    pub method: Option<String>,
1658    /// The ID of the operation. Unique across all operations for a given order. Required for all methods beside get and getByMerchantOrderId.
1659    #[serde(rename = "operationId")]
1660    pub operation_id: Option<String>,
1661    /// The ID of the order. Required for all methods beside getByMerchantOrderId.
1662    #[serde(rename = "orderId")]
1663    pub order_id: Option<String>,
1664    /// Required for refund method.
1665    pub refund: Option<OrdersCustomBatchRequestEntryRefund>,
1666    /// Required for rejectReturnLineItem method.
1667    #[serde(rename = "rejectReturnLineItem")]
1668    pub reject_return_line_item: Option<OrdersCustomBatchRequestEntryRejectReturnLineItem>,
1669    /// Required for returnLineItem method.
1670    #[serde(rename = "returnLineItem")]
1671    pub return_line_item: Option<OrdersCustomBatchRequestEntryReturnLineItem>,
1672    /// Required for returnRefundLineItem method.
1673    #[serde(rename = "returnRefundLineItem")]
1674    pub return_refund_line_item: Option<OrdersCustomBatchRequestEntryReturnRefundLineItem>,
1675    /// Required for setLineItemMetadata method.
1676    #[serde(rename = "setLineItemMetadata")]
1677    pub set_line_item_metadata: Option<OrdersCustomBatchRequestEntrySetLineItemMetadata>,
1678    /// Required for shipLineItems method.
1679    #[serde(rename = "shipLineItems")]
1680    pub ship_line_items: Option<OrdersCustomBatchRequestEntryShipLineItems>,
1681    /// Required for updateLineItemShippingDate method.
1682    #[serde(rename = "updateLineItemShippingDetails")]
1683    pub update_line_item_shipping_details:
1684        Option<OrdersCustomBatchRequestEntryUpdateLineItemShippingDetails>,
1685    /// Required for updateShipment method.
1686    #[serde(rename = "updateShipment")]
1687    pub update_shipment: Option<OrdersCustomBatchRequestEntryUpdateShipment>,
1688}
1689
1690impl common::Part for OrdersCustomBatchRequestEntry {}
1691
1692/// There is no detailed description.
1693///
1694/// This type is not used in any activity, and only used as *part* of another schema.
1695///
1696#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1697#[serde_with::serde_as]
1698#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1699pub struct OrdersCustomBatchRequestEntryCancel {
1700    /// The reason for the cancellation.
1701    pub reason: Option<String>,
1702    /// The explanation of the reason.
1703    #[serde(rename = "reasonText")]
1704    pub reason_text: Option<String>,
1705}
1706
1707impl common::Part for OrdersCustomBatchRequestEntryCancel {}
1708
1709/// There is no detailed description.
1710///
1711/// This type is not used in any activity, and only used as *part* of another schema.
1712///
1713#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1714#[serde_with::serde_as]
1715#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1716pub struct OrdersCustomBatchRequestEntryCancelLineItem {
1717    /// Deprecated. Please use amountPretax and amountTax instead.
1718    pub amount: Option<Price>,
1719    /// Amount to refund for the cancelation. Optional. If not set, Google will calculate the default based on the price and tax of the items involved. The amount must not be larger than the net amount left on the order.
1720    #[serde(rename = "amountPretax")]
1721    pub amount_pretax: Option<Price>,
1722    /// Tax amount that correspond to cancellation amount in amountPretax.
1723    #[serde(rename = "amountTax")]
1724    pub amount_tax: Option<Price>,
1725    /// The ID of the line item to cancel. Either lineItemId or productId is required.
1726    #[serde(rename = "lineItemId")]
1727    pub line_item_id: Option<String>,
1728    /// The ID of the product to cancel. This is the REST ID used in the products service. Either lineItemId or productId is required.
1729    #[serde(rename = "productId")]
1730    pub product_id: Option<String>,
1731    /// The quantity to cancel.
1732    pub quantity: Option<u32>,
1733    /// The reason for the cancellation.
1734    pub reason: Option<String>,
1735    /// The explanation of the reason.
1736    #[serde(rename = "reasonText")]
1737    pub reason_text: Option<String>,
1738}
1739
1740impl common::Part for OrdersCustomBatchRequestEntryCancelLineItem {}
1741
1742/// There is no detailed description.
1743///
1744/// This type is not used in any activity, and only used as *part* of another schema.
1745///
1746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1747#[serde_with::serde_as]
1748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1749pub struct OrdersCustomBatchRequestEntryCreateTestReturnReturnItem {
1750    /// The ID of the line item to return.
1751    #[serde(rename = "lineItemId")]
1752    pub line_item_id: Option<String>,
1753    /// Quantity that is returned.
1754    pub quantity: Option<u32>,
1755}
1756
1757impl common::Part for OrdersCustomBatchRequestEntryCreateTestReturnReturnItem {}
1758
1759/// There is no detailed description.
1760///
1761/// This type is not used in any activity, and only used as *part* of another schema.
1762///
1763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1764#[serde_with::serde_as]
1765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1766pub struct OrdersCustomBatchRequestEntryInStoreRefundLineItem {
1767    /// The amount that is refunded. Required.
1768    #[serde(rename = "amountPretax")]
1769    pub amount_pretax: Option<Price>,
1770    /// Tax amount that correspond to refund amount in amountPretax. Required.
1771    #[serde(rename = "amountTax")]
1772    pub amount_tax: Option<Price>,
1773    /// The ID of the line item to return. Either lineItemId or productId is required.
1774    #[serde(rename = "lineItemId")]
1775    pub line_item_id: Option<String>,
1776    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
1777    #[serde(rename = "productId")]
1778    pub product_id: Option<String>,
1779    /// The quantity to return and refund.
1780    pub quantity: Option<u32>,
1781    /// The reason for the return.
1782    pub reason: Option<String>,
1783    /// The explanation of the reason.
1784    #[serde(rename = "reasonText")]
1785    pub reason_text: Option<String>,
1786}
1787
1788impl common::Part for OrdersCustomBatchRequestEntryInStoreRefundLineItem {}
1789
1790/// There is no detailed description.
1791///
1792/// This type is not used in any activity, and only used as *part* of another schema.
1793///
1794#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1795#[serde_with::serde_as]
1796#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1797pub struct OrdersCustomBatchRequestEntryRefund {
1798    /// Deprecated. Please use amountPretax and amountTax instead.
1799    pub amount: Option<Price>,
1800    /// The amount that is refunded. Either amount or amountPretax and amountTax should be filled.
1801    #[serde(rename = "amountPretax")]
1802    pub amount_pretax: Option<Price>,
1803    /// Tax amount that correspond to refund amount in amountPretax.
1804    #[serde(rename = "amountTax")]
1805    pub amount_tax: Option<Price>,
1806    /// The reason for the refund.
1807    pub reason: Option<String>,
1808    /// The explanation of the reason.
1809    #[serde(rename = "reasonText")]
1810    pub reason_text: Option<String>,
1811}
1812
1813impl common::Part for OrdersCustomBatchRequestEntryRefund {}
1814
1815/// There is no detailed description.
1816///
1817/// This type is not used in any activity, and only used as *part* of another schema.
1818///
1819#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1820#[serde_with::serde_as]
1821#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1822pub struct OrdersCustomBatchRequestEntryRejectReturnLineItem {
1823    /// The ID of the line item to return. Either lineItemId or productId is required.
1824    #[serde(rename = "lineItemId")]
1825    pub line_item_id: Option<String>,
1826    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
1827    #[serde(rename = "productId")]
1828    pub product_id: Option<String>,
1829    /// The quantity to return and refund.
1830    pub quantity: Option<u32>,
1831    /// The reason for the return.
1832    pub reason: Option<String>,
1833    /// The explanation of the reason.
1834    #[serde(rename = "reasonText")]
1835    pub reason_text: Option<String>,
1836}
1837
1838impl common::Part for OrdersCustomBatchRequestEntryRejectReturnLineItem {}
1839
1840/// There is no detailed description.
1841///
1842/// This type is not used in any activity, and only used as *part* of another schema.
1843///
1844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1845#[serde_with::serde_as]
1846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1847pub struct OrdersCustomBatchRequestEntryReturnLineItem {
1848    /// The ID of the line item to return. Either lineItemId or productId is required.
1849    #[serde(rename = "lineItemId")]
1850    pub line_item_id: Option<String>,
1851    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
1852    #[serde(rename = "productId")]
1853    pub product_id: Option<String>,
1854    /// The quantity to return.
1855    pub quantity: Option<u32>,
1856    /// The reason for the return.
1857    pub reason: Option<String>,
1858    /// The explanation of the reason.
1859    #[serde(rename = "reasonText")]
1860    pub reason_text: Option<String>,
1861}
1862
1863impl common::Part for OrdersCustomBatchRequestEntryReturnLineItem {}
1864
1865/// There is no detailed description.
1866///
1867/// This type is not used in any activity, and only used as *part* of another schema.
1868///
1869#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1870#[serde_with::serde_as]
1871#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1872pub struct OrdersCustomBatchRequestEntryReturnRefundLineItem {
1873    /// The amount that is refunded. If omitted, refundless return is assumed (same as calling returnLineItem method). Optional, but if filled then both amountPretax and amountTax must be set.
1874    #[serde(rename = "amountPretax")]
1875    pub amount_pretax: Option<Price>,
1876    /// Tax amount that correspond to refund amount in amountPretax.
1877    #[serde(rename = "amountTax")]
1878    pub amount_tax: Option<Price>,
1879    /// The ID of the line item to return. Either lineItemId or productId is required.
1880    #[serde(rename = "lineItemId")]
1881    pub line_item_id: Option<String>,
1882    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
1883    #[serde(rename = "productId")]
1884    pub product_id: Option<String>,
1885    /// The quantity to return and refund.
1886    pub quantity: Option<u32>,
1887    /// The reason for the return.
1888    pub reason: Option<String>,
1889    /// The explanation of the reason.
1890    #[serde(rename = "reasonText")]
1891    pub reason_text: Option<String>,
1892}
1893
1894impl common::Part for OrdersCustomBatchRequestEntryReturnRefundLineItem {}
1895
1896/// There is no detailed description.
1897///
1898/// This type is not used in any activity, and only used as *part* of another schema.
1899///
1900#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1901#[serde_with::serde_as]
1902#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1903pub struct OrdersCustomBatchRequestEntrySetLineItemMetadata {
1904    /// no description provided
1905    pub annotations: Option<Vec<OrderMerchantProvidedAnnotation>>,
1906    /// The ID of the line item to set metadata. Either lineItemId or productId is required.
1907    #[serde(rename = "lineItemId")]
1908    pub line_item_id: Option<String>,
1909    /// The ID of the product to set metadata. This is the REST ID used in the products service. Either lineItemId or productId is required.
1910    #[serde(rename = "productId")]
1911    pub product_id: Option<String>,
1912}
1913
1914impl common::Part for OrdersCustomBatchRequestEntrySetLineItemMetadata {}
1915
1916/// There is no detailed description.
1917///
1918/// This type is not used in any activity, and only used as *part* of another schema.
1919///
1920#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1921#[serde_with::serde_as]
1922#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1923pub struct OrdersCustomBatchRequestEntryShipLineItems {
1924    /// Deprecated. Please use shipmentInfo instead. The carrier handling the shipment. See shipments[].carrier in the  Orders resource representation for a list of acceptable values.
1925    pub carrier: Option<String>,
1926    /// Line items to ship.
1927    #[serde(rename = "lineItems")]
1928    pub line_items: Option<Vec<OrderShipmentLineItemShipment>>,
1929    /// ID of the shipment group. Required for orders that use the orderinvoices service.
1930    #[serde(rename = "shipmentGroupId")]
1931    pub shipment_group_id: Option<String>,
1932    /// Deprecated. Please use shipmentInfo instead. The ID of the shipment.
1933    #[serde(rename = "shipmentId")]
1934    pub shipment_id: Option<String>,
1935    /// Shipment information. This field is repeated because a single line item can be shipped in several packages (and have several tracking IDs).
1936    #[serde(rename = "shipmentInfos")]
1937    pub shipment_infos: Option<Vec<OrdersCustomBatchRequestEntryShipLineItemsShipmentInfo>>,
1938    /// Deprecated. Please use shipmentInfo instead. The tracking id for the shipment.
1939    #[serde(rename = "trackingId")]
1940    pub tracking_id: Option<String>,
1941}
1942
1943impl common::Part for OrdersCustomBatchRequestEntryShipLineItems {}
1944
1945/// There is no detailed description.
1946///
1947/// This type is not used in any activity, and only used as *part* of another schema.
1948///
1949#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1950#[serde_with::serde_as]
1951#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1952pub struct OrdersCustomBatchRequestEntryShipLineItemsShipmentInfo {
1953    /// The carrier handling the shipment. See shipments[].carrier in the  Orders resource representation for a list of acceptable values.
1954    pub carrier: Option<String>,
1955    /// The ID of the shipment.
1956    #[serde(rename = "shipmentId")]
1957    pub shipment_id: Option<String>,
1958    /// The tracking id for the shipment.
1959    #[serde(rename = "trackingId")]
1960    pub tracking_id: Option<String>,
1961}
1962
1963impl common::Part for OrdersCustomBatchRequestEntryShipLineItemsShipmentInfo {}
1964
1965/// There is no detailed description.
1966///
1967/// This type is not used in any activity, and only used as *part* of another schema.
1968///
1969#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1970#[serde_with::serde_as]
1971#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1972pub struct OrdersCustomBatchRequestEntryUpdateLineItemShippingDetails {
1973    /// Updated delivery by date, in ISO 8601 format. If not specified only ship by date is updated.
1974    #[serde(rename = "deliverByDate")]
1975    pub deliver_by_date: Option<String>,
1976    /// The ID of the line item to set metadata. Either lineItemId or productId is required.
1977    #[serde(rename = "lineItemId")]
1978    pub line_item_id: Option<String>,
1979    /// The ID of the product to set metadata. This is the REST ID used in the products service. Either lineItemId or productId is required.
1980    #[serde(rename = "productId")]
1981    pub product_id: Option<String>,
1982    /// Updated ship by date, in ISO 8601 format. If not specified only deliver by date is updated.
1983    #[serde(rename = "shipByDate")]
1984    pub ship_by_date: Option<String>,
1985}
1986
1987impl common::Part for OrdersCustomBatchRequestEntryUpdateLineItemShippingDetails {}
1988
1989/// There is no detailed description.
1990///
1991/// This type is not used in any activity, and only used as *part* of another schema.
1992///
1993#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1994#[serde_with::serde_as]
1995#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1996pub struct OrdersCustomBatchRequestEntryUpdateShipment {
1997    /// The carrier handling the shipment. Not updated if missing. See shipments[].carrier in the  Orders resource representation for a list of acceptable values.
1998    pub carrier: Option<String>,
1999    /// Date on which the shipment has been delivered, in ISO 8601 format. Optional and can be provided only if status is delivered.
2000    #[serde(rename = "deliveryDate")]
2001    pub delivery_date: Option<String>,
2002    /// The ID of the shipment.
2003    #[serde(rename = "shipmentId")]
2004    pub shipment_id: Option<String>,
2005    /// New status for the shipment. Not updated if missing.
2006    pub status: Option<String>,
2007    /// The tracking id for the shipment. Not updated if missing.
2008    #[serde(rename = "trackingId")]
2009    pub tracking_id: Option<String>,
2010}
2011
2012impl common::Part for OrdersCustomBatchRequestEntryUpdateShipment {}
2013
2014/// There is no detailed description.
2015///
2016/// # Activities
2017///
2018/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2019/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2020///
2021/// * [custombatch orders](OrderCustombatchCall) (response)
2022#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2023#[serde_with::serde_as]
2024#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2025pub struct OrdersCustomBatchResponse {
2026    /// The result of the execution of the batch requests.
2027    pub entries: Option<Vec<OrdersCustomBatchResponseEntry>>,
2028    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCustomBatchResponse".
2029    pub kind: Option<String>,
2030}
2031
2032impl common::ResponseResult for OrdersCustomBatchResponse {}
2033
2034/// There is no detailed description.
2035///
2036/// This type is not used in any activity, and only used as *part* of another schema.
2037///
2038#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2039#[serde_with::serde_as]
2040#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2041pub struct OrdersCustomBatchResponseEntry {
2042    /// The ID of the request entry this entry responds to.
2043    #[serde(rename = "batchId")]
2044    pub batch_id: Option<u32>,
2045    /// A list of errors defined if and only if the request failed.
2046    pub errors: Option<Errors>,
2047    /// The status of the execution. Only defined if  
2048    /// - the request was successful; and
2049    /// - the method is not get, getByMerchantOrderId, or one of the test methods.
2050    #[serde(rename = "executionStatus")]
2051    pub execution_status: Option<String>,
2052    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCustomBatchResponseEntry".
2053    pub kind: Option<String>,
2054    /// The retrieved order. Only defined if the method is get and if the request was successful.
2055    pub order: Option<Order>,
2056}
2057
2058impl common::Part for OrdersCustomBatchResponseEntry {}
2059
2060/// There is no detailed description.
2061///
2062/// # Activities
2063///
2064/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2065/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2066///
2067/// * [getbymerchantorderid orders](OrderGetbymerchantorderidCall) (response)
2068#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2069#[serde_with::serde_as]
2070#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2071pub struct OrdersGetByMerchantOrderIdResponse {
2072    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersGetByMerchantOrderIdResponse".
2073    pub kind: Option<String>,
2074    /// The requested order.
2075    pub order: Option<Order>,
2076}
2077
2078impl common::ResponseResult for OrdersGetByMerchantOrderIdResponse {}
2079
2080/// There is no detailed description.
2081///
2082/// # Activities
2083///
2084/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2085/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2086///
2087/// * [gettestordertemplate orders](OrderGettestordertemplateCall) (response)
2088#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2089#[serde_with::serde_as]
2090#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2091pub struct OrdersGetTestOrderTemplateResponse {
2092    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersGetTestOrderTemplateResponse".
2093    pub kind: Option<String>,
2094    /// The requested test order template.
2095    pub template: Option<TestOrder>,
2096}
2097
2098impl common::ResponseResult for OrdersGetTestOrderTemplateResponse {}
2099
2100/// There is no detailed description.
2101///
2102/// # Activities
2103///
2104/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2105/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2106///
2107/// * [instorerefundlineitem orders](OrderInstorerefundlineitemCall) (request)
2108#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2109#[serde_with::serde_as]
2110#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2111pub struct OrdersInStoreRefundLineItemRequest {
2112    /// The amount that is refunded. Required.
2113    #[serde(rename = "amountPretax")]
2114    pub amount_pretax: Option<Price>,
2115    /// Tax amount that correspond to refund amount in amountPretax. Required.
2116    #[serde(rename = "amountTax")]
2117    pub amount_tax: Option<Price>,
2118    /// The ID of the line item to return. Either lineItemId or productId is required.
2119    #[serde(rename = "lineItemId")]
2120    pub line_item_id: Option<String>,
2121    /// The ID of the operation. Unique across all operations for a given order.
2122    #[serde(rename = "operationId")]
2123    pub operation_id: Option<String>,
2124    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
2125    #[serde(rename = "productId")]
2126    pub product_id: Option<String>,
2127    /// The quantity to return and refund.
2128    pub quantity: Option<u32>,
2129    /// The reason for the return.
2130    pub reason: Option<String>,
2131    /// The explanation of the reason.
2132    #[serde(rename = "reasonText")]
2133    pub reason_text: Option<String>,
2134}
2135
2136impl common::RequestValue for OrdersInStoreRefundLineItemRequest {}
2137
2138/// There is no detailed description.
2139///
2140/// # Activities
2141///
2142/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2143/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2144///
2145/// * [instorerefundlineitem orders](OrderInstorerefundlineitemCall) (response)
2146#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2147#[serde_with::serde_as]
2148#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2149pub struct OrdersInStoreRefundLineItemResponse {
2150    /// The status of the execution.
2151    #[serde(rename = "executionStatus")]
2152    pub execution_status: Option<String>,
2153    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersInStoreRefundLineItemResponse".
2154    pub kind: Option<String>,
2155}
2156
2157impl common::ResponseResult for OrdersInStoreRefundLineItemResponse {}
2158
2159/// There is no detailed description.
2160///
2161/// # Activities
2162///
2163/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2164/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2165///
2166/// * [list orders](OrderListCall) (response)
2167#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2168#[serde_with::serde_as]
2169#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2170pub struct OrdersListResponse {
2171    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersListResponse".
2172    pub kind: Option<String>,
2173    /// The token for the retrieval of the next page of orders.
2174    #[serde(rename = "nextPageToken")]
2175    pub next_page_token: Option<String>,
2176    /// no description provided
2177    pub resources: Option<Vec<Order>>,
2178}
2179
2180impl common::ResponseResult for OrdersListResponse {}
2181
2182/// There is no detailed description.
2183///
2184/// # Activities
2185///
2186/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2187/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2188///
2189/// * [refund orders](OrderRefundCall) (request)
2190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2191#[serde_with::serde_as]
2192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2193pub struct OrdersRefundRequest {
2194    /// Deprecated. Please use amountPretax and amountTax instead.
2195    pub amount: Option<Price>,
2196    /// The amount that is refunded. Either amount or amountPretax and amountTax should be filled.
2197    #[serde(rename = "amountPretax")]
2198    pub amount_pretax: Option<Price>,
2199    /// Tax amount that correspond to refund amount in amountPretax.
2200    #[serde(rename = "amountTax")]
2201    pub amount_tax: Option<Price>,
2202    /// The ID of the operation. Unique across all operations for a given order.
2203    #[serde(rename = "operationId")]
2204    pub operation_id: Option<String>,
2205    /// The reason for the refund.
2206    pub reason: Option<String>,
2207    /// The explanation of the reason.
2208    #[serde(rename = "reasonText")]
2209    pub reason_text: Option<String>,
2210}
2211
2212impl common::RequestValue for OrdersRefundRequest {}
2213
2214/// There is no detailed description.
2215///
2216/// # Activities
2217///
2218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2220///
2221/// * [refund orders](OrderRefundCall) (response)
2222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2223#[serde_with::serde_as]
2224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2225pub struct OrdersRefundResponse {
2226    /// The status of the execution.
2227    #[serde(rename = "executionStatus")]
2228    pub execution_status: Option<String>,
2229    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersRefundResponse".
2230    pub kind: Option<String>,
2231}
2232
2233impl common::ResponseResult for OrdersRefundResponse {}
2234
2235/// There is no detailed description.
2236///
2237/// # Activities
2238///
2239/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2240/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2241///
2242/// * [rejectreturnlineitem orders](OrderRejectreturnlineitemCall) (request)
2243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2244#[serde_with::serde_as]
2245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2246pub struct OrdersRejectReturnLineItemRequest {
2247    /// The ID of the line item to return. Either lineItemId or productId is required.
2248    #[serde(rename = "lineItemId")]
2249    pub line_item_id: Option<String>,
2250    /// The ID of the operation. Unique across all operations for a given order.
2251    #[serde(rename = "operationId")]
2252    pub operation_id: Option<String>,
2253    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
2254    #[serde(rename = "productId")]
2255    pub product_id: Option<String>,
2256    /// The quantity to return and refund.
2257    pub quantity: Option<u32>,
2258    /// The reason for the return.
2259    pub reason: Option<String>,
2260    /// The explanation of the reason.
2261    #[serde(rename = "reasonText")]
2262    pub reason_text: Option<String>,
2263}
2264
2265impl common::RequestValue for OrdersRejectReturnLineItemRequest {}
2266
2267/// There is no detailed description.
2268///
2269/// # Activities
2270///
2271/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2272/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2273///
2274/// * [rejectreturnlineitem orders](OrderRejectreturnlineitemCall) (response)
2275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2276#[serde_with::serde_as]
2277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2278pub struct OrdersRejectReturnLineItemResponse {
2279    /// The status of the execution.
2280    #[serde(rename = "executionStatus")]
2281    pub execution_status: Option<String>,
2282    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersRejectReturnLineItemResponse".
2283    pub kind: Option<String>,
2284}
2285
2286impl common::ResponseResult for OrdersRejectReturnLineItemResponse {}
2287
2288/// There is no detailed description.
2289///
2290/// # Activities
2291///
2292/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2293/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2294///
2295/// * [returnlineitem orders](OrderReturnlineitemCall) (request)
2296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2297#[serde_with::serde_as]
2298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2299pub struct OrdersReturnLineItemRequest {
2300    /// The ID of the line item to return. Either lineItemId or productId is required.
2301    #[serde(rename = "lineItemId")]
2302    pub line_item_id: Option<String>,
2303    /// The ID of the operation. Unique across all operations for a given order.
2304    #[serde(rename = "operationId")]
2305    pub operation_id: Option<String>,
2306    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
2307    #[serde(rename = "productId")]
2308    pub product_id: Option<String>,
2309    /// The quantity to return.
2310    pub quantity: Option<u32>,
2311    /// The reason for the return.
2312    pub reason: Option<String>,
2313    /// The explanation of the reason.
2314    #[serde(rename = "reasonText")]
2315    pub reason_text: Option<String>,
2316}
2317
2318impl common::RequestValue for OrdersReturnLineItemRequest {}
2319
2320/// There is no detailed description.
2321///
2322/// # Activities
2323///
2324/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2325/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2326///
2327/// * [returnlineitem orders](OrderReturnlineitemCall) (response)
2328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2329#[serde_with::serde_as]
2330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2331pub struct OrdersReturnLineItemResponse {
2332    /// The status of the execution.
2333    #[serde(rename = "executionStatus")]
2334    pub execution_status: Option<String>,
2335    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersReturnLineItemResponse".
2336    pub kind: Option<String>,
2337}
2338
2339impl common::ResponseResult for OrdersReturnLineItemResponse {}
2340
2341/// There is no detailed description.
2342///
2343/// # Activities
2344///
2345/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2346/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2347///
2348/// * [returnrefundlineitem orders](OrderReturnrefundlineitemCall) (request)
2349#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2350#[serde_with::serde_as]
2351#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2352pub struct OrdersReturnRefundLineItemRequest {
2353    /// The amount that is refunded. If omitted, refundless return is assumed (same as calling returnLineItem method). Optional, but if filled then both amountPretax and amountTax must be set.
2354    #[serde(rename = "amountPretax")]
2355    pub amount_pretax: Option<Price>,
2356    /// Tax amount that correspond to refund amount in amountPretax.
2357    #[serde(rename = "amountTax")]
2358    pub amount_tax: Option<Price>,
2359    /// The ID of the line item to return. Either lineItemId or productId is required.
2360    #[serde(rename = "lineItemId")]
2361    pub line_item_id: Option<String>,
2362    /// The ID of the operation. Unique across all operations for a given order.
2363    #[serde(rename = "operationId")]
2364    pub operation_id: Option<String>,
2365    /// The ID of the product to return. This is the REST ID used in the products service. Either lineItemId or productId is required.
2366    #[serde(rename = "productId")]
2367    pub product_id: Option<String>,
2368    /// The quantity to return and refund.
2369    pub quantity: Option<u32>,
2370    /// The reason for the return.
2371    pub reason: Option<String>,
2372    /// The explanation of the reason.
2373    #[serde(rename = "reasonText")]
2374    pub reason_text: Option<String>,
2375}
2376
2377impl common::RequestValue for OrdersReturnRefundLineItemRequest {}
2378
2379/// There is no detailed description.
2380///
2381/// # Activities
2382///
2383/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2384/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2385///
2386/// * [returnrefundlineitem orders](OrderReturnrefundlineitemCall) (response)
2387#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2388#[serde_with::serde_as]
2389#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2390pub struct OrdersReturnRefundLineItemResponse {
2391    /// The status of the execution.
2392    #[serde(rename = "executionStatus")]
2393    pub execution_status: Option<String>,
2394    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersReturnRefundLineItemResponse".
2395    pub kind: Option<String>,
2396}
2397
2398impl common::ResponseResult for OrdersReturnRefundLineItemResponse {}
2399
2400/// There is no detailed description.
2401///
2402/// # Activities
2403///
2404/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2405/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2406///
2407/// * [setlineitemmetadata orders](OrderSetlineitemmetadataCall) (request)
2408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2409#[serde_with::serde_as]
2410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2411pub struct OrdersSetLineItemMetadataRequest {
2412    /// no description provided
2413    pub annotations: Option<Vec<OrderMerchantProvidedAnnotation>>,
2414    /// The ID of the line item to set metadata. Either lineItemId or productId is required.
2415    #[serde(rename = "lineItemId")]
2416    pub line_item_id: Option<String>,
2417    /// The ID of the operation. Unique across all operations for a given order.
2418    #[serde(rename = "operationId")]
2419    pub operation_id: Option<String>,
2420    /// The ID of the product to set metadata. This is the REST ID used in the products service. Either lineItemId or productId is required.
2421    #[serde(rename = "productId")]
2422    pub product_id: Option<String>,
2423}
2424
2425impl common::RequestValue for OrdersSetLineItemMetadataRequest {}
2426
2427/// There is no detailed description.
2428///
2429/// # Activities
2430///
2431/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2432/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2433///
2434/// * [setlineitemmetadata orders](OrderSetlineitemmetadataCall) (response)
2435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2436#[serde_with::serde_as]
2437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2438pub struct OrdersSetLineItemMetadataResponse {
2439    /// The status of the execution.
2440    #[serde(rename = "executionStatus")]
2441    pub execution_status: Option<String>,
2442    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersSetLineItemMetadataResponse".
2443    pub kind: Option<String>,
2444}
2445
2446impl common::ResponseResult for OrdersSetLineItemMetadataResponse {}
2447
2448/// There is no detailed description.
2449///
2450/// # Activities
2451///
2452/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2453/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2454///
2455/// * [shiplineitems orders](OrderShiplineitemCall) (request)
2456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2457#[serde_with::serde_as]
2458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2459pub struct OrdersShipLineItemsRequest {
2460    /// Deprecated. Please use shipmentInfo instead. The carrier handling the shipment. See shipments[].carrier in the  Orders resource representation for a list of acceptable values.
2461    pub carrier: Option<String>,
2462    /// Line items to ship.
2463    #[serde(rename = "lineItems")]
2464    pub line_items: Option<Vec<OrderShipmentLineItemShipment>>,
2465    /// The ID of the operation. Unique across all operations for a given order.
2466    #[serde(rename = "operationId")]
2467    pub operation_id: Option<String>,
2468    /// ID of the shipment group. Required for orders that use the orderinvoices service.
2469    #[serde(rename = "shipmentGroupId")]
2470    pub shipment_group_id: Option<String>,
2471    /// Deprecated. Please use shipmentInfo instead. The ID of the shipment.
2472    #[serde(rename = "shipmentId")]
2473    pub shipment_id: Option<String>,
2474    /// Shipment information. This field is repeated because a single line item can be shipped in several packages (and have several tracking IDs).
2475    #[serde(rename = "shipmentInfos")]
2476    pub shipment_infos: Option<Vec<OrdersCustomBatchRequestEntryShipLineItemsShipmentInfo>>,
2477    /// Deprecated. Please use shipmentInfo instead. The tracking id for the shipment.
2478    #[serde(rename = "trackingId")]
2479    pub tracking_id: Option<String>,
2480}
2481
2482impl common::RequestValue for OrdersShipLineItemsRequest {}
2483
2484/// There is no detailed description.
2485///
2486/// # Activities
2487///
2488/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2489/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2490///
2491/// * [shiplineitems orders](OrderShiplineitemCall) (response)
2492#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2493#[serde_with::serde_as]
2494#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2495pub struct OrdersShipLineItemsResponse {
2496    /// The status of the execution.
2497    #[serde(rename = "executionStatus")]
2498    pub execution_status: Option<String>,
2499    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersShipLineItemsResponse".
2500    pub kind: Option<String>,
2501}
2502
2503impl common::ResponseResult for OrdersShipLineItemsResponse {}
2504
2505/// There is no detailed description.
2506///
2507/// # Activities
2508///
2509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2511///
2512/// * [updatelineitemshippingdetails orders](OrderUpdatelineitemshippingdetailCall) (request)
2513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2514#[serde_with::serde_as]
2515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2516pub struct OrdersUpdateLineItemShippingDetailsRequest {
2517    /// Updated delivery by date, in ISO 8601 format. If not specified only ship by date is updated.
2518    #[serde(rename = "deliverByDate")]
2519    pub deliver_by_date: Option<String>,
2520    /// The ID of the line item to set metadata. Either lineItemId or productId is required.
2521    #[serde(rename = "lineItemId")]
2522    pub line_item_id: Option<String>,
2523    /// The ID of the operation. Unique across all operations for a given order.
2524    #[serde(rename = "operationId")]
2525    pub operation_id: Option<String>,
2526    /// The ID of the product to set metadata. This is the REST ID used in the products service. Either lineItemId or productId is required.
2527    #[serde(rename = "productId")]
2528    pub product_id: Option<String>,
2529    /// Updated ship by date, in ISO 8601 format. If not specified only deliver by date is updated.
2530    #[serde(rename = "shipByDate")]
2531    pub ship_by_date: Option<String>,
2532}
2533
2534impl common::RequestValue for OrdersUpdateLineItemShippingDetailsRequest {}
2535
2536/// There is no detailed description.
2537///
2538/// # Activities
2539///
2540/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2541/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2542///
2543/// * [updatelineitemshippingdetails orders](OrderUpdatelineitemshippingdetailCall) (response)
2544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2545#[serde_with::serde_as]
2546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2547pub struct OrdersUpdateLineItemShippingDetailsResponse {
2548    /// The status of the execution.
2549    #[serde(rename = "executionStatus")]
2550    pub execution_status: Option<String>,
2551    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersUpdateLineItemShippingDetailsResponse".
2552    pub kind: Option<String>,
2553}
2554
2555impl common::ResponseResult for OrdersUpdateLineItemShippingDetailsResponse {}
2556
2557/// There is no detailed description.
2558///
2559/// # Activities
2560///
2561/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2562/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2563///
2564/// * [updatemerchantorderid orders](OrderUpdatemerchantorderidCall) (request)
2565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2566#[serde_with::serde_as]
2567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2568pub struct OrdersUpdateMerchantOrderIdRequest {
2569    /// The merchant order id to be assigned to the order. Must be unique per merchant.
2570    #[serde(rename = "merchantOrderId")]
2571    pub merchant_order_id: Option<String>,
2572    /// The ID of the operation. Unique across all operations for a given order.
2573    #[serde(rename = "operationId")]
2574    pub operation_id: Option<String>,
2575}
2576
2577impl common::RequestValue for OrdersUpdateMerchantOrderIdRequest {}
2578
2579/// There is no detailed description.
2580///
2581/// # Activities
2582///
2583/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2584/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2585///
2586/// * [updatemerchantorderid orders](OrderUpdatemerchantorderidCall) (response)
2587#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2588#[serde_with::serde_as]
2589#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2590pub struct OrdersUpdateMerchantOrderIdResponse {
2591    /// The status of the execution.
2592    #[serde(rename = "executionStatus")]
2593    pub execution_status: Option<String>,
2594    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersUpdateMerchantOrderIdResponse".
2595    pub kind: Option<String>,
2596}
2597
2598impl common::ResponseResult for OrdersUpdateMerchantOrderIdResponse {}
2599
2600/// There is no detailed description.
2601///
2602/// # Activities
2603///
2604/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2605/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2606///
2607/// * [updateshipment orders](OrderUpdateshipmentCall) (request)
2608#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2609#[serde_with::serde_as]
2610#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2611pub struct OrdersUpdateShipmentRequest {
2612    /// The carrier handling the shipment. Not updated if missing. See shipments[].carrier in the  Orders resource representation for a list of acceptable values.
2613    pub carrier: Option<String>,
2614    /// Date on which the shipment has been delivered, in ISO 8601 format. Optional and can be provided only if status is delivered.
2615    #[serde(rename = "deliveryDate")]
2616    pub delivery_date: Option<String>,
2617    /// The ID of the operation. Unique across all operations for a given order.
2618    #[serde(rename = "operationId")]
2619    pub operation_id: Option<String>,
2620    /// The ID of the shipment.
2621    #[serde(rename = "shipmentId")]
2622    pub shipment_id: Option<String>,
2623    /// New status for the shipment. Not updated if missing.
2624    pub status: Option<String>,
2625    /// The tracking id for the shipment. Not updated if missing.
2626    #[serde(rename = "trackingId")]
2627    pub tracking_id: Option<String>,
2628}
2629
2630impl common::RequestValue for OrdersUpdateShipmentRequest {}
2631
2632/// There is no detailed description.
2633///
2634/// # Activities
2635///
2636/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2637/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2638///
2639/// * [updateshipment orders](OrderUpdateshipmentCall) (response)
2640#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2641#[serde_with::serde_as]
2642#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2643pub struct OrdersUpdateShipmentResponse {
2644    /// The status of the execution.
2645    #[serde(rename = "executionStatus")]
2646    pub execution_status: Option<String>,
2647    /// Identifies what kind of resource this is. Value: the fixed string "content#ordersUpdateShipmentResponse".
2648    pub kind: Option<String>,
2649}
2650
2651impl common::ResponseResult for OrdersUpdateShipmentResponse {}
2652
2653/// There is no detailed description.
2654///
2655/// This type is not used in any activity, and only used as *part* of another schema.
2656///
2657#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2658#[serde_with::serde_as]
2659#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2660pub struct Price {
2661    /// The currency of the price.
2662    pub currency: Option<String>,
2663    /// The price represented as a number.
2664    pub value: Option<String>,
2665}
2666
2667impl common::Part for Price {}
2668
2669/// There is no detailed description.
2670///
2671/// This type is not used in any activity, and only used as *part* of another schema.
2672///
2673#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2674#[serde_with::serde_as]
2675#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2676pub struct Promotion {
2677    /// [required] Amount of the promotion. The values here are the promotion applied to the unit price pretax and to the total of the tax amounts.
2678    #[serde(rename = "promotionAmount")]
2679    pub promotion_amount: Option<Amount>,
2680    /// [required] ID of the promotion.
2681    #[serde(rename = "promotionId")]
2682    pub promotion_id: Option<String>,
2683}
2684
2685impl common::Part for Promotion {}
2686
2687/// There is no detailed description.
2688///
2689/// This type is not used in any activity, and only used as *part* of another schema.
2690///
2691#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2692#[serde_with::serde_as]
2693#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2694pub struct RefundReason {
2695    /// no description provided
2696    pub description: Option<String>,
2697    /// no description provided
2698    #[serde(rename = "reasonCode")]
2699    pub reason_code: Option<String>,
2700}
2701
2702impl common::Part for RefundReason {}
2703
2704/// There is no detailed description.
2705///
2706/// This type is not used in any activity, and only used as *part* of another schema.
2707///
2708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2709#[serde_with::serde_as]
2710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2711pub struct ReturnShipment {
2712    /// no description provided
2713    #[serde(rename = "creationDate")]
2714    pub creation_date: Option<String>,
2715    /// no description provided
2716    #[serde(rename = "returnMethodType")]
2717    pub return_method_type: Option<String>,
2718    /// no description provided
2719    #[serde(rename = "shipmentId")]
2720    pub shipment_id: Option<String>,
2721    /// no description provided
2722    #[serde(rename = "shipmentTrackingInfos")]
2723    pub shipment_tracking_infos: Option<Vec<ShipmentTrackingInfo>>,
2724}
2725
2726impl common::Part for ReturnShipment {}
2727
2728/// There is no detailed description.
2729///
2730/// This type is not used in any activity, and only used as *part* of another schema.
2731///
2732#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2733#[serde_with::serde_as]
2734#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2735pub struct ShipmentInvoice {
2736    /// [required] Invoice summary.
2737    #[serde(rename = "invoiceSummary")]
2738    pub invoice_summary: Option<InvoiceSummary>,
2739    /// [required] Invoice details per line item.
2740    #[serde(rename = "lineItemInvoices")]
2741    pub line_item_invoices: Option<Vec<ShipmentInvoiceLineItemInvoice>>,
2742    /// [required] ID of the shipment group.
2743    #[serde(rename = "shipmentGroupId")]
2744    pub shipment_group_id: Option<String>,
2745}
2746
2747impl common::Part for ShipmentInvoice {}
2748
2749/// There is no detailed description.
2750///
2751/// This type is not used in any activity, and only used as *part* of another schema.
2752///
2753#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2754#[serde_with::serde_as]
2755#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2756pub struct ShipmentInvoiceLineItemInvoice {
2757    /// ID of the line item. Either lineItemId or productId must be set.
2758    #[serde(rename = "lineItemId")]
2759    pub line_item_id: Option<String>,
2760    /// ID of the product. This is the REST ID used in the products service. Either lineItemId or productId must be set.
2761    #[serde(rename = "productId")]
2762    pub product_id: Option<String>,
2763    /// [required] Unit IDs to define specific units within the line item.
2764    #[serde(rename = "shipmentUnitIds")]
2765    pub shipment_unit_ids: Option<Vec<String>>,
2766    /// [required] Invoice details for a single unit.
2767    #[serde(rename = "unitInvoice")]
2768    pub unit_invoice: Option<UnitInvoice>,
2769}
2770
2771impl common::Part for ShipmentInvoiceLineItemInvoice {}
2772
2773/// There is no detailed description.
2774///
2775/// This type is not used in any activity, and only used as *part* of another schema.
2776///
2777#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2778#[serde_with::serde_as]
2779#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2780pub struct ShipmentTrackingInfo {
2781    /// no description provided
2782    pub carrier: Option<String>,
2783    /// no description provided
2784    #[serde(rename = "trackingNumber")]
2785    pub tracking_number: Option<String>,
2786}
2787
2788impl common::Part for ShipmentTrackingInfo {}
2789
2790/// There is no detailed description.
2791///
2792/// This type is not used in any activity, and only used as *part* of another schema.
2793///
2794#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2795#[serde_with::serde_as]
2796#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2797pub struct TestOrder {
2798    /// The details of the customer who placed the order.
2799    pub customer: Option<TestOrderCustomer>,
2800    /// Whether the orderinvoices service should support this order.
2801    #[serde(rename = "enableOrderinvoices")]
2802    pub enable_orderinvoices: Option<bool>,
2803    /// Identifies what kind of resource this is. Value: the fixed string "content#testOrder".
2804    pub kind: Option<String>,
2805    /// Line items that are ordered. At least one line item must be provided.
2806    #[serde(rename = "lineItems")]
2807    pub line_items: Option<Vec<TestOrderLineItem>>,
2808    /// Determines if test order must be pulled by merchant or pushed to merchant via push integration.
2809    #[serde(rename = "notificationMode")]
2810    pub notification_mode: Option<String>,
2811    /// The details of the payment method.
2812    #[serde(rename = "paymentMethod")]
2813    pub payment_method: Option<TestOrderPaymentMethod>,
2814    /// Identifier of one of the predefined delivery addresses for the delivery.
2815    #[serde(rename = "predefinedDeliveryAddress")]
2816    pub predefined_delivery_address: Option<String>,
2817    /// Deprecated. The details of the merchant provided promotions applied to the order. More details about the program are here.
2818    pub promotions: Option<Vec<OrderLegacyPromotion>>,
2819    /// The total cost of shipping for all items.
2820    #[serde(rename = "shippingCost")]
2821    pub shipping_cost: Option<Price>,
2822    /// The tax for the total shipping cost.
2823    #[serde(rename = "shippingCostTax")]
2824    pub shipping_cost_tax: Option<Price>,
2825    /// The requested shipping option.
2826    #[serde(rename = "shippingOption")]
2827    pub shipping_option: Option<String>,
2828}
2829
2830impl common::Part for TestOrder {}
2831
2832/// There is no detailed description.
2833///
2834/// This type is not used in any activity, and only used as *part* of another schema.
2835///
2836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2837#[serde_with::serde_as]
2838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2839pub struct TestOrderCustomer {
2840    /// Deprecated.
2841    pub email: Option<String>,
2842    /// Deprecated. Please use marketingRightsInfo instead.
2843    #[serde(rename = "explicitMarketingPreference")]
2844    pub explicit_marketing_preference: Option<bool>,
2845    /// Full name of the customer.
2846    #[serde(rename = "fullName")]
2847    pub full_name: Option<String>,
2848    /// Customer's marketing preferences.
2849    #[serde(rename = "marketingRightsInfo")]
2850    pub marketing_rights_info: Option<TestOrderCustomerMarketingRightsInfo>,
2851}
2852
2853impl common::Part for TestOrderCustomer {}
2854
2855/// There is no detailed description.
2856///
2857/// This type is not used in any activity, and only used as *part* of another schema.
2858///
2859#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2860#[serde_with::serde_as]
2861#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2862pub struct TestOrderCustomerMarketingRightsInfo {
2863    /// Last know user use selection regards marketing preferences. In certain cases selection might not be known, so this field would be empty.
2864    #[serde(rename = "explicitMarketingPreference")]
2865    pub explicit_marketing_preference: Option<String>,
2866    /// Timestamp when last time marketing preference was updated. Could be empty, if user wasn't offered a selection yet.
2867    #[serde(rename = "lastUpdatedTimestamp")]
2868    pub last_updated_timestamp: Option<String>,
2869}
2870
2871impl common::Part for TestOrderCustomerMarketingRightsInfo {}
2872
2873/// There is no detailed description.
2874///
2875/// This type is not used in any activity, and only used as *part* of another schema.
2876///
2877#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2878#[serde_with::serde_as]
2879#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2880pub struct TestOrderLineItem {
2881    /// Product data from the time of the order placement.
2882    pub product: Option<TestOrderLineItemProduct>,
2883    /// Number of items ordered.
2884    #[serde(rename = "quantityOrdered")]
2885    pub quantity_ordered: Option<u32>,
2886    /// Details of the return policy for the line item.
2887    #[serde(rename = "returnInfo")]
2888    pub return_info: Option<OrderLineItemReturnInfo>,
2889    /// Details of the requested shipping for the line item.
2890    #[serde(rename = "shippingDetails")]
2891    pub shipping_details: Option<OrderLineItemShippingDetails>,
2892    /// Unit tax for the line item.
2893    #[serde(rename = "unitTax")]
2894    pub unit_tax: Option<Price>,
2895}
2896
2897impl common::Part for TestOrderLineItem {}
2898
2899/// There is no detailed description.
2900///
2901/// This type is not used in any activity, and only used as *part* of another schema.
2902///
2903#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2904#[serde_with::serde_as]
2905#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2906pub struct TestOrderLineItemProduct {
2907    /// Brand of the item.
2908    pub brand: Option<String>,
2909    /// The item's channel.
2910    pub channel: Option<String>,
2911    /// Condition or state of the item.
2912    pub condition: Option<String>,
2913    /// The two-letter ISO 639-1 language code for the item.
2914    #[serde(rename = "contentLanguage")]
2915    pub content_language: Option<String>,
2916    /// Global Trade Item Number (GTIN) of the item. Optional.
2917    pub gtin: Option<String>,
2918    /// URL of an image of the item.
2919    #[serde(rename = "imageLink")]
2920    pub image_link: Option<String>,
2921    /// Shared identifier for all variants of the same product. Optional.
2922    #[serde(rename = "itemGroupId")]
2923    pub item_group_id: Option<String>,
2924    /// Manufacturer Part Number (MPN) of the item. Optional.
2925    pub mpn: Option<String>,
2926    /// An identifier of the item.
2927    #[serde(rename = "offerId")]
2928    pub offer_id: Option<String>,
2929    /// The price for the product.
2930    pub price: Option<Price>,
2931    /// The CLDR territory code of the target country of the product.
2932    #[serde(rename = "targetCountry")]
2933    pub target_country: Option<String>,
2934    /// The title of the product.
2935    pub title: Option<String>,
2936    /// Variant attributes for the item. Optional.
2937    #[serde(rename = "variantAttributes")]
2938    pub variant_attributes: Option<Vec<OrderLineItemProductVariantAttribute>>,
2939}
2940
2941impl common::Part for TestOrderLineItemProduct {}
2942
2943/// There is no detailed description.
2944///
2945/// This type is not used in any activity, and only used as *part* of another schema.
2946///
2947#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2948#[serde_with::serde_as]
2949#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2950pub struct TestOrderPaymentMethod {
2951    /// The card expiration month (January = 1, February = 2 etc.).
2952    #[serde(rename = "expirationMonth")]
2953    pub expiration_month: Option<i32>,
2954    /// The card expiration year (4-digit, e.g. 2015).
2955    #[serde(rename = "expirationYear")]
2956    pub expiration_year: Option<i32>,
2957    /// The last four digits of the card number.
2958    #[serde(rename = "lastFourDigits")]
2959    pub last_four_digits: Option<String>,
2960    /// The billing address.
2961    #[serde(rename = "predefinedBillingAddress")]
2962    pub predefined_billing_address: Option<String>,
2963    /// The type of instrument. Note that real orders might have different values than the four values accepted by createTestOrder.
2964    #[serde(rename = "type")]
2965    pub type_: Option<String>,
2966}
2967
2968impl common::Part for TestOrderPaymentMethod {}
2969
2970/// There is no detailed description.
2971///
2972/// This type is not used in any activity, and only used as *part* of another schema.
2973///
2974#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2975#[serde_with::serde_as]
2976#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2977pub struct UnitInvoice {
2978    /// Additional charges for a unit, e.g. shipping costs.
2979    #[serde(rename = "additionalCharges")]
2980    pub additional_charges: Option<Vec<UnitInvoiceAdditionalCharge>>,
2981    /// Promotions applied to a unit.
2982    pub promotions: Option<Vec<Promotion>>,
2983    /// [required] Price of the unit, before applying taxes.
2984    #[serde(rename = "unitPricePretax")]
2985    pub unit_price_pretax: Option<Price>,
2986    /// Tax amounts to apply to the unit price.
2987    #[serde(rename = "unitPriceTaxes")]
2988    pub unit_price_taxes: Option<Vec<UnitInvoiceTaxLine>>,
2989}
2990
2991impl common::Part for UnitInvoice {}
2992
2993/// There is no detailed description.
2994///
2995/// This type is not used in any activity, and only used as *part* of another schema.
2996///
2997#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2998#[serde_with::serde_as]
2999#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3000pub struct UnitInvoiceAdditionalCharge {
3001    /// [required] Amount of the additional charge.
3002    #[serde(rename = "additionalChargeAmount")]
3003    pub additional_charge_amount: Option<Amount>,
3004    /// Promotions applied to the additional charge.
3005    #[serde(rename = "additionalChargePromotions")]
3006    pub additional_charge_promotions: Option<Vec<Promotion>>,
3007    /// [required] Type of the additional charge.
3008    #[serde(rename = "type")]
3009    pub type_: Option<String>,
3010}
3011
3012impl common::Part for UnitInvoiceAdditionalCharge {}
3013
3014/// There is no detailed description.
3015///
3016/// This type is not used in any activity, and only used as *part* of another schema.
3017///
3018#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3019#[serde_with::serde_as]
3020#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3021pub struct UnitInvoiceTaxLine {
3022    /// [required] Tax amount for the tax type.
3023    #[serde(rename = "taxAmount")]
3024    pub tax_amount: Option<Price>,
3025    /// Optional name of the tax type. This should only be provided if taxType is otherFeeTax.
3026    #[serde(rename = "taxName")]
3027    pub tax_name: Option<String>,
3028    /// [required] Type of the tax.
3029    #[serde(rename = "taxType")]
3030    pub tax_type: Option<String>,
3031}
3032
3033impl common::Part for UnitInvoiceTaxLine {}
3034
3035// ###################
3036// MethodBuilders ###
3037// #################
3038
3039/// A builder providing access to all methods supported on *orderinvoice* resources.
3040/// It is not used directly, but through the [`ShoppingContent`] hub.
3041///
3042/// # Example
3043///
3044/// Instantiate a resource builder
3045///
3046/// ```test_harness,no_run
3047/// extern crate hyper;
3048/// extern crate hyper_rustls;
3049/// extern crate google_content2_sandbox as content2_sandbox;
3050///
3051/// # async fn dox() {
3052/// use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3053///
3054/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3055/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3056///     .with_native_roots()
3057///     .unwrap()
3058///     .https_only()
3059///     .enable_http2()
3060///     .build();
3061///
3062/// let executor = hyper_util::rt::TokioExecutor::new();
3063/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3064///     secret,
3065///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3066///     yup_oauth2::client::CustomHyperClientBuilder::from(
3067///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3068///     ),
3069/// ).build().await.unwrap();
3070///
3071/// let client = hyper_util::client::legacy::Client::builder(
3072///     hyper_util::rt::TokioExecutor::new()
3073/// )
3074/// .build(
3075///     hyper_rustls::HttpsConnectorBuilder::new()
3076///         .with_native_roots()
3077///         .unwrap()
3078///         .https_or_http()
3079///         .enable_http2()
3080///         .build()
3081/// );
3082/// let mut hub = ShoppingContent::new(client, auth);
3083/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3084/// // like `createchargeinvoice(...)` and `createrefundinvoice(...)`
3085/// // to build up your call.
3086/// let rb = hub.orderinvoices();
3087/// # }
3088/// ```
3089pub struct OrderinvoiceMethods<'a, C>
3090where
3091    C: 'a,
3092{
3093    hub: &'a ShoppingContent<C>,
3094}
3095
3096impl<'a, C> common::MethodsBuilder for OrderinvoiceMethods<'a, C> {}
3097
3098impl<'a, C> OrderinvoiceMethods<'a, C> {
3099    /// Create a builder to help you perform the following task:
3100    ///
3101    /// Creates a charge invoice for a shipment group, and triggers a charge capture for non-facilitated payment orders.
3102    ///
3103    /// # Arguments
3104    ///
3105    /// * `request` - No description provided.
3106    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3107    /// * `orderId` - The ID of the order.
3108    pub fn createchargeinvoice(
3109        &self,
3110        request: OrderinvoicesCreateChargeInvoiceRequest,
3111        merchant_id: u64,
3112        order_id: &str,
3113    ) -> OrderinvoiceCreatechargeinvoiceCall<'a, C> {
3114        OrderinvoiceCreatechargeinvoiceCall {
3115            hub: self.hub,
3116            _request: request,
3117            _merchant_id: merchant_id,
3118            _order_id: order_id.to_string(),
3119            _delegate: Default::default(),
3120            _additional_params: Default::default(),
3121            _scopes: Default::default(),
3122        }
3123    }
3124
3125    /// Create a builder to help you perform the following task:
3126    ///
3127    /// Creates a refund invoice for one or more shipment groups, and triggers a refund for non-facilitated payment orders. This can only be used for line items that have previously been charged using createChargeInvoice. All amounts (except for the summary) are incremental with respect to the previous invoice.
3128    ///
3129    /// # Arguments
3130    ///
3131    /// * `request` - No description provided.
3132    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3133    /// * `orderId` - The ID of the order.
3134    pub fn createrefundinvoice(
3135        &self,
3136        request: OrderinvoicesCreateRefundInvoiceRequest,
3137        merchant_id: u64,
3138        order_id: &str,
3139    ) -> OrderinvoiceCreaterefundinvoiceCall<'a, C> {
3140        OrderinvoiceCreaterefundinvoiceCall {
3141            hub: self.hub,
3142            _request: request,
3143            _merchant_id: merchant_id,
3144            _order_id: order_id.to_string(),
3145            _delegate: Default::default(),
3146            _additional_params: Default::default(),
3147            _scopes: Default::default(),
3148        }
3149    }
3150}
3151
3152/// A builder providing access to all methods supported on *orderpayment* resources.
3153/// It is not used directly, but through the [`ShoppingContent`] hub.
3154///
3155/// # Example
3156///
3157/// Instantiate a resource builder
3158///
3159/// ```test_harness,no_run
3160/// extern crate hyper;
3161/// extern crate hyper_rustls;
3162/// extern crate google_content2_sandbox as content2_sandbox;
3163///
3164/// # async fn dox() {
3165/// use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3166///
3167/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3168/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3169///     .with_native_roots()
3170///     .unwrap()
3171///     .https_only()
3172///     .enable_http2()
3173///     .build();
3174///
3175/// let executor = hyper_util::rt::TokioExecutor::new();
3176/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3177///     secret,
3178///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3179///     yup_oauth2::client::CustomHyperClientBuilder::from(
3180///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3181///     ),
3182/// ).build().await.unwrap();
3183///
3184/// let client = hyper_util::client::legacy::Client::builder(
3185///     hyper_util::rt::TokioExecutor::new()
3186/// )
3187/// .build(
3188///     hyper_rustls::HttpsConnectorBuilder::new()
3189///         .with_native_roots()
3190///         .unwrap()
3191///         .https_or_http()
3192///         .enable_http2()
3193///         .build()
3194/// );
3195/// let mut hub = ShoppingContent::new(client, auth);
3196/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3197/// // like `notifyauthapproved(...)`, `notifyauthdeclined(...)`, `notifycharge(...)` and `notifyrefund(...)`
3198/// // to build up your call.
3199/// let rb = hub.orderpayments();
3200/// # }
3201/// ```
3202pub struct OrderpaymentMethods<'a, C>
3203where
3204    C: 'a,
3205{
3206    hub: &'a ShoppingContent<C>,
3207}
3208
3209impl<'a, C> common::MethodsBuilder for OrderpaymentMethods<'a, C> {}
3210
3211impl<'a, C> OrderpaymentMethods<'a, C> {
3212    /// Create a builder to help you perform the following task:
3213    ///
3214    /// Notify about successfully authorizing user's payment method for a given amount.
3215    ///
3216    /// # Arguments
3217    ///
3218    /// * `request` - No description provided.
3219    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3220    /// * `orderId` - The ID of the order for for which payment authorization is happening.
3221    pub fn notifyauthapproved(
3222        &self,
3223        request: OrderpaymentsNotifyAuthApprovedRequest,
3224        merchant_id: u64,
3225        order_id: &str,
3226    ) -> OrderpaymentNotifyauthapprovedCall<'a, C> {
3227        OrderpaymentNotifyauthapprovedCall {
3228            hub: self.hub,
3229            _request: request,
3230            _merchant_id: merchant_id,
3231            _order_id: order_id.to_string(),
3232            _delegate: Default::default(),
3233            _additional_params: Default::default(),
3234            _scopes: Default::default(),
3235        }
3236    }
3237
3238    /// Create a builder to help you perform the following task:
3239    ///
3240    /// Notify about failure to authorize user's payment method.
3241    ///
3242    /// # Arguments
3243    ///
3244    /// * `request` - No description provided.
3245    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3246    /// * `orderId` - The ID of the order for which payment authorization was declined.
3247    pub fn notifyauthdeclined(
3248        &self,
3249        request: OrderpaymentsNotifyAuthDeclinedRequest,
3250        merchant_id: u64,
3251        order_id: &str,
3252    ) -> OrderpaymentNotifyauthdeclinedCall<'a, C> {
3253        OrderpaymentNotifyauthdeclinedCall {
3254            hub: self.hub,
3255            _request: request,
3256            _merchant_id: merchant_id,
3257            _order_id: order_id.to_string(),
3258            _delegate: Default::default(),
3259            _additional_params: Default::default(),
3260            _scopes: Default::default(),
3261        }
3262    }
3263
3264    /// Create a builder to help you perform the following task:
3265    ///
3266    /// Notify about charge on user's selected payments method.
3267    ///
3268    /// # Arguments
3269    ///
3270    /// * `request` - No description provided.
3271    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3272    /// * `orderId` - The ID of the order for which charge is happening.
3273    pub fn notifycharge(
3274        &self,
3275        request: OrderpaymentsNotifyChargeRequest,
3276        merchant_id: u64,
3277        order_id: &str,
3278    ) -> OrderpaymentNotifychargeCall<'a, C> {
3279        OrderpaymentNotifychargeCall {
3280            hub: self.hub,
3281            _request: request,
3282            _merchant_id: merchant_id,
3283            _order_id: order_id.to_string(),
3284            _delegate: Default::default(),
3285            _additional_params: Default::default(),
3286            _scopes: Default::default(),
3287        }
3288    }
3289
3290    /// Create a builder to help you perform the following task:
3291    ///
3292    /// Notify about refund on user's selected payments method.
3293    ///
3294    /// # Arguments
3295    ///
3296    /// * `request` - No description provided.
3297    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3298    /// * `orderId` - The ID of the order for which charge is happening.
3299    pub fn notifyrefund(
3300        &self,
3301        request: OrderpaymentsNotifyRefundRequest,
3302        merchant_id: u64,
3303        order_id: &str,
3304    ) -> OrderpaymentNotifyrefundCall<'a, C> {
3305        OrderpaymentNotifyrefundCall {
3306            hub: self.hub,
3307            _request: request,
3308            _merchant_id: merchant_id,
3309            _order_id: order_id.to_string(),
3310            _delegate: Default::default(),
3311            _additional_params: Default::default(),
3312            _scopes: Default::default(),
3313        }
3314    }
3315}
3316
3317/// A builder providing access to all methods supported on *orderreturn* resources.
3318/// It is not used directly, but through the [`ShoppingContent`] hub.
3319///
3320/// # Example
3321///
3322/// Instantiate a resource builder
3323///
3324/// ```test_harness,no_run
3325/// extern crate hyper;
3326/// extern crate hyper_rustls;
3327/// extern crate google_content2_sandbox as content2_sandbox;
3328///
3329/// # async fn dox() {
3330/// use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3331///
3332/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3333/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3334///     .with_native_roots()
3335///     .unwrap()
3336///     .https_only()
3337///     .enable_http2()
3338///     .build();
3339///
3340/// let executor = hyper_util::rt::TokioExecutor::new();
3341/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3342///     secret,
3343///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3344///     yup_oauth2::client::CustomHyperClientBuilder::from(
3345///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3346///     ),
3347/// ).build().await.unwrap();
3348///
3349/// let client = hyper_util::client::legacy::Client::builder(
3350///     hyper_util::rt::TokioExecutor::new()
3351/// )
3352/// .build(
3353///     hyper_rustls::HttpsConnectorBuilder::new()
3354///         .with_native_roots()
3355///         .unwrap()
3356///         .https_or_http()
3357///         .enable_http2()
3358///         .build()
3359/// );
3360/// let mut hub = ShoppingContent::new(client, auth);
3361/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3362/// // like `get(...)` and `list(...)`
3363/// // to build up your call.
3364/// let rb = hub.orderreturns();
3365/// # }
3366/// ```
3367pub struct OrderreturnMethods<'a, C>
3368where
3369    C: 'a,
3370{
3371    hub: &'a ShoppingContent<C>,
3372}
3373
3374impl<'a, C> common::MethodsBuilder for OrderreturnMethods<'a, C> {}
3375
3376impl<'a, C> OrderreturnMethods<'a, C> {
3377    /// Create a builder to help you perform the following task:
3378    ///
3379    /// Retrieves an order return from your Merchant Center account.
3380    ///
3381    /// # Arguments
3382    ///
3383    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3384    /// * `returnId` - Merchant order return ID generated by Google.
3385    pub fn get(&self, merchant_id: u64, return_id: &str) -> OrderreturnGetCall<'a, C> {
3386        OrderreturnGetCall {
3387            hub: self.hub,
3388            _merchant_id: merchant_id,
3389            _return_id: return_id.to_string(),
3390            _delegate: Default::default(),
3391            _additional_params: Default::default(),
3392            _scopes: Default::default(),
3393        }
3394    }
3395
3396    /// Create a builder to help you perform the following task:
3397    ///
3398    /// Lists order returns in your Merchant Center account.
3399    ///
3400    /// # Arguments
3401    ///
3402    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3403    pub fn list(&self, merchant_id: u64) -> OrderreturnListCall<'a, C> {
3404        OrderreturnListCall {
3405            hub: self.hub,
3406            _merchant_id: merchant_id,
3407            _page_token: Default::default(),
3408            _order_by: Default::default(),
3409            _max_results: Default::default(),
3410            _created_start_date: Default::default(),
3411            _created_end_date: Default::default(),
3412            _delegate: Default::default(),
3413            _additional_params: Default::default(),
3414            _scopes: Default::default(),
3415        }
3416    }
3417}
3418
3419/// A builder providing access to all methods supported on *order* resources.
3420/// It is not used directly, but through the [`ShoppingContent`] hub.
3421///
3422/// # Example
3423///
3424/// Instantiate a resource builder
3425///
3426/// ```test_harness,no_run
3427/// extern crate hyper;
3428/// extern crate hyper_rustls;
3429/// extern crate google_content2_sandbox as content2_sandbox;
3430///
3431/// # async fn dox() {
3432/// use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3433///
3434/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3435/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3436///     .with_native_roots()
3437///     .unwrap()
3438///     .https_only()
3439///     .enable_http2()
3440///     .build();
3441///
3442/// let executor = hyper_util::rt::TokioExecutor::new();
3443/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3444///     secret,
3445///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3446///     yup_oauth2::client::CustomHyperClientBuilder::from(
3447///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3448///     ),
3449/// ).build().await.unwrap();
3450///
3451/// let client = hyper_util::client::legacy::Client::builder(
3452///     hyper_util::rt::TokioExecutor::new()
3453/// )
3454/// .build(
3455///     hyper_rustls::HttpsConnectorBuilder::new()
3456///         .with_native_roots()
3457///         .unwrap()
3458///         .https_or_http()
3459///         .enable_http2()
3460///         .build()
3461/// );
3462/// let mut hub = ShoppingContent::new(client, auth);
3463/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3464/// // like `acknowledge(...)`, `advancetestorder(...)`, `cancel(...)`, `cancellineitem(...)`, `canceltestorderbycustomer(...)`, `createtestorder(...)`, `createtestreturn(...)`, `custombatch(...)`, `get(...)`, `getbymerchantorderid(...)`, `gettestordertemplate(...)`, `instorerefundlineitem(...)`, `list(...)`, `refund(...)`, `rejectreturnlineitem(...)`, `returnlineitem(...)`, `returnrefundlineitem(...)`, `setlineitemmetadata(...)`, `shiplineitems(...)`, `updatelineitemshippingdetails(...)`, `updatemerchantorderid(...)` and `updateshipment(...)`
3465/// // to build up your call.
3466/// let rb = hub.orders();
3467/// # }
3468/// ```
3469pub struct OrderMethods<'a, C>
3470where
3471    C: 'a,
3472{
3473    hub: &'a ShoppingContent<C>,
3474}
3475
3476impl<'a, C> common::MethodsBuilder for OrderMethods<'a, C> {}
3477
3478impl<'a, C> OrderMethods<'a, C> {
3479    /// Create a builder to help you perform the following task:
3480    ///
3481    /// Marks an order as acknowledged.
3482    ///
3483    /// # Arguments
3484    ///
3485    /// * `request` - No description provided.
3486    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3487    /// * `orderId` - The ID of the order.
3488    pub fn acknowledge(
3489        &self,
3490        request: OrdersAcknowledgeRequest,
3491        merchant_id: u64,
3492        order_id: &str,
3493    ) -> OrderAcknowledgeCall<'a, C> {
3494        OrderAcknowledgeCall {
3495            hub: self.hub,
3496            _request: request,
3497            _merchant_id: merchant_id,
3498            _order_id: order_id.to_string(),
3499            _delegate: Default::default(),
3500            _additional_params: Default::default(),
3501            _scopes: Default::default(),
3502        }
3503    }
3504
3505    /// Create a builder to help you perform the following task:
3506    ///
3507    /// Sandbox only. Moves a test order from state "inProgress" to state "pendingShipment".
3508    ///
3509    /// # Arguments
3510    ///
3511    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3512    /// * `orderId` - The ID of the test order to modify.
3513    pub fn advancetestorder(
3514        &self,
3515        merchant_id: u64,
3516        order_id: &str,
3517    ) -> OrderAdvancetestorderCall<'a, C> {
3518        OrderAdvancetestorderCall {
3519            hub: self.hub,
3520            _merchant_id: merchant_id,
3521            _order_id: order_id.to_string(),
3522            _delegate: Default::default(),
3523            _additional_params: Default::default(),
3524            _scopes: Default::default(),
3525        }
3526    }
3527
3528    /// Create a builder to help you perform the following task:
3529    ///
3530    /// Cancels all line items in an order, making a full refund.
3531    ///
3532    /// # Arguments
3533    ///
3534    /// * `request` - No description provided.
3535    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3536    /// * `orderId` - The ID of the order to cancel.
3537    pub fn cancel(
3538        &self,
3539        request: OrdersCancelRequest,
3540        merchant_id: u64,
3541        order_id: &str,
3542    ) -> OrderCancelCall<'a, C> {
3543        OrderCancelCall {
3544            hub: self.hub,
3545            _request: request,
3546            _merchant_id: merchant_id,
3547            _order_id: order_id.to_string(),
3548            _delegate: Default::default(),
3549            _additional_params: Default::default(),
3550            _scopes: Default::default(),
3551        }
3552    }
3553
3554    /// Create a builder to help you perform the following task:
3555    ///
3556    /// Cancels a line item, making a full refund.
3557    ///
3558    /// # Arguments
3559    ///
3560    /// * `request` - No description provided.
3561    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3562    /// * `orderId` - The ID of the order.
3563    pub fn cancellineitem(
3564        &self,
3565        request: OrdersCancelLineItemRequest,
3566        merchant_id: u64,
3567        order_id: &str,
3568    ) -> OrderCancellineitemCall<'a, C> {
3569        OrderCancellineitemCall {
3570            hub: self.hub,
3571            _request: request,
3572            _merchant_id: merchant_id,
3573            _order_id: order_id.to_string(),
3574            _delegate: Default::default(),
3575            _additional_params: Default::default(),
3576            _scopes: Default::default(),
3577        }
3578    }
3579
3580    /// Create a builder to help you perform the following task:
3581    ///
3582    /// Sandbox only. Cancels a test order for customer-initiated cancellation.
3583    ///
3584    /// # Arguments
3585    ///
3586    /// * `request` - No description provided.
3587    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3588    /// * `orderId` - The ID of the test order to cancel.
3589    pub fn canceltestorderbycustomer(
3590        &self,
3591        request: OrdersCancelTestOrderByCustomerRequest,
3592        merchant_id: u64,
3593        order_id: &str,
3594    ) -> OrderCanceltestorderbycustomerCall<'a, C> {
3595        OrderCanceltestorderbycustomerCall {
3596            hub: self.hub,
3597            _request: request,
3598            _merchant_id: merchant_id,
3599            _order_id: order_id.to_string(),
3600            _delegate: Default::default(),
3601            _additional_params: Default::default(),
3602            _scopes: Default::default(),
3603        }
3604    }
3605
3606    /// Create a builder to help you perform the following task:
3607    ///
3608    /// Sandbox only. Creates a test order.
3609    ///
3610    /// # Arguments
3611    ///
3612    /// * `request` - No description provided.
3613    /// * `merchantId` - The ID of the account that should manage the order. This cannot be a multi-client account.
3614    pub fn createtestorder(
3615        &self,
3616        request: OrdersCreateTestOrderRequest,
3617        merchant_id: u64,
3618    ) -> OrderCreatetestorderCall<'a, C> {
3619        OrderCreatetestorderCall {
3620            hub: self.hub,
3621            _request: request,
3622            _merchant_id: merchant_id,
3623            _delegate: Default::default(),
3624            _additional_params: Default::default(),
3625            _scopes: Default::default(),
3626        }
3627    }
3628
3629    /// Create a builder to help you perform the following task:
3630    ///
3631    /// Sandbox only. Creates a test return.
3632    ///
3633    /// # Arguments
3634    ///
3635    /// * `request` - No description provided.
3636    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3637    /// * `orderId` - The ID of the order.
3638    pub fn createtestreturn(
3639        &self,
3640        request: OrdersCreateTestReturnRequest,
3641        merchant_id: u64,
3642        order_id: &str,
3643    ) -> OrderCreatetestreturnCall<'a, C> {
3644        OrderCreatetestreturnCall {
3645            hub: self.hub,
3646            _request: request,
3647            _merchant_id: merchant_id,
3648            _order_id: order_id.to_string(),
3649            _delegate: Default::default(),
3650            _additional_params: Default::default(),
3651            _scopes: Default::default(),
3652        }
3653    }
3654
3655    /// Create a builder to help you perform the following task:
3656    ///
3657    /// Retrieves or modifies multiple orders in a single request.
3658    ///
3659    /// # Arguments
3660    ///
3661    /// * `request` - No description provided.
3662    pub fn custombatch(&self, request: OrdersCustomBatchRequest) -> OrderCustombatchCall<'a, C> {
3663        OrderCustombatchCall {
3664            hub: self.hub,
3665            _request: request,
3666            _delegate: Default::default(),
3667            _additional_params: Default::default(),
3668            _scopes: Default::default(),
3669        }
3670    }
3671
3672    /// Create a builder to help you perform the following task:
3673    ///
3674    /// Retrieves an order from your Merchant Center account.
3675    ///
3676    /// # Arguments
3677    ///
3678    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3679    /// * `orderId` - The ID of the order.
3680    pub fn get(&self, merchant_id: u64, order_id: &str) -> OrderGetCall<'a, C> {
3681        OrderGetCall {
3682            hub: self.hub,
3683            _merchant_id: merchant_id,
3684            _order_id: order_id.to_string(),
3685            _delegate: Default::default(),
3686            _additional_params: Default::default(),
3687            _scopes: Default::default(),
3688        }
3689    }
3690
3691    /// Create a builder to help you perform the following task:
3692    ///
3693    /// Retrieves an order using merchant order id.
3694    ///
3695    /// # Arguments
3696    ///
3697    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3698    /// * `merchantOrderId` - The merchant order id to be looked for.
3699    pub fn getbymerchantorderid(
3700        &self,
3701        merchant_id: u64,
3702        merchant_order_id: &str,
3703    ) -> OrderGetbymerchantorderidCall<'a, C> {
3704        OrderGetbymerchantorderidCall {
3705            hub: self.hub,
3706            _merchant_id: merchant_id,
3707            _merchant_order_id: merchant_order_id.to_string(),
3708            _delegate: Default::default(),
3709            _additional_params: Default::default(),
3710            _scopes: Default::default(),
3711        }
3712    }
3713
3714    /// Create a builder to help you perform the following task:
3715    ///
3716    /// Sandbox only. Retrieves an order template that can be used to quickly create a new order in sandbox.
3717    ///
3718    /// # Arguments
3719    ///
3720    /// * `merchantId` - The ID of the account that should manage the order. This cannot be a multi-client account.
3721    /// * `templateName` - The name of the template to retrieve.
3722    pub fn gettestordertemplate(
3723        &self,
3724        merchant_id: u64,
3725        template_name: &str,
3726    ) -> OrderGettestordertemplateCall<'a, C> {
3727        OrderGettestordertemplateCall {
3728            hub: self.hub,
3729            _merchant_id: merchant_id,
3730            _template_name: template_name.to_string(),
3731            _country: Default::default(),
3732            _delegate: Default::default(),
3733            _additional_params: Default::default(),
3734            _scopes: Default::default(),
3735        }
3736    }
3737
3738    /// Create a builder to help you perform the following task:
3739    ///
3740    /// Notifies that item return and refund was handled directly by merchant outside of Google payments processing (e.g. cash refund done in store).
3741    ///
3742    /// # Arguments
3743    ///
3744    /// * `request` - No description provided.
3745    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3746    /// * `orderId` - The ID of the order.
3747    pub fn instorerefundlineitem(
3748        &self,
3749        request: OrdersInStoreRefundLineItemRequest,
3750        merchant_id: u64,
3751        order_id: &str,
3752    ) -> OrderInstorerefundlineitemCall<'a, C> {
3753        OrderInstorerefundlineitemCall {
3754            hub: self.hub,
3755            _request: request,
3756            _merchant_id: merchant_id,
3757            _order_id: order_id.to_string(),
3758            _delegate: Default::default(),
3759            _additional_params: Default::default(),
3760            _scopes: Default::default(),
3761        }
3762    }
3763
3764    /// Create a builder to help you perform the following task:
3765    ///
3766    /// Lists the orders in your Merchant Center account.
3767    ///
3768    /// # Arguments
3769    ///
3770    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3771    pub fn list(&self, merchant_id: u64) -> OrderListCall<'a, C> {
3772        OrderListCall {
3773            hub: self.hub,
3774            _merchant_id: merchant_id,
3775            _statuses: Default::default(),
3776            _placed_date_start: Default::default(),
3777            _placed_date_end: Default::default(),
3778            _page_token: Default::default(),
3779            _order_by: Default::default(),
3780            _max_results: Default::default(),
3781            _acknowledged: Default::default(),
3782            _delegate: Default::default(),
3783            _additional_params: Default::default(),
3784            _scopes: Default::default(),
3785        }
3786    }
3787
3788    /// Create a builder to help you perform the following task:
3789    ///
3790    /// Deprecated, please use returnRefundLineItem instead.
3791    ///
3792    /// # Arguments
3793    ///
3794    /// * `request` - No description provided.
3795    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3796    /// * `orderId` - The ID of the order to refund.
3797    pub fn refund(
3798        &self,
3799        request: OrdersRefundRequest,
3800        merchant_id: u64,
3801        order_id: &str,
3802    ) -> OrderRefundCall<'a, C> {
3803        OrderRefundCall {
3804            hub: self.hub,
3805            _request: request,
3806            _merchant_id: merchant_id,
3807            _order_id: order_id.to_string(),
3808            _delegate: Default::default(),
3809            _additional_params: Default::default(),
3810            _scopes: Default::default(),
3811        }
3812    }
3813
3814    /// Create a builder to help you perform the following task:
3815    ///
3816    /// Rejects return on an line item.
3817    ///
3818    /// # Arguments
3819    ///
3820    /// * `request` - No description provided.
3821    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3822    /// * `orderId` - The ID of the order.
3823    pub fn rejectreturnlineitem(
3824        &self,
3825        request: OrdersRejectReturnLineItemRequest,
3826        merchant_id: u64,
3827        order_id: &str,
3828    ) -> OrderRejectreturnlineitemCall<'a, C> {
3829        OrderRejectreturnlineitemCall {
3830            hub: self.hub,
3831            _request: request,
3832            _merchant_id: merchant_id,
3833            _order_id: order_id.to_string(),
3834            _delegate: Default::default(),
3835            _additional_params: Default::default(),
3836            _scopes: Default::default(),
3837        }
3838    }
3839
3840    /// Create a builder to help you perform the following task:
3841    ///
3842    /// Returns a line item.
3843    ///
3844    /// # Arguments
3845    ///
3846    /// * `request` - No description provided.
3847    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3848    /// * `orderId` - The ID of the order.
3849    pub fn returnlineitem(
3850        &self,
3851        request: OrdersReturnLineItemRequest,
3852        merchant_id: u64,
3853        order_id: &str,
3854    ) -> OrderReturnlineitemCall<'a, C> {
3855        OrderReturnlineitemCall {
3856            hub: self.hub,
3857            _request: request,
3858            _merchant_id: merchant_id,
3859            _order_id: order_id.to_string(),
3860            _delegate: Default::default(),
3861            _additional_params: Default::default(),
3862            _scopes: Default::default(),
3863        }
3864    }
3865
3866    /// Create a builder to help you perform the following task:
3867    ///
3868    /// Returns and refunds a line item. Note that this method can only be called on fully shipped orders.
3869    ///
3870    /// # Arguments
3871    ///
3872    /// * `request` - No description provided.
3873    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3874    /// * `orderId` - The ID of the order.
3875    pub fn returnrefundlineitem(
3876        &self,
3877        request: OrdersReturnRefundLineItemRequest,
3878        merchant_id: u64,
3879        order_id: &str,
3880    ) -> OrderReturnrefundlineitemCall<'a, C> {
3881        OrderReturnrefundlineitemCall {
3882            hub: self.hub,
3883            _request: request,
3884            _merchant_id: merchant_id,
3885            _order_id: order_id.to_string(),
3886            _delegate: Default::default(),
3887            _additional_params: Default::default(),
3888            _scopes: Default::default(),
3889        }
3890    }
3891
3892    /// Create a builder to help you perform the following task:
3893    ///
3894    /// Sets (overrides) merchant provided annotations on the line item.
3895    ///
3896    /// # Arguments
3897    ///
3898    /// * `request` - No description provided.
3899    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3900    /// * `orderId` - The ID of the order.
3901    pub fn setlineitemmetadata(
3902        &self,
3903        request: OrdersSetLineItemMetadataRequest,
3904        merchant_id: u64,
3905        order_id: &str,
3906    ) -> OrderSetlineitemmetadataCall<'a, C> {
3907        OrderSetlineitemmetadataCall {
3908            hub: self.hub,
3909            _request: request,
3910            _merchant_id: merchant_id,
3911            _order_id: order_id.to_string(),
3912            _delegate: Default::default(),
3913            _additional_params: Default::default(),
3914            _scopes: Default::default(),
3915        }
3916    }
3917
3918    /// Create a builder to help you perform the following task:
3919    ///
3920    /// Marks line item(s) as shipped.
3921    ///
3922    /// # Arguments
3923    ///
3924    /// * `request` - No description provided.
3925    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3926    /// * `orderId` - The ID of the order.
3927    pub fn shiplineitems(
3928        &self,
3929        request: OrdersShipLineItemsRequest,
3930        merchant_id: u64,
3931        order_id: &str,
3932    ) -> OrderShiplineitemCall<'a, C> {
3933        OrderShiplineitemCall {
3934            hub: self.hub,
3935            _request: request,
3936            _merchant_id: merchant_id,
3937            _order_id: order_id.to_string(),
3938            _delegate: Default::default(),
3939            _additional_params: Default::default(),
3940            _scopes: Default::default(),
3941        }
3942    }
3943
3944    /// Create a builder to help you perform the following task:
3945    ///
3946    /// Updates ship by and delivery by dates for a line item.
3947    ///
3948    /// # Arguments
3949    ///
3950    /// * `request` - No description provided.
3951    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3952    /// * `orderId` - The ID of the order.
3953    pub fn updatelineitemshippingdetails(
3954        &self,
3955        request: OrdersUpdateLineItemShippingDetailsRequest,
3956        merchant_id: u64,
3957        order_id: &str,
3958    ) -> OrderUpdatelineitemshippingdetailCall<'a, C> {
3959        OrderUpdatelineitemshippingdetailCall {
3960            hub: self.hub,
3961            _request: request,
3962            _merchant_id: merchant_id,
3963            _order_id: order_id.to_string(),
3964            _delegate: Default::default(),
3965            _additional_params: Default::default(),
3966            _scopes: Default::default(),
3967        }
3968    }
3969
3970    /// Create a builder to help you perform the following task:
3971    ///
3972    /// Updates the merchant order ID for a given order.
3973    ///
3974    /// # Arguments
3975    ///
3976    /// * `request` - No description provided.
3977    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
3978    /// * `orderId` - The ID of the order.
3979    pub fn updatemerchantorderid(
3980        &self,
3981        request: OrdersUpdateMerchantOrderIdRequest,
3982        merchant_id: u64,
3983        order_id: &str,
3984    ) -> OrderUpdatemerchantorderidCall<'a, C> {
3985        OrderUpdatemerchantorderidCall {
3986            hub: self.hub,
3987            _request: request,
3988            _merchant_id: merchant_id,
3989            _order_id: order_id.to_string(),
3990            _delegate: Default::default(),
3991            _additional_params: Default::default(),
3992            _scopes: Default::default(),
3993        }
3994    }
3995
3996    /// Create a builder to help you perform the following task:
3997    ///
3998    /// Updates a shipment's status, carrier, and/or tracking ID.
3999    ///
4000    /// # Arguments
4001    ///
4002    /// * `request` - No description provided.
4003    /// * `merchantId` - The ID of the account that manages the order. This cannot be a multi-client account.
4004    /// * `orderId` - The ID of the order.
4005    pub fn updateshipment(
4006        &self,
4007        request: OrdersUpdateShipmentRequest,
4008        merchant_id: u64,
4009        order_id: &str,
4010    ) -> OrderUpdateshipmentCall<'a, C> {
4011        OrderUpdateshipmentCall {
4012            hub: self.hub,
4013            _request: request,
4014            _merchant_id: merchant_id,
4015            _order_id: order_id.to_string(),
4016            _delegate: Default::default(),
4017            _additional_params: Default::default(),
4018            _scopes: Default::default(),
4019        }
4020    }
4021}
4022
4023// ###################
4024// CallBuilders   ###
4025// #################
4026
4027/// Creates a charge invoice for a shipment group, and triggers a charge capture for non-facilitated payment orders.
4028///
4029/// A builder for the *createchargeinvoice* method supported by a *orderinvoice* resource.
4030/// It is not used directly, but through a [`OrderinvoiceMethods`] instance.
4031///
4032/// # Example
4033///
4034/// Instantiate a resource method builder
4035///
4036/// ```test_harness,no_run
4037/// # extern crate hyper;
4038/// # extern crate hyper_rustls;
4039/// # extern crate google_content2_sandbox as content2_sandbox;
4040/// use content2_sandbox::api::OrderinvoicesCreateChargeInvoiceRequest;
4041/// # async fn dox() {
4042/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4043///
4044/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4045/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4046/// #     .with_native_roots()
4047/// #     .unwrap()
4048/// #     .https_only()
4049/// #     .enable_http2()
4050/// #     .build();
4051///
4052/// # let executor = hyper_util::rt::TokioExecutor::new();
4053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4054/// #     secret,
4055/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4056/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4057/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4058/// #     ),
4059/// # ).build().await.unwrap();
4060///
4061/// # let client = hyper_util::client::legacy::Client::builder(
4062/// #     hyper_util::rt::TokioExecutor::new()
4063/// # )
4064/// # .build(
4065/// #     hyper_rustls::HttpsConnectorBuilder::new()
4066/// #         .with_native_roots()
4067/// #         .unwrap()
4068/// #         .https_or_http()
4069/// #         .enable_http2()
4070/// #         .build()
4071/// # );
4072/// # let mut hub = ShoppingContent::new(client, auth);
4073/// // As the method needs a request, you would usually fill it with the desired information
4074/// // into the respective structure. Some of the parts shown here might not be applicable !
4075/// // Values shown here are possibly random and not representative !
4076/// let mut req = OrderinvoicesCreateChargeInvoiceRequest::default();
4077///
4078/// // You can configure optional parameters by calling the respective setters at will, and
4079/// // execute the final call using `doit()`.
4080/// // Values shown here are possibly random and not representative !
4081/// let result = hub.orderinvoices().createchargeinvoice(req, 64, "orderId")
4082///              .doit().await;
4083/// # }
4084/// ```
4085pub struct OrderinvoiceCreatechargeinvoiceCall<'a, C>
4086where
4087    C: 'a,
4088{
4089    hub: &'a ShoppingContent<C>,
4090    _request: OrderinvoicesCreateChargeInvoiceRequest,
4091    _merchant_id: u64,
4092    _order_id: String,
4093    _delegate: Option<&'a mut dyn common::Delegate>,
4094    _additional_params: HashMap<String, String>,
4095    _scopes: BTreeSet<String>,
4096}
4097
4098impl<'a, C> common::CallBuilder for OrderinvoiceCreatechargeinvoiceCall<'a, C> {}
4099
4100impl<'a, C> OrderinvoiceCreatechargeinvoiceCall<'a, C>
4101where
4102    C: common::Connector,
4103{
4104    /// Perform the operation you have build so far.
4105    pub async fn doit(
4106        mut self,
4107    ) -> common::Result<(common::Response, OrderinvoicesCreateChargeInvoiceResponse)> {
4108        use std::borrow::Cow;
4109        use std::io::{Read, Seek};
4110
4111        use common::{url::Params, ToParts};
4112        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4113
4114        let mut dd = common::DefaultDelegate;
4115        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4116        dlg.begin(common::MethodInfo {
4117            id: "content.orderinvoices.createchargeinvoice",
4118            http_method: hyper::Method::POST,
4119        });
4120
4121        for &field in ["alt", "merchantId", "orderId"].iter() {
4122            if self._additional_params.contains_key(field) {
4123                dlg.finished(false);
4124                return Err(common::Error::FieldClash(field));
4125            }
4126        }
4127
4128        let mut params = Params::with_capacity(5 + self._additional_params.len());
4129        params.push("merchantId", self._merchant_id.to_string());
4130        params.push("orderId", self._order_id);
4131
4132        params.extend(self._additional_params.iter());
4133
4134        params.push("alt", "json");
4135        let mut url =
4136            self.hub._base_url.clone() + "{merchantId}/orderinvoices/{orderId}/createChargeInvoice";
4137        if self._scopes.is_empty() {
4138            self._scopes.insert(Scope::Full.as_ref().to_string());
4139        }
4140
4141        #[allow(clippy::single_element_loop)]
4142        for &(find_this, param_name) in
4143            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
4144        {
4145            url = params.uri_replacement(url, param_name, find_this, false);
4146        }
4147        {
4148            let to_remove = ["orderId", "merchantId"];
4149            params.remove_params(&to_remove);
4150        }
4151
4152        let url = params.parse_with_url(&url);
4153
4154        let mut json_mime_type = mime::APPLICATION_JSON;
4155        let mut request_value_reader = {
4156            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4157            common::remove_json_null_values(&mut value);
4158            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4159            serde_json::to_writer(&mut dst, &value).unwrap();
4160            dst
4161        };
4162        let request_size = request_value_reader
4163            .seek(std::io::SeekFrom::End(0))
4164            .unwrap();
4165        request_value_reader
4166            .seek(std::io::SeekFrom::Start(0))
4167            .unwrap();
4168
4169        loop {
4170            let token = match self
4171                .hub
4172                .auth
4173                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4174                .await
4175            {
4176                Ok(token) => token,
4177                Err(e) => match dlg.token(e) {
4178                    Ok(token) => token,
4179                    Err(e) => {
4180                        dlg.finished(false);
4181                        return Err(common::Error::MissingToken(e));
4182                    }
4183                },
4184            };
4185            request_value_reader
4186                .seek(std::io::SeekFrom::Start(0))
4187                .unwrap();
4188            let mut req_result = {
4189                let client = &self.hub.client;
4190                dlg.pre_request();
4191                let mut req_builder = hyper::Request::builder()
4192                    .method(hyper::Method::POST)
4193                    .uri(url.as_str())
4194                    .header(USER_AGENT, self.hub._user_agent.clone());
4195
4196                if let Some(token) = token.as_ref() {
4197                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4198                }
4199
4200                let request = req_builder
4201                    .header(CONTENT_TYPE, json_mime_type.to_string())
4202                    .header(CONTENT_LENGTH, request_size as u64)
4203                    .body(common::to_body(
4204                        request_value_reader.get_ref().clone().into(),
4205                    ));
4206
4207                client.request(request.unwrap()).await
4208            };
4209
4210            match req_result {
4211                Err(err) => {
4212                    if let common::Retry::After(d) = dlg.http_error(&err) {
4213                        sleep(d).await;
4214                        continue;
4215                    }
4216                    dlg.finished(false);
4217                    return Err(common::Error::HttpError(err));
4218                }
4219                Ok(res) => {
4220                    let (mut parts, body) = res.into_parts();
4221                    let mut body = common::Body::new(body);
4222                    if !parts.status.is_success() {
4223                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4224                        let error = serde_json::from_str(&common::to_string(&bytes));
4225                        let response = common::to_response(parts, bytes.into());
4226
4227                        if let common::Retry::After(d) =
4228                            dlg.http_failure(&response, error.as_ref().ok())
4229                        {
4230                            sleep(d).await;
4231                            continue;
4232                        }
4233
4234                        dlg.finished(false);
4235
4236                        return Err(match error {
4237                            Ok(value) => common::Error::BadRequest(value),
4238                            _ => common::Error::Failure(response),
4239                        });
4240                    }
4241                    let response = {
4242                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4243                        let encoded = common::to_string(&bytes);
4244                        match serde_json::from_str(&encoded) {
4245                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4246                            Err(error) => {
4247                                dlg.response_json_decode_error(&encoded, &error);
4248                                return Err(common::Error::JsonDecodeError(
4249                                    encoded.to_string(),
4250                                    error,
4251                                ));
4252                            }
4253                        }
4254                    };
4255
4256                    dlg.finished(true);
4257                    return Ok(response);
4258                }
4259            }
4260        }
4261    }
4262
4263    ///
4264    /// Sets the *request* property to the given value.
4265    ///
4266    /// Even though the property as already been set when instantiating this call,
4267    /// we provide this method for API completeness.
4268    pub fn request(
4269        mut self,
4270        new_value: OrderinvoicesCreateChargeInvoiceRequest,
4271    ) -> OrderinvoiceCreatechargeinvoiceCall<'a, C> {
4272        self._request = new_value;
4273        self
4274    }
4275    /// The ID of the account that manages the order. This cannot be a multi-client account.
4276    ///
4277    /// Sets the *merchant id* path property to the given value.
4278    ///
4279    /// Even though the property as already been set when instantiating this call,
4280    /// we provide this method for API completeness.
4281    pub fn merchant_id(mut self, new_value: u64) -> OrderinvoiceCreatechargeinvoiceCall<'a, C> {
4282        self._merchant_id = new_value;
4283        self
4284    }
4285    /// The ID of the order.
4286    ///
4287    /// Sets the *order id* path property to the given value.
4288    ///
4289    /// Even though the property as already been set when instantiating this call,
4290    /// we provide this method for API completeness.
4291    pub fn order_id(mut self, new_value: &str) -> OrderinvoiceCreatechargeinvoiceCall<'a, C> {
4292        self._order_id = new_value.to_string();
4293        self
4294    }
4295    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4296    /// while executing the actual API request.
4297    ///
4298    /// ````text
4299    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4300    /// ````
4301    ///
4302    /// Sets the *delegate* property to the given value.
4303    pub fn delegate(
4304        mut self,
4305        new_value: &'a mut dyn common::Delegate,
4306    ) -> OrderinvoiceCreatechargeinvoiceCall<'a, C> {
4307        self._delegate = Some(new_value);
4308        self
4309    }
4310
4311    /// Set any additional parameter of the query string used in the request.
4312    /// It should be used to set parameters which are not yet available through their own
4313    /// setters.
4314    ///
4315    /// Please note that this method must not be used to set any of the known parameters
4316    /// which have their own setter method. If done anyway, the request will fail.
4317    ///
4318    /// # Additional Parameters
4319    ///
4320    /// * *alt* (query-string) - Data format for the response.
4321    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4322    /// * *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.
4323    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4324    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4325    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4326    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4327    pub fn param<T>(mut self, name: T, value: T) -> OrderinvoiceCreatechargeinvoiceCall<'a, C>
4328    where
4329        T: AsRef<str>,
4330    {
4331        self._additional_params
4332            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4333        self
4334    }
4335
4336    /// Identifies the authorization scope for the method you are building.
4337    ///
4338    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4339    /// [`Scope::Full`].
4340    ///
4341    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4342    /// tokens for more than one scope.
4343    ///
4344    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4345    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4346    /// sufficient, a read-write scope will do as well.
4347    pub fn add_scope<St>(mut self, scope: St) -> OrderinvoiceCreatechargeinvoiceCall<'a, C>
4348    where
4349        St: AsRef<str>,
4350    {
4351        self._scopes.insert(String::from(scope.as_ref()));
4352        self
4353    }
4354    /// Identifies the authorization scope(s) for the method you are building.
4355    ///
4356    /// See [`Self::add_scope()`] for details.
4357    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderinvoiceCreatechargeinvoiceCall<'a, C>
4358    where
4359        I: IntoIterator<Item = St>,
4360        St: AsRef<str>,
4361    {
4362        self._scopes
4363            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4364        self
4365    }
4366
4367    /// Removes all scopes, and no default scope will be used either.
4368    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4369    /// for details).
4370    pub fn clear_scopes(mut self) -> OrderinvoiceCreatechargeinvoiceCall<'a, C> {
4371        self._scopes.clear();
4372        self
4373    }
4374}
4375
4376/// Creates a refund invoice for one or more shipment groups, and triggers a refund for non-facilitated payment orders. This can only be used for line items that have previously been charged using createChargeInvoice. All amounts (except for the summary) are incremental with respect to the previous invoice.
4377///
4378/// A builder for the *createrefundinvoice* method supported by a *orderinvoice* resource.
4379/// It is not used directly, but through a [`OrderinvoiceMethods`] instance.
4380///
4381/// # Example
4382///
4383/// Instantiate a resource method builder
4384///
4385/// ```test_harness,no_run
4386/// # extern crate hyper;
4387/// # extern crate hyper_rustls;
4388/// # extern crate google_content2_sandbox as content2_sandbox;
4389/// use content2_sandbox::api::OrderinvoicesCreateRefundInvoiceRequest;
4390/// # async fn dox() {
4391/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4392///
4393/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4394/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4395/// #     .with_native_roots()
4396/// #     .unwrap()
4397/// #     .https_only()
4398/// #     .enable_http2()
4399/// #     .build();
4400///
4401/// # let executor = hyper_util::rt::TokioExecutor::new();
4402/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4403/// #     secret,
4404/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4405/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4406/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4407/// #     ),
4408/// # ).build().await.unwrap();
4409///
4410/// # let client = hyper_util::client::legacy::Client::builder(
4411/// #     hyper_util::rt::TokioExecutor::new()
4412/// # )
4413/// # .build(
4414/// #     hyper_rustls::HttpsConnectorBuilder::new()
4415/// #         .with_native_roots()
4416/// #         .unwrap()
4417/// #         .https_or_http()
4418/// #         .enable_http2()
4419/// #         .build()
4420/// # );
4421/// # let mut hub = ShoppingContent::new(client, auth);
4422/// // As the method needs a request, you would usually fill it with the desired information
4423/// // into the respective structure. Some of the parts shown here might not be applicable !
4424/// // Values shown here are possibly random and not representative !
4425/// let mut req = OrderinvoicesCreateRefundInvoiceRequest::default();
4426///
4427/// // You can configure optional parameters by calling the respective setters at will, and
4428/// // execute the final call using `doit()`.
4429/// // Values shown here are possibly random and not representative !
4430/// let result = hub.orderinvoices().createrefundinvoice(req, 85, "orderId")
4431///              .doit().await;
4432/// # }
4433/// ```
4434pub struct OrderinvoiceCreaterefundinvoiceCall<'a, C>
4435where
4436    C: 'a,
4437{
4438    hub: &'a ShoppingContent<C>,
4439    _request: OrderinvoicesCreateRefundInvoiceRequest,
4440    _merchant_id: u64,
4441    _order_id: String,
4442    _delegate: Option<&'a mut dyn common::Delegate>,
4443    _additional_params: HashMap<String, String>,
4444    _scopes: BTreeSet<String>,
4445}
4446
4447impl<'a, C> common::CallBuilder for OrderinvoiceCreaterefundinvoiceCall<'a, C> {}
4448
4449impl<'a, C> OrderinvoiceCreaterefundinvoiceCall<'a, C>
4450where
4451    C: common::Connector,
4452{
4453    /// Perform the operation you have build so far.
4454    pub async fn doit(
4455        mut self,
4456    ) -> common::Result<(common::Response, OrderinvoicesCreateRefundInvoiceResponse)> {
4457        use std::borrow::Cow;
4458        use std::io::{Read, Seek};
4459
4460        use common::{url::Params, ToParts};
4461        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4462
4463        let mut dd = common::DefaultDelegate;
4464        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4465        dlg.begin(common::MethodInfo {
4466            id: "content.orderinvoices.createrefundinvoice",
4467            http_method: hyper::Method::POST,
4468        });
4469
4470        for &field in ["alt", "merchantId", "orderId"].iter() {
4471            if self._additional_params.contains_key(field) {
4472                dlg.finished(false);
4473                return Err(common::Error::FieldClash(field));
4474            }
4475        }
4476
4477        let mut params = Params::with_capacity(5 + self._additional_params.len());
4478        params.push("merchantId", self._merchant_id.to_string());
4479        params.push("orderId", self._order_id);
4480
4481        params.extend(self._additional_params.iter());
4482
4483        params.push("alt", "json");
4484        let mut url =
4485            self.hub._base_url.clone() + "{merchantId}/orderinvoices/{orderId}/createRefundInvoice";
4486        if self._scopes.is_empty() {
4487            self._scopes.insert(Scope::Full.as_ref().to_string());
4488        }
4489
4490        #[allow(clippy::single_element_loop)]
4491        for &(find_this, param_name) in
4492            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
4493        {
4494            url = params.uri_replacement(url, param_name, find_this, false);
4495        }
4496        {
4497            let to_remove = ["orderId", "merchantId"];
4498            params.remove_params(&to_remove);
4499        }
4500
4501        let url = params.parse_with_url(&url);
4502
4503        let mut json_mime_type = mime::APPLICATION_JSON;
4504        let mut request_value_reader = {
4505            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4506            common::remove_json_null_values(&mut value);
4507            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4508            serde_json::to_writer(&mut dst, &value).unwrap();
4509            dst
4510        };
4511        let request_size = request_value_reader
4512            .seek(std::io::SeekFrom::End(0))
4513            .unwrap();
4514        request_value_reader
4515            .seek(std::io::SeekFrom::Start(0))
4516            .unwrap();
4517
4518        loop {
4519            let token = match self
4520                .hub
4521                .auth
4522                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4523                .await
4524            {
4525                Ok(token) => token,
4526                Err(e) => match dlg.token(e) {
4527                    Ok(token) => token,
4528                    Err(e) => {
4529                        dlg.finished(false);
4530                        return Err(common::Error::MissingToken(e));
4531                    }
4532                },
4533            };
4534            request_value_reader
4535                .seek(std::io::SeekFrom::Start(0))
4536                .unwrap();
4537            let mut req_result = {
4538                let client = &self.hub.client;
4539                dlg.pre_request();
4540                let mut req_builder = hyper::Request::builder()
4541                    .method(hyper::Method::POST)
4542                    .uri(url.as_str())
4543                    .header(USER_AGENT, self.hub._user_agent.clone());
4544
4545                if let Some(token) = token.as_ref() {
4546                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4547                }
4548
4549                let request = req_builder
4550                    .header(CONTENT_TYPE, json_mime_type.to_string())
4551                    .header(CONTENT_LENGTH, request_size as u64)
4552                    .body(common::to_body(
4553                        request_value_reader.get_ref().clone().into(),
4554                    ));
4555
4556                client.request(request.unwrap()).await
4557            };
4558
4559            match req_result {
4560                Err(err) => {
4561                    if let common::Retry::After(d) = dlg.http_error(&err) {
4562                        sleep(d).await;
4563                        continue;
4564                    }
4565                    dlg.finished(false);
4566                    return Err(common::Error::HttpError(err));
4567                }
4568                Ok(res) => {
4569                    let (mut parts, body) = res.into_parts();
4570                    let mut body = common::Body::new(body);
4571                    if !parts.status.is_success() {
4572                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4573                        let error = serde_json::from_str(&common::to_string(&bytes));
4574                        let response = common::to_response(parts, bytes.into());
4575
4576                        if let common::Retry::After(d) =
4577                            dlg.http_failure(&response, error.as_ref().ok())
4578                        {
4579                            sleep(d).await;
4580                            continue;
4581                        }
4582
4583                        dlg.finished(false);
4584
4585                        return Err(match error {
4586                            Ok(value) => common::Error::BadRequest(value),
4587                            _ => common::Error::Failure(response),
4588                        });
4589                    }
4590                    let response = {
4591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4592                        let encoded = common::to_string(&bytes);
4593                        match serde_json::from_str(&encoded) {
4594                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4595                            Err(error) => {
4596                                dlg.response_json_decode_error(&encoded, &error);
4597                                return Err(common::Error::JsonDecodeError(
4598                                    encoded.to_string(),
4599                                    error,
4600                                ));
4601                            }
4602                        }
4603                    };
4604
4605                    dlg.finished(true);
4606                    return Ok(response);
4607                }
4608            }
4609        }
4610    }
4611
4612    ///
4613    /// Sets the *request* property to the given value.
4614    ///
4615    /// Even though the property as already been set when instantiating this call,
4616    /// we provide this method for API completeness.
4617    pub fn request(
4618        mut self,
4619        new_value: OrderinvoicesCreateRefundInvoiceRequest,
4620    ) -> OrderinvoiceCreaterefundinvoiceCall<'a, C> {
4621        self._request = new_value;
4622        self
4623    }
4624    /// The ID of the account that manages the order. This cannot be a multi-client account.
4625    ///
4626    /// Sets the *merchant id* path property to the given value.
4627    ///
4628    /// Even though the property as already been set when instantiating this call,
4629    /// we provide this method for API completeness.
4630    pub fn merchant_id(mut self, new_value: u64) -> OrderinvoiceCreaterefundinvoiceCall<'a, C> {
4631        self._merchant_id = new_value;
4632        self
4633    }
4634    /// The ID of the order.
4635    ///
4636    /// Sets the *order id* path property to the given value.
4637    ///
4638    /// Even though the property as already been set when instantiating this call,
4639    /// we provide this method for API completeness.
4640    pub fn order_id(mut self, new_value: &str) -> OrderinvoiceCreaterefundinvoiceCall<'a, C> {
4641        self._order_id = new_value.to_string();
4642        self
4643    }
4644    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4645    /// while executing the actual API request.
4646    ///
4647    /// ````text
4648    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4649    /// ````
4650    ///
4651    /// Sets the *delegate* property to the given value.
4652    pub fn delegate(
4653        mut self,
4654        new_value: &'a mut dyn common::Delegate,
4655    ) -> OrderinvoiceCreaterefundinvoiceCall<'a, C> {
4656        self._delegate = Some(new_value);
4657        self
4658    }
4659
4660    /// Set any additional parameter of the query string used in the request.
4661    /// It should be used to set parameters which are not yet available through their own
4662    /// setters.
4663    ///
4664    /// Please note that this method must not be used to set any of the known parameters
4665    /// which have their own setter method. If done anyway, the request will fail.
4666    ///
4667    /// # Additional Parameters
4668    ///
4669    /// * *alt* (query-string) - Data format for the response.
4670    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4671    /// * *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.
4672    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4673    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4674    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4675    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4676    pub fn param<T>(mut self, name: T, value: T) -> OrderinvoiceCreaterefundinvoiceCall<'a, C>
4677    where
4678        T: AsRef<str>,
4679    {
4680        self._additional_params
4681            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4682        self
4683    }
4684
4685    /// Identifies the authorization scope for the method you are building.
4686    ///
4687    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4688    /// [`Scope::Full`].
4689    ///
4690    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4691    /// tokens for more than one scope.
4692    ///
4693    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4694    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4695    /// sufficient, a read-write scope will do as well.
4696    pub fn add_scope<St>(mut self, scope: St) -> OrderinvoiceCreaterefundinvoiceCall<'a, C>
4697    where
4698        St: AsRef<str>,
4699    {
4700        self._scopes.insert(String::from(scope.as_ref()));
4701        self
4702    }
4703    /// Identifies the authorization scope(s) for the method you are building.
4704    ///
4705    /// See [`Self::add_scope()`] for details.
4706    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderinvoiceCreaterefundinvoiceCall<'a, C>
4707    where
4708        I: IntoIterator<Item = St>,
4709        St: AsRef<str>,
4710    {
4711        self._scopes
4712            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4713        self
4714    }
4715
4716    /// Removes all scopes, and no default scope will be used either.
4717    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4718    /// for details).
4719    pub fn clear_scopes(mut self) -> OrderinvoiceCreaterefundinvoiceCall<'a, C> {
4720        self._scopes.clear();
4721        self
4722    }
4723}
4724
4725/// Notify about successfully authorizing user's payment method for a given amount.
4726///
4727/// A builder for the *notifyauthapproved* method supported by a *orderpayment* resource.
4728/// It is not used directly, but through a [`OrderpaymentMethods`] instance.
4729///
4730/// # Example
4731///
4732/// Instantiate a resource method builder
4733///
4734/// ```test_harness,no_run
4735/// # extern crate hyper;
4736/// # extern crate hyper_rustls;
4737/// # extern crate google_content2_sandbox as content2_sandbox;
4738/// use content2_sandbox::api::OrderpaymentsNotifyAuthApprovedRequest;
4739/// # async fn dox() {
4740/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4741///
4742/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4743/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4744/// #     .with_native_roots()
4745/// #     .unwrap()
4746/// #     .https_only()
4747/// #     .enable_http2()
4748/// #     .build();
4749///
4750/// # let executor = hyper_util::rt::TokioExecutor::new();
4751/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4752/// #     secret,
4753/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4754/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4755/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4756/// #     ),
4757/// # ).build().await.unwrap();
4758///
4759/// # let client = hyper_util::client::legacy::Client::builder(
4760/// #     hyper_util::rt::TokioExecutor::new()
4761/// # )
4762/// # .build(
4763/// #     hyper_rustls::HttpsConnectorBuilder::new()
4764/// #         .with_native_roots()
4765/// #         .unwrap()
4766/// #         .https_or_http()
4767/// #         .enable_http2()
4768/// #         .build()
4769/// # );
4770/// # let mut hub = ShoppingContent::new(client, auth);
4771/// // As the method needs a request, you would usually fill it with the desired information
4772/// // into the respective structure. Some of the parts shown here might not be applicable !
4773/// // Values shown here are possibly random and not representative !
4774/// let mut req = OrderpaymentsNotifyAuthApprovedRequest::default();
4775///
4776/// // You can configure optional parameters by calling the respective setters at will, and
4777/// // execute the final call using `doit()`.
4778/// // Values shown here are possibly random and not representative !
4779/// let result = hub.orderpayments().notifyauthapproved(req, 51, "orderId")
4780///              .doit().await;
4781/// # }
4782/// ```
4783pub struct OrderpaymentNotifyauthapprovedCall<'a, C>
4784where
4785    C: 'a,
4786{
4787    hub: &'a ShoppingContent<C>,
4788    _request: OrderpaymentsNotifyAuthApprovedRequest,
4789    _merchant_id: u64,
4790    _order_id: String,
4791    _delegate: Option<&'a mut dyn common::Delegate>,
4792    _additional_params: HashMap<String, String>,
4793    _scopes: BTreeSet<String>,
4794}
4795
4796impl<'a, C> common::CallBuilder for OrderpaymentNotifyauthapprovedCall<'a, C> {}
4797
4798impl<'a, C> OrderpaymentNotifyauthapprovedCall<'a, C>
4799where
4800    C: common::Connector,
4801{
4802    /// Perform the operation you have build so far.
4803    pub async fn doit(
4804        mut self,
4805    ) -> common::Result<(common::Response, OrderpaymentsNotifyAuthApprovedResponse)> {
4806        use std::borrow::Cow;
4807        use std::io::{Read, Seek};
4808
4809        use common::{url::Params, ToParts};
4810        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4811
4812        let mut dd = common::DefaultDelegate;
4813        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4814        dlg.begin(common::MethodInfo {
4815            id: "content.orderpayments.notifyauthapproved",
4816            http_method: hyper::Method::POST,
4817        });
4818
4819        for &field in ["alt", "merchantId", "orderId"].iter() {
4820            if self._additional_params.contains_key(field) {
4821                dlg.finished(false);
4822                return Err(common::Error::FieldClash(field));
4823            }
4824        }
4825
4826        let mut params = Params::with_capacity(5 + self._additional_params.len());
4827        params.push("merchantId", self._merchant_id.to_string());
4828        params.push("orderId", self._order_id);
4829
4830        params.extend(self._additional_params.iter());
4831
4832        params.push("alt", "json");
4833        let mut url =
4834            self.hub._base_url.clone() + "{merchantId}/orderpayments/{orderId}/notifyAuthApproved";
4835        if self._scopes.is_empty() {
4836            self._scopes.insert(Scope::Full.as_ref().to_string());
4837        }
4838
4839        #[allow(clippy::single_element_loop)]
4840        for &(find_this, param_name) in
4841            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
4842        {
4843            url = params.uri_replacement(url, param_name, find_this, false);
4844        }
4845        {
4846            let to_remove = ["orderId", "merchantId"];
4847            params.remove_params(&to_remove);
4848        }
4849
4850        let url = params.parse_with_url(&url);
4851
4852        let mut json_mime_type = mime::APPLICATION_JSON;
4853        let mut request_value_reader = {
4854            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4855            common::remove_json_null_values(&mut value);
4856            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4857            serde_json::to_writer(&mut dst, &value).unwrap();
4858            dst
4859        };
4860        let request_size = request_value_reader
4861            .seek(std::io::SeekFrom::End(0))
4862            .unwrap();
4863        request_value_reader
4864            .seek(std::io::SeekFrom::Start(0))
4865            .unwrap();
4866
4867        loop {
4868            let token = match self
4869                .hub
4870                .auth
4871                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4872                .await
4873            {
4874                Ok(token) => token,
4875                Err(e) => match dlg.token(e) {
4876                    Ok(token) => token,
4877                    Err(e) => {
4878                        dlg.finished(false);
4879                        return Err(common::Error::MissingToken(e));
4880                    }
4881                },
4882            };
4883            request_value_reader
4884                .seek(std::io::SeekFrom::Start(0))
4885                .unwrap();
4886            let mut req_result = {
4887                let client = &self.hub.client;
4888                dlg.pre_request();
4889                let mut req_builder = hyper::Request::builder()
4890                    .method(hyper::Method::POST)
4891                    .uri(url.as_str())
4892                    .header(USER_AGENT, self.hub._user_agent.clone());
4893
4894                if let Some(token) = token.as_ref() {
4895                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4896                }
4897
4898                let request = req_builder
4899                    .header(CONTENT_TYPE, json_mime_type.to_string())
4900                    .header(CONTENT_LENGTH, request_size as u64)
4901                    .body(common::to_body(
4902                        request_value_reader.get_ref().clone().into(),
4903                    ));
4904
4905                client.request(request.unwrap()).await
4906            };
4907
4908            match req_result {
4909                Err(err) => {
4910                    if let common::Retry::After(d) = dlg.http_error(&err) {
4911                        sleep(d).await;
4912                        continue;
4913                    }
4914                    dlg.finished(false);
4915                    return Err(common::Error::HttpError(err));
4916                }
4917                Ok(res) => {
4918                    let (mut parts, body) = res.into_parts();
4919                    let mut body = common::Body::new(body);
4920                    if !parts.status.is_success() {
4921                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4922                        let error = serde_json::from_str(&common::to_string(&bytes));
4923                        let response = common::to_response(parts, bytes.into());
4924
4925                        if let common::Retry::After(d) =
4926                            dlg.http_failure(&response, error.as_ref().ok())
4927                        {
4928                            sleep(d).await;
4929                            continue;
4930                        }
4931
4932                        dlg.finished(false);
4933
4934                        return Err(match error {
4935                            Ok(value) => common::Error::BadRequest(value),
4936                            _ => common::Error::Failure(response),
4937                        });
4938                    }
4939                    let response = {
4940                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4941                        let encoded = common::to_string(&bytes);
4942                        match serde_json::from_str(&encoded) {
4943                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4944                            Err(error) => {
4945                                dlg.response_json_decode_error(&encoded, &error);
4946                                return Err(common::Error::JsonDecodeError(
4947                                    encoded.to_string(),
4948                                    error,
4949                                ));
4950                            }
4951                        }
4952                    };
4953
4954                    dlg.finished(true);
4955                    return Ok(response);
4956                }
4957            }
4958        }
4959    }
4960
4961    ///
4962    /// Sets the *request* property to the given value.
4963    ///
4964    /// Even though the property as already been set when instantiating this call,
4965    /// we provide this method for API completeness.
4966    pub fn request(
4967        mut self,
4968        new_value: OrderpaymentsNotifyAuthApprovedRequest,
4969    ) -> OrderpaymentNotifyauthapprovedCall<'a, C> {
4970        self._request = new_value;
4971        self
4972    }
4973    /// The ID of the account that manages the order. This cannot be a multi-client account.
4974    ///
4975    /// Sets the *merchant id* path property to the given value.
4976    ///
4977    /// Even though the property as already been set when instantiating this call,
4978    /// we provide this method for API completeness.
4979    pub fn merchant_id(mut self, new_value: u64) -> OrderpaymentNotifyauthapprovedCall<'a, C> {
4980        self._merchant_id = new_value;
4981        self
4982    }
4983    /// The ID of the order for for which payment authorization is happening.
4984    ///
4985    /// Sets the *order id* path property to the given value.
4986    ///
4987    /// Even though the property as already been set when instantiating this call,
4988    /// we provide this method for API completeness.
4989    pub fn order_id(mut self, new_value: &str) -> OrderpaymentNotifyauthapprovedCall<'a, C> {
4990        self._order_id = new_value.to_string();
4991        self
4992    }
4993    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4994    /// while executing the actual API request.
4995    ///
4996    /// ````text
4997    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4998    /// ````
4999    ///
5000    /// Sets the *delegate* property to the given value.
5001    pub fn delegate(
5002        mut self,
5003        new_value: &'a mut dyn common::Delegate,
5004    ) -> OrderpaymentNotifyauthapprovedCall<'a, C> {
5005        self._delegate = Some(new_value);
5006        self
5007    }
5008
5009    /// Set any additional parameter of the query string used in the request.
5010    /// It should be used to set parameters which are not yet available through their own
5011    /// setters.
5012    ///
5013    /// Please note that this method must not be used to set any of the known parameters
5014    /// which have their own setter method. If done anyway, the request will fail.
5015    ///
5016    /// # Additional Parameters
5017    ///
5018    /// * *alt* (query-string) - Data format for the response.
5019    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5020    /// * *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.
5021    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5022    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5023    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5024    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5025    pub fn param<T>(mut self, name: T, value: T) -> OrderpaymentNotifyauthapprovedCall<'a, C>
5026    where
5027        T: AsRef<str>,
5028    {
5029        self._additional_params
5030            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5031        self
5032    }
5033
5034    /// Identifies the authorization scope for the method you are building.
5035    ///
5036    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5037    /// [`Scope::Full`].
5038    ///
5039    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5040    /// tokens for more than one scope.
5041    ///
5042    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5043    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5044    /// sufficient, a read-write scope will do as well.
5045    pub fn add_scope<St>(mut self, scope: St) -> OrderpaymentNotifyauthapprovedCall<'a, C>
5046    where
5047        St: AsRef<str>,
5048    {
5049        self._scopes.insert(String::from(scope.as_ref()));
5050        self
5051    }
5052    /// Identifies the authorization scope(s) for the method you are building.
5053    ///
5054    /// See [`Self::add_scope()`] for details.
5055    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderpaymentNotifyauthapprovedCall<'a, C>
5056    where
5057        I: IntoIterator<Item = St>,
5058        St: AsRef<str>,
5059    {
5060        self._scopes
5061            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5062        self
5063    }
5064
5065    /// Removes all scopes, and no default scope will be used either.
5066    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5067    /// for details).
5068    pub fn clear_scopes(mut self) -> OrderpaymentNotifyauthapprovedCall<'a, C> {
5069        self._scopes.clear();
5070        self
5071    }
5072}
5073
5074/// Notify about failure to authorize user's payment method.
5075///
5076/// A builder for the *notifyauthdeclined* method supported by a *orderpayment* resource.
5077/// It is not used directly, but through a [`OrderpaymentMethods`] instance.
5078///
5079/// # Example
5080///
5081/// Instantiate a resource method builder
5082///
5083/// ```test_harness,no_run
5084/// # extern crate hyper;
5085/// # extern crate hyper_rustls;
5086/// # extern crate google_content2_sandbox as content2_sandbox;
5087/// use content2_sandbox::api::OrderpaymentsNotifyAuthDeclinedRequest;
5088/// # async fn dox() {
5089/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5090///
5091/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5092/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5093/// #     .with_native_roots()
5094/// #     .unwrap()
5095/// #     .https_only()
5096/// #     .enable_http2()
5097/// #     .build();
5098///
5099/// # let executor = hyper_util::rt::TokioExecutor::new();
5100/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5101/// #     secret,
5102/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5103/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5104/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5105/// #     ),
5106/// # ).build().await.unwrap();
5107///
5108/// # let client = hyper_util::client::legacy::Client::builder(
5109/// #     hyper_util::rt::TokioExecutor::new()
5110/// # )
5111/// # .build(
5112/// #     hyper_rustls::HttpsConnectorBuilder::new()
5113/// #         .with_native_roots()
5114/// #         .unwrap()
5115/// #         .https_or_http()
5116/// #         .enable_http2()
5117/// #         .build()
5118/// # );
5119/// # let mut hub = ShoppingContent::new(client, auth);
5120/// // As the method needs a request, you would usually fill it with the desired information
5121/// // into the respective structure. Some of the parts shown here might not be applicable !
5122/// // Values shown here are possibly random and not representative !
5123/// let mut req = OrderpaymentsNotifyAuthDeclinedRequest::default();
5124///
5125/// // You can configure optional parameters by calling the respective setters at will, and
5126/// // execute the final call using `doit()`.
5127/// // Values shown here are possibly random and not representative !
5128/// let result = hub.orderpayments().notifyauthdeclined(req, 94, "orderId")
5129///              .doit().await;
5130/// # }
5131/// ```
5132pub struct OrderpaymentNotifyauthdeclinedCall<'a, C>
5133where
5134    C: 'a,
5135{
5136    hub: &'a ShoppingContent<C>,
5137    _request: OrderpaymentsNotifyAuthDeclinedRequest,
5138    _merchant_id: u64,
5139    _order_id: String,
5140    _delegate: Option<&'a mut dyn common::Delegate>,
5141    _additional_params: HashMap<String, String>,
5142    _scopes: BTreeSet<String>,
5143}
5144
5145impl<'a, C> common::CallBuilder for OrderpaymentNotifyauthdeclinedCall<'a, C> {}
5146
5147impl<'a, C> OrderpaymentNotifyauthdeclinedCall<'a, C>
5148where
5149    C: common::Connector,
5150{
5151    /// Perform the operation you have build so far.
5152    pub async fn doit(
5153        mut self,
5154    ) -> common::Result<(common::Response, OrderpaymentsNotifyAuthDeclinedResponse)> {
5155        use std::borrow::Cow;
5156        use std::io::{Read, Seek};
5157
5158        use common::{url::Params, ToParts};
5159        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5160
5161        let mut dd = common::DefaultDelegate;
5162        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5163        dlg.begin(common::MethodInfo {
5164            id: "content.orderpayments.notifyauthdeclined",
5165            http_method: hyper::Method::POST,
5166        });
5167
5168        for &field in ["alt", "merchantId", "orderId"].iter() {
5169            if self._additional_params.contains_key(field) {
5170                dlg.finished(false);
5171                return Err(common::Error::FieldClash(field));
5172            }
5173        }
5174
5175        let mut params = Params::with_capacity(5 + self._additional_params.len());
5176        params.push("merchantId", self._merchant_id.to_string());
5177        params.push("orderId", self._order_id);
5178
5179        params.extend(self._additional_params.iter());
5180
5181        params.push("alt", "json");
5182        let mut url =
5183            self.hub._base_url.clone() + "{merchantId}/orderpayments/{orderId}/notifyAuthDeclined";
5184        if self._scopes.is_empty() {
5185            self._scopes.insert(Scope::Full.as_ref().to_string());
5186        }
5187
5188        #[allow(clippy::single_element_loop)]
5189        for &(find_this, param_name) in
5190            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
5191        {
5192            url = params.uri_replacement(url, param_name, find_this, false);
5193        }
5194        {
5195            let to_remove = ["orderId", "merchantId"];
5196            params.remove_params(&to_remove);
5197        }
5198
5199        let url = params.parse_with_url(&url);
5200
5201        let mut json_mime_type = mime::APPLICATION_JSON;
5202        let mut request_value_reader = {
5203            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5204            common::remove_json_null_values(&mut value);
5205            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5206            serde_json::to_writer(&mut dst, &value).unwrap();
5207            dst
5208        };
5209        let request_size = request_value_reader
5210            .seek(std::io::SeekFrom::End(0))
5211            .unwrap();
5212        request_value_reader
5213            .seek(std::io::SeekFrom::Start(0))
5214            .unwrap();
5215
5216        loop {
5217            let token = match self
5218                .hub
5219                .auth
5220                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5221                .await
5222            {
5223                Ok(token) => token,
5224                Err(e) => match dlg.token(e) {
5225                    Ok(token) => token,
5226                    Err(e) => {
5227                        dlg.finished(false);
5228                        return Err(common::Error::MissingToken(e));
5229                    }
5230                },
5231            };
5232            request_value_reader
5233                .seek(std::io::SeekFrom::Start(0))
5234                .unwrap();
5235            let mut req_result = {
5236                let client = &self.hub.client;
5237                dlg.pre_request();
5238                let mut req_builder = hyper::Request::builder()
5239                    .method(hyper::Method::POST)
5240                    .uri(url.as_str())
5241                    .header(USER_AGENT, self.hub._user_agent.clone());
5242
5243                if let Some(token) = token.as_ref() {
5244                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5245                }
5246
5247                let request = req_builder
5248                    .header(CONTENT_TYPE, json_mime_type.to_string())
5249                    .header(CONTENT_LENGTH, request_size as u64)
5250                    .body(common::to_body(
5251                        request_value_reader.get_ref().clone().into(),
5252                    ));
5253
5254                client.request(request.unwrap()).await
5255            };
5256
5257            match req_result {
5258                Err(err) => {
5259                    if let common::Retry::After(d) = dlg.http_error(&err) {
5260                        sleep(d).await;
5261                        continue;
5262                    }
5263                    dlg.finished(false);
5264                    return Err(common::Error::HttpError(err));
5265                }
5266                Ok(res) => {
5267                    let (mut parts, body) = res.into_parts();
5268                    let mut body = common::Body::new(body);
5269                    if !parts.status.is_success() {
5270                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5271                        let error = serde_json::from_str(&common::to_string(&bytes));
5272                        let response = common::to_response(parts, bytes.into());
5273
5274                        if let common::Retry::After(d) =
5275                            dlg.http_failure(&response, error.as_ref().ok())
5276                        {
5277                            sleep(d).await;
5278                            continue;
5279                        }
5280
5281                        dlg.finished(false);
5282
5283                        return Err(match error {
5284                            Ok(value) => common::Error::BadRequest(value),
5285                            _ => common::Error::Failure(response),
5286                        });
5287                    }
5288                    let response = {
5289                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5290                        let encoded = common::to_string(&bytes);
5291                        match serde_json::from_str(&encoded) {
5292                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5293                            Err(error) => {
5294                                dlg.response_json_decode_error(&encoded, &error);
5295                                return Err(common::Error::JsonDecodeError(
5296                                    encoded.to_string(),
5297                                    error,
5298                                ));
5299                            }
5300                        }
5301                    };
5302
5303                    dlg.finished(true);
5304                    return Ok(response);
5305                }
5306            }
5307        }
5308    }
5309
5310    ///
5311    /// Sets the *request* property to the given value.
5312    ///
5313    /// Even though the property as already been set when instantiating this call,
5314    /// we provide this method for API completeness.
5315    pub fn request(
5316        mut self,
5317        new_value: OrderpaymentsNotifyAuthDeclinedRequest,
5318    ) -> OrderpaymentNotifyauthdeclinedCall<'a, C> {
5319        self._request = new_value;
5320        self
5321    }
5322    /// The ID of the account that manages the order. This cannot be a multi-client account.
5323    ///
5324    /// Sets the *merchant id* path property to the given value.
5325    ///
5326    /// Even though the property as already been set when instantiating this call,
5327    /// we provide this method for API completeness.
5328    pub fn merchant_id(mut self, new_value: u64) -> OrderpaymentNotifyauthdeclinedCall<'a, C> {
5329        self._merchant_id = new_value;
5330        self
5331    }
5332    /// The ID of the order for which payment authorization was declined.
5333    ///
5334    /// Sets the *order id* path property to the given value.
5335    ///
5336    /// Even though the property as already been set when instantiating this call,
5337    /// we provide this method for API completeness.
5338    pub fn order_id(mut self, new_value: &str) -> OrderpaymentNotifyauthdeclinedCall<'a, C> {
5339        self._order_id = new_value.to_string();
5340        self
5341    }
5342    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5343    /// while executing the actual API request.
5344    ///
5345    /// ````text
5346    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5347    /// ````
5348    ///
5349    /// Sets the *delegate* property to the given value.
5350    pub fn delegate(
5351        mut self,
5352        new_value: &'a mut dyn common::Delegate,
5353    ) -> OrderpaymentNotifyauthdeclinedCall<'a, C> {
5354        self._delegate = Some(new_value);
5355        self
5356    }
5357
5358    /// Set any additional parameter of the query string used in the request.
5359    /// It should be used to set parameters which are not yet available through their own
5360    /// setters.
5361    ///
5362    /// Please note that this method must not be used to set any of the known parameters
5363    /// which have their own setter method. If done anyway, the request will fail.
5364    ///
5365    /// # Additional Parameters
5366    ///
5367    /// * *alt* (query-string) - Data format for the response.
5368    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5369    /// * *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.
5370    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5371    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5372    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5373    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5374    pub fn param<T>(mut self, name: T, value: T) -> OrderpaymentNotifyauthdeclinedCall<'a, C>
5375    where
5376        T: AsRef<str>,
5377    {
5378        self._additional_params
5379            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5380        self
5381    }
5382
5383    /// Identifies the authorization scope for the method you are building.
5384    ///
5385    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5386    /// [`Scope::Full`].
5387    ///
5388    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5389    /// tokens for more than one scope.
5390    ///
5391    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5392    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5393    /// sufficient, a read-write scope will do as well.
5394    pub fn add_scope<St>(mut self, scope: St) -> OrderpaymentNotifyauthdeclinedCall<'a, C>
5395    where
5396        St: AsRef<str>,
5397    {
5398        self._scopes.insert(String::from(scope.as_ref()));
5399        self
5400    }
5401    /// Identifies the authorization scope(s) for the method you are building.
5402    ///
5403    /// See [`Self::add_scope()`] for details.
5404    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderpaymentNotifyauthdeclinedCall<'a, C>
5405    where
5406        I: IntoIterator<Item = St>,
5407        St: AsRef<str>,
5408    {
5409        self._scopes
5410            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5411        self
5412    }
5413
5414    /// Removes all scopes, and no default scope will be used either.
5415    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5416    /// for details).
5417    pub fn clear_scopes(mut self) -> OrderpaymentNotifyauthdeclinedCall<'a, C> {
5418        self._scopes.clear();
5419        self
5420    }
5421}
5422
5423/// Notify about charge on user's selected payments method.
5424///
5425/// A builder for the *notifycharge* method supported by a *orderpayment* resource.
5426/// It is not used directly, but through a [`OrderpaymentMethods`] instance.
5427///
5428/// # Example
5429///
5430/// Instantiate a resource method builder
5431///
5432/// ```test_harness,no_run
5433/// # extern crate hyper;
5434/// # extern crate hyper_rustls;
5435/// # extern crate google_content2_sandbox as content2_sandbox;
5436/// use content2_sandbox::api::OrderpaymentsNotifyChargeRequest;
5437/// # async fn dox() {
5438/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5439///
5440/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5441/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5442/// #     .with_native_roots()
5443/// #     .unwrap()
5444/// #     .https_only()
5445/// #     .enable_http2()
5446/// #     .build();
5447///
5448/// # let executor = hyper_util::rt::TokioExecutor::new();
5449/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5450/// #     secret,
5451/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5452/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5453/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5454/// #     ),
5455/// # ).build().await.unwrap();
5456///
5457/// # let client = hyper_util::client::legacy::Client::builder(
5458/// #     hyper_util::rt::TokioExecutor::new()
5459/// # )
5460/// # .build(
5461/// #     hyper_rustls::HttpsConnectorBuilder::new()
5462/// #         .with_native_roots()
5463/// #         .unwrap()
5464/// #         .https_or_http()
5465/// #         .enable_http2()
5466/// #         .build()
5467/// # );
5468/// # let mut hub = ShoppingContent::new(client, auth);
5469/// // As the method needs a request, you would usually fill it with the desired information
5470/// // into the respective structure. Some of the parts shown here might not be applicable !
5471/// // Values shown here are possibly random and not representative !
5472/// let mut req = OrderpaymentsNotifyChargeRequest::default();
5473///
5474/// // You can configure optional parameters by calling the respective setters at will, and
5475/// // execute the final call using `doit()`.
5476/// // Values shown here are possibly random and not representative !
5477/// let result = hub.orderpayments().notifycharge(req, 84, "orderId")
5478///              .doit().await;
5479/// # }
5480/// ```
5481pub struct OrderpaymentNotifychargeCall<'a, C>
5482where
5483    C: 'a,
5484{
5485    hub: &'a ShoppingContent<C>,
5486    _request: OrderpaymentsNotifyChargeRequest,
5487    _merchant_id: u64,
5488    _order_id: String,
5489    _delegate: Option<&'a mut dyn common::Delegate>,
5490    _additional_params: HashMap<String, String>,
5491    _scopes: BTreeSet<String>,
5492}
5493
5494impl<'a, C> common::CallBuilder for OrderpaymentNotifychargeCall<'a, C> {}
5495
5496impl<'a, C> OrderpaymentNotifychargeCall<'a, C>
5497where
5498    C: common::Connector,
5499{
5500    /// Perform the operation you have build so far.
5501    pub async fn doit(
5502        mut self,
5503    ) -> common::Result<(common::Response, OrderpaymentsNotifyChargeResponse)> {
5504        use std::borrow::Cow;
5505        use std::io::{Read, Seek};
5506
5507        use common::{url::Params, ToParts};
5508        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5509
5510        let mut dd = common::DefaultDelegate;
5511        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5512        dlg.begin(common::MethodInfo {
5513            id: "content.orderpayments.notifycharge",
5514            http_method: hyper::Method::POST,
5515        });
5516
5517        for &field in ["alt", "merchantId", "orderId"].iter() {
5518            if self._additional_params.contains_key(field) {
5519                dlg.finished(false);
5520                return Err(common::Error::FieldClash(field));
5521            }
5522        }
5523
5524        let mut params = Params::with_capacity(5 + self._additional_params.len());
5525        params.push("merchantId", self._merchant_id.to_string());
5526        params.push("orderId", self._order_id);
5527
5528        params.extend(self._additional_params.iter());
5529
5530        params.push("alt", "json");
5531        let mut url =
5532            self.hub._base_url.clone() + "{merchantId}/orderpayments/{orderId}/notifyCharge";
5533        if self._scopes.is_empty() {
5534            self._scopes.insert(Scope::Full.as_ref().to_string());
5535        }
5536
5537        #[allow(clippy::single_element_loop)]
5538        for &(find_this, param_name) in
5539            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
5540        {
5541            url = params.uri_replacement(url, param_name, find_this, false);
5542        }
5543        {
5544            let to_remove = ["orderId", "merchantId"];
5545            params.remove_params(&to_remove);
5546        }
5547
5548        let url = params.parse_with_url(&url);
5549
5550        let mut json_mime_type = mime::APPLICATION_JSON;
5551        let mut request_value_reader = {
5552            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5553            common::remove_json_null_values(&mut value);
5554            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5555            serde_json::to_writer(&mut dst, &value).unwrap();
5556            dst
5557        };
5558        let request_size = request_value_reader
5559            .seek(std::io::SeekFrom::End(0))
5560            .unwrap();
5561        request_value_reader
5562            .seek(std::io::SeekFrom::Start(0))
5563            .unwrap();
5564
5565        loop {
5566            let token = match self
5567                .hub
5568                .auth
5569                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5570                .await
5571            {
5572                Ok(token) => token,
5573                Err(e) => match dlg.token(e) {
5574                    Ok(token) => token,
5575                    Err(e) => {
5576                        dlg.finished(false);
5577                        return Err(common::Error::MissingToken(e));
5578                    }
5579                },
5580            };
5581            request_value_reader
5582                .seek(std::io::SeekFrom::Start(0))
5583                .unwrap();
5584            let mut req_result = {
5585                let client = &self.hub.client;
5586                dlg.pre_request();
5587                let mut req_builder = hyper::Request::builder()
5588                    .method(hyper::Method::POST)
5589                    .uri(url.as_str())
5590                    .header(USER_AGENT, self.hub._user_agent.clone());
5591
5592                if let Some(token) = token.as_ref() {
5593                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5594                }
5595
5596                let request = req_builder
5597                    .header(CONTENT_TYPE, json_mime_type.to_string())
5598                    .header(CONTENT_LENGTH, request_size as u64)
5599                    .body(common::to_body(
5600                        request_value_reader.get_ref().clone().into(),
5601                    ));
5602
5603                client.request(request.unwrap()).await
5604            };
5605
5606            match req_result {
5607                Err(err) => {
5608                    if let common::Retry::After(d) = dlg.http_error(&err) {
5609                        sleep(d).await;
5610                        continue;
5611                    }
5612                    dlg.finished(false);
5613                    return Err(common::Error::HttpError(err));
5614                }
5615                Ok(res) => {
5616                    let (mut parts, body) = res.into_parts();
5617                    let mut body = common::Body::new(body);
5618                    if !parts.status.is_success() {
5619                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5620                        let error = serde_json::from_str(&common::to_string(&bytes));
5621                        let response = common::to_response(parts, bytes.into());
5622
5623                        if let common::Retry::After(d) =
5624                            dlg.http_failure(&response, error.as_ref().ok())
5625                        {
5626                            sleep(d).await;
5627                            continue;
5628                        }
5629
5630                        dlg.finished(false);
5631
5632                        return Err(match error {
5633                            Ok(value) => common::Error::BadRequest(value),
5634                            _ => common::Error::Failure(response),
5635                        });
5636                    }
5637                    let response = {
5638                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5639                        let encoded = common::to_string(&bytes);
5640                        match serde_json::from_str(&encoded) {
5641                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5642                            Err(error) => {
5643                                dlg.response_json_decode_error(&encoded, &error);
5644                                return Err(common::Error::JsonDecodeError(
5645                                    encoded.to_string(),
5646                                    error,
5647                                ));
5648                            }
5649                        }
5650                    };
5651
5652                    dlg.finished(true);
5653                    return Ok(response);
5654                }
5655            }
5656        }
5657    }
5658
5659    ///
5660    /// Sets the *request* property to the given value.
5661    ///
5662    /// Even though the property as already been set when instantiating this call,
5663    /// we provide this method for API completeness.
5664    pub fn request(
5665        mut self,
5666        new_value: OrderpaymentsNotifyChargeRequest,
5667    ) -> OrderpaymentNotifychargeCall<'a, C> {
5668        self._request = new_value;
5669        self
5670    }
5671    /// The ID of the account that manages the order. This cannot be a multi-client account.
5672    ///
5673    /// Sets the *merchant id* path property to the given value.
5674    ///
5675    /// Even though the property as already been set when instantiating this call,
5676    /// we provide this method for API completeness.
5677    pub fn merchant_id(mut self, new_value: u64) -> OrderpaymentNotifychargeCall<'a, C> {
5678        self._merchant_id = new_value;
5679        self
5680    }
5681    /// The ID of the order for which charge is happening.
5682    ///
5683    /// Sets the *order id* path property to the given value.
5684    ///
5685    /// Even though the property as already been set when instantiating this call,
5686    /// we provide this method for API completeness.
5687    pub fn order_id(mut self, new_value: &str) -> OrderpaymentNotifychargeCall<'a, C> {
5688        self._order_id = new_value.to_string();
5689        self
5690    }
5691    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5692    /// while executing the actual API request.
5693    ///
5694    /// ````text
5695    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5696    /// ````
5697    ///
5698    /// Sets the *delegate* property to the given value.
5699    pub fn delegate(
5700        mut self,
5701        new_value: &'a mut dyn common::Delegate,
5702    ) -> OrderpaymentNotifychargeCall<'a, C> {
5703        self._delegate = Some(new_value);
5704        self
5705    }
5706
5707    /// Set any additional parameter of the query string used in the request.
5708    /// It should be used to set parameters which are not yet available through their own
5709    /// setters.
5710    ///
5711    /// Please note that this method must not be used to set any of the known parameters
5712    /// which have their own setter method. If done anyway, the request will fail.
5713    ///
5714    /// # Additional Parameters
5715    ///
5716    /// * *alt* (query-string) - Data format for the response.
5717    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5718    /// * *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.
5719    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5720    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5721    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5722    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5723    pub fn param<T>(mut self, name: T, value: T) -> OrderpaymentNotifychargeCall<'a, C>
5724    where
5725        T: AsRef<str>,
5726    {
5727        self._additional_params
5728            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5729        self
5730    }
5731
5732    /// Identifies the authorization scope for the method you are building.
5733    ///
5734    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5735    /// [`Scope::Full`].
5736    ///
5737    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5738    /// tokens for more than one scope.
5739    ///
5740    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5741    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5742    /// sufficient, a read-write scope will do as well.
5743    pub fn add_scope<St>(mut self, scope: St) -> OrderpaymentNotifychargeCall<'a, C>
5744    where
5745        St: AsRef<str>,
5746    {
5747        self._scopes.insert(String::from(scope.as_ref()));
5748        self
5749    }
5750    /// Identifies the authorization scope(s) for the method you are building.
5751    ///
5752    /// See [`Self::add_scope()`] for details.
5753    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderpaymentNotifychargeCall<'a, C>
5754    where
5755        I: IntoIterator<Item = St>,
5756        St: AsRef<str>,
5757    {
5758        self._scopes
5759            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5760        self
5761    }
5762
5763    /// Removes all scopes, and no default scope will be used either.
5764    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5765    /// for details).
5766    pub fn clear_scopes(mut self) -> OrderpaymentNotifychargeCall<'a, C> {
5767        self._scopes.clear();
5768        self
5769    }
5770}
5771
5772/// Notify about refund on user's selected payments method.
5773///
5774/// A builder for the *notifyrefund* method supported by a *orderpayment* resource.
5775/// It is not used directly, but through a [`OrderpaymentMethods`] instance.
5776///
5777/// # Example
5778///
5779/// Instantiate a resource method builder
5780///
5781/// ```test_harness,no_run
5782/// # extern crate hyper;
5783/// # extern crate hyper_rustls;
5784/// # extern crate google_content2_sandbox as content2_sandbox;
5785/// use content2_sandbox::api::OrderpaymentsNotifyRefundRequest;
5786/// # async fn dox() {
5787/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5788///
5789/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5790/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5791/// #     .with_native_roots()
5792/// #     .unwrap()
5793/// #     .https_only()
5794/// #     .enable_http2()
5795/// #     .build();
5796///
5797/// # let executor = hyper_util::rt::TokioExecutor::new();
5798/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5799/// #     secret,
5800/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5801/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5802/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5803/// #     ),
5804/// # ).build().await.unwrap();
5805///
5806/// # let client = hyper_util::client::legacy::Client::builder(
5807/// #     hyper_util::rt::TokioExecutor::new()
5808/// # )
5809/// # .build(
5810/// #     hyper_rustls::HttpsConnectorBuilder::new()
5811/// #         .with_native_roots()
5812/// #         .unwrap()
5813/// #         .https_or_http()
5814/// #         .enable_http2()
5815/// #         .build()
5816/// # );
5817/// # let mut hub = ShoppingContent::new(client, auth);
5818/// // As the method needs a request, you would usually fill it with the desired information
5819/// // into the respective structure. Some of the parts shown here might not be applicable !
5820/// // Values shown here are possibly random and not representative !
5821/// let mut req = OrderpaymentsNotifyRefundRequest::default();
5822///
5823/// // You can configure optional parameters by calling the respective setters at will, and
5824/// // execute the final call using `doit()`.
5825/// // Values shown here are possibly random and not representative !
5826/// let result = hub.orderpayments().notifyrefund(req, 45, "orderId")
5827///              .doit().await;
5828/// # }
5829/// ```
5830pub struct OrderpaymentNotifyrefundCall<'a, C>
5831where
5832    C: 'a,
5833{
5834    hub: &'a ShoppingContent<C>,
5835    _request: OrderpaymentsNotifyRefundRequest,
5836    _merchant_id: u64,
5837    _order_id: String,
5838    _delegate: Option<&'a mut dyn common::Delegate>,
5839    _additional_params: HashMap<String, String>,
5840    _scopes: BTreeSet<String>,
5841}
5842
5843impl<'a, C> common::CallBuilder for OrderpaymentNotifyrefundCall<'a, C> {}
5844
5845impl<'a, C> OrderpaymentNotifyrefundCall<'a, C>
5846where
5847    C: common::Connector,
5848{
5849    /// Perform the operation you have build so far.
5850    pub async fn doit(
5851        mut self,
5852    ) -> common::Result<(common::Response, OrderpaymentsNotifyRefundResponse)> {
5853        use std::borrow::Cow;
5854        use std::io::{Read, Seek};
5855
5856        use common::{url::Params, ToParts};
5857        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5858
5859        let mut dd = common::DefaultDelegate;
5860        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5861        dlg.begin(common::MethodInfo {
5862            id: "content.orderpayments.notifyrefund",
5863            http_method: hyper::Method::POST,
5864        });
5865
5866        for &field in ["alt", "merchantId", "orderId"].iter() {
5867            if self._additional_params.contains_key(field) {
5868                dlg.finished(false);
5869                return Err(common::Error::FieldClash(field));
5870            }
5871        }
5872
5873        let mut params = Params::with_capacity(5 + self._additional_params.len());
5874        params.push("merchantId", self._merchant_id.to_string());
5875        params.push("orderId", self._order_id);
5876
5877        params.extend(self._additional_params.iter());
5878
5879        params.push("alt", "json");
5880        let mut url =
5881            self.hub._base_url.clone() + "{merchantId}/orderpayments/{orderId}/notifyRefund";
5882        if self._scopes.is_empty() {
5883            self._scopes.insert(Scope::Full.as_ref().to_string());
5884        }
5885
5886        #[allow(clippy::single_element_loop)]
5887        for &(find_this, param_name) in
5888            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
5889        {
5890            url = params.uri_replacement(url, param_name, find_this, false);
5891        }
5892        {
5893            let to_remove = ["orderId", "merchantId"];
5894            params.remove_params(&to_remove);
5895        }
5896
5897        let url = params.parse_with_url(&url);
5898
5899        let mut json_mime_type = mime::APPLICATION_JSON;
5900        let mut request_value_reader = {
5901            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5902            common::remove_json_null_values(&mut value);
5903            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5904            serde_json::to_writer(&mut dst, &value).unwrap();
5905            dst
5906        };
5907        let request_size = request_value_reader
5908            .seek(std::io::SeekFrom::End(0))
5909            .unwrap();
5910        request_value_reader
5911            .seek(std::io::SeekFrom::Start(0))
5912            .unwrap();
5913
5914        loop {
5915            let token = match self
5916                .hub
5917                .auth
5918                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5919                .await
5920            {
5921                Ok(token) => token,
5922                Err(e) => match dlg.token(e) {
5923                    Ok(token) => token,
5924                    Err(e) => {
5925                        dlg.finished(false);
5926                        return Err(common::Error::MissingToken(e));
5927                    }
5928                },
5929            };
5930            request_value_reader
5931                .seek(std::io::SeekFrom::Start(0))
5932                .unwrap();
5933            let mut req_result = {
5934                let client = &self.hub.client;
5935                dlg.pre_request();
5936                let mut req_builder = hyper::Request::builder()
5937                    .method(hyper::Method::POST)
5938                    .uri(url.as_str())
5939                    .header(USER_AGENT, self.hub._user_agent.clone());
5940
5941                if let Some(token) = token.as_ref() {
5942                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5943                }
5944
5945                let request = req_builder
5946                    .header(CONTENT_TYPE, json_mime_type.to_string())
5947                    .header(CONTENT_LENGTH, request_size as u64)
5948                    .body(common::to_body(
5949                        request_value_reader.get_ref().clone().into(),
5950                    ));
5951
5952                client.request(request.unwrap()).await
5953            };
5954
5955            match req_result {
5956                Err(err) => {
5957                    if let common::Retry::After(d) = dlg.http_error(&err) {
5958                        sleep(d).await;
5959                        continue;
5960                    }
5961                    dlg.finished(false);
5962                    return Err(common::Error::HttpError(err));
5963                }
5964                Ok(res) => {
5965                    let (mut parts, body) = res.into_parts();
5966                    let mut body = common::Body::new(body);
5967                    if !parts.status.is_success() {
5968                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5969                        let error = serde_json::from_str(&common::to_string(&bytes));
5970                        let response = common::to_response(parts, bytes.into());
5971
5972                        if let common::Retry::After(d) =
5973                            dlg.http_failure(&response, error.as_ref().ok())
5974                        {
5975                            sleep(d).await;
5976                            continue;
5977                        }
5978
5979                        dlg.finished(false);
5980
5981                        return Err(match error {
5982                            Ok(value) => common::Error::BadRequest(value),
5983                            _ => common::Error::Failure(response),
5984                        });
5985                    }
5986                    let response = {
5987                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5988                        let encoded = common::to_string(&bytes);
5989                        match serde_json::from_str(&encoded) {
5990                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5991                            Err(error) => {
5992                                dlg.response_json_decode_error(&encoded, &error);
5993                                return Err(common::Error::JsonDecodeError(
5994                                    encoded.to_string(),
5995                                    error,
5996                                ));
5997                            }
5998                        }
5999                    };
6000
6001                    dlg.finished(true);
6002                    return Ok(response);
6003                }
6004            }
6005        }
6006    }
6007
6008    ///
6009    /// Sets the *request* property to the given value.
6010    ///
6011    /// Even though the property as already been set when instantiating this call,
6012    /// we provide this method for API completeness.
6013    pub fn request(
6014        mut self,
6015        new_value: OrderpaymentsNotifyRefundRequest,
6016    ) -> OrderpaymentNotifyrefundCall<'a, C> {
6017        self._request = new_value;
6018        self
6019    }
6020    /// The ID of the account that manages the order. This cannot be a multi-client account.
6021    ///
6022    /// Sets the *merchant id* path property to the given value.
6023    ///
6024    /// Even though the property as already been set when instantiating this call,
6025    /// we provide this method for API completeness.
6026    pub fn merchant_id(mut self, new_value: u64) -> OrderpaymentNotifyrefundCall<'a, C> {
6027        self._merchant_id = new_value;
6028        self
6029    }
6030    /// The ID of the order for which charge is happening.
6031    ///
6032    /// Sets the *order id* path property to the given value.
6033    ///
6034    /// Even though the property as already been set when instantiating this call,
6035    /// we provide this method for API completeness.
6036    pub fn order_id(mut self, new_value: &str) -> OrderpaymentNotifyrefundCall<'a, C> {
6037        self._order_id = new_value.to_string();
6038        self
6039    }
6040    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6041    /// while executing the actual API request.
6042    ///
6043    /// ````text
6044    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6045    /// ````
6046    ///
6047    /// Sets the *delegate* property to the given value.
6048    pub fn delegate(
6049        mut self,
6050        new_value: &'a mut dyn common::Delegate,
6051    ) -> OrderpaymentNotifyrefundCall<'a, C> {
6052        self._delegate = Some(new_value);
6053        self
6054    }
6055
6056    /// Set any additional parameter of the query string used in the request.
6057    /// It should be used to set parameters which are not yet available through their own
6058    /// setters.
6059    ///
6060    /// Please note that this method must not be used to set any of the known parameters
6061    /// which have their own setter method. If done anyway, the request will fail.
6062    ///
6063    /// # Additional Parameters
6064    ///
6065    /// * *alt* (query-string) - Data format for the response.
6066    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6067    /// * *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.
6068    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6069    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6070    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6071    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6072    pub fn param<T>(mut self, name: T, value: T) -> OrderpaymentNotifyrefundCall<'a, C>
6073    where
6074        T: AsRef<str>,
6075    {
6076        self._additional_params
6077            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6078        self
6079    }
6080
6081    /// Identifies the authorization scope for the method you are building.
6082    ///
6083    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6084    /// [`Scope::Full`].
6085    ///
6086    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6087    /// tokens for more than one scope.
6088    ///
6089    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6090    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6091    /// sufficient, a read-write scope will do as well.
6092    pub fn add_scope<St>(mut self, scope: St) -> OrderpaymentNotifyrefundCall<'a, C>
6093    where
6094        St: AsRef<str>,
6095    {
6096        self._scopes.insert(String::from(scope.as_ref()));
6097        self
6098    }
6099    /// Identifies the authorization scope(s) for the method you are building.
6100    ///
6101    /// See [`Self::add_scope()`] for details.
6102    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderpaymentNotifyrefundCall<'a, C>
6103    where
6104        I: IntoIterator<Item = St>,
6105        St: AsRef<str>,
6106    {
6107        self._scopes
6108            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6109        self
6110    }
6111
6112    /// Removes all scopes, and no default scope will be used either.
6113    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6114    /// for details).
6115    pub fn clear_scopes(mut self) -> OrderpaymentNotifyrefundCall<'a, C> {
6116        self._scopes.clear();
6117        self
6118    }
6119}
6120
6121/// Retrieves an order return from your Merchant Center account.
6122///
6123/// A builder for the *get* method supported by a *orderreturn* resource.
6124/// It is not used directly, but through a [`OrderreturnMethods`] instance.
6125///
6126/// # Example
6127///
6128/// Instantiate a resource method builder
6129///
6130/// ```test_harness,no_run
6131/// # extern crate hyper;
6132/// # extern crate hyper_rustls;
6133/// # extern crate google_content2_sandbox as content2_sandbox;
6134/// # async fn dox() {
6135/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6136///
6137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6138/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6139/// #     .with_native_roots()
6140/// #     .unwrap()
6141/// #     .https_only()
6142/// #     .enable_http2()
6143/// #     .build();
6144///
6145/// # let executor = hyper_util::rt::TokioExecutor::new();
6146/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6147/// #     secret,
6148/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6149/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6150/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6151/// #     ),
6152/// # ).build().await.unwrap();
6153///
6154/// # let client = hyper_util::client::legacy::Client::builder(
6155/// #     hyper_util::rt::TokioExecutor::new()
6156/// # )
6157/// # .build(
6158/// #     hyper_rustls::HttpsConnectorBuilder::new()
6159/// #         .with_native_roots()
6160/// #         .unwrap()
6161/// #         .https_or_http()
6162/// #         .enable_http2()
6163/// #         .build()
6164/// # );
6165/// # let mut hub = ShoppingContent::new(client, auth);
6166/// // You can configure optional parameters by calling the respective setters at will, and
6167/// // execute the final call using `doit()`.
6168/// // Values shown here are possibly random and not representative !
6169/// let result = hub.orderreturns().get(15, "returnId")
6170///              .doit().await;
6171/// # }
6172/// ```
6173pub struct OrderreturnGetCall<'a, C>
6174where
6175    C: 'a,
6176{
6177    hub: &'a ShoppingContent<C>,
6178    _merchant_id: u64,
6179    _return_id: String,
6180    _delegate: Option<&'a mut dyn common::Delegate>,
6181    _additional_params: HashMap<String, String>,
6182    _scopes: BTreeSet<String>,
6183}
6184
6185impl<'a, C> common::CallBuilder for OrderreturnGetCall<'a, C> {}
6186
6187impl<'a, C> OrderreturnGetCall<'a, C>
6188where
6189    C: common::Connector,
6190{
6191    /// Perform the operation you have build so far.
6192    pub async fn doit(mut self) -> common::Result<(common::Response, MerchantOrderReturn)> {
6193        use std::borrow::Cow;
6194        use std::io::{Read, Seek};
6195
6196        use common::{url::Params, ToParts};
6197        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6198
6199        let mut dd = common::DefaultDelegate;
6200        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6201        dlg.begin(common::MethodInfo {
6202            id: "content.orderreturns.get",
6203            http_method: hyper::Method::GET,
6204        });
6205
6206        for &field in ["alt", "merchantId", "returnId"].iter() {
6207            if self._additional_params.contains_key(field) {
6208                dlg.finished(false);
6209                return Err(common::Error::FieldClash(field));
6210            }
6211        }
6212
6213        let mut params = Params::with_capacity(4 + self._additional_params.len());
6214        params.push("merchantId", self._merchant_id.to_string());
6215        params.push("returnId", self._return_id);
6216
6217        params.extend(self._additional_params.iter());
6218
6219        params.push("alt", "json");
6220        let mut url = self.hub._base_url.clone() + "{merchantId}/orderreturns/{returnId}";
6221        if self._scopes.is_empty() {
6222            self._scopes.insert(Scope::Full.as_ref().to_string());
6223        }
6224
6225        #[allow(clippy::single_element_loop)]
6226        for &(find_this, param_name) in
6227            [("{merchantId}", "merchantId"), ("{returnId}", "returnId")].iter()
6228        {
6229            url = params.uri_replacement(url, param_name, find_this, false);
6230        }
6231        {
6232            let to_remove = ["returnId", "merchantId"];
6233            params.remove_params(&to_remove);
6234        }
6235
6236        let url = params.parse_with_url(&url);
6237
6238        loop {
6239            let token = match self
6240                .hub
6241                .auth
6242                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6243                .await
6244            {
6245                Ok(token) => token,
6246                Err(e) => match dlg.token(e) {
6247                    Ok(token) => token,
6248                    Err(e) => {
6249                        dlg.finished(false);
6250                        return Err(common::Error::MissingToken(e));
6251                    }
6252                },
6253            };
6254            let mut req_result = {
6255                let client = &self.hub.client;
6256                dlg.pre_request();
6257                let mut req_builder = hyper::Request::builder()
6258                    .method(hyper::Method::GET)
6259                    .uri(url.as_str())
6260                    .header(USER_AGENT, self.hub._user_agent.clone());
6261
6262                if let Some(token) = token.as_ref() {
6263                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6264                }
6265
6266                let request = req_builder
6267                    .header(CONTENT_LENGTH, 0_u64)
6268                    .body(common::to_body::<String>(None));
6269
6270                client.request(request.unwrap()).await
6271            };
6272
6273            match req_result {
6274                Err(err) => {
6275                    if let common::Retry::After(d) = dlg.http_error(&err) {
6276                        sleep(d).await;
6277                        continue;
6278                    }
6279                    dlg.finished(false);
6280                    return Err(common::Error::HttpError(err));
6281                }
6282                Ok(res) => {
6283                    let (mut parts, body) = res.into_parts();
6284                    let mut body = common::Body::new(body);
6285                    if !parts.status.is_success() {
6286                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6287                        let error = serde_json::from_str(&common::to_string(&bytes));
6288                        let response = common::to_response(parts, bytes.into());
6289
6290                        if let common::Retry::After(d) =
6291                            dlg.http_failure(&response, error.as_ref().ok())
6292                        {
6293                            sleep(d).await;
6294                            continue;
6295                        }
6296
6297                        dlg.finished(false);
6298
6299                        return Err(match error {
6300                            Ok(value) => common::Error::BadRequest(value),
6301                            _ => common::Error::Failure(response),
6302                        });
6303                    }
6304                    let response = {
6305                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6306                        let encoded = common::to_string(&bytes);
6307                        match serde_json::from_str(&encoded) {
6308                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6309                            Err(error) => {
6310                                dlg.response_json_decode_error(&encoded, &error);
6311                                return Err(common::Error::JsonDecodeError(
6312                                    encoded.to_string(),
6313                                    error,
6314                                ));
6315                            }
6316                        }
6317                    };
6318
6319                    dlg.finished(true);
6320                    return Ok(response);
6321                }
6322            }
6323        }
6324    }
6325
6326    /// The ID of the account that manages the order. This cannot be a multi-client account.
6327    ///
6328    /// Sets the *merchant id* path property to the given value.
6329    ///
6330    /// Even though the property as already been set when instantiating this call,
6331    /// we provide this method for API completeness.
6332    pub fn merchant_id(mut self, new_value: u64) -> OrderreturnGetCall<'a, C> {
6333        self._merchant_id = new_value;
6334        self
6335    }
6336    /// Merchant order return ID generated by Google.
6337    ///
6338    /// Sets the *return id* path property to the given value.
6339    ///
6340    /// Even though the property as already been set when instantiating this call,
6341    /// we provide this method for API completeness.
6342    pub fn return_id(mut self, new_value: &str) -> OrderreturnGetCall<'a, C> {
6343        self._return_id = new_value.to_string();
6344        self
6345    }
6346    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6347    /// while executing the actual API request.
6348    ///
6349    /// ````text
6350    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6351    /// ````
6352    ///
6353    /// Sets the *delegate* property to the given value.
6354    pub fn delegate(
6355        mut self,
6356        new_value: &'a mut dyn common::Delegate,
6357    ) -> OrderreturnGetCall<'a, C> {
6358        self._delegate = Some(new_value);
6359        self
6360    }
6361
6362    /// Set any additional parameter of the query string used in the request.
6363    /// It should be used to set parameters which are not yet available through their own
6364    /// setters.
6365    ///
6366    /// Please note that this method must not be used to set any of the known parameters
6367    /// which have their own setter method. If done anyway, the request will fail.
6368    ///
6369    /// # Additional Parameters
6370    ///
6371    /// * *alt* (query-string) - Data format for the response.
6372    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6373    /// * *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.
6374    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6375    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6376    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6377    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6378    pub fn param<T>(mut self, name: T, value: T) -> OrderreturnGetCall<'a, C>
6379    where
6380        T: AsRef<str>,
6381    {
6382        self._additional_params
6383            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6384        self
6385    }
6386
6387    /// Identifies the authorization scope for the method you are building.
6388    ///
6389    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6390    /// [`Scope::Full`].
6391    ///
6392    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6393    /// tokens for more than one scope.
6394    ///
6395    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6396    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6397    /// sufficient, a read-write scope will do as well.
6398    pub fn add_scope<St>(mut self, scope: St) -> OrderreturnGetCall<'a, C>
6399    where
6400        St: AsRef<str>,
6401    {
6402        self._scopes.insert(String::from(scope.as_ref()));
6403        self
6404    }
6405    /// Identifies the authorization scope(s) for the method you are building.
6406    ///
6407    /// See [`Self::add_scope()`] for details.
6408    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderreturnGetCall<'a, C>
6409    where
6410        I: IntoIterator<Item = St>,
6411        St: AsRef<str>,
6412    {
6413        self._scopes
6414            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6415        self
6416    }
6417
6418    /// Removes all scopes, and no default scope will be used either.
6419    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6420    /// for details).
6421    pub fn clear_scopes(mut self) -> OrderreturnGetCall<'a, C> {
6422        self._scopes.clear();
6423        self
6424    }
6425}
6426
6427/// Lists order returns in your Merchant Center account.
6428///
6429/// A builder for the *list* method supported by a *orderreturn* resource.
6430/// It is not used directly, but through a [`OrderreturnMethods`] instance.
6431///
6432/// # Example
6433///
6434/// Instantiate a resource method builder
6435///
6436/// ```test_harness,no_run
6437/// # extern crate hyper;
6438/// # extern crate hyper_rustls;
6439/// # extern crate google_content2_sandbox as content2_sandbox;
6440/// # async fn dox() {
6441/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6442///
6443/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6444/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6445/// #     .with_native_roots()
6446/// #     .unwrap()
6447/// #     .https_only()
6448/// #     .enable_http2()
6449/// #     .build();
6450///
6451/// # let executor = hyper_util::rt::TokioExecutor::new();
6452/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6453/// #     secret,
6454/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6455/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6456/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6457/// #     ),
6458/// # ).build().await.unwrap();
6459///
6460/// # let client = hyper_util::client::legacy::Client::builder(
6461/// #     hyper_util::rt::TokioExecutor::new()
6462/// # )
6463/// # .build(
6464/// #     hyper_rustls::HttpsConnectorBuilder::new()
6465/// #         .with_native_roots()
6466/// #         .unwrap()
6467/// #         .https_or_http()
6468/// #         .enable_http2()
6469/// #         .build()
6470/// # );
6471/// # let mut hub = ShoppingContent::new(client, auth);
6472/// // You can configure optional parameters by calling the respective setters at will, and
6473/// // execute the final call using `doit()`.
6474/// // Values shown here are possibly random and not representative !
6475/// let result = hub.orderreturns().list(31)
6476///              .page_token("sed")
6477///              .order_by("no")
6478///              .max_results(86)
6479///              .created_start_date("kasd")
6480///              .created_end_date("et")
6481///              .doit().await;
6482/// # }
6483/// ```
6484pub struct OrderreturnListCall<'a, C>
6485where
6486    C: 'a,
6487{
6488    hub: &'a ShoppingContent<C>,
6489    _merchant_id: u64,
6490    _page_token: Option<String>,
6491    _order_by: Option<String>,
6492    _max_results: Option<u32>,
6493    _created_start_date: Option<String>,
6494    _created_end_date: Option<String>,
6495    _delegate: Option<&'a mut dyn common::Delegate>,
6496    _additional_params: HashMap<String, String>,
6497    _scopes: BTreeSet<String>,
6498}
6499
6500impl<'a, C> common::CallBuilder for OrderreturnListCall<'a, C> {}
6501
6502impl<'a, C> OrderreturnListCall<'a, C>
6503where
6504    C: common::Connector,
6505{
6506    /// Perform the operation you have build so far.
6507    pub async fn doit(mut self) -> common::Result<(common::Response, OrderreturnsListResponse)> {
6508        use std::borrow::Cow;
6509        use std::io::{Read, Seek};
6510
6511        use common::{url::Params, ToParts};
6512        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6513
6514        let mut dd = common::DefaultDelegate;
6515        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6516        dlg.begin(common::MethodInfo {
6517            id: "content.orderreturns.list",
6518            http_method: hyper::Method::GET,
6519        });
6520
6521        for &field in [
6522            "alt",
6523            "merchantId",
6524            "pageToken",
6525            "orderBy",
6526            "maxResults",
6527            "createdStartDate",
6528            "createdEndDate",
6529        ]
6530        .iter()
6531        {
6532            if self._additional_params.contains_key(field) {
6533                dlg.finished(false);
6534                return Err(common::Error::FieldClash(field));
6535            }
6536        }
6537
6538        let mut params = Params::with_capacity(8 + self._additional_params.len());
6539        params.push("merchantId", self._merchant_id.to_string());
6540        if let Some(value) = self._page_token.as_ref() {
6541            params.push("pageToken", value);
6542        }
6543        if let Some(value) = self._order_by.as_ref() {
6544            params.push("orderBy", value);
6545        }
6546        if let Some(value) = self._max_results.as_ref() {
6547            params.push("maxResults", value.to_string());
6548        }
6549        if let Some(value) = self._created_start_date.as_ref() {
6550            params.push("createdStartDate", value);
6551        }
6552        if let Some(value) = self._created_end_date.as_ref() {
6553            params.push("createdEndDate", value);
6554        }
6555
6556        params.extend(self._additional_params.iter());
6557
6558        params.push("alt", "json");
6559        let mut url = self.hub._base_url.clone() + "{merchantId}/orderreturns";
6560        if self._scopes.is_empty() {
6561            self._scopes.insert(Scope::Full.as_ref().to_string());
6562        }
6563
6564        #[allow(clippy::single_element_loop)]
6565        for &(find_this, param_name) in [("{merchantId}", "merchantId")].iter() {
6566            url = params.uri_replacement(url, param_name, find_this, false);
6567        }
6568        {
6569            let to_remove = ["merchantId"];
6570            params.remove_params(&to_remove);
6571        }
6572
6573        let url = params.parse_with_url(&url);
6574
6575        loop {
6576            let token = match self
6577                .hub
6578                .auth
6579                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6580                .await
6581            {
6582                Ok(token) => token,
6583                Err(e) => match dlg.token(e) {
6584                    Ok(token) => token,
6585                    Err(e) => {
6586                        dlg.finished(false);
6587                        return Err(common::Error::MissingToken(e));
6588                    }
6589                },
6590            };
6591            let mut req_result = {
6592                let client = &self.hub.client;
6593                dlg.pre_request();
6594                let mut req_builder = hyper::Request::builder()
6595                    .method(hyper::Method::GET)
6596                    .uri(url.as_str())
6597                    .header(USER_AGENT, self.hub._user_agent.clone());
6598
6599                if let Some(token) = token.as_ref() {
6600                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6601                }
6602
6603                let request = req_builder
6604                    .header(CONTENT_LENGTH, 0_u64)
6605                    .body(common::to_body::<String>(None));
6606
6607                client.request(request.unwrap()).await
6608            };
6609
6610            match req_result {
6611                Err(err) => {
6612                    if let common::Retry::After(d) = dlg.http_error(&err) {
6613                        sleep(d).await;
6614                        continue;
6615                    }
6616                    dlg.finished(false);
6617                    return Err(common::Error::HttpError(err));
6618                }
6619                Ok(res) => {
6620                    let (mut parts, body) = res.into_parts();
6621                    let mut body = common::Body::new(body);
6622                    if !parts.status.is_success() {
6623                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6624                        let error = serde_json::from_str(&common::to_string(&bytes));
6625                        let response = common::to_response(parts, bytes.into());
6626
6627                        if let common::Retry::After(d) =
6628                            dlg.http_failure(&response, error.as_ref().ok())
6629                        {
6630                            sleep(d).await;
6631                            continue;
6632                        }
6633
6634                        dlg.finished(false);
6635
6636                        return Err(match error {
6637                            Ok(value) => common::Error::BadRequest(value),
6638                            _ => common::Error::Failure(response),
6639                        });
6640                    }
6641                    let response = {
6642                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6643                        let encoded = common::to_string(&bytes);
6644                        match serde_json::from_str(&encoded) {
6645                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6646                            Err(error) => {
6647                                dlg.response_json_decode_error(&encoded, &error);
6648                                return Err(common::Error::JsonDecodeError(
6649                                    encoded.to_string(),
6650                                    error,
6651                                ));
6652                            }
6653                        }
6654                    };
6655
6656                    dlg.finished(true);
6657                    return Ok(response);
6658                }
6659            }
6660        }
6661    }
6662
6663    /// The ID of the account that manages the order. This cannot be a multi-client account.
6664    ///
6665    /// Sets the *merchant id* path property to the given value.
6666    ///
6667    /// Even though the property as already been set when instantiating this call,
6668    /// we provide this method for API completeness.
6669    pub fn merchant_id(mut self, new_value: u64) -> OrderreturnListCall<'a, C> {
6670        self._merchant_id = new_value;
6671        self
6672    }
6673    /// The token returned by the previous request.
6674    ///
6675    /// Sets the *page token* query property to the given value.
6676    pub fn page_token(mut self, new_value: &str) -> OrderreturnListCall<'a, C> {
6677        self._page_token = Some(new_value.to_string());
6678        self
6679    }
6680    /// Return the results in the specified order.
6681    ///
6682    /// Sets the *order by* query property to the given value.
6683    pub fn order_by(mut self, new_value: &str) -> OrderreturnListCall<'a, C> {
6684        self._order_by = Some(new_value.to_string());
6685        self
6686    }
6687    /// The maximum number of order returns to return in the response, used for paging. The default value is 25 returns per page, and the maximum allowed value is 250 returns per page.
6688    ///
6689    /// Sets the *max results* query property to the given value.
6690    pub fn max_results(mut self, new_value: u32) -> OrderreturnListCall<'a, C> {
6691        self._max_results = Some(new_value);
6692        self
6693    }
6694    /// Obtains order returns created after this date (inclusively), in ISO 8601 format.
6695    ///
6696    /// Sets the *created start date* query property to the given value.
6697    pub fn created_start_date(mut self, new_value: &str) -> OrderreturnListCall<'a, C> {
6698        self._created_start_date = Some(new_value.to_string());
6699        self
6700    }
6701    /// Obtains order returns created before this date (inclusively), in ISO 8601 format.
6702    ///
6703    /// Sets the *created end date* query property to the given value.
6704    pub fn created_end_date(mut self, new_value: &str) -> OrderreturnListCall<'a, C> {
6705        self._created_end_date = Some(new_value.to_string());
6706        self
6707    }
6708    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6709    /// while executing the actual API request.
6710    ///
6711    /// ````text
6712    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6713    /// ````
6714    ///
6715    /// Sets the *delegate* property to the given value.
6716    pub fn delegate(
6717        mut self,
6718        new_value: &'a mut dyn common::Delegate,
6719    ) -> OrderreturnListCall<'a, C> {
6720        self._delegate = Some(new_value);
6721        self
6722    }
6723
6724    /// Set any additional parameter of the query string used in the request.
6725    /// It should be used to set parameters which are not yet available through their own
6726    /// setters.
6727    ///
6728    /// Please note that this method must not be used to set any of the known parameters
6729    /// which have their own setter method. If done anyway, the request will fail.
6730    ///
6731    /// # Additional Parameters
6732    ///
6733    /// * *alt* (query-string) - Data format for the response.
6734    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6735    /// * *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.
6736    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6737    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6738    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6739    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6740    pub fn param<T>(mut self, name: T, value: T) -> OrderreturnListCall<'a, C>
6741    where
6742        T: AsRef<str>,
6743    {
6744        self._additional_params
6745            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6746        self
6747    }
6748
6749    /// Identifies the authorization scope for the method you are building.
6750    ///
6751    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6752    /// [`Scope::Full`].
6753    ///
6754    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6755    /// tokens for more than one scope.
6756    ///
6757    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6758    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6759    /// sufficient, a read-write scope will do as well.
6760    pub fn add_scope<St>(mut self, scope: St) -> OrderreturnListCall<'a, C>
6761    where
6762        St: AsRef<str>,
6763    {
6764        self._scopes.insert(String::from(scope.as_ref()));
6765        self
6766    }
6767    /// Identifies the authorization scope(s) for the method you are building.
6768    ///
6769    /// See [`Self::add_scope()`] for details.
6770    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderreturnListCall<'a, C>
6771    where
6772        I: IntoIterator<Item = St>,
6773        St: AsRef<str>,
6774    {
6775        self._scopes
6776            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6777        self
6778    }
6779
6780    /// Removes all scopes, and no default scope will be used either.
6781    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6782    /// for details).
6783    pub fn clear_scopes(mut self) -> OrderreturnListCall<'a, C> {
6784        self._scopes.clear();
6785        self
6786    }
6787}
6788
6789/// Marks an order as acknowledged.
6790///
6791/// A builder for the *acknowledge* method supported by a *order* resource.
6792/// It is not used directly, but through a [`OrderMethods`] instance.
6793///
6794/// # Example
6795///
6796/// Instantiate a resource method builder
6797///
6798/// ```test_harness,no_run
6799/// # extern crate hyper;
6800/// # extern crate hyper_rustls;
6801/// # extern crate google_content2_sandbox as content2_sandbox;
6802/// use content2_sandbox::api::OrdersAcknowledgeRequest;
6803/// # async fn dox() {
6804/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6805///
6806/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6807/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6808/// #     .with_native_roots()
6809/// #     .unwrap()
6810/// #     .https_only()
6811/// #     .enable_http2()
6812/// #     .build();
6813///
6814/// # let executor = hyper_util::rt::TokioExecutor::new();
6815/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6816/// #     secret,
6817/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6818/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6819/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6820/// #     ),
6821/// # ).build().await.unwrap();
6822///
6823/// # let client = hyper_util::client::legacy::Client::builder(
6824/// #     hyper_util::rt::TokioExecutor::new()
6825/// # )
6826/// # .build(
6827/// #     hyper_rustls::HttpsConnectorBuilder::new()
6828/// #         .with_native_roots()
6829/// #         .unwrap()
6830/// #         .https_or_http()
6831/// #         .enable_http2()
6832/// #         .build()
6833/// # );
6834/// # let mut hub = ShoppingContent::new(client, auth);
6835/// // As the method needs a request, you would usually fill it with the desired information
6836/// // into the respective structure. Some of the parts shown here might not be applicable !
6837/// // Values shown here are possibly random and not representative !
6838/// let mut req = OrdersAcknowledgeRequest::default();
6839///
6840/// // You can configure optional parameters by calling the respective setters at will, and
6841/// // execute the final call using `doit()`.
6842/// // Values shown here are possibly random and not representative !
6843/// let result = hub.orders().acknowledge(req, 58, "orderId")
6844///              .doit().await;
6845/// # }
6846/// ```
6847pub struct OrderAcknowledgeCall<'a, C>
6848where
6849    C: 'a,
6850{
6851    hub: &'a ShoppingContent<C>,
6852    _request: OrdersAcknowledgeRequest,
6853    _merchant_id: u64,
6854    _order_id: String,
6855    _delegate: Option<&'a mut dyn common::Delegate>,
6856    _additional_params: HashMap<String, String>,
6857    _scopes: BTreeSet<String>,
6858}
6859
6860impl<'a, C> common::CallBuilder for OrderAcknowledgeCall<'a, C> {}
6861
6862impl<'a, C> OrderAcknowledgeCall<'a, C>
6863where
6864    C: common::Connector,
6865{
6866    /// Perform the operation you have build so far.
6867    pub async fn doit(mut self) -> common::Result<(common::Response, OrdersAcknowledgeResponse)> {
6868        use std::borrow::Cow;
6869        use std::io::{Read, Seek};
6870
6871        use common::{url::Params, ToParts};
6872        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6873
6874        let mut dd = common::DefaultDelegate;
6875        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6876        dlg.begin(common::MethodInfo {
6877            id: "content.orders.acknowledge",
6878            http_method: hyper::Method::POST,
6879        });
6880
6881        for &field in ["alt", "merchantId", "orderId"].iter() {
6882            if self._additional_params.contains_key(field) {
6883                dlg.finished(false);
6884                return Err(common::Error::FieldClash(field));
6885            }
6886        }
6887
6888        let mut params = Params::with_capacity(5 + self._additional_params.len());
6889        params.push("merchantId", self._merchant_id.to_string());
6890        params.push("orderId", self._order_id);
6891
6892        params.extend(self._additional_params.iter());
6893
6894        params.push("alt", "json");
6895        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/acknowledge";
6896        if self._scopes.is_empty() {
6897            self._scopes.insert(Scope::Full.as_ref().to_string());
6898        }
6899
6900        #[allow(clippy::single_element_loop)]
6901        for &(find_this, param_name) in
6902            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
6903        {
6904            url = params.uri_replacement(url, param_name, find_this, false);
6905        }
6906        {
6907            let to_remove = ["orderId", "merchantId"];
6908            params.remove_params(&to_remove);
6909        }
6910
6911        let url = params.parse_with_url(&url);
6912
6913        let mut json_mime_type = mime::APPLICATION_JSON;
6914        let mut request_value_reader = {
6915            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6916            common::remove_json_null_values(&mut value);
6917            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6918            serde_json::to_writer(&mut dst, &value).unwrap();
6919            dst
6920        };
6921        let request_size = request_value_reader
6922            .seek(std::io::SeekFrom::End(0))
6923            .unwrap();
6924        request_value_reader
6925            .seek(std::io::SeekFrom::Start(0))
6926            .unwrap();
6927
6928        loop {
6929            let token = match self
6930                .hub
6931                .auth
6932                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6933                .await
6934            {
6935                Ok(token) => token,
6936                Err(e) => match dlg.token(e) {
6937                    Ok(token) => token,
6938                    Err(e) => {
6939                        dlg.finished(false);
6940                        return Err(common::Error::MissingToken(e));
6941                    }
6942                },
6943            };
6944            request_value_reader
6945                .seek(std::io::SeekFrom::Start(0))
6946                .unwrap();
6947            let mut req_result = {
6948                let client = &self.hub.client;
6949                dlg.pre_request();
6950                let mut req_builder = hyper::Request::builder()
6951                    .method(hyper::Method::POST)
6952                    .uri(url.as_str())
6953                    .header(USER_AGENT, self.hub._user_agent.clone());
6954
6955                if let Some(token) = token.as_ref() {
6956                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6957                }
6958
6959                let request = req_builder
6960                    .header(CONTENT_TYPE, json_mime_type.to_string())
6961                    .header(CONTENT_LENGTH, request_size as u64)
6962                    .body(common::to_body(
6963                        request_value_reader.get_ref().clone().into(),
6964                    ));
6965
6966                client.request(request.unwrap()).await
6967            };
6968
6969            match req_result {
6970                Err(err) => {
6971                    if let common::Retry::After(d) = dlg.http_error(&err) {
6972                        sleep(d).await;
6973                        continue;
6974                    }
6975                    dlg.finished(false);
6976                    return Err(common::Error::HttpError(err));
6977                }
6978                Ok(res) => {
6979                    let (mut parts, body) = res.into_parts();
6980                    let mut body = common::Body::new(body);
6981                    if !parts.status.is_success() {
6982                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6983                        let error = serde_json::from_str(&common::to_string(&bytes));
6984                        let response = common::to_response(parts, bytes.into());
6985
6986                        if let common::Retry::After(d) =
6987                            dlg.http_failure(&response, error.as_ref().ok())
6988                        {
6989                            sleep(d).await;
6990                            continue;
6991                        }
6992
6993                        dlg.finished(false);
6994
6995                        return Err(match error {
6996                            Ok(value) => common::Error::BadRequest(value),
6997                            _ => common::Error::Failure(response),
6998                        });
6999                    }
7000                    let response = {
7001                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7002                        let encoded = common::to_string(&bytes);
7003                        match serde_json::from_str(&encoded) {
7004                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7005                            Err(error) => {
7006                                dlg.response_json_decode_error(&encoded, &error);
7007                                return Err(common::Error::JsonDecodeError(
7008                                    encoded.to_string(),
7009                                    error,
7010                                ));
7011                            }
7012                        }
7013                    };
7014
7015                    dlg.finished(true);
7016                    return Ok(response);
7017                }
7018            }
7019        }
7020    }
7021
7022    ///
7023    /// Sets the *request* property to the given value.
7024    ///
7025    /// Even though the property as already been set when instantiating this call,
7026    /// we provide this method for API completeness.
7027    pub fn request(mut self, new_value: OrdersAcknowledgeRequest) -> OrderAcknowledgeCall<'a, C> {
7028        self._request = new_value;
7029        self
7030    }
7031    /// The ID of the account that manages the order. This cannot be a multi-client account.
7032    ///
7033    /// Sets the *merchant id* path property to the given value.
7034    ///
7035    /// Even though the property as already been set when instantiating this call,
7036    /// we provide this method for API completeness.
7037    pub fn merchant_id(mut self, new_value: u64) -> OrderAcknowledgeCall<'a, C> {
7038        self._merchant_id = new_value;
7039        self
7040    }
7041    /// The ID of the order.
7042    ///
7043    /// Sets the *order id* path property to the given value.
7044    ///
7045    /// Even though the property as already been set when instantiating this call,
7046    /// we provide this method for API completeness.
7047    pub fn order_id(mut self, new_value: &str) -> OrderAcknowledgeCall<'a, C> {
7048        self._order_id = new_value.to_string();
7049        self
7050    }
7051    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7052    /// while executing the actual API request.
7053    ///
7054    /// ````text
7055    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7056    /// ````
7057    ///
7058    /// Sets the *delegate* property to the given value.
7059    pub fn delegate(
7060        mut self,
7061        new_value: &'a mut dyn common::Delegate,
7062    ) -> OrderAcknowledgeCall<'a, C> {
7063        self._delegate = Some(new_value);
7064        self
7065    }
7066
7067    /// Set any additional parameter of the query string used in the request.
7068    /// It should be used to set parameters which are not yet available through their own
7069    /// setters.
7070    ///
7071    /// Please note that this method must not be used to set any of the known parameters
7072    /// which have their own setter method. If done anyway, the request will fail.
7073    ///
7074    /// # Additional Parameters
7075    ///
7076    /// * *alt* (query-string) - Data format for the response.
7077    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7078    /// * *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.
7079    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7080    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7081    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7082    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7083    pub fn param<T>(mut self, name: T, value: T) -> OrderAcknowledgeCall<'a, C>
7084    where
7085        T: AsRef<str>,
7086    {
7087        self._additional_params
7088            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7089        self
7090    }
7091
7092    /// Identifies the authorization scope for the method you are building.
7093    ///
7094    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7095    /// [`Scope::Full`].
7096    ///
7097    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7098    /// tokens for more than one scope.
7099    ///
7100    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7101    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7102    /// sufficient, a read-write scope will do as well.
7103    pub fn add_scope<St>(mut self, scope: St) -> OrderAcknowledgeCall<'a, C>
7104    where
7105        St: AsRef<str>,
7106    {
7107        self._scopes.insert(String::from(scope.as_ref()));
7108        self
7109    }
7110    /// Identifies the authorization scope(s) for the method you are building.
7111    ///
7112    /// See [`Self::add_scope()`] for details.
7113    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderAcknowledgeCall<'a, C>
7114    where
7115        I: IntoIterator<Item = St>,
7116        St: AsRef<str>,
7117    {
7118        self._scopes
7119            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7120        self
7121    }
7122
7123    /// Removes all scopes, and no default scope will be used either.
7124    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7125    /// for details).
7126    pub fn clear_scopes(mut self) -> OrderAcknowledgeCall<'a, C> {
7127        self._scopes.clear();
7128        self
7129    }
7130}
7131
7132/// Sandbox only. Moves a test order from state "inProgress" to state "pendingShipment".
7133///
7134/// A builder for the *advancetestorder* method supported by a *order* resource.
7135/// It is not used directly, but through a [`OrderMethods`] instance.
7136///
7137/// # Example
7138///
7139/// Instantiate a resource method builder
7140///
7141/// ```test_harness,no_run
7142/// # extern crate hyper;
7143/// # extern crate hyper_rustls;
7144/// # extern crate google_content2_sandbox as content2_sandbox;
7145/// # async fn dox() {
7146/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7147///
7148/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7149/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7150/// #     .with_native_roots()
7151/// #     .unwrap()
7152/// #     .https_only()
7153/// #     .enable_http2()
7154/// #     .build();
7155///
7156/// # let executor = hyper_util::rt::TokioExecutor::new();
7157/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7158/// #     secret,
7159/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7160/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7161/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7162/// #     ),
7163/// # ).build().await.unwrap();
7164///
7165/// # let client = hyper_util::client::legacy::Client::builder(
7166/// #     hyper_util::rt::TokioExecutor::new()
7167/// # )
7168/// # .build(
7169/// #     hyper_rustls::HttpsConnectorBuilder::new()
7170/// #         .with_native_roots()
7171/// #         .unwrap()
7172/// #         .https_or_http()
7173/// #         .enable_http2()
7174/// #         .build()
7175/// # );
7176/// # let mut hub = ShoppingContent::new(client, auth);
7177/// // You can configure optional parameters by calling the respective setters at will, and
7178/// // execute the final call using `doit()`.
7179/// // Values shown here are possibly random and not representative !
7180/// let result = hub.orders().advancetestorder(33, "orderId")
7181///              .doit().await;
7182/// # }
7183/// ```
7184pub struct OrderAdvancetestorderCall<'a, C>
7185where
7186    C: 'a,
7187{
7188    hub: &'a ShoppingContent<C>,
7189    _merchant_id: u64,
7190    _order_id: String,
7191    _delegate: Option<&'a mut dyn common::Delegate>,
7192    _additional_params: HashMap<String, String>,
7193    _scopes: BTreeSet<String>,
7194}
7195
7196impl<'a, C> common::CallBuilder for OrderAdvancetestorderCall<'a, C> {}
7197
7198impl<'a, C> OrderAdvancetestorderCall<'a, C>
7199where
7200    C: common::Connector,
7201{
7202    /// Perform the operation you have build so far.
7203    pub async fn doit(
7204        mut self,
7205    ) -> common::Result<(common::Response, OrdersAdvanceTestOrderResponse)> {
7206        use std::borrow::Cow;
7207        use std::io::{Read, Seek};
7208
7209        use common::{url::Params, ToParts};
7210        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7211
7212        let mut dd = common::DefaultDelegate;
7213        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7214        dlg.begin(common::MethodInfo {
7215            id: "content.orders.advancetestorder",
7216            http_method: hyper::Method::POST,
7217        });
7218
7219        for &field in ["alt", "merchantId", "orderId"].iter() {
7220            if self._additional_params.contains_key(field) {
7221                dlg.finished(false);
7222                return Err(common::Error::FieldClash(field));
7223            }
7224        }
7225
7226        let mut params = Params::with_capacity(4 + self._additional_params.len());
7227        params.push("merchantId", self._merchant_id.to_string());
7228        params.push("orderId", self._order_id);
7229
7230        params.extend(self._additional_params.iter());
7231
7232        params.push("alt", "json");
7233        let mut url = self.hub._base_url.clone() + "{merchantId}/testorders/{orderId}/advance";
7234        if self._scopes.is_empty() {
7235            self._scopes.insert(Scope::Full.as_ref().to_string());
7236        }
7237
7238        #[allow(clippy::single_element_loop)]
7239        for &(find_this, param_name) in
7240            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
7241        {
7242            url = params.uri_replacement(url, param_name, find_this, false);
7243        }
7244        {
7245            let to_remove = ["orderId", "merchantId"];
7246            params.remove_params(&to_remove);
7247        }
7248
7249        let url = params.parse_with_url(&url);
7250
7251        loop {
7252            let token = match self
7253                .hub
7254                .auth
7255                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7256                .await
7257            {
7258                Ok(token) => token,
7259                Err(e) => match dlg.token(e) {
7260                    Ok(token) => token,
7261                    Err(e) => {
7262                        dlg.finished(false);
7263                        return Err(common::Error::MissingToken(e));
7264                    }
7265                },
7266            };
7267            let mut req_result = {
7268                let client = &self.hub.client;
7269                dlg.pre_request();
7270                let mut req_builder = hyper::Request::builder()
7271                    .method(hyper::Method::POST)
7272                    .uri(url.as_str())
7273                    .header(USER_AGENT, self.hub._user_agent.clone());
7274
7275                if let Some(token) = token.as_ref() {
7276                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7277                }
7278
7279                let request = req_builder
7280                    .header(CONTENT_LENGTH, 0_u64)
7281                    .body(common::to_body::<String>(None));
7282
7283                client.request(request.unwrap()).await
7284            };
7285
7286            match req_result {
7287                Err(err) => {
7288                    if let common::Retry::After(d) = dlg.http_error(&err) {
7289                        sleep(d).await;
7290                        continue;
7291                    }
7292                    dlg.finished(false);
7293                    return Err(common::Error::HttpError(err));
7294                }
7295                Ok(res) => {
7296                    let (mut parts, body) = res.into_parts();
7297                    let mut body = common::Body::new(body);
7298                    if !parts.status.is_success() {
7299                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7300                        let error = serde_json::from_str(&common::to_string(&bytes));
7301                        let response = common::to_response(parts, bytes.into());
7302
7303                        if let common::Retry::After(d) =
7304                            dlg.http_failure(&response, error.as_ref().ok())
7305                        {
7306                            sleep(d).await;
7307                            continue;
7308                        }
7309
7310                        dlg.finished(false);
7311
7312                        return Err(match error {
7313                            Ok(value) => common::Error::BadRequest(value),
7314                            _ => common::Error::Failure(response),
7315                        });
7316                    }
7317                    let response = {
7318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7319                        let encoded = common::to_string(&bytes);
7320                        match serde_json::from_str(&encoded) {
7321                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7322                            Err(error) => {
7323                                dlg.response_json_decode_error(&encoded, &error);
7324                                return Err(common::Error::JsonDecodeError(
7325                                    encoded.to_string(),
7326                                    error,
7327                                ));
7328                            }
7329                        }
7330                    };
7331
7332                    dlg.finished(true);
7333                    return Ok(response);
7334                }
7335            }
7336        }
7337    }
7338
7339    /// The ID of the account that manages the order. This cannot be a multi-client account.
7340    ///
7341    /// Sets the *merchant id* path property to the given value.
7342    ///
7343    /// Even though the property as already been set when instantiating this call,
7344    /// we provide this method for API completeness.
7345    pub fn merchant_id(mut self, new_value: u64) -> OrderAdvancetestorderCall<'a, C> {
7346        self._merchant_id = new_value;
7347        self
7348    }
7349    /// The ID of the test order to modify.
7350    ///
7351    /// Sets the *order id* path property to the given value.
7352    ///
7353    /// Even though the property as already been set when instantiating this call,
7354    /// we provide this method for API completeness.
7355    pub fn order_id(mut self, new_value: &str) -> OrderAdvancetestorderCall<'a, C> {
7356        self._order_id = new_value.to_string();
7357        self
7358    }
7359    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7360    /// while executing the actual API request.
7361    ///
7362    /// ````text
7363    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7364    /// ````
7365    ///
7366    /// Sets the *delegate* property to the given value.
7367    pub fn delegate(
7368        mut self,
7369        new_value: &'a mut dyn common::Delegate,
7370    ) -> OrderAdvancetestorderCall<'a, C> {
7371        self._delegate = Some(new_value);
7372        self
7373    }
7374
7375    /// Set any additional parameter of the query string used in the request.
7376    /// It should be used to set parameters which are not yet available through their own
7377    /// setters.
7378    ///
7379    /// Please note that this method must not be used to set any of the known parameters
7380    /// which have their own setter method. If done anyway, the request will fail.
7381    ///
7382    /// # Additional Parameters
7383    ///
7384    /// * *alt* (query-string) - Data format for the response.
7385    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7386    /// * *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.
7387    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7388    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7389    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7390    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7391    pub fn param<T>(mut self, name: T, value: T) -> OrderAdvancetestorderCall<'a, C>
7392    where
7393        T: AsRef<str>,
7394    {
7395        self._additional_params
7396            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7397        self
7398    }
7399
7400    /// Identifies the authorization scope for the method you are building.
7401    ///
7402    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7403    /// [`Scope::Full`].
7404    ///
7405    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7406    /// tokens for more than one scope.
7407    ///
7408    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7409    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7410    /// sufficient, a read-write scope will do as well.
7411    pub fn add_scope<St>(mut self, scope: St) -> OrderAdvancetestorderCall<'a, C>
7412    where
7413        St: AsRef<str>,
7414    {
7415        self._scopes.insert(String::from(scope.as_ref()));
7416        self
7417    }
7418    /// Identifies the authorization scope(s) for the method you are building.
7419    ///
7420    /// See [`Self::add_scope()`] for details.
7421    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderAdvancetestorderCall<'a, C>
7422    where
7423        I: IntoIterator<Item = St>,
7424        St: AsRef<str>,
7425    {
7426        self._scopes
7427            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7428        self
7429    }
7430
7431    /// Removes all scopes, and no default scope will be used either.
7432    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7433    /// for details).
7434    pub fn clear_scopes(mut self) -> OrderAdvancetestorderCall<'a, C> {
7435        self._scopes.clear();
7436        self
7437    }
7438}
7439
7440/// Cancels all line items in an order, making a full refund.
7441///
7442/// A builder for the *cancel* method supported by a *order* resource.
7443/// It is not used directly, but through a [`OrderMethods`] instance.
7444///
7445/// # Example
7446///
7447/// Instantiate a resource method builder
7448///
7449/// ```test_harness,no_run
7450/// # extern crate hyper;
7451/// # extern crate hyper_rustls;
7452/// # extern crate google_content2_sandbox as content2_sandbox;
7453/// use content2_sandbox::api::OrdersCancelRequest;
7454/// # async fn dox() {
7455/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7456///
7457/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7458/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7459/// #     .with_native_roots()
7460/// #     .unwrap()
7461/// #     .https_only()
7462/// #     .enable_http2()
7463/// #     .build();
7464///
7465/// # let executor = hyper_util::rt::TokioExecutor::new();
7466/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7467/// #     secret,
7468/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7469/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7470/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7471/// #     ),
7472/// # ).build().await.unwrap();
7473///
7474/// # let client = hyper_util::client::legacy::Client::builder(
7475/// #     hyper_util::rt::TokioExecutor::new()
7476/// # )
7477/// # .build(
7478/// #     hyper_rustls::HttpsConnectorBuilder::new()
7479/// #         .with_native_roots()
7480/// #         .unwrap()
7481/// #         .https_or_http()
7482/// #         .enable_http2()
7483/// #         .build()
7484/// # );
7485/// # let mut hub = ShoppingContent::new(client, auth);
7486/// // As the method needs a request, you would usually fill it with the desired information
7487/// // into the respective structure. Some of the parts shown here might not be applicable !
7488/// // Values shown here are possibly random and not representative !
7489/// let mut req = OrdersCancelRequest::default();
7490///
7491/// // You can configure optional parameters by calling the respective setters at will, and
7492/// // execute the final call using `doit()`.
7493/// // Values shown here are possibly random and not representative !
7494/// let result = hub.orders().cancel(req, 70, "orderId")
7495///              .doit().await;
7496/// # }
7497/// ```
7498pub struct OrderCancelCall<'a, C>
7499where
7500    C: 'a,
7501{
7502    hub: &'a ShoppingContent<C>,
7503    _request: OrdersCancelRequest,
7504    _merchant_id: u64,
7505    _order_id: String,
7506    _delegate: Option<&'a mut dyn common::Delegate>,
7507    _additional_params: HashMap<String, String>,
7508    _scopes: BTreeSet<String>,
7509}
7510
7511impl<'a, C> common::CallBuilder for OrderCancelCall<'a, C> {}
7512
7513impl<'a, C> OrderCancelCall<'a, C>
7514where
7515    C: common::Connector,
7516{
7517    /// Perform the operation you have build so far.
7518    pub async fn doit(mut self) -> common::Result<(common::Response, OrdersCancelResponse)> {
7519        use std::borrow::Cow;
7520        use std::io::{Read, Seek};
7521
7522        use common::{url::Params, ToParts};
7523        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7524
7525        let mut dd = common::DefaultDelegate;
7526        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7527        dlg.begin(common::MethodInfo {
7528            id: "content.orders.cancel",
7529            http_method: hyper::Method::POST,
7530        });
7531
7532        for &field in ["alt", "merchantId", "orderId"].iter() {
7533            if self._additional_params.contains_key(field) {
7534                dlg.finished(false);
7535                return Err(common::Error::FieldClash(field));
7536            }
7537        }
7538
7539        let mut params = Params::with_capacity(5 + self._additional_params.len());
7540        params.push("merchantId", self._merchant_id.to_string());
7541        params.push("orderId", self._order_id);
7542
7543        params.extend(self._additional_params.iter());
7544
7545        params.push("alt", "json");
7546        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/cancel";
7547        if self._scopes.is_empty() {
7548            self._scopes.insert(Scope::Full.as_ref().to_string());
7549        }
7550
7551        #[allow(clippy::single_element_loop)]
7552        for &(find_this, param_name) in
7553            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
7554        {
7555            url = params.uri_replacement(url, param_name, find_this, false);
7556        }
7557        {
7558            let to_remove = ["orderId", "merchantId"];
7559            params.remove_params(&to_remove);
7560        }
7561
7562        let url = params.parse_with_url(&url);
7563
7564        let mut json_mime_type = mime::APPLICATION_JSON;
7565        let mut request_value_reader = {
7566            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7567            common::remove_json_null_values(&mut value);
7568            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7569            serde_json::to_writer(&mut dst, &value).unwrap();
7570            dst
7571        };
7572        let request_size = request_value_reader
7573            .seek(std::io::SeekFrom::End(0))
7574            .unwrap();
7575        request_value_reader
7576            .seek(std::io::SeekFrom::Start(0))
7577            .unwrap();
7578
7579        loop {
7580            let token = match self
7581                .hub
7582                .auth
7583                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7584                .await
7585            {
7586                Ok(token) => token,
7587                Err(e) => match dlg.token(e) {
7588                    Ok(token) => token,
7589                    Err(e) => {
7590                        dlg.finished(false);
7591                        return Err(common::Error::MissingToken(e));
7592                    }
7593                },
7594            };
7595            request_value_reader
7596                .seek(std::io::SeekFrom::Start(0))
7597                .unwrap();
7598            let mut req_result = {
7599                let client = &self.hub.client;
7600                dlg.pre_request();
7601                let mut req_builder = hyper::Request::builder()
7602                    .method(hyper::Method::POST)
7603                    .uri(url.as_str())
7604                    .header(USER_AGENT, self.hub._user_agent.clone());
7605
7606                if let Some(token) = token.as_ref() {
7607                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7608                }
7609
7610                let request = req_builder
7611                    .header(CONTENT_TYPE, json_mime_type.to_string())
7612                    .header(CONTENT_LENGTH, request_size as u64)
7613                    .body(common::to_body(
7614                        request_value_reader.get_ref().clone().into(),
7615                    ));
7616
7617                client.request(request.unwrap()).await
7618            };
7619
7620            match req_result {
7621                Err(err) => {
7622                    if let common::Retry::After(d) = dlg.http_error(&err) {
7623                        sleep(d).await;
7624                        continue;
7625                    }
7626                    dlg.finished(false);
7627                    return Err(common::Error::HttpError(err));
7628                }
7629                Ok(res) => {
7630                    let (mut parts, body) = res.into_parts();
7631                    let mut body = common::Body::new(body);
7632                    if !parts.status.is_success() {
7633                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7634                        let error = serde_json::from_str(&common::to_string(&bytes));
7635                        let response = common::to_response(parts, bytes.into());
7636
7637                        if let common::Retry::After(d) =
7638                            dlg.http_failure(&response, error.as_ref().ok())
7639                        {
7640                            sleep(d).await;
7641                            continue;
7642                        }
7643
7644                        dlg.finished(false);
7645
7646                        return Err(match error {
7647                            Ok(value) => common::Error::BadRequest(value),
7648                            _ => common::Error::Failure(response),
7649                        });
7650                    }
7651                    let response = {
7652                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7653                        let encoded = common::to_string(&bytes);
7654                        match serde_json::from_str(&encoded) {
7655                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7656                            Err(error) => {
7657                                dlg.response_json_decode_error(&encoded, &error);
7658                                return Err(common::Error::JsonDecodeError(
7659                                    encoded.to_string(),
7660                                    error,
7661                                ));
7662                            }
7663                        }
7664                    };
7665
7666                    dlg.finished(true);
7667                    return Ok(response);
7668                }
7669            }
7670        }
7671    }
7672
7673    ///
7674    /// Sets the *request* property to the given value.
7675    ///
7676    /// Even though the property as already been set when instantiating this call,
7677    /// we provide this method for API completeness.
7678    pub fn request(mut self, new_value: OrdersCancelRequest) -> OrderCancelCall<'a, C> {
7679        self._request = new_value;
7680        self
7681    }
7682    /// The ID of the account that manages the order. This cannot be a multi-client account.
7683    ///
7684    /// Sets the *merchant id* path property to the given value.
7685    ///
7686    /// Even though the property as already been set when instantiating this call,
7687    /// we provide this method for API completeness.
7688    pub fn merchant_id(mut self, new_value: u64) -> OrderCancelCall<'a, C> {
7689        self._merchant_id = new_value;
7690        self
7691    }
7692    /// The ID of the order to cancel.
7693    ///
7694    /// Sets the *order id* path property to the given value.
7695    ///
7696    /// Even though the property as already been set when instantiating this call,
7697    /// we provide this method for API completeness.
7698    pub fn order_id(mut self, new_value: &str) -> OrderCancelCall<'a, C> {
7699        self._order_id = new_value.to_string();
7700        self
7701    }
7702    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7703    /// while executing the actual API request.
7704    ///
7705    /// ````text
7706    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7707    /// ````
7708    ///
7709    /// Sets the *delegate* property to the given value.
7710    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderCancelCall<'a, C> {
7711        self._delegate = Some(new_value);
7712        self
7713    }
7714
7715    /// Set any additional parameter of the query string used in the request.
7716    /// It should be used to set parameters which are not yet available through their own
7717    /// setters.
7718    ///
7719    /// Please note that this method must not be used to set any of the known parameters
7720    /// which have their own setter method. If done anyway, the request will fail.
7721    ///
7722    /// # Additional Parameters
7723    ///
7724    /// * *alt* (query-string) - Data format for the response.
7725    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7726    /// * *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.
7727    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7728    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7729    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7730    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7731    pub fn param<T>(mut self, name: T, value: T) -> OrderCancelCall<'a, C>
7732    where
7733        T: AsRef<str>,
7734    {
7735        self._additional_params
7736            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7737        self
7738    }
7739
7740    /// Identifies the authorization scope for the method you are building.
7741    ///
7742    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7743    /// [`Scope::Full`].
7744    ///
7745    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7746    /// tokens for more than one scope.
7747    ///
7748    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7749    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7750    /// sufficient, a read-write scope will do as well.
7751    pub fn add_scope<St>(mut self, scope: St) -> OrderCancelCall<'a, C>
7752    where
7753        St: AsRef<str>,
7754    {
7755        self._scopes.insert(String::from(scope.as_ref()));
7756        self
7757    }
7758    /// Identifies the authorization scope(s) for the method you are building.
7759    ///
7760    /// See [`Self::add_scope()`] for details.
7761    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderCancelCall<'a, C>
7762    where
7763        I: IntoIterator<Item = St>,
7764        St: AsRef<str>,
7765    {
7766        self._scopes
7767            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7768        self
7769    }
7770
7771    /// Removes all scopes, and no default scope will be used either.
7772    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7773    /// for details).
7774    pub fn clear_scopes(mut self) -> OrderCancelCall<'a, C> {
7775        self._scopes.clear();
7776        self
7777    }
7778}
7779
7780/// Cancels a line item, making a full refund.
7781///
7782/// A builder for the *cancellineitem* method supported by a *order* resource.
7783/// It is not used directly, but through a [`OrderMethods`] instance.
7784///
7785/// # Example
7786///
7787/// Instantiate a resource method builder
7788///
7789/// ```test_harness,no_run
7790/// # extern crate hyper;
7791/// # extern crate hyper_rustls;
7792/// # extern crate google_content2_sandbox as content2_sandbox;
7793/// use content2_sandbox::api::OrdersCancelLineItemRequest;
7794/// # async fn dox() {
7795/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7796///
7797/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7798/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7799/// #     .with_native_roots()
7800/// #     .unwrap()
7801/// #     .https_only()
7802/// #     .enable_http2()
7803/// #     .build();
7804///
7805/// # let executor = hyper_util::rt::TokioExecutor::new();
7806/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7807/// #     secret,
7808/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7809/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7810/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7811/// #     ),
7812/// # ).build().await.unwrap();
7813///
7814/// # let client = hyper_util::client::legacy::Client::builder(
7815/// #     hyper_util::rt::TokioExecutor::new()
7816/// # )
7817/// # .build(
7818/// #     hyper_rustls::HttpsConnectorBuilder::new()
7819/// #         .with_native_roots()
7820/// #         .unwrap()
7821/// #         .https_or_http()
7822/// #         .enable_http2()
7823/// #         .build()
7824/// # );
7825/// # let mut hub = ShoppingContent::new(client, auth);
7826/// // As the method needs a request, you would usually fill it with the desired information
7827/// // into the respective structure. Some of the parts shown here might not be applicable !
7828/// // Values shown here are possibly random and not representative !
7829/// let mut req = OrdersCancelLineItemRequest::default();
7830///
7831/// // You can configure optional parameters by calling the respective setters at will, and
7832/// // execute the final call using `doit()`.
7833/// // Values shown here are possibly random and not representative !
7834/// let result = hub.orders().cancellineitem(req, 81, "orderId")
7835///              .doit().await;
7836/// # }
7837/// ```
7838pub struct OrderCancellineitemCall<'a, C>
7839where
7840    C: 'a,
7841{
7842    hub: &'a ShoppingContent<C>,
7843    _request: OrdersCancelLineItemRequest,
7844    _merchant_id: u64,
7845    _order_id: String,
7846    _delegate: Option<&'a mut dyn common::Delegate>,
7847    _additional_params: HashMap<String, String>,
7848    _scopes: BTreeSet<String>,
7849}
7850
7851impl<'a, C> common::CallBuilder for OrderCancellineitemCall<'a, C> {}
7852
7853impl<'a, C> OrderCancellineitemCall<'a, C>
7854where
7855    C: common::Connector,
7856{
7857    /// Perform the operation you have build so far.
7858    pub async fn doit(
7859        mut self,
7860    ) -> common::Result<(common::Response, OrdersCancelLineItemResponse)> {
7861        use std::borrow::Cow;
7862        use std::io::{Read, Seek};
7863
7864        use common::{url::Params, ToParts};
7865        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7866
7867        let mut dd = common::DefaultDelegate;
7868        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7869        dlg.begin(common::MethodInfo {
7870            id: "content.orders.cancellineitem",
7871            http_method: hyper::Method::POST,
7872        });
7873
7874        for &field in ["alt", "merchantId", "orderId"].iter() {
7875            if self._additional_params.contains_key(field) {
7876                dlg.finished(false);
7877                return Err(common::Error::FieldClash(field));
7878            }
7879        }
7880
7881        let mut params = Params::with_capacity(5 + self._additional_params.len());
7882        params.push("merchantId", self._merchant_id.to_string());
7883        params.push("orderId", self._order_id);
7884
7885        params.extend(self._additional_params.iter());
7886
7887        params.push("alt", "json");
7888        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/cancelLineItem";
7889        if self._scopes.is_empty() {
7890            self._scopes.insert(Scope::Full.as_ref().to_string());
7891        }
7892
7893        #[allow(clippy::single_element_loop)]
7894        for &(find_this, param_name) in
7895            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
7896        {
7897            url = params.uri_replacement(url, param_name, find_this, false);
7898        }
7899        {
7900            let to_remove = ["orderId", "merchantId"];
7901            params.remove_params(&to_remove);
7902        }
7903
7904        let url = params.parse_with_url(&url);
7905
7906        let mut json_mime_type = mime::APPLICATION_JSON;
7907        let mut request_value_reader = {
7908            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7909            common::remove_json_null_values(&mut value);
7910            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7911            serde_json::to_writer(&mut dst, &value).unwrap();
7912            dst
7913        };
7914        let request_size = request_value_reader
7915            .seek(std::io::SeekFrom::End(0))
7916            .unwrap();
7917        request_value_reader
7918            .seek(std::io::SeekFrom::Start(0))
7919            .unwrap();
7920
7921        loop {
7922            let token = match self
7923                .hub
7924                .auth
7925                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7926                .await
7927            {
7928                Ok(token) => token,
7929                Err(e) => match dlg.token(e) {
7930                    Ok(token) => token,
7931                    Err(e) => {
7932                        dlg.finished(false);
7933                        return Err(common::Error::MissingToken(e));
7934                    }
7935                },
7936            };
7937            request_value_reader
7938                .seek(std::io::SeekFrom::Start(0))
7939                .unwrap();
7940            let mut req_result = {
7941                let client = &self.hub.client;
7942                dlg.pre_request();
7943                let mut req_builder = hyper::Request::builder()
7944                    .method(hyper::Method::POST)
7945                    .uri(url.as_str())
7946                    .header(USER_AGENT, self.hub._user_agent.clone());
7947
7948                if let Some(token) = token.as_ref() {
7949                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7950                }
7951
7952                let request = req_builder
7953                    .header(CONTENT_TYPE, json_mime_type.to_string())
7954                    .header(CONTENT_LENGTH, request_size as u64)
7955                    .body(common::to_body(
7956                        request_value_reader.get_ref().clone().into(),
7957                    ));
7958
7959                client.request(request.unwrap()).await
7960            };
7961
7962            match req_result {
7963                Err(err) => {
7964                    if let common::Retry::After(d) = dlg.http_error(&err) {
7965                        sleep(d).await;
7966                        continue;
7967                    }
7968                    dlg.finished(false);
7969                    return Err(common::Error::HttpError(err));
7970                }
7971                Ok(res) => {
7972                    let (mut parts, body) = res.into_parts();
7973                    let mut body = common::Body::new(body);
7974                    if !parts.status.is_success() {
7975                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7976                        let error = serde_json::from_str(&common::to_string(&bytes));
7977                        let response = common::to_response(parts, bytes.into());
7978
7979                        if let common::Retry::After(d) =
7980                            dlg.http_failure(&response, error.as_ref().ok())
7981                        {
7982                            sleep(d).await;
7983                            continue;
7984                        }
7985
7986                        dlg.finished(false);
7987
7988                        return Err(match error {
7989                            Ok(value) => common::Error::BadRequest(value),
7990                            _ => common::Error::Failure(response),
7991                        });
7992                    }
7993                    let response = {
7994                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7995                        let encoded = common::to_string(&bytes);
7996                        match serde_json::from_str(&encoded) {
7997                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7998                            Err(error) => {
7999                                dlg.response_json_decode_error(&encoded, &error);
8000                                return Err(common::Error::JsonDecodeError(
8001                                    encoded.to_string(),
8002                                    error,
8003                                ));
8004                            }
8005                        }
8006                    };
8007
8008                    dlg.finished(true);
8009                    return Ok(response);
8010                }
8011            }
8012        }
8013    }
8014
8015    ///
8016    /// Sets the *request* property to the given value.
8017    ///
8018    /// Even though the property as already been set when instantiating this call,
8019    /// we provide this method for API completeness.
8020    pub fn request(
8021        mut self,
8022        new_value: OrdersCancelLineItemRequest,
8023    ) -> OrderCancellineitemCall<'a, C> {
8024        self._request = new_value;
8025        self
8026    }
8027    /// The ID of the account that manages the order. This cannot be a multi-client account.
8028    ///
8029    /// Sets the *merchant id* path property to the given value.
8030    ///
8031    /// Even though the property as already been set when instantiating this call,
8032    /// we provide this method for API completeness.
8033    pub fn merchant_id(mut self, new_value: u64) -> OrderCancellineitemCall<'a, C> {
8034        self._merchant_id = new_value;
8035        self
8036    }
8037    /// The ID of the order.
8038    ///
8039    /// Sets the *order id* path property to the given value.
8040    ///
8041    /// Even though the property as already been set when instantiating this call,
8042    /// we provide this method for API completeness.
8043    pub fn order_id(mut self, new_value: &str) -> OrderCancellineitemCall<'a, C> {
8044        self._order_id = new_value.to_string();
8045        self
8046    }
8047    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8048    /// while executing the actual API request.
8049    ///
8050    /// ````text
8051    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8052    /// ````
8053    ///
8054    /// Sets the *delegate* property to the given value.
8055    pub fn delegate(
8056        mut self,
8057        new_value: &'a mut dyn common::Delegate,
8058    ) -> OrderCancellineitemCall<'a, C> {
8059        self._delegate = Some(new_value);
8060        self
8061    }
8062
8063    /// Set any additional parameter of the query string used in the request.
8064    /// It should be used to set parameters which are not yet available through their own
8065    /// setters.
8066    ///
8067    /// Please note that this method must not be used to set any of the known parameters
8068    /// which have their own setter method. If done anyway, the request will fail.
8069    ///
8070    /// # Additional Parameters
8071    ///
8072    /// * *alt* (query-string) - Data format for the response.
8073    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8074    /// * *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.
8075    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8076    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8077    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8078    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8079    pub fn param<T>(mut self, name: T, value: T) -> OrderCancellineitemCall<'a, C>
8080    where
8081        T: AsRef<str>,
8082    {
8083        self._additional_params
8084            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8085        self
8086    }
8087
8088    /// Identifies the authorization scope for the method you are building.
8089    ///
8090    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8091    /// [`Scope::Full`].
8092    ///
8093    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8094    /// tokens for more than one scope.
8095    ///
8096    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8097    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8098    /// sufficient, a read-write scope will do as well.
8099    pub fn add_scope<St>(mut self, scope: St) -> OrderCancellineitemCall<'a, C>
8100    where
8101        St: AsRef<str>,
8102    {
8103        self._scopes.insert(String::from(scope.as_ref()));
8104        self
8105    }
8106    /// Identifies the authorization scope(s) for the method you are building.
8107    ///
8108    /// See [`Self::add_scope()`] for details.
8109    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderCancellineitemCall<'a, C>
8110    where
8111        I: IntoIterator<Item = St>,
8112        St: AsRef<str>,
8113    {
8114        self._scopes
8115            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8116        self
8117    }
8118
8119    /// Removes all scopes, and no default scope will be used either.
8120    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8121    /// for details).
8122    pub fn clear_scopes(mut self) -> OrderCancellineitemCall<'a, C> {
8123        self._scopes.clear();
8124        self
8125    }
8126}
8127
8128/// Sandbox only. Cancels a test order for customer-initiated cancellation.
8129///
8130/// A builder for the *canceltestorderbycustomer* method supported by a *order* resource.
8131/// It is not used directly, but through a [`OrderMethods`] instance.
8132///
8133/// # Example
8134///
8135/// Instantiate a resource method builder
8136///
8137/// ```test_harness,no_run
8138/// # extern crate hyper;
8139/// # extern crate hyper_rustls;
8140/// # extern crate google_content2_sandbox as content2_sandbox;
8141/// use content2_sandbox::api::OrdersCancelTestOrderByCustomerRequest;
8142/// # async fn dox() {
8143/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8144///
8145/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8146/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8147/// #     .with_native_roots()
8148/// #     .unwrap()
8149/// #     .https_only()
8150/// #     .enable_http2()
8151/// #     .build();
8152///
8153/// # let executor = hyper_util::rt::TokioExecutor::new();
8154/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8155/// #     secret,
8156/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8157/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8158/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8159/// #     ),
8160/// # ).build().await.unwrap();
8161///
8162/// # let client = hyper_util::client::legacy::Client::builder(
8163/// #     hyper_util::rt::TokioExecutor::new()
8164/// # )
8165/// # .build(
8166/// #     hyper_rustls::HttpsConnectorBuilder::new()
8167/// #         .with_native_roots()
8168/// #         .unwrap()
8169/// #         .https_or_http()
8170/// #         .enable_http2()
8171/// #         .build()
8172/// # );
8173/// # let mut hub = ShoppingContent::new(client, auth);
8174/// // As the method needs a request, you would usually fill it with the desired information
8175/// // into the respective structure. Some of the parts shown here might not be applicable !
8176/// // Values shown here are possibly random and not representative !
8177/// let mut req = OrdersCancelTestOrderByCustomerRequest::default();
8178///
8179/// // You can configure optional parameters by calling the respective setters at will, and
8180/// // execute the final call using `doit()`.
8181/// // Values shown here are possibly random and not representative !
8182/// let result = hub.orders().canceltestorderbycustomer(req, 79, "orderId")
8183///              .doit().await;
8184/// # }
8185/// ```
8186pub struct OrderCanceltestorderbycustomerCall<'a, C>
8187where
8188    C: 'a,
8189{
8190    hub: &'a ShoppingContent<C>,
8191    _request: OrdersCancelTestOrderByCustomerRequest,
8192    _merchant_id: u64,
8193    _order_id: String,
8194    _delegate: Option<&'a mut dyn common::Delegate>,
8195    _additional_params: HashMap<String, String>,
8196    _scopes: BTreeSet<String>,
8197}
8198
8199impl<'a, C> common::CallBuilder for OrderCanceltestorderbycustomerCall<'a, C> {}
8200
8201impl<'a, C> OrderCanceltestorderbycustomerCall<'a, C>
8202where
8203    C: common::Connector,
8204{
8205    /// Perform the operation you have build so far.
8206    pub async fn doit(
8207        mut self,
8208    ) -> common::Result<(common::Response, OrdersCancelTestOrderByCustomerResponse)> {
8209        use std::borrow::Cow;
8210        use std::io::{Read, Seek};
8211
8212        use common::{url::Params, ToParts};
8213        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8214
8215        let mut dd = common::DefaultDelegate;
8216        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8217        dlg.begin(common::MethodInfo {
8218            id: "content.orders.canceltestorderbycustomer",
8219            http_method: hyper::Method::POST,
8220        });
8221
8222        for &field in ["alt", "merchantId", "orderId"].iter() {
8223            if self._additional_params.contains_key(field) {
8224                dlg.finished(false);
8225                return Err(common::Error::FieldClash(field));
8226            }
8227        }
8228
8229        let mut params = Params::with_capacity(5 + self._additional_params.len());
8230        params.push("merchantId", self._merchant_id.to_string());
8231        params.push("orderId", self._order_id);
8232
8233        params.extend(self._additional_params.iter());
8234
8235        params.push("alt", "json");
8236        let mut url =
8237            self.hub._base_url.clone() + "{merchantId}/testorders/{orderId}/cancelByCustomer";
8238        if self._scopes.is_empty() {
8239            self._scopes.insert(Scope::Full.as_ref().to_string());
8240        }
8241
8242        #[allow(clippy::single_element_loop)]
8243        for &(find_this, param_name) in
8244            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
8245        {
8246            url = params.uri_replacement(url, param_name, find_this, false);
8247        }
8248        {
8249            let to_remove = ["orderId", "merchantId"];
8250            params.remove_params(&to_remove);
8251        }
8252
8253        let url = params.parse_with_url(&url);
8254
8255        let mut json_mime_type = mime::APPLICATION_JSON;
8256        let mut request_value_reader = {
8257            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8258            common::remove_json_null_values(&mut value);
8259            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8260            serde_json::to_writer(&mut dst, &value).unwrap();
8261            dst
8262        };
8263        let request_size = request_value_reader
8264            .seek(std::io::SeekFrom::End(0))
8265            .unwrap();
8266        request_value_reader
8267            .seek(std::io::SeekFrom::Start(0))
8268            .unwrap();
8269
8270        loop {
8271            let token = match self
8272                .hub
8273                .auth
8274                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8275                .await
8276            {
8277                Ok(token) => token,
8278                Err(e) => match dlg.token(e) {
8279                    Ok(token) => token,
8280                    Err(e) => {
8281                        dlg.finished(false);
8282                        return Err(common::Error::MissingToken(e));
8283                    }
8284                },
8285            };
8286            request_value_reader
8287                .seek(std::io::SeekFrom::Start(0))
8288                .unwrap();
8289            let mut req_result = {
8290                let client = &self.hub.client;
8291                dlg.pre_request();
8292                let mut req_builder = hyper::Request::builder()
8293                    .method(hyper::Method::POST)
8294                    .uri(url.as_str())
8295                    .header(USER_AGENT, self.hub._user_agent.clone());
8296
8297                if let Some(token) = token.as_ref() {
8298                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8299                }
8300
8301                let request = req_builder
8302                    .header(CONTENT_TYPE, json_mime_type.to_string())
8303                    .header(CONTENT_LENGTH, request_size as u64)
8304                    .body(common::to_body(
8305                        request_value_reader.get_ref().clone().into(),
8306                    ));
8307
8308                client.request(request.unwrap()).await
8309            };
8310
8311            match req_result {
8312                Err(err) => {
8313                    if let common::Retry::After(d) = dlg.http_error(&err) {
8314                        sleep(d).await;
8315                        continue;
8316                    }
8317                    dlg.finished(false);
8318                    return Err(common::Error::HttpError(err));
8319                }
8320                Ok(res) => {
8321                    let (mut parts, body) = res.into_parts();
8322                    let mut body = common::Body::new(body);
8323                    if !parts.status.is_success() {
8324                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8325                        let error = serde_json::from_str(&common::to_string(&bytes));
8326                        let response = common::to_response(parts, bytes.into());
8327
8328                        if let common::Retry::After(d) =
8329                            dlg.http_failure(&response, error.as_ref().ok())
8330                        {
8331                            sleep(d).await;
8332                            continue;
8333                        }
8334
8335                        dlg.finished(false);
8336
8337                        return Err(match error {
8338                            Ok(value) => common::Error::BadRequest(value),
8339                            _ => common::Error::Failure(response),
8340                        });
8341                    }
8342                    let response = {
8343                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8344                        let encoded = common::to_string(&bytes);
8345                        match serde_json::from_str(&encoded) {
8346                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8347                            Err(error) => {
8348                                dlg.response_json_decode_error(&encoded, &error);
8349                                return Err(common::Error::JsonDecodeError(
8350                                    encoded.to_string(),
8351                                    error,
8352                                ));
8353                            }
8354                        }
8355                    };
8356
8357                    dlg.finished(true);
8358                    return Ok(response);
8359                }
8360            }
8361        }
8362    }
8363
8364    ///
8365    /// Sets the *request* property to the given value.
8366    ///
8367    /// Even though the property as already been set when instantiating this call,
8368    /// we provide this method for API completeness.
8369    pub fn request(
8370        mut self,
8371        new_value: OrdersCancelTestOrderByCustomerRequest,
8372    ) -> OrderCanceltestorderbycustomerCall<'a, C> {
8373        self._request = new_value;
8374        self
8375    }
8376    /// The ID of the account that manages the order. This cannot be a multi-client account.
8377    ///
8378    /// Sets the *merchant id* path property to the given value.
8379    ///
8380    /// Even though the property as already been set when instantiating this call,
8381    /// we provide this method for API completeness.
8382    pub fn merchant_id(mut self, new_value: u64) -> OrderCanceltestorderbycustomerCall<'a, C> {
8383        self._merchant_id = new_value;
8384        self
8385    }
8386    /// The ID of the test order to cancel.
8387    ///
8388    /// Sets the *order id* path property to the given value.
8389    ///
8390    /// Even though the property as already been set when instantiating this call,
8391    /// we provide this method for API completeness.
8392    pub fn order_id(mut self, new_value: &str) -> OrderCanceltestorderbycustomerCall<'a, C> {
8393        self._order_id = new_value.to_string();
8394        self
8395    }
8396    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8397    /// while executing the actual API request.
8398    ///
8399    /// ````text
8400    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8401    /// ````
8402    ///
8403    /// Sets the *delegate* property to the given value.
8404    pub fn delegate(
8405        mut self,
8406        new_value: &'a mut dyn common::Delegate,
8407    ) -> OrderCanceltestorderbycustomerCall<'a, C> {
8408        self._delegate = Some(new_value);
8409        self
8410    }
8411
8412    /// Set any additional parameter of the query string used in the request.
8413    /// It should be used to set parameters which are not yet available through their own
8414    /// setters.
8415    ///
8416    /// Please note that this method must not be used to set any of the known parameters
8417    /// which have their own setter method. If done anyway, the request will fail.
8418    ///
8419    /// # Additional Parameters
8420    ///
8421    /// * *alt* (query-string) - Data format for the response.
8422    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8423    /// * *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.
8424    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8425    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8426    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8427    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8428    pub fn param<T>(mut self, name: T, value: T) -> OrderCanceltestorderbycustomerCall<'a, C>
8429    where
8430        T: AsRef<str>,
8431    {
8432        self._additional_params
8433            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8434        self
8435    }
8436
8437    /// Identifies the authorization scope for the method you are building.
8438    ///
8439    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8440    /// [`Scope::Full`].
8441    ///
8442    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8443    /// tokens for more than one scope.
8444    ///
8445    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8446    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8447    /// sufficient, a read-write scope will do as well.
8448    pub fn add_scope<St>(mut self, scope: St) -> OrderCanceltestorderbycustomerCall<'a, C>
8449    where
8450        St: AsRef<str>,
8451    {
8452        self._scopes.insert(String::from(scope.as_ref()));
8453        self
8454    }
8455    /// Identifies the authorization scope(s) for the method you are building.
8456    ///
8457    /// See [`Self::add_scope()`] for details.
8458    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderCanceltestorderbycustomerCall<'a, C>
8459    where
8460        I: IntoIterator<Item = St>,
8461        St: AsRef<str>,
8462    {
8463        self._scopes
8464            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8465        self
8466    }
8467
8468    /// Removes all scopes, and no default scope will be used either.
8469    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8470    /// for details).
8471    pub fn clear_scopes(mut self) -> OrderCanceltestorderbycustomerCall<'a, C> {
8472        self._scopes.clear();
8473        self
8474    }
8475}
8476
8477/// Sandbox only. Creates a test order.
8478///
8479/// A builder for the *createtestorder* method supported by a *order* resource.
8480/// It is not used directly, but through a [`OrderMethods`] instance.
8481///
8482/// # Example
8483///
8484/// Instantiate a resource method builder
8485///
8486/// ```test_harness,no_run
8487/// # extern crate hyper;
8488/// # extern crate hyper_rustls;
8489/// # extern crate google_content2_sandbox as content2_sandbox;
8490/// use content2_sandbox::api::OrdersCreateTestOrderRequest;
8491/// # async fn dox() {
8492/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8493///
8494/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8495/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8496/// #     .with_native_roots()
8497/// #     .unwrap()
8498/// #     .https_only()
8499/// #     .enable_http2()
8500/// #     .build();
8501///
8502/// # let executor = hyper_util::rt::TokioExecutor::new();
8503/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8504/// #     secret,
8505/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8506/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8507/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8508/// #     ),
8509/// # ).build().await.unwrap();
8510///
8511/// # let client = hyper_util::client::legacy::Client::builder(
8512/// #     hyper_util::rt::TokioExecutor::new()
8513/// # )
8514/// # .build(
8515/// #     hyper_rustls::HttpsConnectorBuilder::new()
8516/// #         .with_native_roots()
8517/// #         .unwrap()
8518/// #         .https_or_http()
8519/// #         .enable_http2()
8520/// #         .build()
8521/// # );
8522/// # let mut hub = ShoppingContent::new(client, auth);
8523/// // As the method needs a request, you would usually fill it with the desired information
8524/// // into the respective structure. Some of the parts shown here might not be applicable !
8525/// // Values shown here are possibly random and not representative !
8526/// let mut req = OrdersCreateTestOrderRequest::default();
8527///
8528/// // You can configure optional parameters by calling the respective setters at will, and
8529/// // execute the final call using `doit()`.
8530/// // Values shown here are possibly random and not representative !
8531/// let result = hub.orders().createtestorder(req, 99)
8532///              .doit().await;
8533/// # }
8534/// ```
8535pub struct OrderCreatetestorderCall<'a, C>
8536where
8537    C: 'a,
8538{
8539    hub: &'a ShoppingContent<C>,
8540    _request: OrdersCreateTestOrderRequest,
8541    _merchant_id: u64,
8542    _delegate: Option<&'a mut dyn common::Delegate>,
8543    _additional_params: HashMap<String, String>,
8544    _scopes: BTreeSet<String>,
8545}
8546
8547impl<'a, C> common::CallBuilder for OrderCreatetestorderCall<'a, C> {}
8548
8549impl<'a, C> OrderCreatetestorderCall<'a, C>
8550where
8551    C: common::Connector,
8552{
8553    /// Perform the operation you have build so far.
8554    pub async fn doit(
8555        mut self,
8556    ) -> common::Result<(common::Response, OrdersCreateTestOrderResponse)> {
8557        use std::borrow::Cow;
8558        use std::io::{Read, Seek};
8559
8560        use common::{url::Params, ToParts};
8561        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8562
8563        let mut dd = common::DefaultDelegate;
8564        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8565        dlg.begin(common::MethodInfo {
8566            id: "content.orders.createtestorder",
8567            http_method: hyper::Method::POST,
8568        });
8569
8570        for &field in ["alt", "merchantId"].iter() {
8571            if self._additional_params.contains_key(field) {
8572                dlg.finished(false);
8573                return Err(common::Error::FieldClash(field));
8574            }
8575        }
8576
8577        let mut params = Params::with_capacity(4 + self._additional_params.len());
8578        params.push("merchantId", self._merchant_id.to_string());
8579
8580        params.extend(self._additional_params.iter());
8581
8582        params.push("alt", "json");
8583        let mut url = self.hub._base_url.clone() + "{merchantId}/testorders";
8584        if self._scopes.is_empty() {
8585            self._scopes.insert(Scope::Full.as_ref().to_string());
8586        }
8587
8588        #[allow(clippy::single_element_loop)]
8589        for &(find_this, param_name) in [("{merchantId}", "merchantId")].iter() {
8590            url = params.uri_replacement(url, param_name, find_this, false);
8591        }
8592        {
8593            let to_remove = ["merchantId"];
8594            params.remove_params(&to_remove);
8595        }
8596
8597        let url = params.parse_with_url(&url);
8598
8599        let mut json_mime_type = mime::APPLICATION_JSON;
8600        let mut request_value_reader = {
8601            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8602            common::remove_json_null_values(&mut value);
8603            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8604            serde_json::to_writer(&mut dst, &value).unwrap();
8605            dst
8606        };
8607        let request_size = request_value_reader
8608            .seek(std::io::SeekFrom::End(0))
8609            .unwrap();
8610        request_value_reader
8611            .seek(std::io::SeekFrom::Start(0))
8612            .unwrap();
8613
8614        loop {
8615            let token = match self
8616                .hub
8617                .auth
8618                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8619                .await
8620            {
8621                Ok(token) => token,
8622                Err(e) => match dlg.token(e) {
8623                    Ok(token) => token,
8624                    Err(e) => {
8625                        dlg.finished(false);
8626                        return Err(common::Error::MissingToken(e));
8627                    }
8628                },
8629            };
8630            request_value_reader
8631                .seek(std::io::SeekFrom::Start(0))
8632                .unwrap();
8633            let mut req_result = {
8634                let client = &self.hub.client;
8635                dlg.pre_request();
8636                let mut req_builder = hyper::Request::builder()
8637                    .method(hyper::Method::POST)
8638                    .uri(url.as_str())
8639                    .header(USER_AGENT, self.hub._user_agent.clone());
8640
8641                if let Some(token) = token.as_ref() {
8642                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8643                }
8644
8645                let request = req_builder
8646                    .header(CONTENT_TYPE, json_mime_type.to_string())
8647                    .header(CONTENT_LENGTH, request_size as u64)
8648                    .body(common::to_body(
8649                        request_value_reader.get_ref().clone().into(),
8650                    ));
8651
8652                client.request(request.unwrap()).await
8653            };
8654
8655            match req_result {
8656                Err(err) => {
8657                    if let common::Retry::After(d) = dlg.http_error(&err) {
8658                        sleep(d).await;
8659                        continue;
8660                    }
8661                    dlg.finished(false);
8662                    return Err(common::Error::HttpError(err));
8663                }
8664                Ok(res) => {
8665                    let (mut parts, body) = res.into_parts();
8666                    let mut body = common::Body::new(body);
8667                    if !parts.status.is_success() {
8668                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8669                        let error = serde_json::from_str(&common::to_string(&bytes));
8670                        let response = common::to_response(parts, bytes.into());
8671
8672                        if let common::Retry::After(d) =
8673                            dlg.http_failure(&response, error.as_ref().ok())
8674                        {
8675                            sleep(d).await;
8676                            continue;
8677                        }
8678
8679                        dlg.finished(false);
8680
8681                        return Err(match error {
8682                            Ok(value) => common::Error::BadRequest(value),
8683                            _ => common::Error::Failure(response),
8684                        });
8685                    }
8686                    let response = {
8687                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8688                        let encoded = common::to_string(&bytes);
8689                        match serde_json::from_str(&encoded) {
8690                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8691                            Err(error) => {
8692                                dlg.response_json_decode_error(&encoded, &error);
8693                                return Err(common::Error::JsonDecodeError(
8694                                    encoded.to_string(),
8695                                    error,
8696                                ));
8697                            }
8698                        }
8699                    };
8700
8701                    dlg.finished(true);
8702                    return Ok(response);
8703                }
8704            }
8705        }
8706    }
8707
8708    ///
8709    /// Sets the *request* property to the given value.
8710    ///
8711    /// Even though the property as already been set when instantiating this call,
8712    /// we provide this method for API completeness.
8713    pub fn request(
8714        mut self,
8715        new_value: OrdersCreateTestOrderRequest,
8716    ) -> OrderCreatetestorderCall<'a, C> {
8717        self._request = new_value;
8718        self
8719    }
8720    /// The ID of the account that should manage the order. This cannot be a multi-client account.
8721    ///
8722    /// Sets the *merchant id* path property to the given value.
8723    ///
8724    /// Even though the property as already been set when instantiating this call,
8725    /// we provide this method for API completeness.
8726    pub fn merchant_id(mut self, new_value: u64) -> OrderCreatetestorderCall<'a, C> {
8727        self._merchant_id = new_value;
8728        self
8729    }
8730    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8731    /// while executing the actual API request.
8732    ///
8733    /// ````text
8734    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8735    /// ````
8736    ///
8737    /// Sets the *delegate* property to the given value.
8738    pub fn delegate(
8739        mut self,
8740        new_value: &'a mut dyn common::Delegate,
8741    ) -> OrderCreatetestorderCall<'a, C> {
8742        self._delegate = Some(new_value);
8743        self
8744    }
8745
8746    /// Set any additional parameter of the query string used in the request.
8747    /// It should be used to set parameters which are not yet available through their own
8748    /// setters.
8749    ///
8750    /// Please note that this method must not be used to set any of the known parameters
8751    /// which have their own setter method. If done anyway, the request will fail.
8752    ///
8753    /// # Additional Parameters
8754    ///
8755    /// * *alt* (query-string) - Data format for the response.
8756    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8757    /// * *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.
8758    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8759    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8760    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8761    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8762    pub fn param<T>(mut self, name: T, value: T) -> OrderCreatetestorderCall<'a, C>
8763    where
8764        T: AsRef<str>,
8765    {
8766        self._additional_params
8767            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8768        self
8769    }
8770
8771    /// Identifies the authorization scope for the method you are building.
8772    ///
8773    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8774    /// [`Scope::Full`].
8775    ///
8776    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8777    /// tokens for more than one scope.
8778    ///
8779    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8780    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8781    /// sufficient, a read-write scope will do as well.
8782    pub fn add_scope<St>(mut self, scope: St) -> OrderCreatetestorderCall<'a, C>
8783    where
8784        St: AsRef<str>,
8785    {
8786        self._scopes.insert(String::from(scope.as_ref()));
8787        self
8788    }
8789    /// Identifies the authorization scope(s) for the method you are building.
8790    ///
8791    /// See [`Self::add_scope()`] for details.
8792    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderCreatetestorderCall<'a, C>
8793    where
8794        I: IntoIterator<Item = St>,
8795        St: AsRef<str>,
8796    {
8797        self._scopes
8798            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8799        self
8800    }
8801
8802    /// Removes all scopes, and no default scope will be used either.
8803    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8804    /// for details).
8805    pub fn clear_scopes(mut self) -> OrderCreatetestorderCall<'a, C> {
8806        self._scopes.clear();
8807        self
8808    }
8809}
8810
8811/// Sandbox only. Creates a test return.
8812///
8813/// A builder for the *createtestreturn* method supported by a *order* resource.
8814/// It is not used directly, but through a [`OrderMethods`] instance.
8815///
8816/// # Example
8817///
8818/// Instantiate a resource method builder
8819///
8820/// ```test_harness,no_run
8821/// # extern crate hyper;
8822/// # extern crate hyper_rustls;
8823/// # extern crate google_content2_sandbox as content2_sandbox;
8824/// use content2_sandbox::api::OrdersCreateTestReturnRequest;
8825/// # async fn dox() {
8826/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8827///
8828/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8829/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8830/// #     .with_native_roots()
8831/// #     .unwrap()
8832/// #     .https_only()
8833/// #     .enable_http2()
8834/// #     .build();
8835///
8836/// # let executor = hyper_util::rt::TokioExecutor::new();
8837/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8838/// #     secret,
8839/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8840/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8841/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8842/// #     ),
8843/// # ).build().await.unwrap();
8844///
8845/// # let client = hyper_util::client::legacy::Client::builder(
8846/// #     hyper_util::rt::TokioExecutor::new()
8847/// # )
8848/// # .build(
8849/// #     hyper_rustls::HttpsConnectorBuilder::new()
8850/// #         .with_native_roots()
8851/// #         .unwrap()
8852/// #         .https_or_http()
8853/// #         .enable_http2()
8854/// #         .build()
8855/// # );
8856/// # let mut hub = ShoppingContent::new(client, auth);
8857/// // As the method needs a request, you would usually fill it with the desired information
8858/// // into the respective structure. Some of the parts shown here might not be applicable !
8859/// // Values shown here are possibly random and not representative !
8860/// let mut req = OrdersCreateTestReturnRequest::default();
8861///
8862/// // You can configure optional parameters by calling the respective setters at will, and
8863/// // execute the final call using `doit()`.
8864/// // Values shown here are possibly random and not representative !
8865/// let result = hub.orders().createtestreturn(req, 5, "orderId")
8866///              .doit().await;
8867/// # }
8868/// ```
8869pub struct OrderCreatetestreturnCall<'a, C>
8870where
8871    C: 'a,
8872{
8873    hub: &'a ShoppingContent<C>,
8874    _request: OrdersCreateTestReturnRequest,
8875    _merchant_id: u64,
8876    _order_id: String,
8877    _delegate: Option<&'a mut dyn common::Delegate>,
8878    _additional_params: HashMap<String, String>,
8879    _scopes: BTreeSet<String>,
8880}
8881
8882impl<'a, C> common::CallBuilder for OrderCreatetestreturnCall<'a, C> {}
8883
8884impl<'a, C> OrderCreatetestreturnCall<'a, C>
8885where
8886    C: common::Connector,
8887{
8888    /// Perform the operation you have build so far.
8889    pub async fn doit(
8890        mut self,
8891    ) -> common::Result<(common::Response, OrdersCreateTestReturnResponse)> {
8892        use std::borrow::Cow;
8893        use std::io::{Read, Seek};
8894
8895        use common::{url::Params, ToParts};
8896        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8897
8898        let mut dd = common::DefaultDelegate;
8899        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8900        dlg.begin(common::MethodInfo {
8901            id: "content.orders.createtestreturn",
8902            http_method: hyper::Method::POST,
8903        });
8904
8905        for &field in ["alt", "merchantId", "orderId"].iter() {
8906            if self._additional_params.contains_key(field) {
8907                dlg.finished(false);
8908                return Err(common::Error::FieldClash(field));
8909            }
8910        }
8911
8912        let mut params = Params::with_capacity(5 + self._additional_params.len());
8913        params.push("merchantId", self._merchant_id.to_string());
8914        params.push("orderId", self._order_id);
8915
8916        params.extend(self._additional_params.iter());
8917
8918        params.push("alt", "json");
8919        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/testreturn";
8920        if self._scopes.is_empty() {
8921            self._scopes.insert(Scope::Full.as_ref().to_string());
8922        }
8923
8924        #[allow(clippy::single_element_loop)]
8925        for &(find_this, param_name) in
8926            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
8927        {
8928            url = params.uri_replacement(url, param_name, find_this, false);
8929        }
8930        {
8931            let to_remove = ["orderId", "merchantId"];
8932            params.remove_params(&to_remove);
8933        }
8934
8935        let url = params.parse_with_url(&url);
8936
8937        let mut json_mime_type = mime::APPLICATION_JSON;
8938        let mut request_value_reader = {
8939            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8940            common::remove_json_null_values(&mut value);
8941            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8942            serde_json::to_writer(&mut dst, &value).unwrap();
8943            dst
8944        };
8945        let request_size = request_value_reader
8946            .seek(std::io::SeekFrom::End(0))
8947            .unwrap();
8948        request_value_reader
8949            .seek(std::io::SeekFrom::Start(0))
8950            .unwrap();
8951
8952        loop {
8953            let token = match self
8954                .hub
8955                .auth
8956                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8957                .await
8958            {
8959                Ok(token) => token,
8960                Err(e) => match dlg.token(e) {
8961                    Ok(token) => token,
8962                    Err(e) => {
8963                        dlg.finished(false);
8964                        return Err(common::Error::MissingToken(e));
8965                    }
8966                },
8967            };
8968            request_value_reader
8969                .seek(std::io::SeekFrom::Start(0))
8970                .unwrap();
8971            let mut req_result = {
8972                let client = &self.hub.client;
8973                dlg.pre_request();
8974                let mut req_builder = hyper::Request::builder()
8975                    .method(hyper::Method::POST)
8976                    .uri(url.as_str())
8977                    .header(USER_AGENT, self.hub._user_agent.clone());
8978
8979                if let Some(token) = token.as_ref() {
8980                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8981                }
8982
8983                let request = req_builder
8984                    .header(CONTENT_TYPE, json_mime_type.to_string())
8985                    .header(CONTENT_LENGTH, request_size as u64)
8986                    .body(common::to_body(
8987                        request_value_reader.get_ref().clone().into(),
8988                    ));
8989
8990                client.request(request.unwrap()).await
8991            };
8992
8993            match req_result {
8994                Err(err) => {
8995                    if let common::Retry::After(d) = dlg.http_error(&err) {
8996                        sleep(d).await;
8997                        continue;
8998                    }
8999                    dlg.finished(false);
9000                    return Err(common::Error::HttpError(err));
9001                }
9002                Ok(res) => {
9003                    let (mut parts, body) = res.into_parts();
9004                    let mut body = common::Body::new(body);
9005                    if !parts.status.is_success() {
9006                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9007                        let error = serde_json::from_str(&common::to_string(&bytes));
9008                        let response = common::to_response(parts, bytes.into());
9009
9010                        if let common::Retry::After(d) =
9011                            dlg.http_failure(&response, error.as_ref().ok())
9012                        {
9013                            sleep(d).await;
9014                            continue;
9015                        }
9016
9017                        dlg.finished(false);
9018
9019                        return Err(match error {
9020                            Ok(value) => common::Error::BadRequest(value),
9021                            _ => common::Error::Failure(response),
9022                        });
9023                    }
9024                    let response = {
9025                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9026                        let encoded = common::to_string(&bytes);
9027                        match serde_json::from_str(&encoded) {
9028                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9029                            Err(error) => {
9030                                dlg.response_json_decode_error(&encoded, &error);
9031                                return Err(common::Error::JsonDecodeError(
9032                                    encoded.to_string(),
9033                                    error,
9034                                ));
9035                            }
9036                        }
9037                    };
9038
9039                    dlg.finished(true);
9040                    return Ok(response);
9041                }
9042            }
9043        }
9044    }
9045
9046    ///
9047    /// Sets the *request* property to the given value.
9048    ///
9049    /// Even though the property as already been set when instantiating this call,
9050    /// we provide this method for API completeness.
9051    pub fn request(
9052        mut self,
9053        new_value: OrdersCreateTestReturnRequest,
9054    ) -> OrderCreatetestreturnCall<'a, C> {
9055        self._request = new_value;
9056        self
9057    }
9058    /// The ID of the account that manages the order. This cannot be a multi-client account.
9059    ///
9060    /// Sets the *merchant id* path property to the given value.
9061    ///
9062    /// Even though the property as already been set when instantiating this call,
9063    /// we provide this method for API completeness.
9064    pub fn merchant_id(mut self, new_value: u64) -> OrderCreatetestreturnCall<'a, C> {
9065        self._merchant_id = new_value;
9066        self
9067    }
9068    /// The ID of the order.
9069    ///
9070    /// Sets the *order id* path property to the given value.
9071    ///
9072    /// Even though the property as already been set when instantiating this call,
9073    /// we provide this method for API completeness.
9074    pub fn order_id(mut self, new_value: &str) -> OrderCreatetestreturnCall<'a, C> {
9075        self._order_id = new_value.to_string();
9076        self
9077    }
9078    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9079    /// while executing the actual API request.
9080    ///
9081    /// ````text
9082    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9083    /// ````
9084    ///
9085    /// Sets the *delegate* property to the given value.
9086    pub fn delegate(
9087        mut self,
9088        new_value: &'a mut dyn common::Delegate,
9089    ) -> OrderCreatetestreturnCall<'a, C> {
9090        self._delegate = Some(new_value);
9091        self
9092    }
9093
9094    /// Set any additional parameter of the query string used in the request.
9095    /// It should be used to set parameters which are not yet available through their own
9096    /// setters.
9097    ///
9098    /// Please note that this method must not be used to set any of the known parameters
9099    /// which have their own setter method. If done anyway, the request will fail.
9100    ///
9101    /// # Additional Parameters
9102    ///
9103    /// * *alt* (query-string) - Data format for the response.
9104    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9105    /// * *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.
9106    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9107    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9108    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9109    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9110    pub fn param<T>(mut self, name: T, value: T) -> OrderCreatetestreturnCall<'a, C>
9111    where
9112        T: AsRef<str>,
9113    {
9114        self._additional_params
9115            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9116        self
9117    }
9118
9119    /// Identifies the authorization scope for the method you are building.
9120    ///
9121    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9122    /// [`Scope::Full`].
9123    ///
9124    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9125    /// tokens for more than one scope.
9126    ///
9127    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9128    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9129    /// sufficient, a read-write scope will do as well.
9130    pub fn add_scope<St>(mut self, scope: St) -> OrderCreatetestreturnCall<'a, C>
9131    where
9132        St: AsRef<str>,
9133    {
9134        self._scopes.insert(String::from(scope.as_ref()));
9135        self
9136    }
9137    /// Identifies the authorization scope(s) for the method you are building.
9138    ///
9139    /// See [`Self::add_scope()`] for details.
9140    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderCreatetestreturnCall<'a, C>
9141    where
9142        I: IntoIterator<Item = St>,
9143        St: AsRef<str>,
9144    {
9145        self._scopes
9146            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9147        self
9148    }
9149
9150    /// Removes all scopes, and no default scope will be used either.
9151    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9152    /// for details).
9153    pub fn clear_scopes(mut self) -> OrderCreatetestreturnCall<'a, C> {
9154        self._scopes.clear();
9155        self
9156    }
9157}
9158
9159/// Retrieves or modifies multiple orders in a single request.
9160///
9161/// A builder for the *custombatch* method supported by a *order* resource.
9162/// It is not used directly, but through a [`OrderMethods`] instance.
9163///
9164/// # Example
9165///
9166/// Instantiate a resource method builder
9167///
9168/// ```test_harness,no_run
9169/// # extern crate hyper;
9170/// # extern crate hyper_rustls;
9171/// # extern crate google_content2_sandbox as content2_sandbox;
9172/// use content2_sandbox::api::OrdersCustomBatchRequest;
9173/// # async fn dox() {
9174/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9175///
9176/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9177/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9178/// #     .with_native_roots()
9179/// #     .unwrap()
9180/// #     .https_only()
9181/// #     .enable_http2()
9182/// #     .build();
9183///
9184/// # let executor = hyper_util::rt::TokioExecutor::new();
9185/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9186/// #     secret,
9187/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9188/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9189/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9190/// #     ),
9191/// # ).build().await.unwrap();
9192///
9193/// # let client = hyper_util::client::legacy::Client::builder(
9194/// #     hyper_util::rt::TokioExecutor::new()
9195/// # )
9196/// # .build(
9197/// #     hyper_rustls::HttpsConnectorBuilder::new()
9198/// #         .with_native_roots()
9199/// #         .unwrap()
9200/// #         .https_or_http()
9201/// #         .enable_http2()
9202/// #         .build()
9203/// # );
9204/// # let mut hub = ShoppingContent::new(client, auth);
9205/// // As the method needs a request, you would usually fill it with the desired information
9206/// // into the respective structure. Some of the parts shown here might not be applicable !
9207/// // Values shown here are possibly random and not representative !
9208/// let mut req = OrdersCustomBatchRequest::default();
9209///
9210/// // You can configure optional parameters by calling the respective setters at will, and
9211/// // execute the final call using `doit()`.
9212/// // Values shown here are possibly random and not representative !
9213/// let result = hub.orders().custombatch(req)
9214///              .doit().await;
9215/// # }
9216/// ```
9217pub struct OrderCustombatchCall<'a, C>
9218where
9219    C: 'a,
9220{
9221    hub: &'a ShoppingContent<C>,
9222    _request: OrdersCustomBatchRequest,
9223    _delegate: Option<&'a mut dyn common::Delegate>,
9224    _additional_params: HashMap<String, String>,
9225    _scopes: BTreeSet<String>,
9226}
9227
9228impl<'a, C> common::CallBuilder for OrderCustombatchCall<'a, C> {}
9229
9230impl<'a, C> OrderCustombatchCall<'a, C>
9231where
9232    C: common::Connector,
9233{
9234    /// Perform the operation you have build so far.
9235    pub async fn doit(mut self) -> common::Result<(common::Response, OrdersCustomBatchResponse)> {
9236        use std::borrow::Cow;
9237        use std::io::{Read, Seek};
9238
9239        use common::{url::Params, ToParts};
9240        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9241
9242        let mut dd = common::DefaultDelegate;
9243        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9244        dlg.begin(common::MethodInfo {
9245            id: "content.orders.custombatch",
9246            http_method: hyper::Method::POST,
9247        });
9248
9249        for &field in ["alt"].iter() {
9250            if self._additional_params.contains_key(field) {
9251                dlg.finished(false);
9252                return Err(common::Error::FieldClash(field));
9253            }
9254        }
9255
9256        let mut params = Params::with_capacity(3 + self._additional_params.len());
9257
9258        params.extend(self._additional_params.iter());
9259
9260        params.push("alt", "json");
9261        let mut url = self.hub._base_url.clone() + "orders/batch";
9262        if self._scopes.is_empty() {
9263            self._scopes.insert(Scope::Full.as_ref().to_string());
9264        }
9265
9266        let url = params.parse_with_url(&url);
9267
9268        let mut json_mime_type = mime::APPLICATION_JSON;
9269        let mut request_value_reader = {
9270            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9271            common::remove_json_null_values(&mut value);
9272            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9273            serde_json::to_writer(&mut dst, &value).unwrap();
9274            dst
9275        };
9276        let request_size = request_value_reader
9277            .seek(std::io::SeekFrom::End(0))
9278            .unwrap();
9279        request_value_reader
9280            .seek(std::io::SeekFrom::Start(0))
9281            .unwrap();
9282
9283        loop {
9284            let token = match self
9285                .hub
9286                .auth
9287                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9288                .await
9289            {
9290                Ok(token) => token,
9291                Err(e) => match dlg.token(e) {
9292                    Ok(token) => token,
9293                    Err(e) => {
9294                        dlg.finished(false);
9295                        return Err(common::Error::MissingToken(e));
9296                    }
9297                },
9298            };
9299            request_value_reader
9300                .seek(std::io::SeekFrom::Start(0))
9301                .unwrap();
9302            let mut req_result = {
9303                let client = &self.hub.client;
9304                dlg.pre_request();
9305                let mut req_builder = hyper::Request::builder()
9306                    .method(hyper::Method::POST)
9307                    .uri(url.as_str())
9308                    .header(USER_AGENT, self.hub._user_agent.clone());
9309
9310                if let Some(token) = token.as_ref() {
9311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9312                }
9313
9314                let request = req_builder
9315                    .header(CONTENT_TYPE, json_mime_type.to_string())
9316                    .header(CONTENT_LENGTH, request_size as u64)
9317                    .body(common::to_body(
9318                        request_value_reader.get_ref().clone().into(),
9319                    ));
9320
9321                client.request(request.unwrap()).await
9322            };
9323
9324            match req_result {
9325                Err(err) => {
9326                    if let common::Retry::After(d) = dlg.http_error(&err) {
9327                        sleep(d).await;
9328                        continue;
9329                    }
9330                    dlg.finished(false);
9331                    return Err(common::Error::HttpError(err));
9332                }
9333                Ok(res) => {
9334                    let (mut parts, body) = res.into_parts();
9335                    let mut body = common::Body::new(body);
9336                    if !parts.status.is_success() {
9337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9338                        let error = serde_json::from_str(&common::to_string(&bytes));
9339                        let response = common::to_response(parts, bytes.into());
9340
9341                        if let common::Retry::After(d) =
9342                            dlg.http_failure(&response, error.as_ref().ok())
9343                        {
9344                            sleep(d).await;
9345                            continue;
9346                        }
9347
9348                        dlg.finished(false);
9349
9350                        return Err(match error {
9351                            Ok(value) => common::Error::BadRequest(value),
9352                            _ => common::Error::Failure(response),
9353                        });
9354                    }
9355                    let response = {
9356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9357                        let encoded = common::to_string(&bytes);
9358                        match serde_json::from_str(&encoded) {
9359                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9360                            Err(error) => {
9361                                dlg.response_json_decode_error(&encoded, &error);
9362                                return Err(common::Error::JsonDecodeError(
9363                                    encoded.to_string(),
9364                                    error,
9365                                ));
9366                            }
9367                        }
9368                    };
9369
9370                    dlg.finished(true);
9371                    return Ok(response);
9372                }
9373            }
9374        }
9375    }
9376
9377    ///
9378    /// Sets the *request* property to the given value.
9379    ///
9380    /// Even though the property as already been set when instantiating this call,
9381    /// we provide this method for API completeness.
9382    pub fn request(mut self, new_value: OrdersCustomBatchRequest) -> OrderCustombatchCall<'a, C> {
9383        self._request = new_value;
9384        self
9385    }
9386    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9387    /// while executing the actual API request.
9388    ///
9389    /// ````text
9390    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9391    /// ````
9392    ///
9393    /// Sets the *delegate* property to the given value.
9394    pub fn delegate(
9395        mut self,
9396        new_value: &'a mut dyn common::Delegate,
9397    ) -> OrderCustombatchCall<'a, C> {
9398        self._delegate = Some(new_value);
9399        self
9400    }
9401
9402    /// Set any additional parameter of the query string used in the request.
9403    /// It should be used to set parameters which are not yet available through their own
9404    /// setters.
9405    ///
9406    /// Please note that this method must not be used to set any of the known parameters
9407    /// which have their own setter method. If done anyway, the request will fail.
9408    ///
9409    /// # Additional Parameters
9410    ///
9411    /// * *alt* (query-string) - Data format for the response.
9412    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9413    /// * *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.
9414    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9415    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9416    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9417    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9418    pub fn param<T>(mut self, name: T, value: T) -> OrderCustombatchCall<'a, C>
9419    where
9420        T: AsRef<str>,
9421    {
9422        self._additional_params
9423            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9424        self
9425    }
9426
9427    /// Identifies the authorization scope for the method you are building.
9428    ///
9429    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9430    /// [`Scope::Full`].
9431    ///
9432    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9433    /// tokens for more than one scope.
9434    ///
9435    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9436    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9437    /// sufficient, a read-write scope will do as well.
9438    pub fn add_scope<St>(mut self, scope: St) -> OrderCustombatchCall<'a, C>
9439    where
9440        St: AsRef<str>,
9441    {
9442        self._scopes.insert(String::from(scope.as_ref()));
9443        self
9444    }
9445    /// Identifies the authorization scope(s) for the method you are building.
9446    ///
9447    /// See [`Self::add_scope()`] for details.
9448    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderCustombatchCall<'a, C>
9449    where
9450        I: IntoIterator<Item = St>,
9451        St: AsRef<str>,
9452    {
9453        self._scopes
9454            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9455        self
9456    }
9457
9458    /// Removes all scopes, and no default scope will be used either.
9459    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9460    /// for details).
9461    pub fn clear_scopes(mut self) -> OrderCustombatchCall<'a, C> {
9462        self._scopes.clear();
9463        self
9464    }
9465}
9466
9467/// Retrieves an order from your Merchant Center account.
9468///
9469/// A builder for the *get* method supported by a *order* resource.
9470/// It is not used directly, but through a [`OrderMethods`] instance.
9471///
9472/// # Example
9473///
9474/// Instantiate a resource method builder
9475///
9476/// ```test_harness,no_run
9477/// # extern crate hyper;
9478/// # extern crate hyper_rustls;
9479/// # extern crate google_content2_sandbox as content2_sandbox;
9480/// # async fn dox() {
9481/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9482///
9483/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9484/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9485/// #     .with_native_roots()
9486/// #     .unwrap()
9487/// #     .https_only()
9488/// #     .enable_http2()
9489/// #     .build();
9490///
9491/// # let executor = hyper_util::rt::TokioExecutor::new();
9492/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9493/// #     secret,
9494/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9495/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9496/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9497/// #     ),
9498/// # ).build().await.unwrap();
9499///
9500/// # let client = hyper_util::client::legacy::Client::builder(
9501/// #     hyper_util::rt::TokioExecutor::new()
9502/// # )
9503/// # .build(
9504/// #     hyper_rustls::HttpsConnectorBuilder::new()
9505/// #         .with_native_roots()
9506/// #         .unwrap()
9507/// #         .https_or_http()
9508/// #         .enable_http2()
9509/// #         .build()
9510/// # );
9511/// # let mut hub = ShoppingContent::new(client, auth);
9512/// // You can configure optional parameters by calling the respective setters at will, and
9513/// // execute the final call using `doit()`.
9514/// // Values shown here are possibly random and not representative !
9515/// let result = hub.orders().get(52, "orderId")
9516///              .doit().await;
9517/// # }
9518/// ```
9519pub struct OrderGetCall<'a, C>
9520where
9521    C: 'a,
9522{
9523    hub: &'a ShoppingContent<C>,
9524    _merchant_id: u64,
9525    _order_id: String,
9526    _delegate: Option<&'a mut dyn common::Delegate>,
9527    _additional_params: HashMap<String, String>,
9528    _scopes: BTreeSet<String>,
9529}
9530
9531impl<'a, C> common::CallBuilder for OrderGetCall<'a, C> {}
9532
9533impl<'a, C> OrderGetCall<'a, C>
9534where
9535    C: common::Connector,
9536{
9537    /// Perform the operation you have build so far.
9538    pub async fn doit(mut self) -> common::Result<(common::Response, Order)> {
9539        use std::borrow::Cow;
9540        use std::io::{Read, Seek};
9541
9542        use common::{url::Params, ToParts};
9543        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9544
9545        let mut dd = common::DefaultDelegate;
9546        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9547        dlg.begin(common::MethodInfo {
9548            id: "content.orders.get",
9549            http_method: hyper::Method::GET,
9550        });
9551
9552        for &field in ["alt", "merchantId", "orderId"].iter() {
9553            if self._additional_params.contains_key(field) {
9554                dlg.finished(false);
9555                return Err(common::Error::FieldClash(field));
9556            }
9557        }
9558
9559        let mut params = Params::with_capacity(4 + self._additional_params.len());
9560        params.push("merchantId", self._merchant_id.to_string());
9561        params.push("orderId", self._order_id);
9562
9563        params.extend(self._additional_params.iter());
9564
9565        params.push("alt", "json");
9566        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}";
9567        if self._scopes.is_empty() {
9568            self._scopes.insert(Scope::Full.as_ref().to_string());
9569        }
9570
9571        #[allow(clippy::single_element_loop)]
9572        for &(find_this, param_name) in
9573            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
9574        {
9575            url = params.uri_replacement(url, param_name, find_this, false);
9576        }
9577        {
9578            let to_remove = ["orderId", "merchantId"];
9579            params.remove_params(&to_remove);
9580        }
9581
9582        let url = params.parse_with_url(&url);
9583
9584        loop {
9585            let token = match self
9586                .hub
9587                .auth
9588                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9589                .await
9590            {
9591                Ok(token) => token,
9592                Err(e) => match dlg.token(e) {
9593                    Ok(token) => token,
9594                    Err(e) => {
9595                        dlg.finished(false);
9596                        return Err(common::Error::MissingToken(e));
9597                    }
9598                },
9599            };
9600            let mut req_result = {
9601                let client = &self.hub.client;
9602                dlg.pre_request();
9603                let mut req_builder = hyper::Request::builder()
9604                    .method(hyper::Method::GET)
9605                    .uri(url.as_str())
9606                    .header(USER_AGENT, self.hub._user_agent.clone());
9607
9608                if let Some(token) = token.as_ref() {
9609                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9610                }
9611
9612                let request = req_builder
9613                    .header(CONTENT_LENGTH, 0_u64)
9614                    .body(common::to_body::<String>(None));
9615
9616                client.request(request.unwrap()).await
9617            };
9618
9619            match req_result {
9620                Err(err) => {
9621                    if let common::Retry::After(d) = dlg.http_error(&err) {
9622                        sleep(d).await;
9623                        continue;
9624                    }
9625                    dlg.finished(false);
9626                    return Err(common::Error::HttpError(err));
9627                }
9628                Ok(res) => {
9629                    let (mut parts, body) = res.into_parts();
9630                    let mut body = common::Body::new(body);
9631                    if !parts.status.is_success() {
9632                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9633                        let error = serde_json::from_str(&common::to_string(&bytes));
9634                        let response = common::to_response(parts, bytes.into());
9635
9636                        if let common::Retry::After(d) =
9637                            dlg.http_failure(&response, error.as_ref().ok())
9638                        {
9639                            sleep(d).await;
9640                            continue;
9641                        }
9642
9643                        dlg.finished(false);
9644
9645                        return Err(match error {
9646                            Ok(value) => common::Error::BadRequest(value),
9647                            _ => common::Error::Failure(response),
9648                        });
9649                    }
9650                    let response = {
9651                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9652                        let encoded = common::to_string(&bytes);
9653                        match serde_json::from_str(&encoded) {
9654                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9655                            Err(error) => {
9656                                dlg.response_json_decode_error(&encoded, &error);
9657                                return Err(common::Error::JsonDecodeError(
9658                                    encoded.to_string(),
9659                                    error,
9660                                ));
9661                            }
9662                        }
9663                    };
9664
9665                    dlg.finished(true);
9666                    return Ok(response);
9667                }
9668            }
9669        }
9670    }
9671
9672    /// The ID of the account that manages the order. This cannot be a multi-client account.
9673    ///
9674    /// Sets the *merchant id* path property to the given value.
9675    ///
9676    /// Even though the property as already been set when instantiating this call,
9677    /// we provide this method for API completeness.
9678    pub fn merchant_id(mut self, new_value: u64) -> OrderGetCall<'a, C> {
9679        self._merchant_id = new_value;
9680        self
9681    }
9682    /// The ID of the order.
9683    ///
9684    /// Sets the *order id* path property to the given value.
9685    ///
9686    /// Even though the property as already been set when instantiating this call,
9687    /// we provide this method for API completeness.
9688    pub fn order_id(mut self, new_value: &str) -> OrderGetCall<'a, C> {
9689        self._order_id = new_value.to_string();
9690        self
9691    }
9692    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9693    /// while executing the actual API request.
9694    ///
9695    /// ````text
9696    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9697    /// ````
9698    ///
9699    /// Sets the *delegate* property to the given value.
9700    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderGetCall<'a, C> {
9701        self._delegate = Some(new_value);
9702        self
9703    }
9704
9705    /// Set any additional parameter of the query string used in the request.
9706    /// It should be used to set parameters which are not yet available through their own
9707    /// setters.
9708    ///
9709    /// Please note that this method must not be used to set any of the known parameters
9710    /// which have their own setter method. If done anyway, the request will fail.
9711    ///
9712    /// # Additional Parameters
9713    ///
9714    /// * *alt* (query-string) - Data format for the response.
9715    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9716    /// * *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.
9717    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9718    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9719    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9720    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9721    pub fn param<T>(mut self, name: T, value: T) -> OrderGetCall<'a, C>
9722    where
9723        T: AsRef<str>,
9724    {
9725        self._additional_params
9726            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9727        self
9728    }
9729
9730    /// Identifies the authorization scope for the method you are building.
9731    ///
9732    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9733    /// [`Scope::Full`].
9734    ///
9735    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9736    /// tokens for more than one scope.
9737    ///
9738    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9739    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9740    /// sufficient, a read-write scope will do as well.
9741    pub fn add_scope<St>(mut self, scope: St) -> OrderGetCall<'a, C>
9742    where
9743        St: AsRef<str>,
9744    {
9745        self._scopes.insert(String::from(scope.as_ref()));
9746        self
9747    }
9748    /// Identifies the authorization scope(s) for the method you are building.
9749    ///
9750    /// See [`Self::add_scope()`] for details.
9751    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderGetCall<'a, C>
9752    where
9753        I: IntoIterator<Item = St>,
9754        St: AsRef<str>,
9755    {
9756        self._scopes
9757            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9758        self
9759    }
9760
9761    /// Removes all scopes, and no default scope will be used either.
9762    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9763    /// for details).
9764    pub fn clear_scopes(mut self) -> OrderGetCall<'a, C> {
9765        self._scopes.clear();
9766        self
9767    }
9768}
9769
9770/// Retrieves an order using merchant order id.
9771///
9772/// A builder for the *getbymerchantorderid* method supported by a *order* resource.
9773/// It is not used directly, but through a [`OrderMethods`] instance.
9774///
9775/// # Example
9776///
9777/// Instantiate a resource method builder
9778///
9779/// ```test_harness,no_run
9780/// # extern crate hyper;
9781/// # extern crate hyper_rustls;
9782/// # extern crate google_content2_sandbox as content2_sandbox;
9783/// # async fn dox() {
9784/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9785///
9786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9787/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9788/// #     .with_native_roots()
9789/// #     .unwrap()
9790/// #     .https_only()
9791/// #     .enable_http2()
9792/// #     .build();
9793///
9794/// # let executor = hyper_util::rt::TokioExecutor::new();
9795/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9796/// #     secret,
9797/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9798/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9799/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9800/// #     ),
9801/// # ).build().await.unwrap();
9802///
9803/// # let client = hyper_util::client::legacy::Client::builder(
9804/// #     hyper_util::rt::TokioExecutor::new()
9805/// # )
9806/// # .build(
9807/// #     hyper_rustls::HttpsConnectorBuilder::new()
9808/// #         .with_native_roots()
9809/// #         .unwrap()
9810/// #         .https_or_http()
9811/// #         .enable_http2()
9812/// #         .build()
9813/// # );
9814/// # let mut hub = ShoppingContent::new(client, auth);
9815/// // You can configure optional parameters by calling the respective setters at will, and
9816/// // execute the final call using `doit()`.
9817/// // Values shown here are possibly random and not representative !
9818/// let result = hub.orders().getbymerchantorderid(79, "merchantOrderId")
9819///              .doit().await;
9820/// # }
9821/// ```
9822pub struct OrderGetbymerchantorderidCall<'a, C>
9823where
9824    C: 'a,
9825{
9826    hub: &'a ShoppingContent<C>,
9827    _merchant_id: u64,
9828    _merchant_order_id: String,
9829    _delegate: Option<&'a mut dyn common::Delegate>,
9830    _additional_params: HashMap<String, String>,
9831    _scopes: BTreeSet<String>,
9832}
9833
9834impl<'a, C> common::CallBuilder for OrderGetbymerchantorderidCall<'a, C> {}
9835
9836impl<'a, C> OrderGetbymerchantorderidCall<'a, C>
9837where
9838    C: common::Connector,
9839{
9840    /// Perform the operation you have build so far.
9841    pub async fn doit(
9842        mut self,
9843    ) -> common::Result<(common::Response, OrdersGetByMerchantOrderIdResponse)> {
9844        use std::borrow::Cow;
9845        use std::io::{Read, Seek};
9846
9847        use common::{url::Params, ToParts};
9848        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9849
9850        let mut dd = common::DefaultDelegate;
9851        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9852        dlg.begin(common::MethodInfo {
9853            id: "content.orders.getbymerchantorderid",
9854            http_method: hyper::Method::GET,
9855        });
9856
9857        for &field in ["alt", "merchantId", "merchantOrderId"].iter() {
9858            if self._additional_params.contains_key(field) {
9859                dlg.finished(false);
9860                return Err(common::Error::FieldClash(field));
9861            }
9862        }
9863
9864        let mut params = Params::with_capacity(4 + self._additional_params.len());
9865        params.push("merchantId", self._merchant_id.to_string());
9866        params.push("merchantOrderId", self._merchant_order_id);
9867
9868        params.extend(self._additional_params.iter());
9869
9870        params.push("alt", "json");
9871        let mut url =
9872            self.hub._base_url.clone() + "{merchantId}/ordersbymerchantid/{merchantOrderId}";
9873        if self._scopes.is_empty() {
9874            self._scopes.insert(Scope::Full.as_ref().to_string());
9875        }
9876
9877        #[allow(clippy::single_element_loop)]
9878        for &(find_this, param_name) in [
9879            ("{merchantId}", "merchantId"),
9880            ("{merchantOrderId}", "merchantOrderId"),
9881        ]
9882        .iter()
9883        {
9884            url = params.uri_replacement(url, param_name, find_this, false);
9885        }
9886        {
9887            let to_remove = ["merchantOrderId", "merchantId"];
9888            params.remove_params(&to_remove);
9889        }
9890
9891        let url = params.parse_with_url(&url);
9892
9893        loop {
9894            let token = match self
9895                .hub
9896                .auth
9897                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9898                .await
9899            {
9900                Ok(token) => token,
9901                Err(e) => match dlg.token(e) {
9902                    Ok(token) => token,
9903                    Err(e) => {
9904                        dlg.finished(false);
9905                        return Err(common::Error::MissingToken(e));
9906                    }
9907                },
9908            };
9909            let mut req_result = {
9910                let client = &self.hub.client;
9911                dlg.pre_request();
9912                let mut req_builder = hyper::Request::builder()
9913                    .method(hyper::Method::GET)
9914                    .uri(url.as_str())
9915                    .header(USER_AGENT, self.hub._user_agent.clone());
9916
9917                if let Some(token) = token.as_ref() {
9918                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9919                }
9920
9921                let request = req_builder
9922                    .header(CONTENT_LENGTH, 0_u64)
9923                    .body(common::to_body::<String>(None));
9924
9925                client.request(request.unwrap()).await
9926            };
9927
9928            match req_result {
9929                Err(err) => {
9930                    if let common::Retry::After(d) = dlg.http_error(&err) {
9931                        sleep(d).await;
9932                        continue;
9933                    }
9934                    dlg.finished(false);
9935                    return Err(common::Error::HttpError(err));
9936                }
9937                Ok(res) => {
9938                    let (mut parts, body) = res.into_parts();
9939                    let mut body = common::Body::new(body);
9940                    if !parts.status.is_success() {
9941                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9942                        let error = serde_json::from_str(&common::to_string(&bytes));
9943                        let response = common::to_response(parts, bytes.into());
9944
9945                        if let common::Retry::After(d) =
9946                            dlg.http_failure(&response, error.as_ref().ok())
9947                        {
9948                            sleep(d).await;
9949                            continue;
9950                        }
9951
9952                        dlg.finished(false);
9953
9954                        return Err(match error {
9955                            Ok(value) => common::Error::BadRequest(value),
9956                            _ => common::Error::Failure(response),
9957                        });
9958                    }
9959                    let response = {
9960                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9961                        let encoded = common::to_string(&bytes);
9962                        match serde_json::from_str(&encoded) {
9963                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9964                            Err(error) => {
9965                                dlg.response_json_decode_error(&encoded, &error);
9966                                return Err(common::Error::JsonDecodeError(
9967                                    encoded.to_string(),
9968                                    error,
9969                                ));
9970                            }
9971                        }
9972                    };
9973
9974                    dlg.finished(true);
9975                    return Ok(response);
9976                }
9977            }
9978        }
9979    }
9980
9981    /// The ID of the account that manages the order. This cannot be a multi-client account.
9982    ///
9983    /// Sets the *merchant id* path property to the given value.
9984    ///
9985    /// Even though the property as already been set when instantiating this call,
9986    /// we provide this method for API completeness.
9987    pub fn merchant_id(mut self, new_value: u64) -> OrderGetbymerchantorderidCall<'a, C> {
9988        self._merchant_id = new_value;
9989        self
9990    }
9991    /// The merchant order id to be looked for.
9992    ///
9993    /// Sets the *merchant order id* path property to the given value.
9994    ///
9995    /// Even though the property as already been set when instantiating this call,
9996    /// we provide this method for API completeness.
9997    pub fn merchant_order_id(mut self, new_value: &str) -> OrderGetbymerchantorderidCall<'a, C> {
9998        self._merchant_order_id = new_value.to_string();
9999        self
10000    }
10001    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10002    /// while executing the actual API request.
10003    ///
10004    /// ````text
10005    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10006    /// ````
10007    ///
10008    /// Sets the *delegate* property to the given value.
10009    pub fn delegate(
10010        mut self,
10011        new_value: &'a mut dyn common::Delegate,
10012    ) -> OrderGetbymerchantorderidCall<'a, C> {
10013        self._delegate = Some(new_value);
10014        self
10015    }
10016
10017    /// Set any additional parameter of the query string used in the request.
10018    /// It should be used to set parameters which are not yet available through their own
10019    /// setters.
10020    ///
10021    /// Please note that this method must not be used to set any of the known parameters
10022    /// which have their own setter method. If done anyway, the request will fail.
10023    ///
10024    /// # Additional Parameters
10025    ///
10026    /// * *alt* (query-string) - Data format for the response.
10027    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10028    /// * *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.
10029    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10030    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10031    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10032    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10033    pub fn param<T>(mut self, name: T, value: T) -> OrderGetbymerchantorderidCall<'a, C>
10034    where
10035        T: AsRef<str>,
10036    {
10037        self._additional_params
10038            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10039        self
10040    }
10041
10042    /// Identifies the authorization scope for the method you are building.
10043    ///
10044    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10045    /// [`Scope::Full`].
10046    ///
10047    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10048    /// tokens for more than one scope.
10049    ///
10050    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10051    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10052    /// sufficient, a read-write scope will do as well.
10053    pub fn add_scope<St>(mut self, scope: St) -> OrderGetbymerchantorderidCall<'a, C>
10054    where
10055        St: AsRef<str>,
10056    {
10057        self._scopes.insert(String::from(scope.as_ref()));
10058        self
10059    }
10060    /// Identifies the authorization scope(s) for the method you are building.
10061    ///
10062    /// See [`Self::add_scope()`] for details.
10063    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderGetbymerchantorderidCall<'a, C>
10064    where
10065        I: IntoIterator<Item = St>,
10066        St: AsRef<str>,
10067    {
10068        self._scopes
10069            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10070        self
10071    }
10072
10073    /// Removes all scopes, and no default scope will be used either.
10074    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10075    /// for details).
10076    pub fn clear_scopes(mut self) -> OrderGetbymerchantorderidCall<'a, C> {
10077        self._scopes.clear();
10078        self
10079    }
10080}
10081
10082/// Sandbox only. Retrieves an order template that can be used to quickly create a new order in sandbox.
10083///
10084/// A builder for the *gettestordertemplate* method supported by a *order* resource.
10085/// It is not used directly, but through a [`OrderMethods`] instance.
10086///
10087/// # Example
10088///
10089/// Instantiate a resource method builder
10090///
10091/// ```test_harness,no_run
10092/// # extern crate hyper;
10093/// # extern crate hyper_rustls;
10094/// # extern crate google_content2_sandbox as content2_sandbox;
10095/// # async fn dox() {
10096/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10097///
10098/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10099/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10100/// #     .with_native_roots()
10101/// #     .unwrap()
10102/// #     .https_only()
10103/// #     .enable_http2()
10104/// #     .build();
10105///
10106/// # let executor = hyper_util::rt::TokioExecutor::new();
10107/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10108/// #     secret,
10109/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10110/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10111/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10112/// #     ),
10113/// # ).build().await.unwrap();
10114///
10115/// # let client = hyper_util::client::legacy::Client::builder(
10116/// #     hyper_util::rt::TokioExecutor::new()
10117/// # )
10118/// # .build(
10119/// #     hyper_rustls::HttpsConnectorBuilder::new()
10120/// #         .with_native_roots()
10121/// #         .unwrap()
10122/// #         .https_or_http()
10123/// #         .enable_http2()
10124/// #         .build()
10125/// # );
10126/// # let mut hub = ShoppingContent::new(client, auth);
10127/// // You can configure optional parameters by calling the respective setters at will, and
10128/// // execute the final call using `doit()`.
10129/// // Values shown here are possibly random and not representative !
10130/// let result = hub.orders().gettestordertemplate(86, "templateName")
10131///              .country("duo")
10132///              .doit().await;
10133/// # }
10134/// ```
10135pub struct OrderGettestordertemplateCall<'a, C>
10136where
10137    C: 'a,
10138{
10139    hub: &'a ShoppingContent<C>,
10140    _merchant_id: u64,
10141    _template_name: String,
10142    _country: Option<String>,
10143    _delegate: Option<&'a mut dyn common::Delegate>,
10144    _additional_params: HashMap<String, String>,
10145    _scopes: BTreeSet<String>,
10146}
10147
10148impl<'a, C> common::CallBuilder for OrderGettestordertemplateCall<'a, C> {}
10149
10150impl<'a, C> OrderGettestordertemplateCall<'a, C>
10151where
10152    C: common::Connector,
10153{
10154    /// Perform the operation you have build so far.
10155    pub async fn doit(
10156        mut self,
10157    ) -> common::Result<(common::Response, OrdersGetTestOrderTemplateResponse)> {
10158        use std::borrow::Cow;
10159        use std::io::{Read, Seek};
10160
10161        use common::{url::Params, ToParts};
10162        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10163
10164        let mut dd = common::DefaultDelegate;
10165        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10166        dlg.begin(common::MethodInfo {
10167            id: "content.orders.gettestordertemplate",
10168            http_method: hyper::Method::GET,
10169        });
10170
10171        for &field in ["alt", "merchantId", "templateName", "country"].iter() {
10172            if self._additional_params.contains_key(field) {
10173                dlg.finished(false);
10174                return Err(common::Error::FieldClash(field));
10175            }
10176        }
10177
10178        let mut params = Params::with_capacity(5 + self._additional_params.len());
10179        params.push("merchantId", self._merchant_id.to_string());
10180        params.push("templateName", self._template_name);
10181        if let Some(value) = self._country.as_ref() {
10182            params.push("country", value);
10183        }
10184
10185        params.extend(self._additional_params.iter());
10186
10187        params.push("alt", "json");
10188        let mut url = self.hub._base_url.clone() + "{merchantId}/testordertemplates/{templateName}";
10189        if self._scopes.is_empty() {
10190            self._scopes.insert(Scope::Full.as_ref().to_string());
10191        }
10192
10193        #[allow(clippy::single_element_loop)]
10194        for &(find_this, param_name) in [
10195            ("{merchantId}", "merchantId"),
10196            ("{templateName}", "templateName"),
10197        ]
10198        .iter()
10199        {
10200            url = params.uri_replacement(url, param_name, find_this, false);
10201        }
10202        {
10203            let to_remove = ["templateName", "merchantId"];
10204            params.remove_params(&to_remove);
10205        }
10206
10207        let url = params.parse_with_url(&url);
10208
10209        loop {
10210            let token = match self
10211                .hub
10212                .auth
10213                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10214                .await
10215            {
10216                Ok(token) => token,
10217                Err(e) => match dlg.token(e) {
10218                    Ok(token) => token,
10219                    Err(e) => {
10220                        dlg.finished(false);
10221                        return Err(common::Error::MissingToken(e));
10222                    }
10223                },
10224            };
10225            let mut req_result = {
10226                let client = &self.hub.client;
10227                dlg.pre_request();
10228                let mut req_builder = hyper::Request::builder()
10229                    .method(hyper::Method::GET)
10230                    .uri(url.as_str())
10231                    .header(USER_AGENT, self.hub._user_agent.clone());
10232
10233                if let Some(token) = token.as_ref() {
10234                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10235                }
10236
10237                let request = req_builder
10238                    .header(CONTENT_LENGTH, 0_u64)
10239                    .body(common::to_body::<String>(None));
10240
10241                client.request(request.unwrap()).await
10242            };
10243
10244            match req_result {
10245                Err(err) => {
10246                    if let common::Retry::After(d) = dlg.http_error(&err) {
10247                        sleep(d).await;
10248                        continue;
10249                    }
10250                    dlg.finished(false);
10251                    return Err(common::Error::HttpError(err));
10252                }
10253                Ok(res) => {
10254                    let (mut parts, body) = res.into_parts();
10255                    let mut body = common::Body::new(body);
10256                    if !parts.status.is_success() {
10257                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10258                        let error = serde_json::from_str(&common::to_string(&bytes));
10259                        let response = common::to_response(parts, bytes.into());
10260
10261                        if let common::Retry::After(d) =
10262                            dlg.http_failure(&response, error.as_ref().ok())
10263                        {
10264                            sleep(d).await;
10265                            continue;
10266                        }
10267
10268                        dlg.finished(false);
10269
10270                        return Err(match error {
10271                            Ok(value) => common::Error::BadRequest(value),
10272                            _ => common::Error::Failure(response),
10273                        });
10274                    }
10275                    let response = {
10276                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10277                        let encoded = common::to_string(&bytes);
10278                        match serde_json::from_str(&encoded) {
10279                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10280                            Err(error) => {
10281                                dlg.response_json_decode_error(&encoded, &error);
10282                                return Err(common::Error::JsonDecodeError(
10283                                    encoded.to_string(),
10284                                    error,
10285                                ));
10286                            }
10287                        }
10288                    };
10289
10290                    dlg.finished(true);
10291                    return Ok(response);
10292                }
10293            }
10294        }
10295    }
10296
10297    /// The ID of the account that should manage the order. This cannot be a multi-client account.
10298    ///
10299    /// Sets the *merchant id* path property to the given value.
10300    ///
10301    /// Even though the property as already been set when instantiating this call,
10302    /// we provide this method for API completeness.
10303    pub fn merchant_id(mut self, new_value: u64) -> OrderGettestordertemplateCall<'a, C> {
10304        self._merchant_id = new_value;
10305        self
10306    }
10307    /// The name of the template to retrieve.
10308    ///
10309    /// Sets the *template name* path property to the given value.
10310    ///
10311    /// Even though the property as already been set when instantiating this call,
10312    /// we provide this method for API completeness.
10313    pub fn template_name(mut self, new_value: &str) -> OrderGettestordertemplateCall<'a, C> {
10314        self._template_name = new_value.to_string();
10315        self
10316    }
10317    /// The country of the template to retrieve. Defaults to US.
10318    ///
10319    /// Sets the *country* query property to the given value.
10320    pub fn country(mut self, new_value: &str) -> OrderGettestordertemplateCall<'a, C> {
10321        self._country = Some(new_value.to_string());
10322        self
10323    }
10324    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10325    /// while executing the actual API request.
10326    ///
10327    /// ````text
10328    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10329    /// ````
10330    ///
10331    /// Sets the *delegate* property to the given value.
10332    pub fn delegate(
10333        mut self,
10334        new_value: &'a mut dyn common::Delegate,
10335    ) -> OrderGettestordertemplateCall<'a, C> {
10336        self._delegate = Some(new_value);
10337        self
10338    }
10339
10340    /// Set any additional parameter of the query string used in the request.
10341    /// It should be used to set parameters which are not yet available through their own
10342    /// setters.
10343    ///
10344    /// Please note that this method must not be used to set any of the known parameters
10345    /// which have their own setter method. If done anyway, the request will fail.
10346    ///
10347    /// # Additional Parameters
10348    ///
10349    /// * *alt* (query-string) - Data format for the response.
10350    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10351    /// * *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.
10352    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10353    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10354    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10355    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10356    pub fn param<T>(mut self, name: T, value: T) -> OrderGettestordertemplateCall<'a, C>
10357    where
10358        T: AsRef<str>,
10359    {
10360        self._additional_params
10361            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10362        self
10363    }
10364
10365    /// Identifies the authorization scope for the method you are building.
10366    ///
10367    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10368    /// [`Scope::Full`].
10369    ///
10370    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10371    /// tokens for more than one scope.
10372    ///
10373    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10374    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10375    /// sufficient, a read-write scope will do as well.
10376    pub fn add_scope<St>(mut self, scope: St) -> OrderGettestordertemplateCall<'a, C>
10377    where
10378        St: AsRef<str>,
10379    {
10380        self._scopes.insert(String::from(scope.as_ref()));
10381        self
10382    }
10383    /// Identifies the authorization scope(s) for the method you are building.
10384    ///
10385    /// See [`Self::add_scope()`] for details.
10386    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderGettestordertemplateCall<'a, C>
10387    where
10388        I: IntoIterator<Item = St>,
10389        St: AsRef<str>,
10390    {
10391        self._scopes
10392            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10393        self
10394    }
10395
10396    /// Removes all scopes, and no default scope will be used either.
10397    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10398    /// for details).
10399    pub fn clear_scopes(mut self) -> OrderGettestordertemplateCall<'a, C> {
10400        self._scopes.clear();
10401        self
10402    }
10403}
10404
10405/// Notifies that item return and refund was handled directly by merchant outside of Google payments processing (e.g. cash refund done in store).
10406///
10407/// A builder for the *instorerefundlineitem* method supported by a *order* resource.
10408/// It is not used directly, but through a [`OrderMethods`] instance.
10409///
10410/// # Example
10411///
10412/// Instantiate a resource method builder
10413///
10414/// ```test_harness,no_run
10415/// # extern crate hyper;
10416/// # extern crate hyper_rustls;
10417/// # extern crate google_content2_sandbox as content2_sandbox;
10418/// use content2_sandbox::api::OrdersInStoreRefundLineItemRequest;
10419/// # async fn dox() {
10420/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10421///
10422/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10423/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10424/// #     .with_native_roots()
10425/// #     .unwrap()
10426/// #     .https_only()
10427/// #     .enable_http2()
10428/// #     .build();
10429///
10430/// # let executor = hyper_util::rt::TokioExecutor::new();
10431/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10432/// #     secret,
10433/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10434/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10435/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10436/// #     ),
10437/// # ).build().await.unwrap();
10438///
10439/// # let client = hyper_util::client::legacy::Client::builder(
10440/// #     hyper_util::rt::TokioExecutor::new()
10441/// # )
10442/// # .build(
10443/// #     hyper_rustls::HttpsConnectorBuilder::new()
10444/// #         .with_native_roots()
10445/// #         .unwrap()
10446/// #         .https_or_http()
10447/// #         .enable_http2()
10448/// #         .build()
10449/// # );
10450/// # let mut hub = ShoppingContent::new(client, auth);
10451/// // As the method needs a request, you would usually fill it with the desired information
10452/// // into the respective structure. Some of the parts shown here might not be applicable !
10453/// // Values shown here are possibly random and not representative !
10454/// let mut req = OrdersInStoreRefundLineItemRequest::default();
10455///
10456/// // You can configure optional parameters by calling the respective setters at will, and
10457/// // execute the final call using `doit()`.
10458/// // Values shown here are possibly random and not representative !
10459/// let result = hub.orders().instorerefundlineitem(req, 25, "orderId")
10460///              .doit().await;
10461/// # }
10462/// ```
10463pub struct OrderInstorerefundlineitemCall<'a, C>
10464where
10465    C: 'a,
10466{
10467    hub: &'a ShoppingContent<C>,
10468    _request: OrdersInStoreRefundLineItemRequest,
10469    _merchant_id: u64,
10470    _order_id: String,
10471    _delegate: Option<&'a mut dyn common::Delegate>,
10472    _additional_params: HashMap<String, String>,
10473    _scopes: BTreeSet<String>,
10474}
10475
10476impl<'a, C> common::CallBuilder for OrderInstorerefundlineitemCall<'a, C> {}
10477
10478impl<'a, C> OrderInstorerefundlineitemCall<'a, C>
10479where
10480    C: common::Connector,
10481{
10482    /// Perform the operation you have build so far.
10483    pub async fn doit(
10484        mut self,
10485    ) -> common::Result<(common::Response, OrdersInStoreRefundLineItemResponse)> {
10486        use std::borrow::Cow;
10487        use std::io::{Read, Seek};
10488
10489        use common::{url::Params, ToParts};
10490        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10491
10492        let mut dd = common::DefaultDelegate;
10493        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10494        dlg.begin(common::MethodInfo {
10495            id: "content.orders.instorerefundlineitem",
10496            http_method: hyper::Method::POST,
10497        });
10498
10499        for &field in ["alt", "merchantId", "orderId"].iter() {
10500            if self._additional_params.contains_key(field) {
10501                dlg.finished(false);
10502                return Err(common::Error::FieldClash(field));
10503            }
10504        }
10505
10506        let mut params = Params::with_capacity(5 + self._additional_params.len());
10507        params.push("merchantId", self._merchant_id.to_string());
10508        params.push("orderId", self._order_id);
10509
10510        params.extend(self._additional_params.iter());
10511
10512        params.push("alt", "json");
10513        let mut url =
10514            self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/inStoreRefundLineItem";
10515        if self._scopes.is_empty() {
10516            self._scopes.insert(Scope::Full.as_ref().to_string());
10517        }
10518
10519        #[allow(clippy::single_element_loop)]
10520        for &(find_this, param_name) in
10521            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
10522        {
10523            url = params.uri_replacement(url, param_name, find_this, false);
10524        }
10525        {
10526            let to_remove = ["orderId", "merchantId"];
10527            params.remove_params(&to_remove);
10528        }
10529
10530        let url = params.parse_with_url(&url);
10531
10532        let mut json_mime_type = mime::APPLICATION_JSON;
10533        let mut request_value_reader = {
10534            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10535            common::remove_json_null_values(&mut value);
10536            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10537            serde_json::to_writer(&mut dst, &value).unwrap();
10538            dst
10539        };
10540        let request_size = request_value_reader
10541            .seek(std::io::SeekFrom::End(0))
10542            .unwrap();
10543        request_value_reader
10544            .seek(std::io::SeekFrom::Start(0))
10545            .unwrap();
10546
10547        loop {
10548            let token = match self
10549                .hub
10550                .auth
10551                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10552                .await
10553            {
10554                Ok(token) => token,
10555                Err(e) => match dlg.token(e) {
10556                    Ok(token) => token,
10557                    Err(e) => {
10558                        dlg.finished(false);
10559                        return Err(common::Error::MissingToken(e));
10560                    }
10561                },
10562            };
10563            request_value_reader
10564                .seek(std::io::SeekFrom::Start(0))
10565                .unwrap();
10566            let mut req_result = {
10567                let client = &self.hub.client;
10568                dlg.pre_request();
10569                let mut req_builder = hyper::Request::builder()
10570                    .method(hyper::Method::POST)
10571                    .uri(url.as_str())
10572                    .header(USER_AGENT, self.hub._user_agent.clone());
10573
10574                if let Some(token) = token.as_ref() {
10575                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10576                }
10577
10578                let request = req_builder
10579                    .header(CONTENT_TYPE, json_mime_type.to_string())
10580                    .header(CONTENT_LENGTH, request_size as u64)
10581                    .body(common::to_body(
10582                        request_value_reader.get_ref().clone().into(),
10583                    ));
10584
10585                client.request(request.unwrap()).await
10586            };
10587
10588            match req_result {
10589                Err(err) => {
10590                    if let common::Retry::After(d) = dlg.http_error(&err) {
10591                        sleep(d).await;
10592                        continue;
10593                    }
10594                    dlg.finished(false);
10595                    return Err(common::Error::HttpError(err));
10596                }
10597                Ok(res) => {
10598                    let (mut parts, body) = res.into_parts();
10599                    let mut body = common::Body::new(body);
10600                    if !parts.status.is_success() {
10601                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10602                        let error = serde_json::from_str(&common::to_string(&bytes));
10603                        let response = common::to_response(parts, bytes.into());
10604
10605                        if let common::Retry::After(d) =
10606                            dlg.http_failure(&response, error.as_ref().ok())
10607                        {
10608                            sleep(d).await;
10609                            continue;
10610                        }
10611
10612                        dlg.finished(false);
10613
10614                        return Err(match error {
10615                            Ok(value) => common::Error::BadRequest(value),
10616                            _ => common::Error::Failure(response),
10617                        });
10618                    }
10619                    let response = {
10620                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10621                        let encoded = common::to_string(&bytes);
10622                        match serde_json::from_str(&encoded) {
10623                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10624                            Err(error) => {
10625                                dlg.response_json_decode_error(&encoded, &error);
10626                                return Err(common::Error::JsonDecodeError(
10627                                    encoded.to_string(),
10628                                    error,
10629                                ));
10630                            }
10631                        }
10632                    };
10633
10634                    dlg.finished(true);
10635                    return Ok(response);
10636                }
10637            }
10638        }
10639    }
10640
10641    ///
10642    /// Sets the *request* property to the given value.
10643    ///
10644    /// Even though the property as already been set when instantiating this call,
10645    /// we provide this method for API completeness.
10646    pub fn request(
10647        mut self,
10648        new_value: OrdersInStoreRefundLineItemRequest,
10649    ) -> OrderInstorerefundlineitemCall<'a, C> {
10650        self._request = new_value;
10651        self
10652    }
10653    /// The ID of the account that manages the order. This cannot be a multi-client account.
10654    ///
10655    /// Sets the *merchant id* path property to the given value.
10656    ///
10657    /// Even though the property as already been set when instantiating this call,
10658    /// we provide this method for API completeness.
10659    pub fn merchant_id(mut self, new_value: u64) -> OrderInstorerefundlineitemCall<'a, C> {
10660        self._merchant_id = new_value;
10661        self
10662    }
10663    /// The ID of the order.
10664    ///
10665    /// Sets the *order id* path property to the given value.
10666    ///
10667    /// Even though the property as already been set when instantiating this call,
10668    /// we provide this method for API completeness.
10669    pub fn order_id(mut self, new_value: &str) -> OrderInstorerefundlineitemCall<'a, C> {
10670        self._order_id = new_value.to_string();
10671        self
10672    }
10673    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10674    /// while executing the actual API request.
10675    ///
10676    /// ````text
10677    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10678    /// ````
10679    ///
10680    /// Sets the *delegate* property to the given value.
10681    pub fn delegate(
10682        mut self,
10683        new_value: &'a mut dyn common::Delegate,
10684    ) -> OrderInstorerefundlineitemCall<'a, C> {
10685        self._delegate = Some(new_value);
10686        self
10687    }
10688
10689    /// Set any additional parameter of the query string used in the request.
10690    /// It should be used to set parameters which are not yet available through their own
10691    /// setters.
10692    ///
10693    /// Please note that this method must not be used to set any of the known parameters
10694    /// which have their own setter method. If done anyway, the request will fail.
10695    ///
10696    /// # Additional Parameters
10697    ///
10698    /// * *alt* (query-string) - Data format for the response.
10699    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10700    /// * *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.
10701    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10702    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10703    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10704    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10705    pub fn param<T>(mut self, name: T, value: T) -> OrderInstorerefundlineitemCall<'a, C>
10706    where
10707        T: AsRef<str>,
10708    {
10709        self._additional_params
10710            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10711        self
10712    }
10713
10714    /// Identifies the authorization scope for the method you are building.
10715    ///
10716    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10717    /// [`Scope::Full`].
10718    ///
10719    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10720    /// tokens for more than one scope.
10721    ///
10722    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10723    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10724    /// sufficient, a read-write scope will do as well.
10725    pub fn add_scope<St>(mut self, scope: St) -> OrderInstorerefundlineitemCall<'a, C>
10726    where
10727        St: AsRef<str>,
10728    {
10729        self._scopes.insert(String::from(scope.as_ref()));
10730        self
10731    }
10732    /// Identifies the authorization scope(s) for the method you are building.
10733    ///
10734    /// See [`Self::add_scope()`] for details.
10735    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderInstorerefundlineitemCall<'a, C>
10736    where
10737        I: IntoIterator<Item = St>,
10738        St: AsRef<str>,
10739    {
10740        self._scopes
10741            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10742        self
10743    }
10744
10745    /// Removes all scopes, and no default scope will be used either.
10746    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10747    /// for details).
10748    pub fn clear_scopes(mut self) -> OrderInstorerefundlineitemCall<'a, C> {
10749        self._scopes.clear();
10750        self
10751    }
10752}
10753
10754/// Lists the orders in your Merchant Center account.
10755///
10756/// A builder for the *list* method supported by a *order* resource.
10757/// It is not used directly, but through a [`OrderMethods`] instance.
10758///
10759/// # Example
10760///
10761/// Instantiate a resource method builder
10762///
10763/// ```test_harness,no_run
10764/// # extern crate hyper;
10765/// # extern crate hyper_rustls;
10766/// # extern crate google_content2_sandbox as content2_sandbox;
10767/// # async fn dox() {
10768/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10769///
10770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10771/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10772/// #     .with_native_roots()
10773/// #     .unwrap()
10774/// #     .https_only()
10775/// #     .enable_http2()
10776/// #     .build();
10777///
10778/// # let executor = hyper_util::rt::TokioExecutor::new();
10779/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10780/// #     secret,
10781/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10782/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10783/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10784/// #     ),
10785/// # ).build().await.unwrap();
10786///
10787/// # let client = hyper_util::client::legacy::Client::builder(
10788/// #     hyper_util::rt::TokioExecutor::new()
10789/// # )
10790/// # .build(
10791/// #     hyper_rustls::HttpsConnectorBuilder::new()
10792/// #         .with_native_roots()
10793/// #         .unwrap()
10794/// #         .https_or_http()
10795/// #         .enable_http2()
10796/// #         .build()
10797/// # );
10798/// # let mut hub = ShoppingContent::new(client, auth);
10799/// // You can configure optional parameters by calling the respective setters at will, and
10800/// // execute the final call using `doit()`.
10801/// // Values shown here are possibly random and not representative !
10802/// let result = hub.orders().list(13)
10803///              .add_statuses("Stet")
10804///              .placed_date_start("vero")
10805///              .placed_date_end("elitr")
10806///              .page_token("Lorem")
10807///              .order_by("diam")
10808///              .max_results(40)
10809///              .acknowledged(false)
10810///              .doit().await;
10811/// # }
10812/// ```
10813pub struct OrderListCall<'a, C>
10814where
10815    C: 'a,
10816{
10817    hub: &'a ShoppingContent<C>,
10818    _merchant_id: u64,
10819    _statuses: Vec<String>,
10820    _placed_date_start: Option<String>,
10821    _placed_date_end: Option<String>,
10822    _page_token: Option<String>,
10823    _order_by: Option<String>,
10824    _max_results: Option<u32>,
10825    _acknowledged: Option<bool>,
10826    _delegate: Option<&'a mut dyn common::Delegate>,
10827    _additional_params: HashMap<String, String>,
10828    _scopes: BTreeSet<String>,
10829}
10830
10831impl<'a, C> common::CallBuilder for OrderListCall<'a, C> {}
10832
10833impl<'a, C> OrderListCall<'a, C>
10834where
10835    C: common::Connector,
10836{
10837    /// Perform the operation you have build so far.
10838    pub async fn doit(mut self) -> common::Result<(common::Response, OrdersListResponse)> {
10839        use std::borrow::Cow;
10840        use std::io::{Read, Seek};
10841
10842        use common::{url::Params, ToParts};
10843        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10844
10845        let mut dd = common::DefaultDelegate;
10846        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10847        dlg.begin(common::MethodInfo {
10848            id: "content.orders.list",
10849            http_method: hyper::Method::GET,
10850        });
10851
10852        for &field in [
10853            "alt",
10854            "merchantId",
10855            "statuses",
10856            "placedDateStart",
10857            "placedDateEnd",
10858            "pageToken",
10859            "orderBy",
10860            "maxResults",
10861            "acknowledged",
10862        ]
10863        .iter()
10864        {
10865            if self._additional_params.contains_key(field) {
10866                dlg.finished(false);
10867                return Err(common::Error::FieldClash(field));
10868            }
10869        }
10870
10871        let mut params = Params::with_capacity(10 + self._additional_params.len());
10872        params.push("merchantId", self._merchant_id.to_string());
10873        if !self._statuses.is_empty() {
10874            for f in self._statuses.iter() {
10875                params.push("statuses", f);
10876            }
10877        }
10878        if let Some(value) = self._placed_date_start.as_ref() {
10879            params.push("placedDateStart", value);
10880        }
10881        if let Some(value) = self._placed_date_end.as_ref() {
10882            params.push("placedDateEnd", value);
10883        }
10884        if let Some(value) = self._page_token.as_ref() {
10885            params.push("pageToken", value);
10886        }
10887        if let Some(value) = self._order_by.as_ref() {
10888            params.push("orderBy", value);
10889        }
10890        if let Some(value) = self._max_results.as_ref() {
10891            params.push("maxResults", value.to_string());
10892        }
10893        if let Some(value) = self._acknowledged.as_ref() {
10894            params.push("acknowledged", value.to_string());
10895        }
10896
10897        params.extend(self._additional_params.iter());
10898
10899        params.push("alt", "json");
10900        let mut url = self.hub._base_url.clone() + "{merchantId}/orders";
10901        if self._scopes.is_empty() {
10902            self._scopes.insert(Scope::Full.as_ref().to_string());
10903        }
10904
10905        #[allow(clippy::single_element_loop)]
10906        for &(find_this, param_name) in [("{merchantId}", "merchantId")].iter() {
10907            url = params.uri_replacement(url, param_name, find_this, false);
10908        }
10909        {
10910            let to_remove = ["merchantId"];
10911            params.remove_params(&to_remove);
10912        }
10913
10914        let url = params.parse_with_url(&url);
10915
10916        loop {
10917            let token = match self
10918                .hub
10919                .auth
10920                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10921                .await
10922            {
10923                Ok(token) => token,
10924                Err(e) => match dlg.token(e) {
10925                    Ok(token) => token,
10926                    Err(e) => {
10927                        dlg.finished(false);
10928                        return Err(common::Error::MissingToken(e));
10929                    }
10930                },
10931            };
10932            let mut req_result = {
10933                let client = &self.hub.client;
10934                dlg.pre_request();
10935                let mut req_builder = hyper::Request::builder()
10936                    .method(hyper::Method::GET)
10937                    .uri(url.as_str())
10938                    .header(USER_AGENT, self.hub._user_agent.clone());
10939
10940                if let Some(token) = token.as_ref() {
10941                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10942                }
10943
10944                let request = req_builder
10945                    .header(CONTENT_LENGTH, 0_u64)
10946                    .body(common::to_body::<String>(None));
10947
10948                client.request(request.unwrap()).await
10949            };
10950
10951            match req_result {
10952                Err(err) => {
10953                    if let common::Retry::After(d) = dlg.http_error(&err) {
10954                        sleep(d).await;
10955                        continue;
10956                    }
10957                    dlg.finished(false);
10958                    return Err(common::Error::HttpError(err));
10959                }
10960                Ok(res) => {
10961                    let (mut parts, body) = res.into_parts();
10962                    let mut body = common::Body::new(body);
10963                    if !parts.status.is_success() {
10964                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10965                        let error = serde_json::from_str(&common::to_string(&bytes));
10966                        let response = common::to_response(parts, bytes.into());
10967
10968                        if let common::Retry::After(d) =
10969                            dlg.http_failure(&response, error.as_ref().ok())
10970                        {
10971                            sleep(d).await;
10972                            continue;
10973                        }
10974
10975                        dlg.finished(false);
10976
10977                        return Err(match error {
10978                            Ok(value) => common::Error::BadRequest(value),
10979                            _ => common::Error::Failure(response),
10980                        });
10981                    }
10982                    let response = {
10983                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10984                        let encoded = common::to_string(&bytes);
10985                        match serde_json::from_str(&encoded) {
10986                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10987                            Err(error) => {
10988                                dlg.response_json_decode_error(&encoded, &error);
10989                                return Err(common::Error::JsonDecodeError(
10990                                    encoded.to_string(),
10991                                    error,
10992                                ));
10993                            }
10994                        }
10995                    };
10996
10997                    dlg.finished(true);
10998                    return Ok(response);
10999                }
11000            }
11001        }
11002    }
11003
11004    /// The ID of the account that manages the order. This cannot be a multi-client account.
11005    ///
11006    /// Sets the *merchant id* path property to the given value.
11007    ///
11008    /// Even though the property as already been set when instantiating this call,
11009    /// we provide this method for API completeness.
11010    pub fn merchant_id(mut self, new_value: u64) -> OrderListCall<'a, C> {
11011        self._merchant_id = new_value;
11012        self
11013    }
11014    /// Obtains orders that match any of the specified statuses. Multiple values can be specified with comma separation. Additionally, please note that active is a shortcut for pendingShipment and partiallyShipped, and completed is a shortcut for shipped , partiallyDelivered, delivered, partiallyReturned, returned, and canceled.
11015    ///
11016    /// Append the given value to the *statuses* query property.
11017    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11018    pub fn add_statuses(mut self, new_value: &str) -> OrderListCall<'a, C> {
11019        self._statuses.push(new_value.to_string());
11020        self
11021    }
11022    /// Obtains orders placed after this date (inclusively), in ISO 8601 format.
11023    ///
11024    /// Sets the *placed date start* query property to the given value.
11025    pub fn placed_date_start(mut self, new_value: &str) -> OrderListCall<'a, C> {
11026        self._placed_date_start = Some(new_value.to_string());
11027        self
11028    }
11029    /// Obtains orders placed before this date (exclusively), in ISO 8601 format.
11030    ///
11031    /// Sets the *placed date end* query property to the given value.
11032    pub fn placed_date_end(mut self, new_value: &str) -> OrderListCall<'a, C> {
11033        self._placed_date_end = Some(new_value.to_string());
11034        self
11035    }
11036    /// The token returned by the previous request.
11037    ///
11038    /// Sets the *page token* query property to the given value.
11039    pub fn page_token(mut self, new_value: &str) -> OrderListCall<'a, C> {
11040        self._page_token = Some(new_value.to_string());
11041        self
11042    }
11043    /// The ordering of the returned list. The only supported value are placedDate desc and placedDate asc for now, which returns orders sorted by placement date. "placedDate desc" stands for listing orders by placement date, from oldest to most recent. "placedDate asc" stands for listing orders by placement date, from most recent to oldest. In future releases we'll support other sorting criteria.
11044    ///
11045    /// Sets the *order by* query property to the given value.
11046    pub fn order_by(mut self, new_value: &str) -> OrderListCall<'a, C> {
11047        self._order_by = Some(new_value.to_string());
11048        self
11049    }
11050    /// The maximum number of orders to return in the response, used for paging. The default value is 25 orders per page, and the maximum allowed value is 250 orders per page.
11051    /// Known issue: All List calls will return all Orders without limit regardless of the value of this field.
11052    ///
11053    /// Sets the *max results* query property to the given value.
11054    pub fn max_results(mut self, new_value: u32) -> OrderListCall<'a, C> {
11055        self._max_results = Some(new_value);
11056        self
11057    }
11058    /// Obtains orders that match the acknowledgement status. When set to true, obtains orders that have been acknowledged. When false, obtains orders that have not been acknowledged.
11059    /// We recommend using this filter set to false, in conjunction with the acknowledge call, such that only un-acknowledged orders are returned.
11060    ///
11061    /// Sets the *acknowledged* query property to the given value.
11062    pub fn acknowledged(mut self, new_value: bool) -> OrderListCall<'a, C> {
11063        self._acknowledged = Some(new_value);
11064        self
11065    }
11066    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11067    /// while executing the actual API request.
11068    ///
11069    /// ````text
11070    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11071    /// ````
11072    ///
11073    /// Sets the *delegate* property to the given value.
11074    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderListCall<'a, C> {
11075        self._delegate = Some(new_value);
11076        self
11077    }
11078
11079    /// Set any additional parameter of the query string used in the request.
11080    /// It should be used to set parameters which are not yet available through their own
11081    /// setters.
11082    ///
11083    /// Please note that this method must not be used to set any of the known parameters
11084    /// which have their own setter method. If done anyway, the request will fail.
11085    ///
11086    /// # Additional Parameters
11087    ///
11088    /// * *alt* (query-string) - Data format for the response.
11089    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11090    /// * *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.
11091    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11092    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11093    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11094    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11095    pub fn param<T>(mut self, name: T, value: T) -> OrderListCall<'a, C>
11096    where
11097        T: AsRef<str>,
11098    {
11099        self._additional_params
11100            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11101        self
11102    }
11103
11104    /// Identifies the authorization scope for the method you are building.
11105    ///
11106    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11107    /// [`Scope::Full`].
11108    ///
11109    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11110    /// tokens for more than one scope.
11111    ///
11112    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11113    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11114    /// sufficient, a read-write scope will do as well.
11115    pub fn add_scope<St>(mut self, scope: St) -> OrderListCall<'a, C>
11116    where
11117        St: AsRef<str>,
11118    {
11119        self._scopes.insert(String::from(scope.as_ref()));
11120        self
11121    }
11122    /// Identifies the authorization scope(s) for the method you are building.
11123    ///
11124    /// See [`Self::add_scope()`] for details.
11125    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderListCall<'a, C>
11126    where
11127        I: IntoIterator<Item = St>,
11128        St: AsRef<str>,
11129    {
11130        self._scopes
11131            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11132        self
11133    }
11134
11135    /// Removes all scopes, and no default scope will be used either.
11136    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11137    /// for details).
11138    pub fn clear_scopes(mut self) -> OrderListCall<'a, C> {
11139        self._scopes.clear();
11140        self
11141    }
11142}
11143
11144/// Deprecated, please use returnRefundLineItem instead.
11145///
11146/// A builder for the *refund* method supported by a *order* resource.
11147/// It is not used directly, but through a [`OrderMethods`] instance.
11148///
11149/// # Example
11150///
11151/// Instantiate a resource method builder
11152///
11153/// ```test_harness,no_run
11154/// # extern crate hyper;
11155/// # extern crate hyper_rustls;
11156/// # extern crate google_content2_sandbox as content2_sandbox;
11157/// use content2_sandbox::api::OrdersRefundRequest;
11158/// # async fn dox() {
11159/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11160///
11161/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11162/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11163/// #     .with_native_roots()
11164/// #     .unwrap()
11165/// #     .https_only()
11166/// #     .enable_http2()
11167/// #     .build();
11168///
11169/// # let executor = hyper_util::rt::TokioExecutor::new();
11170/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11171/// #     secret,
11172/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11173/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11174/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11175/// #     ),
11176/// # ).build().await.unwrap();
11177///
11178/// # let client = hyper_util::client::legacy::Client::builder(
11179/// #     hyper_util::rt::TokioExecutor::new()
11180/// # )
11181/// # .build(
11182/// #     hyper_rustls::HttpsConnectorBuilder::new()
11183/// #         .with_native_roots()
11184/// #         .unwrap()
11185/// #         .https_or_http()
11186/// #         .enable_http2()
11187/// #         .build()
11188/// # );
11189/// # let mut hub = ShoppingContent::new(client, auth);
11190/// // As the method needs a request, you would usually fill it with the desired information
11191/// // into the respective structure. Some of the parts shown here might not be applicable !
11192/// // Values shown here are possibly random and not representative !
11193/// let mut req = OrdersRefundRequest::default();
11194///
11195/// // You can configure optional parameters by calling the respective setters at will, and
11196/// // execute the final call using `doit()`.
11197/// // Values shown here are possibly random and not representative !
11198/// let result = hub.orders().refund(req, 78, "orderId")
11199///              .doit().await;
11200/// # }
11201/// ```
11202pub struct OrderRefundCall<'a, C>
11203where
11204    C: 'a,
11205{
11206    hub: &'a ShoppingContent<C>,
11207    _request: OrdersRefundRequest,
11208    _merchant_id: u64,
11209    _order_id: String,
11210    _delegate: Option<&'a mut dyn common::Delegate>,
11211    _additional_params: HashMap<String, String>,
11212    _scopes: BTreeSet<String>,
11213}
11214
11215impl<'a, C> common::CallBuilder for OrderRefundCall<'a, C> {}
11216
11217impl<'a, C> OrderRefundCall<'a, C>
11218where
11219    C: common::Connector,
11220{
11221    /// Perform the operation you have build so far.
11222    pub async fn doit(mut self) -> common::Result<(common::Response, OrdersRefundResponse)> {
11223        use std::borrow::Cow;
11224        use std::io::{Read, Seek};
11225
11226        use common::{url::Params, ToParts};
11227        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11228
11229        let mut dd = common::DefaultDelegate;
11230        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11231        dlg.begin(common::MethodInfo {
11232            id: "content.orders.refund",
11233            http_method: hyper::Method::POST,
11234        });
11235
11236        for &field in ["alt", "merchantId", "orderId"].iter() {
11237            if self._additional_params.contains_key(field) {
11238                dlg.finished(false);
11239                return Err(common::Error::FieldClash(field));
11240            }
11241        }
11242
11243        let mut params = Params::with_capacity(5 + self._additional_params.len());
11244        params.push("merchantId", self._merchant_id.to_string());
11245        params.push("orderId", self._order_id);
11246
11247        params.extend(self._additional_params.iter());
11248
11249        params.push("alt", "json");
11250        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/refund";
11251        if self._scopes.is_empty() {
11252            self._scopes.insert(Scope::Full.as_ref().to_string());
11253        }
11254
11255        #[allow(clippy::single_element_loop)]
11256        for &(find_this, param_name) in
11257            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
11258        {
11259            url = params.uri_replacement(url, param_name, find_this, false);
11260        }
11261        {
11262            let to_remove = ["orderId", "merchantId"];
11263            params.remove_params(&to_remove);
11264        }
11265
11266        let url = params.parse_with_url(&url);
11267
11268        let mut json_mime_type = mime::APPLICATION_JSON;
11269        let mut request_value_reader = {
11270            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11271            common::remove_json_null_values(&mut value);
11272            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11273            serde_json::to_writer(&mut dst, &value).unwrap();
11274            dst
11275        };
11276        let request_size = request_value_reader
11277            .seek(std::io::SeekFrom::End(0))
11278            .unwrap();
11279        request_value_reader
11280            .seek(std::io::SeekFrom::Start(0))
11281            .unwrap();
11282
11283        loop {
11284            let token = match self
11285                .hub
11286                .auth
11287                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11288                .await
11289            {
11290                Ok(token) => token,
11291                Err(e) => match dlg.token(e) {
11292                    Ok(token) => token,
11293                    Err(e) => {
11294                        dlg.finished(false);
11295                        return Err(common::Error::MissingToken(e));
11296                    }
11297                },
11298            };
11299            request_value_reader
11300                .seek(std::io::SeekFrom::Start(0))
11301                .unwrap();
11302            let mut req_result = {
11303                let client = &self.hub.client;
11304                dlg.pre_request();
11305                let mut req_builder = hyper::Request::builder()
11306                    .method(hyper::Method::POST)
11307                    .uri(url.as_str())
11308                    .header(USER_AGENT, self.hub._user_agent.clone());
11309
11310                if let Some(token) = token.as_ref() {
11311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11312                }
11313
11314                let request = req_builder
11315                    .header(CONTENT_TYPE, json_mime_type.to_string())
11316                    .header(CONTENT_LENGTH, request_size as u64)
11317                    .body(common::to_body(
11318                        request_value_reader.get_ref().clone().into(),
11319                    ));
11320
11321                client.request(request.unwrap()).await
11322            };
11323
11324            match req_result {
11325                Err(err) => {
11326                    if let common::Retry::After(d) = dlg.http_error(&err) {
11327                        sleep(d).await;
11328                        continue;
11329                    }
11330                    dlg.finished(false);
11331                    return Err(common::Error::HttpError(err));
11332                }
11333                Ok(res) => {
11334                    let (mut parts, body) = res.into_parts();
11335                    let mut body = common::Body::new(body);
11336                    if !parts.status.is_success() {
11337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11338                        let error = serde_json::from_str(&common::to_string(&bytes));
11339                        let response = common::to_response(parts, bytes.into());
11340
11341                        if let common::Retry::After(d) =
11342                            dlg.http_failure(&response, error.as_ref().ok())
11343                        {
11344                            sleep(d).await;
11345                            continue;
11346                        }
11347
11348                        dlg.finished(false);
11349
11350                        return Err(match error {
11351                            Ok(value) => common::Error::BadRequest(value),
11352                            _ => common::Error::Failure(response),
11353                        });
11354                    }
11355                    let response = {
11356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11357                        let encoded = common::to_string(&bytes);
11358                        match serde_json::from_str(&encoded) {
11359                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11360                            Err(error) => {
11361                                dlg.response_json_decode_error(&encoded, &error);
11362                                return Err(common::Error::JsonDecodeError(
11363                                    encoded.to_string(),
11364                                    error,
11365                                ));
11366                            }
11367                        }
11368                    };
11369
11370                    dlg.finished(true);
11371                    return Ok(response);
11372                }
11373            }
11374        }
11375    }
11376
11377    ///
11378    /// Sets the *request* property to the given value.
11379    ///
11380    /// Even though the property as already been set when instantiating this call,
11381    /// we provide this method for API completeness.
11382    pub fn request(mut self, new_value: OrdersRefundRequest) -> OrderRefundCall<'a, C> {
11383        self._request = new_value;
11384        self
11385    }
11386    /// The ID of the account that manages the order. This cannot be a multi-client account.
11387    ///
11388    /// Sets the *merchant id* path property to the given value.
11389    ///
11390    /// Even though the property as already been set when instantiating this call,
11391    /// we provide this method for API completeness.
11392    pub fn merchant_id(mut self, new_value: u64) -> OrderRefundCall<'a, C> {
11393        self._merchant_id = new_value;
11394        self
11395    }
11396    /// The ID of the order to refund.
11397    ///
11398    /// Sets the *order id* path property to the given value.
11399    ///
11400    /// Even though the property as already been set when instantiating this call,
11401    /// we provide this method for API completeness.
11402    pub fn order_id(mut self, new_value: &str) -> OrderRefundCall<'a, C> {
11403        self._order_id = new_value.to_string();
11404        self
11405    }
11406    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11407    /// while executing the actual API request.
11408    ///
11409    /// ````text
11410    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11411    /// ````
11412    ///
11413    /// Sets the *delegate* property to the given value.
11414    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderRefundCall<'a, C> {
11415        self._delegate = Some(new_value);
11416        self
11417    }
11418
11419    /// Set any additional parameter of the query string used in the request.
11420    /// It should be used to set parameters which are not yet available through their own
11421    /// setters.
11422    ///
11423    /// Please note that this method must not be used to set any of the known parameters
11424    /// which have their own setter method. If done anyway, the request will fail.
11425    ///
11426    /// # Additional Parameters
11427    ///
11428    /// * *alt* (query-string) - Data format for the response.
11429    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11430    /// * *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.
11431    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11432    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11433    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11434    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11435    pub fn param<T>(mut self, name: T, value: T) -> OrderRefundCall<'a, C>
11436    where
11437        T: AsRef<str>,
11438    {
11439        self._additional_params
11440            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11441        self
11442    }
11443
11444    /// Identifies the authorization scope for the method you are building.
11445    ///
11446    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11447    /// [`Scope::Full`].
11448    ///
11449    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11450    /// tokens for more than one scope.
11451    ///
11452    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11453    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11454    /// sufficient, a read-write scope will do as well.
11455    pub fn add_scope<St>(mut self, scope: St) -> OrderRefundCall<'a, C>
11456    where
11457        St: AsRef<str>,
11458    {
11459        self._scopes.insert(String::from(scope.as_ref()));
11460        self
11461    }
11462    /// Identifies the authorization scope(s) for the method you are building.
11463    ///
11464    /// See [`Self::add_scope()`] for details.
11465    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderRefundCall<'a, C>
11466    where
11467        I: IntoIterator<Item = St>,
11468        St: AsRef<str>,
11469    {
11470        self._scopes
11471            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11472        self
11473    }
11474
11475    /// Removes all scopes, and no default scope will be used either.
11476    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11477    /// for details).
11478    pub fn clear_scopes(mut self) -> OrderRefundCall<'a, C> {
11479        self._scopes.clear();
11480        self
11481    }
11482}
11483
11484/// Rejects return on an line item.
11485///
11486/// A builder for the *rejectreturnlineitem* method supported by a *order* resource.
11487/// It is not used directly, but through a [`OrderMethods`] instance.
11488///
11489/// # Example
11490///
11491/// Instantiate a resource method builder
11492///
11493/// ```test_harness,no_run
11494/// # extern crate hyper;
11495/// # extern crate hyper_rustls;
11496/// # extern crate google_content2_sandbox as content2_sandbox;
11497/// use content2_sandbox::api::OrdersRejectReturnLineItemRequest;
11498/// # async fn dox() {
11499/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11500///
11501/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11502/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11503/// #     .with_native_roots()
11504/// #     .unwrap()
11505/// #     .https_only()
11506/// #     .enable_http2()
11507/// #     .build();
11508///
11509/// # let executor = hyper_util::rt::TokioExecutor::new();
11510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11511/// #     secret,
11512/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11513/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11514/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11515/// #     ),
11516/// # ).build().await.unwrap();
11517///
11518/// # let client = hyper_util::client::legacy::Client::builder(
11519/// #     hyper_util::rt::TokioExecutor::new()
11520/// # )
11521/// # .build(
11522/// #     hyper_rustls::HttpsConnectorBuilder::new()
11523/// #         .with_native_roots()
11524/// #         .unwrap()
11525/// #         .https_or_http()
11526/// #         .enable_http2()
11527/// #         .build()
11528/// # );
11529/// # let mut hub = ShoppingContent::new(client, auth);
11530/// // As the method needs a request, you would usually fill it with the desired information
11531/// // into the respective structure. Some of the parts shown here might not be applicable !
11532/// // Values shown here are possibly random and not representative !
11533/// let mut req = OrdersRejectReturnLineItemRequest::default();
11534///
11535/// // You can configure optional parameters by calling the respective setters at will, and
11536/// // execute the final call using `doit()`.
11537/// // Values shown here are possibly random and not representative !
11538/// let result = hub.orders().rejectreturnlineitem(req, 55, "orderId")
11539///              .doit().await;
11540/// # }
11541/// ```
11542pub struct OrderRejectreturnlineitemCall<'a, C>
11543where
11544    C: 'a,
11545{
11546    hub: &'a ShoppingContent<C>,
11547    _request: OrdersRejectReturnLineItemRequest,
11548    _merchant_id: u64,
11549    _order_id: String,
11550    _delegate: Option<&'a mut dyn common::Delegate>,
11551    _additional_params: HashMap<String, String>,
11552    _scopes: BTreeSet<String>,
11553}
11554
11555impl<'a, C> common::CallBuilder for OrderRejectreturnlineitemCall<'a, C> {}
11556
11557impl<'a, C> OrderRejectreturnlineitemCall<'a, C>
11558where
11559    C: common::Connector,
11560{
11561    /// Perform the operation you have build so far.
11562    pub async fn doit(
11563        mut self,
11564    ) -> common::Result<(common::Response, OrdersRejectReturnLineItemResponse)> {
11565        use std::borrow::Cow;
11566        use std::io::{Read, Seek};
11567
11568        use common::{url::Params, ToParts};
11569        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11570
11571        let mut dd = common::DefaultDelegate;
11572        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11573        dlg.begin(common::MethodInfo {
11574            id: "content.orders.rejectreturnlineitem",
11575            http_method: hyper::Method::POST,
11576        });
11577
11578        for &field in ["alt", "merchantId", "orderId"].iter() {
11579            if self._additional_params.contains_key(field) {
11580                dlg.finished(false);
11581                return Err(common::Error::FieldClash(field));
11582            }
11583        }
11584
11585        let mut params = Params::with_capacity(5 + self._additional_params.len());
11586        params.push("merchantId", self._merchant_id.to_string());
11587        params.push("orderId", self._order_id);
11588
11589        params.extend(self._additional_params.iter());
11590
11591        params.push("alt", "json");
11592        let mut url =
11593            self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/rejectReturnLineItem";
11594        if self._scopes.is_empty() {
11595            self._scopes.insert(Scope::Full.as_ref().to_string());
11596        }
11597
11598        #[allow(clippy::single_element_loop)]
11599        for &(find_this, param_name) in
11600            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
11601        {
11602            url = params.uri_replacement(url, param_name, find_this, false);
11603        }
11604        {
11605            let to_remove = ["orderId", "merchantId"];
11606            params.remove_params(&to_remove);
11607        }
11608
11609        let url = params.parse_with_url(&url);
11610
11611        let mut json_mime_type = mime::APPLICATION_JSON;
11612        let mut request_value_reader = {
11613            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11614            common::remove_json_null_values(&mut value);
11615            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11616            serde_json::to_writer(&mut dst, &value).unwrap();
11617            dst
11618        };
11619        let request_size = request_value_reader
11620            .seek(std::io::SeekFrom::End(0))
11621            .unwrap();
11622        request_value_reader
11623            .seek(std::io::SeekFrom::Start(0))
11624            .unwrap();
11625
11626        loop {
11627            let token = match self
11628                .hub
11629                .auth
11630                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11631                .await
11632            {
11633                Ok(token) => token,
11634                Err(e) => match dlg.token(e) {
11635                    Ok(token) => token,
11636                    Err(e) => {
11637                        dlg.finished(false);
11638                        return Err(common::Error::MissingToken(e));
11639                    }
11640                },
11641            };
11642            request_value_reader
11643                .seek(std::io::SeekFrom::Start(0))
11644                .unwrap();
11645            let mut req_result = {
11646                let client = &self.hub.client;
11647                dlg.pre_request();
11648                let mut req_builder = hyper::Request::builder()
11649                    .method(hyper::Method::POST)
11650                    .uri(url.as_str())
11651                    .header(USER_AGENT, self.hub._user_agent.clone());
11652
11653                if let Some(token) = token.as_ref() {
11654                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11655                }
11656
11657                let request = req_builder
11658                    .header(CONTENT_TYPE, json_mime_type.to_string())
11659                    .header(CONTENT_LENGTH, request_size as u64)
11660                    .body(common::to_body(
11661                        request_value_reader.get_ref().clone().into(),
11662                    ));
11663
11664                client.request(request.unwrap()).await
11665            };
11666
11667            match req_result {
11668                Err(err) => {
11669                    if let common::Retry::After(d) = dlg.http_error(&err) {
11670                        sleep(d).await;
11671                        continue;
11672                    }
11673                    dlg.finished(false);
11674                    return Err(common::Error::HttpError(err));
11675                }
11676                Ok(res) => {
11677                    let (mut parts, body) = res.into_parts();
11678                    let mut body = common::Body::new(body);
11679                    if !parts.status.is_success() {
11680                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11681                        let error = serde_json::from_str(&common::to_string(&bytes));
11682                        let response = common::to_response(parts, bytes.into());
11683
11684                        if let common::Retry::After(d) =
11685                            dlg.http_failure(&response, error.as_ref().ok())
11686                        {
11687                            sleep(d).await;
11688                            continue;
11689                        }
11690
11691                        dlg.finished(false);
11692
11693                        return Err(match error {
11694                            Ok(value) => common::Error::BadRequest(value),
11695                            _ => common::Error::Failure(response),
11696                        });
11697                    }
11698                    let response = {
11699                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11700                        let encoded = common::to_string(&bytes);
11701                        match serde_json::from_str(&encoded) {
11702                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11703                            Err(error) => {
11704                                dlg.response_json_decode_error(&encoded, &error);
11705                                return Err(common::Error::JsonDecodeError(
11706                                    encoded.to_string(),
11707                                    error,
11708                                ));
11709                            }
11710                        }
11711                    };
11712
11713                    dlg.finished(true);
11714                    return Ok(response);
11715                }
11716            }
11717        }
11718    }
11719
11720    ///
11721    /// Sets the *request* property to the given value.
11722    ///
11723    /// Even though the property as already been set when instantiating this call,
11724    /// we provide this method for API completeness.
11725    pub fn request(
11726        mut self,
11727        new_value: OrdersRejectReturnLineItemRequest,
11728    ) -> OrderRejectreturnlineitemCall<'a, C> {
11729        self._request = new_value;
11730        self
11731    }
11732    /// The ID of the account that manages the order. This cannot be a multi-client account.
11733    ///
11734    /// Sets the *merchant id* path property to the given value.
11735    ///
11736    /// Even though the property as already been set when instantiating this call,
11737    /// we provide this method for API completeness.
11738    pub fn merchant_id(mut self, new_value: u64) -> OrderRejectreturnlineitemCall<'a, C> {
11739        self._merchant_id = new_value;
11740        self
11741    }
11742    /// The ID of the order.
11743    ///
11744    /// Sets the *order id* path property to the given value.
11745    ///
11746    /// Even though the property as already been set when instantiating this call,
11747    /// we provide this method for API completeness.
11748    pub fn order_id(mut self, new_value: &str) -> OrderRejectreturnlineitemCall<'a, C> {
11749        self._order_id = new_value.to_string();
11750        self
11751    }
11752    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11753    /// while executing the actual API request.
11754    ///
11755    /// ````text
11756    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11757    /// ````
11758    ///
11759    /// Sets the *delegate* property to the given value.
11760    pub fn delegate(
11761        mut self,
11762        new_value: &'a mut dyn common::Delegate,
11763    ) -> OrderRejectreturnlineitemCall<'a, C> {
11764        self._delegate = Some(new_value);
11765        self
11766    }
11767
11768    /// Set any additional parameter of the query string used in the request.
11769    /// It should be used to set parameters which are not yet available through their own
11770    /// setters.
11771    ///
11772    /// Please note that this method must not be used to set any of the known parameters
11773    /// which have their own setter method. If done anyway, the request will fail.
11774    ///
11775    /// # Additional Parameters
11776    ///
11777    /// * *alt* (query-string) - Data format for the response.
11778    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11779    /// * *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.
11780    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11781    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11782    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11783    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11784    pub fn param<T>(mut self, name: T, value: T) -> OrderRejectreturnlineitemCall<'a, C>
11785    where
11786        T: AsRef<str>,
11787    {
11788        self._additional_params
11789            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11790        self
11791    }
11792
11793    /// Identifies the authorization scope for the method you are building.
11794    ///
11795    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11796    /// [`Scope::Full`].
11797    ///
11798    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11799    /// tokens for more than one scope.
11800    ///
11801    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11802    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11803    /// sufficient, a read-write scope will do as well.
11804    pub fn add_scope<St>(mut self, scope: St) -> OrderRejectreturnlineitemCall<'a, C>
11805    where
11806        St: AsRef<str>,
11807    {
11808        self._scopes.insert(String::from(scope.as_ref()));
11809        self
11810    }
11811    /// Identifies the authorization scope(s) for the method you are building.
11812    ///
11813    /// See [`Self::add_scope()`] for details.
11814    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderRejectreturnlineitemCall<'a, C>
11815    where
11816        I: IntoIterator<Item = St>,
11817        St: AsRef<str>,
11818    {
11819        self._scopes
11820            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11821        self
11822    }
11823
11824    /// Removes all scopes, and no default scope will be used either.
11825    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11826    /// for details).
11827    pub fn clear_scopes(mut self) -> OrderRejectreturnlineitemCall<'a, C> {
11828        self._scopes.clear();
11829        self
11830    }
11831}
11832
11833/// Returns a line item.
11834///
11835/// A builder for the *returnlineitem* method supported by a *order* resource.
11836/// It is not used directly, but through a [`OrderMethods`] instance.
11837///
11838/// # Example
11839///
11840/// Instantiate a resource method builder
11841///
11842/// ```test_harness,no_run
11843/// # extern crate hyper;
11844/// # extern crate hyper_rustls;
11845/// # extern crate google_content2_sandbox as content2_sandbox;
11846/// use content2_sandbox::api::OrdersReturnLineItemRequest;
11847/// # async fn dox() {
11848/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11849///
11850/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11851/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11852/// #     .with_native_roots()
11853/// #     .unwrap()
11854/// #     .https_only()
11855/// #     .enable_http2()
11856/// #     .build();
11857///
11858/// # let executor = hyper_util::rt::TokioExecutor::new();
11859/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11860/// #     secret,
11861/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11862/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11863/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11864/// #     ),
11865/// # ).build().await.unwrap();
11866///
11867/// # let client = hyper_util::client::legacy::Client::builder(
11868/// #     hyper_util::rt::TokioExecutor::new()
11869/// # )
11870/// # .build(
11871/// #     hyper_rustls::HttpsConnectorBuilder::new()
11872/// #         .with_native_roots()
11873/// #         .unwrap()
11874/// #         .https_or_http()
11875/// #         .enable_http2()
11876/// #         .build()
11877/// # );
11878/// # let mut hub = ShoppingContent::new(client, auth);
11879/// // As the method needs a request, you would usually fill it with the desired information
11880/// // into the respective structure. Some of the parts shown here might not be applicable !
11881/// // Values shown here are possibly random and not representative !
11882/// let mut req = OrdersReturnLineItemRequest::default();
11883///
11884/// // You can configure optional parameters by calling the respective setters at will, and
11885/// // execute the final call using `doit()`.
11886/// // Values shown here are possibly random and not representative !
11887/// let result = hub.orders().returnlineitem(req, 29, "orderId")
11888///              .doit().await;
11889/// # }
11890/// ```
11891pub struct OrderReturnlineitemCall<'a, C>
11892where
11893    C: 'a,
11894{
11895    hub: &'a ShoppingContent<C>,
11896    _request: OrdersReturnLineItemRequest,
11897    _merchant_id: u64,
11898    _order_id: String,
11899    _delegate: Option<&'a mut dyn common::Delegate>,
11900    _additional_params: HashMap<String, String>,
11901    _scopes: BTreeSet<String>,
11902}
11903
11904impl<'a, C> common::CallBuilder for OrderReturnlineitemCall<'a, C> {}
11905
11906impl<'a, C> OrderReturnlineitemCall<'a, C>
11907where
11908    C: common::Connector,
11909{
11910    /// Perform the operation you have build so far.
11911    pub async fn doit(
11912        mut self,
11913    ) -> common::Result<(common::Response, OrdersReturnLineItemResponse)> {
11914        use std::borrow::Cow;
11915        use std::io::{Read, Seek};
11916
11917        use common::{url::Params, ToParts};
11918        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11919
11920        let mut dd = common::DefaultDelegate;
11921        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11922        dlg.begin(common::MethodInfo {
11923            id: "content.orders.returnlineitem",
11924            http_method: hyper::Method::POST,
11925        });
11926
11927        for &field in ["alt", "merchantId", "orderId"].iter() {
11928            if self._additional_params.contains_key(field) {
11929                dlg.finished(false);
11930                return Err(common::Error::FieldClash(field));
11931            }
11932        }
11933
11934        let mut params = Params::with_capacity(5 + self._additional_params.len());
11935        params.push("merchantId", self._merchant_id.to_string());
11936        params.push("orderId", self._order_id);
11937
11938        params.extend(self._additional_params.iter());
11939
11940        params.push("alt", "json");
11941        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/returnLineItem";
11942        if self._scopes.is_empty() {
11943            self._scopes.insert(Scope::Full.as_ref().to_string());
11944        }
11945
11946        #[allow(clippy::single_element_loop)]
11947        for &(find_this, param_name) in
11948            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
11949        {
11950            url = params.uri_replacement(url, param_name, find_this, false);
11951        }
11952        {
11953            let to_remove = ["orderId", "merchantId"];
11954            params.remove_params(&to_remove);
11955        }
11956
11957        let url = params.parse_with_url(&url);
11958
11959        let mut json_mime_type = mime::APPLICATION_JSON;
11960        let mut request_value_reader = {
11961            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11962            common::remove_json_null_values(&mut value);
11963            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11964            serde_json::to_writer(&mut dst, &value).unwrap();
11965            dst
11966        };
11967        let request_size = request_value_reader
11968            .seek(std::io::SeekFrom::End(0))
11969            .unwrap();
11970        request_value_reader
11971            .seek(std::io::SeekFrom::Start(0))
11972            .unwrap();
11973
11974        loop {
11975            let token = match self
11976                .hub
11977                .auth
11978                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11979                .await
11980            {
11981                Ok(token) => token,
11982                Err(e) => match dlg.token(e) {
11983                    Ok(token) => token,
11984                    Err(e) => {
11985                        dlg.finished(false);
11986                        return Err(common::Error::MissingToken(e));
11987                    }
11988                },
11989            };
11990            request_value_reader
11991                .seek(std::io::SeekFrom::Start(0))
11992                .unwrap();
11993            let mut req_result = {
11994                let client = &self.hub.client;
11995                dlg.pre_request();
11996                let mut req_builder = hyper::Request::builder()
11997                    .method(hyper::Method::POST)
11998                    .uri(url.as_str())
11999                    .header(USER_AGENT, self.hub._user_agent.clone());
12000
12001                if let Some(token) = token.as_ref() {
12002                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12003                }
12004
12005                let request = req_builder
12006                    .header(CONTENT_TYPE, json_mime_type.to_string())
12007                    .header(CONTENT_LENGTH, request_size as u64)
12008                    .body(common::to_body(
12009                        request_value_reader.get_ref().clone().into(),
12010                    ));
12011
12012                client.request(request.unwrap()).await
12013            };
12014
12015            match req_result {
12016                Err(err) => {
12017                    if let common::Retry::After(d) = dlg.http_error(&err) {
12018                        sleep(d).await;
12019                        continue;
12020                    }
12021                    dlg.finished(false);
12022                    return Err(common::Error::HttpError(err));
12023                }
12024                Ok(res) => {
12025                    let (mut parts, body) = res.into_parts();
12026                    let mut body = common::Body::new(body);
12027                    if !parts.status.is_success() {
12028                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12029                        let error = serde_json::from_str(&common::to_string(&bytes));
12030                        let response = common::to_response(parts, bytes.into());
12031
12032                        if let common::Retry::After(d) =
12033                            dlg.http_failure(&response, error.as_ref().ok())
12034                        {
12035                            sleep(d).await;
12036                            continue;
12037                        }
12038
12039                        dlg.finished(false);
12040
12041                        return Err(match error {
12042                            Ok(value) => common::Error::BadRequest(value),
12043                            _ => common::Error::Failure(response),
12044                        });
12045                    }
12046                    let response = {
12047                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12048                        let encoded = common::to_string(&bytes);
12049                        match serde_json::from_str(&encoded) {
12050                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12051                            Err(error) => {
12052                                dlg.response_json_decode_error(&encoded, &error);
12053                                return Err(common::Error::JsonDecodeError(
12054                                    encoded.to_string(),
12055                                    error,
12056                                ));
12057                            }
12058                        }
12059                    };
12060
12061                    dlg.finished(true);
12062                    return Ok(response);
12063                }
12064            }
12065        }
12066    }
12067
12068    ///
12069    /// Sets the *request* property to the given value.
12070    ///
12071    /// Even though the property as already been set when instantiating this call,
12072    /// we provide this method for API completeness.
12073    pub fn request(
12074        mut self,
12075        new_value: OrdersReturnLineItemRequest,
12076    ) -> OrderReturnlineitemCall<'a, C> {
12077        self._request = new_value;
12078        self
12079    }
12080    /// The ID of the account that manages the order. This cannot be a multi-client account.
12081    ///
12082    /// Sets the *merchant id* path property to the given value.
12083    ///
12084    /// Even though the property as already been set when instantiating this call,
12085    /// we provide this method for API completeness.
12086    pub fn merchant_id(mut self, new_value: u64) -> OrderReturnlineitemCall<'a, C> {
12087        self._merchant_id = new_value;
12088        self
12089    }
12090    /// The ID of the order.
12091    ///
12092    /// Sets the *order id* path property to the given value.
12093    ///
12094    /// Even though the property as already been set when instantiating this call,
12095    /// we provide this method for API completeness.
12096    pub fn order_id(mut self, new_value: &str) -> OrderReturnlineitemCall<'a, C> {
12097        self._order_id = new_value.to_string();
12098        self
12099    }
12100    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12101    /// while executing the actual API request.
12102    ///
12103    /// ````text
12104    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12105    /// ````
12106    ///
12107    /// Sets the *delegate* property to the given value.
12108    pub fn delegate(
12109        mut self,
12110        new_value: &'a mut dyn common::Delegate,
12111    ) -> OrderReturnlineitemCall<'a, C> {
12112        self._delegate = Some(new_value);
12113        self
12114    }
12115
12116    /// Set any additional parameter of the query string used in the request.
12117    /// It should be used to set parameters which are not yet available through their own
12118    /// setters.
12119    ///
12120    /// Please note that this method must not be used to set any of the known parameters
12121    /// which have their own setter method. If done anyway, the request will fail.
12122    ///
12123    /// # Additional Parameters
12124    ///
12125    /// * *alt* (query-string) - Data format for the response.
12126    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12127    /// * *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.
12128    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12129    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12130    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12131    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12132    pub fn param<T>(mut self, name: T, value: T) -> OrderReturnlineitemCall<'a, C>
12133    where
12134        T: AsRef<str>,
12135    {
12136        self._additional_params
12137            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12138        self
12139    }
12140
12141    /// Identifies the authorization scope for the method you are building.
12142    ///
12143    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12144    /// [`Scope::Full`].
12145    ///
12146    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12147    /// tokens for more than one scope.
12148    ///
12149    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12150    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12151    /// sufficient, a read-write scope will do as well.
12152    pub fn add_scope<St>(mut self, scope: St) -> OrderReturnlineitemCall<'a, C>
12153    where
12154        St: AsRef<str>,
12155    {
12156        self._scopes.insert(String::from(scope.as_ref()));
12157        self
12158    }
12159    /// Identifies the authorization scope(s) for the method you are building.
12160    ///
12161    /// See [`Self::add_scope()`] for details.
12162    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderReturnlineitemCall<'a, C>
12163    where
12164        I: IntoIterator<Item = St>,
12165        St: AsRef<str>,
12166    {
12167        self._scopes
12168            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12169        self
12170    }
12171
12172    /// Removes all scopes, and no default scope will be used either.
12173    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12174    /// for details).
12175    pub fn clear_scopes(mut self) -> OrderReturnlineitemCall<'a, C> {
12176        self._scopes.clear();
12177        self
12178    }
12179}
12180
12181/// Returns and refunds a line item. Note that this method can only be called on fully shipped orders.
12182///
12183/// A builder for the *returnrefundlineitem* method supported by a *order* resource.
12184/// It is not used directly, but through a [`OrderMethods`] instance.
12185///
12186/// # Example
12187///
12188/// Instantiate a resource method builder
12189///
12190/// ```test_harness,no_run
12191/// # extern crate hyper;
12192/// # extern crate hyper_rustls;
12193/// # extern crate google_content2_sandbox as content2_sandbox;
12194/// use content2_sandbox::api::OrdersReturnRefundLineItemRequest;
12195/// # async fn dox() {
12196/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12197///
12198/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12199/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12200/// #     .with_native_roots()
12201/// #     .unwrap()
12202/// #     .https_only()
12203/// #     .enable_http2()
12204/// #     .build();
12205///
12206/// # let executor = hyper_util::rt::TokioExecutor::new();
12207/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12208/// #     secret,
12209/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12210/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12211/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12212/// #     ),
12213/// # ).build().await.unwrap();
12214///
12215/// # let client = hyper_util::client::legacy::Client::builder(
12216/// #     hyper_util::rt::TokioExecutor::new()
12217/// # )
12218/// # .build(
12219/// #     hyper_rustls::HttpsConnectorBuilder::new()
12220/// #         .with_native_roots()
12221/// #         .unwrap()
12222/// #         .https_or_http()
12223/// #         .enable_http2()
12224/// #         .build()
12225/// # );
12226/// # let mut hub = ShoppingContent::new(client, auth);
12227/// // As the method needs a request, you would usually fill it with the desired information
12228/// // into the respective structure. Some of the parts shown here might not be applicable !
12229/// // Values shown here are possibly random and not representative !
12230/// let mut req = OrdersReturnRefundLineItemRequest::default();
12231///
12232/// // You can configure optional parameters by calling the respective setters at will, and
12233/// // execute the final call using `doit()`.
12234/// // Values shown here are possibly random and not representative !
12235/// let result = hub.orders().returnrefundlineitem(req, 5, "orderId")
12236///              .doit().await;
12237/// # }
12238/// ```
12239pub struct OrderReturnrefundlineitemCall<'a, C>
12240where
12241    C: 'a,
12242{
12243    hub: &'a ShoppingContent<C>,
12244    _request: OrdersReturnRefundLineItemRequest,
12245    _merchant_id: u64,
12246    _order_id: String,
12247    _delegate: Option<&'a mut dyn common::Delegate>,
12248    _additional_params: HashMap<String, String>,
12249    _scopes: BTreeSet<String>,
12250}
12251
12252impl<'a, C> common::CallBuilder for OrderReturnrefundlineitemCall<'a, C> {}
12253
12254impl<'a, C> OrderReturnrefundlineitemCall<'a, C>
12255where
12256    C: common::Connector,
12257{
12258    /// Perform the operation you have build so far.
12259    pub async fn doit(
12260        mut self,
12261    ) -> common::Result<(common::Response, OrdersReturnRefundLineItemResponse)> {
12262        use std::borrow::Cow;
12263        use std::io::{Read, Seek};
12264
12265        use common::{url::Params, ToParts};
12266        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12267
12268        let mut dd = common::DefaultDelegate;
12269        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12270        dlg.begin(common::MethodInfo {
12271            id: "content.orders.returnrefundlineitem",
12272            http_method: hyper::Method::POST,
12273        });
12274
12275        for &field in ["alt", "merchantId", "orderId"].iter() {
12276            if self._additional_params.contains_key(field) {
12277                dlg.finished(false);
12278                return Err(common::Error::FieldClash(field));
12279            }
12280        }
12281
12282        let mut params = Params::with_capacity(5 + self._additional_params.len());
12283        params.push("merchantId", self._merchant_id.to_string());
12284        params.push("orderId", self._order_id);
12285
12286        params.extend(self._additional_params.iter());
12287
12288        params.push("alt", "json");
12289        let mut url =
12290            self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/returnRefundLineItem";
12291        if self._scopes.is_empty() {
12292            self._scopes.insert(Scope::Full.as_ref().to_string());
12293        }
12294
12295        #[allow(clippy::single_element_loop)]
12296        for &(find_this, param_name) in
12297            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
12298        {
12299            url = params.uri_replacement(url, param_name, find_this, false);
12300        }
12301        {
12302            let to_remove = ["orderId", "merchantId"];
12303            params.remove_params(&to_remove);
12304        }
12305
12306        let url = params.parse_with_url(&url);
12307
12308        let mut json_mime_type = mime::APPLICATION_JSON;
12309        let mut request_value_reader = {
12310            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12311            common::remove_json_null_values(&mut value);
12312            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12313            serde_json::to_writer(&mut dst, &value).unwrap();
12314            dst
12315        };
12316        let request_size = request_value_reader
12317            .seek(std::io::SeekFrom::End(0))
12318            .unwrap();
12319        request_value_reader
12320            .seek(std::io::SeekFrom::Start(0))
12321            .unwrap();
12322
12323        loop {
12324            let token = match self
12325                .hub
12326                .auth
12327                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12328                .await
12329            {
12330                Ok(token) => token,
12331                Err(e) => match dlg.token(e) {
12332                    Ok(token) => token,
12333                    Err(e) => {
12334                        dlg.finished(false);
12335                        return Err(common::Error::MissingToken(e));
12336                    }
12337                },
12338            };
12339            request_value_reader
12340                .seek(std::io::SeekFrom::Start(0))
12341                .unwrap();
12342            let mut req_result = {
12343                let client = &self.hub.client;
12344                dlg.pre_request();
12345                let mut req_builder = hyper::Request::builder()
12346                    .method(hyper::Method::POST)
12347                    .uri(url.as_str())
12348                    .header(USER_AGENT, self.hub._user_agent.clone());
12349
12350                if let Some(token) = token.as_ref() {
12351                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12352                }
12353
12354                let request = req_builder
12355                    .header(CONTENT_TYPE, json_mime_type.to_string())
12356                    .header(CONTENT_LENGTH, request_size as u64)
12357                    .body(common::to_body(
12358                        request_value_reader.get_ref().clone().into(),
12359                    ));
12360
12361                client.request(request.unwrap()).await
12362            };
12363
12364            match req_result {
12365                Err(err) => {
12366                    if let common::Retry::After(d) = dlg.http_error(&err) {
12367                        sleep(d).await;
12368                        continue;
12369                    }
12370                    dlg.finished(false);
12371                    return Err(common::Error::HttpError(err));
12372                }
12373                Ok(res) => {
12374                    let (mut parts, body) = res.into_parts();
12375                    let mut body = common::Body::new(body);
12376                    if !parts.status.is_success() {
12377                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12378                        let error = serde_json::from_str(&common::to_string(&bytes));
12379                        let response = common::to_response(parts, bytes.into());
12380
12381                        if let common::Retry::After(d) =
12382                            dlg.http_failure(&response, error.as_ref().ok())
12383                        {
12384                            sleep(d).await;
12385                            continue;
12386                        }
12387
12388                        dlg.finished(false);
12389
12390                        return Err(match error {
12391                            Ok(value) => common::Error::BadRequest(value),
12392                            _ => common::Error::Failure(response),
12393                        });
12394                    }
12395                    let response = {
12396                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12397                        let encoded = common::to_string(&bytes);
12398                        match serde_json::from_str(&encoded) {
12399                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12400                            Err(error) => {
12401                                dlg.response_json_decode_error(&encoded, &error);
12402                                return Err(common::Error::JsonDecodeError(
12403                                    encoded.to_string(),
12404                                    error,
12405                                ));
12406                            }
12407                        }
12408                    };
12409
12410                    dlg.finished(true);
12411                    return Ok(response);
12412                }
12413            }
12414        }
12415    }
12416
12417    ///
12418    /// Sets the *request* property to the given value.
12419    ///
12420    /// Even though the property as already been set when instantiating this call,
12421    /// we provide this method for API completeness.
12422    pub fn request(
12423        mut self,
12424        new_value: OrdersReturnRefundLineItemRequest,
12425    ) -> OrderReturnrefundlineitemCall<'a, C> {
12426        self._request = new_value;
12427        self
12428    }
12429    /// The ID of the account that manages the order. This cannot be a multi-client account.
12430    ///
12431    /// Sets the *merchant id* path property to the given value.
12432    ///
12433    /// Even though the property as already been set when instantiating this call,
12434    /// we provide this method for API completeness.
12435    pub fn merchant_id(mut self, new_value: u64) -> OrderReturnrefundlineitemCall<'a, C> {
12436        self._merchant_id = new_value;
12437        self
12438    }
12439    /// The ID of the order.
12440    ///
12441    /// Sets the *order id* path property to the given value.
12442    ///
12443    /// Even though the property as already been set when instantiating this call,
12444    /// we provide this method for API completeness.
12445    pub fn order_id(mut self, new_value: &str) -> OrderReturnrefundlineitemCall<'a, C> {
12446        self._order_id = new_value.to_string();
12447        self
12448    }
12449    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12450    /// while executing the actual API request.
12451    ///
12452    /// ````text
12453    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12454    /// ````
12455    ///
12456    /// Sets the *delegate* property to the given value.
12457    pub fn delegate(
12458        mut self,
12459        new_value: &'a mut dyn common::Delegate,
12460    ) -> OrderReturnrefundlineitemCall<'a, C> {
12461        self._delegate = Some(new_value);
12462        self
12463    }
12464
12465    /// Set any additional parameter of the query string used in the request.
12466    /// It should be used to set parameters which are not yet available through their own
12467    /// setters.
12468    ///
12469    /// Please note that this method must not be used to set any of the known parameters
12470    /// which have their own setter method. If done anyway, the request will fail.
12471    ///
12472    /// # Additional Parameters
12473    ///
12474    /// * *alt* (query-string) - Data format for the response.
12475    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12476    /// * *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.
12477    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12478    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12479    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12480    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12481    pub fn param<T>(mut self, name: T, value: T) -> OrderReturnrefundlineitemCall<'a, C>
12482    where
12483        T: AsRef<str>,
12484    {
12485        self._additional_params
12486            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12487        self
12488    }
12489
12490    /// Identifies the authorization scope for the method you are building.
12491    ///
12492    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12493    /// [`Scope::Full`].
12494    ///
12495    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12496    /// tokens for more than one scope.
12497    ///
12498    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12499    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12500    /// sufficient, a read-write scope will do as well.
12501    pub fn add_scope<St>(mut self, scope: St) -> OrderReturnrefundlineitemCall<'a, C>
12502    where
12503        St: AsRef<str>,
12504    {
12505        self._scopes.insert(String::from(scope.as_ref()));
12506        self
12507    }
12508    /// Identifies the authorization scope(s) for the method you are building.
12509    ///
12510    /// See [`Self::add_scope()`] for details.
12511    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderReturnrefundlineitemCall<'a, C>
12512    where
12513        I: IntoIterator<Item = St>,
12514        St: AsRef<str>,
12515    {
12516        self._scopes
12517            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12518        self
12519    }
12520
12521    /// Removes all scopes, and no default scope will be used either.
12522    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12523    /// for details).
12524    pub fn clear_scopes(mut self) -> OrderReturnrefundlineitemCall<'a, C> {
12525        self._scopes.clear();
12526        self
12527    }
12528}
12529
12530/// Sets (overrides) merchant provided annotations on the line item.
12531///
12532/// A builder for the *setlineitemmetadata* method supported by a *order* resource.
12533/// It is not used directly, but through a [`OrderMethods`] instance.
12534///
12535/// # Example
12536///
12537/// Instantiate a resource method builder
12538///
12539/// ```test_harness,no_run
12540/// # extern crate hyper;
12541/// # extern crate hyper_rustls;
12542/// # extern crate google_content2_sandbox as content2_sandbox;
12543/// use content2_sandbox::api::OrdersSetLineItemMetadataRequest;
12544/// # async fn dox() {
12545/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12546///
12547/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12548/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12549/// #     .with_native_roots()
12550/// #     .unwrap()
12551/// #     .https_only()
12552/// #     .enable_http2()
12553/// #     .build();
12554///
12555/// # let executor = hyper_util::rt::TokioExecutor::new();
12556/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12557/// #     secret,
12558/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12559/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12560/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12561/// #     ),
12562/// # ).build().await.unwrap();
12563///
12564/// # let client = hyper_util::client::legacy::Client::builder(
12565/// #     hyper_util::rt::TokioExecutor::new()
12566/// # )
12567/// # .build(
12568/// #     hyper_rustls::HttpsConnectorBuilder::new()
12569/// #         .with_native_roots()
12570/// #         .unwrap()
12571/// #         .https_or_http()
12572/// #         .enable_http2()
12573/// #         .build()
12574/// # );
12575/// # let mut hub = ShoppingContent::new(client, auth);
12576/// // As the method needs a request, you would usually fill it with the desired information
12577/// // into the respective structure. Some of the parts shown here might not be applicable !
12578/// // Values shown here are possibly random and not representative !
12579/// let mut req = OrdersSetLineItemMetadataRequest::default();
12580///
12581/// // You can configure optional parameters by calling the respective setters at will, and
12582/// // execute the final call using `doit()`.
12583/// // Values shown here are possibly random and not representative !
12584/// let result = hub.orders().setlineitemmetadata(req, 71, "orderId")
12585///              .doit().await;
12586/// # }
12587/// ```
12588pub struct OrderSetlineitemmetadataCall<'a, C>
12589where
12590    C: 'a,
12591{
12592    hub: &'a ShoppingContent<C>,
12593    _request: OrdersSetLineItemMetadataRequest,
12594    _merchant_id: u64,
12595    _order_id: String,
12596    _delegate: Option<&'a mut dyn common::Delegate>,
12597    _additional_params: HashMap<String, String>,
12598    _scopes: BTreeSet<String>,
12599}
12600
12601impl<'a, C> common::CallBuilder for OrderSetlineitemmetadataCall<'a, C> {}
12602
12603impl<'a, C> OrderSetlineitemmetadataCall<'a, C>
12604where
12605    C: common::Connector,
12606{
12607    /// Perform the operation you have build so far.
12608    pub async fn doit(
12609        mut self,
12610    ) -> common::Result<(common::Response, OrdersSetLineItemMetadataResponse)> {
12611        use std::borrow::Cow;
12612        use std::io::{Read, Seek};
12613
12614        use common::{url::Params, ToParts};
12615        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12616
12617        let mut dd = common::DefaultDelegate;
12618        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12619        dlg.begin(common::MethodInfo {
12620            id: "content.orders.setlineitemmetadata",
12621            http_method: hyper::Method::POST,
12622        });
12623
12624        for &field in ["alt", "merchantId", "orderId"].iter() {
12625            if self._additional_params.contains_key(field) {
12626                dlg.finished(false);
12627                return Err(common::Error::FieldClash(field));
12628            }
12629        }
12630
12631        let mut params = Params::with_capacity(5 + self._additional_params.len());
12632        params.push("merchantId", self._merchant_id.to_string());
12633        params.push("orderId", self._order_id);
12634
12635        params.extend(self._additional_params.iter());
12636
12637        params.push("alt", "json");
12638        let mut url =
12639            self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/setLineItemMetadata";
12640        if self._scopes.is_empty() {
12641            self._scopes.insert(Scope::Full.as_ref().to_string());
12642        }
12643
12644        #[allow(clippy::single_element_loop)]
12645        for &(find_this, param_name) in
12646            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
12647        {
12648            url = params.uri_replacement(url, param_name, find_this, false);
12649        }
12650        {
12651            let to_remove = ["orderId", "merchantId"];
12652            params.remove_params(&to_remove);
12653        }
12654
12655        let url = params.parse_with_url(&url);
12656
12657        let mut json_mime_type = mime::APPLICATION_JSON;
12658        let mut request_value_reader = {
12659            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12660            common::remove_json_null_values(&mut value);
12661            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12662            serde_json::to_writer(&mut dst, &value).unwrap();
12663            dst
12664        };
12665        let request_size = request_value_reader
12666            .seek(std::io::SeekFrom::End(0))
12667            .unwrap();
12668        request_value_reader
12669            .seek(std::io::SeekFrom::Start(0))
12670            .unwrap();
12671
12672        loop {
12673            let token = match self
12674                .hub
12675                .auth
12676                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12677                .await
12678            {
12679                Ok(token) => token,
12680                Err(e) => match dlg.token(e) {
12681                    Ok(token) => token,
12682                    Err(e) => {
12683                        dlg.finished(false);
12684                        return Err(common::Error::MissingToken(e));
12685                    }
12686                },
12687            };
12688            request_value_reader
12689                .seek(std::io::SeekFrom::Start(0))
12690                .unwrap();
12691            let mut req_result = {
12692                let client = &self.hub.client;
12693                dlg.pre_request();
12694                let mut req_builder = hyper::Request::builder()
12695                    .method(hyper::Method::POST)
12696                    .uri(url.as_str())
12697                    .header(USER_AGENT, self.hub._user_agent.clone());
12698
12699                if let Some(token) = token.as_ref() {
12700                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12701                }
12702
12703                let request = req_builder
12704                    .header(CONTENT_TYPE, json_mime_type.to_string())
12705                    .header(CONTENT_LENGTH, request_size as u64)
12706                    .body(common::to_body(
12707                        request_value_reader.get_ref().clone().into(),
12708                    ));
12709
12710                client.request(request.unwrap()).await
12711            };
12712
12713            match req_result {
12714                Err(err) => {
12715                    if let common::Retry::After(d) = dlg.http_error(&err) {
12716                        sleep(d).await;
12717                        continue;
12718                    }
12719                    dlg.finished(false);
12720                    return Err(common::Error::HttpError(err));
12721                }
12722                Ok(res) => {
12723                    let (mut parts, body) = res.into_parts();
12724                    let mut body = common::Body::new(body);
12725                    if !parts.status.is_success() {
12726                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12727                        let error = serde_json::from_str(&common::to_string(&bytes));
12728                        let response = common::to_response(parts, bytes.into());
12729
12730                        if let common::Retry::After(d) =
12731                            dlg.http_failure(&response, error.as_ref().ok())
12732                        {
12733                            sleep(d).await;
12734                            continue;
12735                        }
12736
12737                        dlg.finished(false);
12738
12739                        return Err(match error {
12740                            Ok(value) => common::Error::BadRequest(value),
12741                            _ => common::Error::Failure(response),
12742                        });
12743                    }
12744                    let response = {
12745                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12746                        let encoded = common::to_string(&bytes);
12747                        match serde_json::from_str(&encoded) {
12748                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12749                            Err(error) => {
12750                                dlg.response_json_decode_error(&encoded, &error);
12751                                return Err(common::Error::JsonDecodeError(
12752                                    encoded.to_string(),
12753                                    error,
12754                                ));
12755                            }
12756                        }
12757                    };
12758
12759                    dlg.finished(true);
12760                    return Ok(response);
12761                }
12762            }
12763        }
12764    }
12765
12766    ///
12767    /// Sets the *request* property to the given value.
12768    ///
12769    /// Even though the property as already been set when instantiating this call,
12770    /// we provide this method for API completeness.
12771    pub fn request(
12772        mut self,
12773        new_value: OrdersSetLineItemMetadataRequest,
12774    ) -> OrderSetlineitemmetadataCall<'a, C> {
12775        self._request = new_value;
12776        self
12777    }
12778    /// The ID of the account that manages the order. This cannot be a multi-client account.
12779    ///
12780    /// Sets the *merchant id* path property to the given value.
12781    ///
12782    /// Even though the property as already been set when instantiating this call,
12783    /// we provide this method for API completeness.
12784    pub fn merchant_id(mut self, new_value: u64) -> OrderSetlineitemmetadataCall<'a, C> {
12785        self._merchant_id = new_value;
12786        self
12787    }
12788    /// The ID of the order.
12789    ///
12790    /// Sets the *order id* path property to the given value.
12791    ///
12792    /// Even though the property as already been set when instantiating this call,
12793    /// we provide this method for API completeness.
12794    pub fn order_id(mut self, new_value: &str) -> OrderSetlineitemmetadataCall<'a, C> {
12795        self._order_id = new_value.to_string();
12796        self
12797    }
12798    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12799    /// while executing the actual API request.
12800    ///
12801    /// ````text
12802    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12803    /// ````
12804    ///
12805    /// Sets the *delegate* property to the given value.
12806    pub fn delegate(
12807        mut self,
12808        new_value: &'a mut dyn common::Delegate,
12809    ) -> OrderSetlineitemmetadataCall<'a, C> {
12810        self._delegate = Some(new_value);
12811        self
12812    }
12813
12814    /// Set any additional parameter of the query string used in the request.
12815    /// It should be used to set parameters which are not yet available through their own
12816    /// setters.
12817    ///
12818    /// Please note that this method must not be used to set any of the known parameters
12819    /// which have their own setter method. If done anyway, the request will fail.
12820    ///
12821    /// # Additional Parameters
12822    ///
12823    /// * *alt* (query-string) - Data format for the response.
12824    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12825    /// * *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.
12826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12827    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12828    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12829    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12830    pub fn param<T>(mut self, name: T, value: T) -> OrderSetlineitemmetadataCall<'a, C>
12831    where
12832        T: AsRef<str>,
12833    {
12834        self._additional_params
12835            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12836        self
12837    }
12838
12839    /// Identifies the authorization scope for the method you are building.
12840    ///
12841    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12842    /// [`Scope::Full`].
12843    ///
12844    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12845    /// tokens for more than one scope.
12846    ///
12847    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12848    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12849    /// sufficient, a read-write scope will do as well.
12850    pub fn add_scope<St>(mut self, scope: St) -> OrderSetlineitemmetadataCall<'a, C>
12851    where
12852        St: AsRef<str>,
12853    {
12854        self._scopes.insert(String::from(scope.as_ref()));
12855        self
12856    }
12857    /// Identifies the authorization scope(s) for the method you are building.
12858    ///
12859    /// See [`Self::add_scope()`] for details.
12860    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderSetlineitemmetadataCall<'a, C>
12861    where
12862        I: IntoIterator<Item = St>,
12863        St: AsRef<str>,
12864    {
12865        self._scopes
12866            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12867        self
12868    }
12869
12870    /// Removes all scopes, and no default scope will be used either.
12871    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12872    /// for details).
12873    pub fn clear_scopes(mut self) -> OrderSetlineitemmetadataCall<'a, C> {
12874        self._scopes.clear();
12875        self
12876    }
12877}
12878
12879/// Marks line item(s) as shipped.
12880///
12881/// A builder for the *shiplineitems* method supported by a *order* resource.
12882/// It is not used directly, but through a [`OrderMethods`] instance.
12883///
12884/// # Example
12885///
12886/// Instantiate a resource method builder
12887///
12888/// ```test_harness,no_run
12889/// # extern crate hyper;
12890/// # extern crate hyper_rustls;
12891/// # extern crate google_content2_sandbox as content2_sandbox;
12892/// use content2_sandbox::api::OrdersShipLineItemsRequest;
12893/// # async fn dox() {
12894/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12895///
12896/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12897/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12898/// #     .with_native_roots()
12899/// #     .unwrap()
12900/// #     .https_only()
12901/// #     .enable_http2()
12902/// #     .build();
12903///
12904/// # let executor = hyper_util::rt::TokioExecutor::new();
12905/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12906/// #     secret,
12907/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12908/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12909/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12910/// #     ),
12911/// # ).build().await.unwrap();
12912///
12913/// # let client = hyper_util::client::legacy::Client::builder(
12914/// #     hyper_util::rt::TokioExecutor::new()
12915/// # )
12916/// # .build(
12917/// #     hyper_rustls::HttpsConnectorBuilder::new()
12918/// #         .with_native_roots()
12919/// #         .unwrap()
12920/// #         .https_or_http()
12921/// #         .enable_http2()
12922/// #         .build()
12923/// # );
12924/// # let mut hub = ShoppingContent::new(client, auth);
12925/// // As the method needs a request, you would usually fill it with the desired information
12926/// // into the respective structure. Some of the parts shown here might not be applicable !
12927/// // Values shown here are possibly random and not representative !
12928/// let mut req = OrdersShipLineItemsRequest::default();
12929///
12930/// // You can configure optional parameters by calling the respective setters at will, and
12931/// // execute the final call using `doit()`.
12932/// // Values shown here are possibly random and not representative !
12933/// let result = hub.orders().shiplineitems(req, 82, "orderId")
12934///              .doit().await;
12935/// # }
12936/// ```
12937pub struct OrderShiplineitemCall<'a, C>
12938where
12939    C: 'a,
12940{
12941    hub: &'a ShoppingContent<C>,
12942    _request: OrdersShipLineItemsRequest,
12943    _merchant_id: u64,
12944    _order_id: String,
12945    _delegate: Option<&'a mut dyn common::Delegate>,
12946    _additional_params: HashMap<String, String>,
12947    _scopes: BTreeSet<String>,
12948}
12949
12950impl<'a, C> common::CallBuilder for OrderShiplineitemCall<'a, C> {}
12951
12952impl<'a, C> OrderShiplineitemCall<'a, C>
12953where
12954    C: common::Connector,
12955{
12956    /// Perform the operation you have build so far.
12957    pub async fn doit(mut self) -> common::Result<(common::Response, OrdersShipLineItemsResponse)> {
12958        use std::borrow::Cow;
12959        use std::io::{Read, Seek};
12960
12961        use common::{url::Params, ToParts};
12962        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12963
12964        let mut dd = common::DefaultDelegate;
12965        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12966        dlg.begin(common::MethodInfo {
12967            id: "content.orders.shiplineitems",
12968            http_method: hyper::Method::POST,
12969        });
12970
12971        for &field in ["alt", "merchantId", "orderId"].iter() {
12972            if self._additional_params.contains_key(field) {
12973                dlg.finished(false);
12974                return Err(common::Error::FieldClash(field));
12975            }
12976        }
12977
12978        let mut params = Params::with_capacity(5 + self._additional_params.len());
12979        params.push("merchantId", self._merchant_id.to_string());
12980        params.push("orderId", self._order_id);
12981
12982        params.extend(self._additional_params.iter());
12983
12984        params.push("alt", "json");
12985        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/shipLineItems";
12986        if self._scopes.is_empty() {
12987            self._scopes.insert(Scope::Full.as_ref().to_string());
12988        }
12989
12990        #[allow(clippy::single_element_loop)]
12991        for &(find_this, param_name) in
12992            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
12993        {
12994            url = params.uri_replacement(url, param_name, find_this, false);
12995        }
12996        {
12997            let to_remove = ["orderId", "merchantId"];
12998            params.remove_params(&to_remove);
12999        }
13000
13001        let url = params.parse_with_url(&url);
13002
13003        let mut json_mime_type = mime::APPLICATION_JSON;
13004        let mut request_value_reader = {
13005            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13006            common::remove_json_null_values(&mut value);
13007            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13008            serde_json::to_writer(&mut dst, &value).unwrap();
13009            dst
13010        };
13011        let request_size = request_value_reader
13012            .seek(std::io::SeekFrom::End(0))
13013            .unwrap();
13014        request_value_reader
13015            .seek(std::io::SeekFrom::Start(0))
13016            .unwrap();
13017
13018        loop {
13019            let token = match self
13020                .hub
13021                .auth
13022                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13023                .await
13024            {
13025                Ok(token) => token,
13026                Err(e) => match dlg.token(e) {
13027                    Ok(token) => token,
13028                    Err(e) => {
13029                        dlg.finished(false);
13030                        return Err(common::Error::MissingToken(e));
13031                    }
13032                },
13033            };
13034            request_value_reader
13035                .seek(std::io::SeekFrom::Start(0))
13036                .unwrap();
13037            let mut req_result = {
13038                let client = &self.hub.client;
13039                dlg.pre_request();
13040                let mut req_builder = hyper::Request::builder()
13041                    .method(hyper::Method::POST)
13042                    .uri(url.as_str())
13043                    .header(USER_AGENT, self.hub._user_agent.clone());
13044
13045                if let Some(token) = token.as_ref() {
13046                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13047                }
13048
13049                let request = req_builder
13050                    .header(CONTENT_TYPE, json_mime_type.to_string())
13051                    .header(CONTENT_LENGTH, request_size as u64)
13052                    .body(common::to_body(
13053                        request_value_reader.get_ref().clone().into(),
13054                    ));
13055
13056                client.request(request.unwrap()).await
13057            };
13058
13059            match req_result {
13060                Err(err) => {
13061                    if let common::Retry::After(d) = dlg.http_error(&err) {
13062                        sleep(d).await;
13063                        continue;
13064                    }
13065                    dlg.finished(false);
13066                    return Err(common::Error::HttpError(err));
13067                }
13068                Ok(res) => {
13069                    let (mut parts, body) = res.into_parts();
13070                    let mut body = common::Body::new(body);
13071                    if !parts.status.is_success() {
13072                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13073                        let error = serde_json::from_str(&common::to_string(&bytes));
13074                        let response = common::to_response(parts, bytes.into());
13075
13076                        if let common::Retry::After(d) =
13077                            dlg.http_failure(&response, error.as_ref().ok())
13078                        {
13079                            sleep(d).await;
13080                            continue;
13081                        }
13082
13083                        dlg.finished(false);
13084
13085                        return Err(match error {
13086                            Ok(value) => common::Error::BadRequest(value),
13087                            _ => common::Error::Failure(response),
13088                        });
13089                    }
13090                    let response = {
13091                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13092                        let encoded = common::to_string(&bytes);
13093                        match serde_json::from_str(&encoded) {
13094                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13095                            Err(error) => {
13096                                dlg.response_json_decode_error(&encoded, &error);
13097                                return Err(common::Error::JsonDecodeError(
13098                                    encoded.to_string(),
13099                                    error,
13100                                ));
13101                            }
13102                        }
13103                    };
13104
13105                    dlg.finished(true);
13106                    return Ok(response);
13107                }
13108            }
13109        }
13110    }
13111
13112    ///
13113    /// Sets the *request* property to the given value.
13114    ///
13115    /// Even though the property as already been set when instantiating this call,
13116    /// we provide this method for API completeness.
13117    pub fn request(
13118        mut self,
13119        new_value: OrdersShipLineItemsRequest,
13120    ) -> OrderShiplineitemCall<'a, C> {
13121        self._request = new_value;
13122        self
13123    }
13124    /// The ID of the account that manages the order. This cannot be a multi-client account.
13125    ///
13126    /// Sets the *merchant id* path property to the given value.
13127    ///
13128    /// Even though the property as already been set when instantiating this call,
13129    /// we provide this method for API completeness.
13130    pub fn merchant_id(mut self, new_value: u64) -> OrderShiplineitemCall<'a, C> {
13131        self._merchant_id = new_value;
13132        self
13133    }
13134    /// The ID of the order.
13135    ///
13136    /// Sets the *order id* path property to the given value.
13137    ///
13138    /// Even though the property as already been set when instantiating this call,
13139    /// we provide this method for API completeness.
13140    pub fn order_id(mut self, new_value: &str) -> OrderShiplineitemCall<'a, C> {
13141        self._order_id = new_value.to_string();
13142        self
13143    }
13144    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13145    /// while executing the actual API request.
13146    ///
13147    /// ````text
13148    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13149    /// ````
13150    ///
13151    /// Sets the *delegate* property to the given value.
13152    pub fn delegate(
13153        mut self,
13154        new_value: &'a mut dyn common::Delegate,
13155    ) -> OrderShiplineitemCall<'a, C> {
13156        self._delegate = Some(new_value);
13157        self
13158    }
13159
13160    /// Set any additional parameter of the query string used in the request.
13161    /// It should be used to set parameters which are not yet available through their own
13162    /// setters.
13163    ///
13164    /// Please note that this method must not be used to set any of the known parameters
13165    /// which have their own setter method. If done anyway, the request will fail.
13166    ///
13167    /// # Additional Parameters
13168    ///
13169    /// * *alt* (query-string) - Data format for the response.
13170    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13171    /// * *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.
13172    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13173    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13174    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13175    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13176    pub fn param<T>(mut self, name: T, value: T) -> OrderShiplineitemCall<'a, C>
13177    where
13178        T: AsRef<str>,
13179    {
13180        self._additional_params
13181            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13182        self
13183    }
13184
13185    /// Identifies the authorization scope for the method you are building.
13186    ///
13187    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13188    /// [`Scope::Full`].
13189    ///
13190    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13191    /// tokens for more than one scope.
13192    ///
13193    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13194    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13195    /// sufficient, a read-write scope will do as well.
13196    pub fn add_scope<St>(mut self, scope: St) -> OrderShiplineitemCall<'a, C>
13197    where
13198        St: AsRef<str>,
13199    {
13200        self._scopes.insert(String::from(scope.as_ref()));
13201        self
13202    }
13203    /// Identifies the authorization scope(s) for the method you are building.
13204    ///
13205    /// See [`Self::add_scope()`] for details.
13206    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderShiplineitemCall<'a, C>
13207    where
13208        I: IntoIterator<Item = St>,
13209        St: AsRef<str>,
13210    {
13211        self._scopes
13212            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13213        self
13214    }
13215
13216    /// Removes all scopes, and no default scope will be used either.
13217    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13218    /// for details).
13219    pub fn clear_scopes(mut self) -> OrderShiplineitemCall<'a, C> {
13220        self._scopes.clear();
13221        self
13222    }
13223}
13224
13225/// Updates ship by and delivery by dates for a line item.
13226///
13227/// A builder for the *updatelineitemshippingdetails* method supported by a *order* resource.
13228/// It is not used directly, but through a [`OrderMethods`] instance.
13229///
13230/// # Example
13231///
13232/// Instantiate a resource method builder
13233///
13234/// ```test_harness,no_run
13235/// # extern crate hyper;
13236/// # extern crate hyper_rustls;
13237/// # extern crate google_content2_sandbox as content2_sandbox;
13238/// use content2_sandbox::api::OrdersUpdateLineItemShippingDetailsRequest;
13239/// # async fn dox() {
13240/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13241///
13242/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13243/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13244/// #     .with_native_roots()
13245/// #     .unwrap()
13246/// #     .https_only()
13247/// #     .enable_http2()
13248/// #     .build();
13249///
13250/// # let executor = hyper_util::rt::TokioExecutor::new();
13251/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13252/// #     secret,
13253/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13254/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13255/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13256/// #     ),
13257/// # ).build().await.unwrap();
13258///
13259/// # let client = hyper_util::client::legacy::Client::builder(
13260/// #     hyper_util::rt::TokioExecutor::new()
13261/// # )
13262/// # .build(
13263/// #     hyper_rustls::HttpsConnectorBuilder::new()
13264/// #         .with_native_roots()
13265/// #         .unwrap()
13266/// #         .https_or_http()
13267/// #         .enable_http2()
13268/// #         .build()
13269/// # );
13270/// # let mut hub = ShoppingContent::new(client, auth);
13271/// // As the method needs a request, you would usually fill it with the desired information
13272/// // into the respective structure. Some of the parts shown here might not be applicable !
13273/// // Values shown here are possibly random and not representative !
13274/// let mut req = OrdersUpdateLineItemShippingDetailsRequest::default();
13275///
13276/// // You can configure optional parameters by calling the respective setters at will, and
13277/// // execute the final call using `doit()`.
13278/// // Values shown here are possibly random and not representative !
13279/// let result = hub.orders().updatelineitemshippingdetails(req, 27, "orderId")
13280///              .doit().await;
13281/// # }
13282/// ```
13283pub struct OrderUpdatelineitemshippingdetailCall<'a, C>
13284where
13285    C: 'a,
13286{
13287    hub: &'a ShoppingContent<C>,
13288    _request: OrdersUpdateLineItemShippingDetailsRequest,
13289    _merchant_id: u64,
13290    _order_id: String,
13291    _delegate: Option<&'a mut dyn common::Delegate>,
13292    _additional_params: HashMap<String, String>,
13293    _scopes: BTreeSet<String>,
13294}
13295
13296impl<'a, C> common::CallBuilder for OrderUpdatelineitemshippingdetailCall<'a, C> {}
13297
13298impl<'a, C> OrderUpdatelineitemshippingdetailCall<'a, C>
13299where
13300    C: common::Connector,
13301{
13302    /// Perform the operation you have build so far.
13303    pub async fn doit(
13304        mut self,
13305    ) -> common::Result<(
13306        common::Response,
13307        OrdersUpdateLineItemShippingDetailsResponse,
13308    )> {
13309        use std::borrow::Cow;
13310        use std::io::{Read, Seek};
13311
13312        use common::{url::Params, ToParts};
13313        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13314
13315        let mut dd = common::DefaultDelegate;
13316        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13317        dlg.begin(common::MethodInfo {
13318            id: "content.orders.updatelineitemshippingdetails",
13319            http_method: hyper::Method::POST,
13320        });
13321
13322        for &field in ["alt", "merchantId", "orderId"].iter() {
13323            if self._additional_params.contains_key(field) {
13324                dlg.finished(false);
13325                return Err(common::Error::FieldClash(field));
13326            }
13327        }
13328
13329        let mut params = Params::with_capacity(5 + self._additional_params.len());
13330        params.push("merchantId", self._merchant_id.to_string());
13331        params.push("orderId", self._order_id);
13332
13333        params.extend(self._additional_params.iter());
13334
13335        params.push("alt", "json");
13336        let mut url = self.hub._base_url.clone()
13337            + "{merchantId}/orders/{orderId}/updateLineItemShippingDetails";
13338        if self._scopes.is_empty() {
13339            self._scopes.insert(Scope::Full.as_ref().to_string());
13340        }
13341
13342        #[allow(clippy::single_element_loop)]
13343        for &(find_this, param_name) in
13344            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
13345        {
13346            url = params.uri_replacement(url, param_name, find_this, false);
13347        }
13348        {
13349            let to_remove = ["orderId", "merchantId"];
13350            params.remove_params(&to_remove);
13351        }
13352
13353        let url = params.parse_with_url(&url);
13354
13355        let mut json_mime_type = mime::APPLICATION_JSON;
13356        let mut request_value_reader = {
13357            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13358            common::remove_json_null_values(&mut value);
13359            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13360            serde_json::to_writer(&mut dst, &value).unwrap();
13361            dst
13362        };
13363        let request_size = request_value_reader
13364            .seek(std::io::SeekFrom::End(0))
13365            .unwrap();
13366        request_value_reader
13367            .seek(std::io::SeekFrom::Start(0))
13368            .unwrap();
13369
13370        loop {
13371            let token = match self
13372                .hub
13373                .auth
13374                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13375                .await
13376            {
13377                Ok(token) => token,
13378                Err(e) => match dlg.token(e) {
13379                    Ok(token) => token,
13380                    Err(e) => {
13381                        dlg.finished(false);
13382                        return Err(common::Error::MissingToken(e));
13383                    }
13384                },
13385            };
13386            request_value_reader
13387                .seek(std::io::SeekFrom::Start(0))
13388                .unwrap();
13389            let mut req_result = {
13390                let client = &self.hub.client;
13391                dlg.pre_request();
13392                let mut req_builder = hyper::Request::builder()
13393                    .method(hyper::Method::POST)
13394                    .uri(url.as_str())
13395                    .header(USER_AGENT, self.hub._user_agent.clone());
13396
13397                if let Some(token) = token.as_ref() {
13398                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13399                }
13400
13401                let request = req_builder
13402                    .header(CONTENT_TYPE, json_mime_type.to_string())
13403                    .header(CONTENT_LENGTH, request_size as u64)
13404                    .body(common::to_body(
13405                        request_value_reader.get_ref().clone().into(),
13406                    ));
13407
13408                client.request(request.unwrap()).await
13409            };
13410
13411            match req_result {
13412                Err(err) => {
13413                    if let common::Retry::After(d) = dlg.http_error(&err) {
13414                        sleep(d).await;
13415                        continue;
13416                    }
13417                    dlg.finished(false);
13418                    return Err(common::Error::HttpError(err));
13419                }
13420                Ok(res) => {
13421                    let (mut parts, body) = res.into_parts();
13422                    let mut body = common::Body::new(body);
13423                    if !parts.status.is_success() {
13424                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13425                        let error = serde_json::from_str(&common::to_string(&bytes));
13426                        let response = common::to_response(parts, bytes.into());
13427
13428                        if let common::Retry::After(d) =
13429                            dlg.http_failure(&response, error.as_ref().ok())
13430                        {
13431                            sleep(d).await;
13432                            continue;
13433                        }
13434
13435                        dlg.finished(false);
13436
13437                        return Err(match error {
13438                            Ok(value) => common::Error::BadRequest(value),
13439                            _ => common::Error::Failure(response),
13440                        });
13441                    }
13442                    let response = {
13443                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13444                        let encoded = common::to_string(&bytes);
13445                        match serde_json::from_str(&encoded) {
13446                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13447                            Err(error) => {
13448                                dlg.response_json_decode_error(&encoded, &error);
13449                                return Err(common::Error::JsonDecodeError(
13450                                    encoded.to_string(),
13451                                    error,
13452                                ));
13453                            }
13454                        }
13455                    };
13456
13457                    dlg.finished(true);
13458                    return Ok(response);
13459                }
13460            }
13461        }
13462    }
13463
13464    ///
13465    /// Sets the *request* property to the given value.
13466    ///
13467    /// Even though the property as already been set when instantiating this call,
13468    /// we provide this method for API completeness.
13469    pub fn request(
13470        mut self,
13471        new_value: OrdersUpdateLineItemShippingDetailsRequest,
13472    ) -> OrderUpdatelineitemshippingdetailCall<'a, C> {
13473        self._request = new_value;
13474        self
13475    }
13476    /// The ID of the account that manages the order. This cannot be a multi-client account.
13477    ///
13478    /// Sets the *merchant id* path property to the given value.
13479    ///
13480    /// Even though the property as already been set when instantiating this call,
13481    /// we provide this method for API completeness.
13482    pub fn merchant_id(mut self, new_value: u64) -> OrderUpdatelineitemshippingdetailCall<'a, C> {
13483        self._merchant_id = new_value;
13484        self
13485    }
13486    /// The ID of the order.
13487    ///
13488    /// Sets the *order id* path property to the given value.
13489    ///
13490    /// Even though the property as already been set when instantiating this call,
13491    /// we provide this method for API completeness.
13492    pub fn order_id(mut self, new_value: &str) -> OrderUpdatelineitemshippingdetailCall<'a, C> {
13493        self._order_id = new_value.to_string();
13494        self
13495    }
13496    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13497    /// while executing the actual API request.
13498    ///
13499    /// ````text
13500    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13501    /// ````
13502    ///
13503    /// Sets the *delegate* property to the given value.
13504    pub fn delegate(
13505        mut self,
13506        new_value: &'a mut dyn common::Delegate,
13507    ) -> OrderUpdatelineitemshippingdetailCall<'a, C> {
13508        self._delegate = Some(new_value);
13509        self
13510    }
13511
13512    /// Set any additional parameter of the query string used in the request.
13513    /// It should be used to set parameters which are not yet available through their own
13514    /// setters.
13515    ///
13516    /// Please note that this method must not be used to set any of the known parameters
13517    /// which have their own setter method. If done anyway, the request will fail.
13518    ///
13519    /// # Additional Parameters
13520    ///
13521    /// * *alt* (query-string) - Data format for the response.
13522    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13523    /// * *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.
13524    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13525    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13526    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13527    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13528    pub fn param<T>(mut self, name: T, value: T) -> OrderUpdatelineitemshippingdetailCall<'a, C>
13529    where
13530        T: AsRef<str>,
13531    {
13532        self._additional_params
13533            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13534        self
13535    }
13536
13537    /// Identifies the authorization scope for the method you are building.
13538    ///
13539    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13540    /// [`Scope::Full`].
13541    ///
13542    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13543    /// tokens for more than one scope.
13544    ///
13545    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13546    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13547    /// sufficient, a read-write scope will do as well.
13548    pub fn add_scope<St>(mut self, scope: St) -> OrderUpdatelineitemshippingdetailCall<'a, C>
13549    where
13550        St: AsRef<str>,
13551    {
13552        self._scopes.insert(String::from(scope.as_ref()));
13553        self
13554    }
13555    /// Identifies the authorization scope(s) for the method you are building.
13556    ///
13557    /// See [`Self::add_scope()`] for details.
13558    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderUpdatelineitemshippingdetailCall<'a, C>
13559    where
13560        I: IntoIterator<Item = St>,
13561        St: AsRef<str>,
13562    {
13563        self._scopes
13564            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13565        self
13566    }
13567
13568    /// Removes all scopes, and no default scope will be used either.
13569    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13570    /// for details).
13571    pub fn clear_scopes(mut self) -> OrderUpdatelineitemshippingdetailCall<'a, C> {
13572        self._scopes.clear();
13573        self
13574    }
13575}
13576
13577/// Updates the merchant order ID for a given order.
13578///
13579/// A builder for the *updatemerchantorderid* method supported by a *order* resource.
13580/// It is not used directly, but through a [`OrderMethods`] instance.
13581///
13582/// # Example
13583///
13584/// Instantiate a resource method builder
13585///
13586/// ```test_harness,no_run
13587/// # extern crate hyper;
13588/// # extern crate hyper_rustls;
13589/// # extern crate google_content2_sandbox as content2_sandbox;
13590/// use content2_sandbox::api::OrdersUpdateMerchantOrderIdRequest;
13591/// # async fn dox() {
13592/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13593///
13594/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13595/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13596/// #     .with_native_roots()
13597/// #     .unwrap()
13598/// #     .https_only()
13599/// #     .enable_http2()
13600/// #     .build();
13601///
13602/// # let executor = hyper_util::rt::TokioExecutor::new();
13603/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13604/// #     secret,
13605/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13606/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13607/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13608/// #     ),
13609/// # ).build().await.unwrap();
13610///
13611/// # let client = hyper_util::client::legacy::Client::builder(
13612/// #     hyper_util::rt::TokioExecutor::new()
13613/// # )
13614/// # .build(
13615/// #     hyper_rustls::HttpsConnectorBuilder::new()
13616/// #         .with_native_roots()
13617/// #         .unwrap()
13618/// #         .https_or_http()
13619/// #         .enable_http2()
13620/// #         .build()
13621/// # );
13622/// # let mut hub = ShoppingContent::new(client, auth);
13623/// // As the method needs a request, you would usually fill it with the desired information
13624/// // into the respective structure. Some of the parts shown here might not be applicable !
13625/// // Values shown here are possibly random and not representative !
13626/// let mut req = OrdersUpdateMerchantOrderIdRequest::default();
13627///
13628/// // You can configure optional parameters by calling the respective setters at will, and
13629/// // execute the final call using `doit()`.
13630/// // Values shown here are possibly random and not representative !
13631/// let result = hub.orders().updatemerchantorderid(req, 23, "orderId")
13632///              .doit().await;
13633/// # }
13634/// ```
13635pub struct OrderUpdatemerchantorderidCall<'a, C>
13636where
13637    C: 'a,
13638{
13639    hub: &'a ShoppingContent<C>,
13640    _request: OrdersUpdateMerchantOrderIdRequest,
13641    _merchant_id: u64,
13642    _order_id: String,
13643    _delegate: Option<&'a mut dyn common::Delegate>,
13644    _additional_params: HashMap<String, String>,
13645    _scopes: BTreeSet<String>,
13646}
13647
13648impl<'a, C> common::CallBuilder for OrderUpdatemerchantorderidCall<'a, C> {}
13649
13650impl<'a, C> OrderUpdatemerchantorderidCall<'a, C>
13651where
13652    C: common::Connector,
13653{
13654    /// Perform the operation you have build so far.
13655    pub async fn doit(
13656        mut self,
13657    ) -> common::Result<(common::Response, OrdersUpdateMerchantOrderIdResponse)> {
13658        use std::borrow::Cow;
13659        use std::io::{Read, Seek};
13660
13661        use common::{url::Params, ToParts};
13662        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13663
13664        let mut dd = common::DefaultDelegate;
13665        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13666        dlg.begin(common::MethodInfo {
13667            id: "content.orders.updatemerchantorderid",
13668            http_method: hyper::Method::POST,
13669        });
13670
13671        for &field in ["alt", "merchantId", "orderId"].iter() {
13672            if self._additional_params.contains_key(field) {
13673                dlg.finished(false);
13674                return Err(common::Error::FieldClash(field));
13675            }
13676        }
13677
13678        let mut params = Params::with_capacity(5 + self._additional_params.len());
13679        params.push("merchantId", self._merchant_id.to_string());
13680        params.push("orderId", self._order_id);
13681
13682        params.extend(self._additional_params.iter());
13683
13684        params.push("alt", "json");
13685        let mut url =
13686            self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/updateMerchantOrderId";
13687        if self._scopes.is_empty() {
13688            self._scopes.insert(Scope::Full.as_ref().to_string());
13689        }
13690
13691        #[allow(clippy::single_element_loop)]
13692        for &(find_this, param_name) in
13693            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
13694        {
13695            url = params.uri_replacement(url, param_name, find_this, false);
13696        }
13697        {
13698            let to_remove = ["orderId", "merchantId"];
13699            params.remove_params(&to_remove);
13700        }
13701
13702        let url = params.parse_with_url(&url);
13703
13704        let mut json_mime_type = mime::APPLICATION_JSON;
13705        let mut request_value_reader = {
13706            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13707            common::remove_json_null_values(&mut value);
13708            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13709            serde_json::to_writer(&mut dst, &value).unwrap();
13710            dst
13711        };
13712        let request_size = request_value_reader
13713            .seek(std::io::SeekFrom::End(0))
13714            .unwrap();
13715        request_value_reader
13716            .seek(std::io::SeekFrom::Start(0))
13717            .unwrap();
13718
13719        loop {
13720            let token = match self
13721                .hub
13722                .auth
13723                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13724                .await
13725            {
13726                Ok(token) => token,
13727                Err(e) => match dlg.token(e) {
13728                    Ok(token) => token,
13729                    Err(e) => {
13730                        dlg.finished(false);
13731                        return Err(common::Error::MissingToken(e));
13732                    }
13733                },
13734            };
13735            request_value_reader
13736                .seek(std::io::SeekFrom::Start(0))
13737                .unwrap();
13738            let mut req_result = {
13739                let client = &self.hub.client;
13740                dlg.pre_request();
13741                let mut req_builder = hyper::Request::builder()
13742                    .method(hyper::Method::POST)
13743                    .uri(url.as_str())
13744                    .header(USER_AGENT, self.hub._user_agent.clone());
13745
13746                if let Some(token) = token.as_ref() {
13747                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13748                }
13749
13750                let request = req_builder
13751                    .header(CONTENT_TYPE, json_mime_type.to_string())
13752                    .header(CONTENT_LENGTH, request_size as u64)
13753                    .body(common::to_body(
13754                        request_value_reader.get_ref().clone().into(),
13755                    ));
13756
13757                client.request(request.unwrap()).await
13758            };
13759
13760            match req_result {
13761                Err(err) => {
13762                    if let common::Retry::After(d) = dlg.http_error(&err) {
13763                        sleep(d).await;
13764                        continue;
13765                    }
13766                    dlg.finished(false);
13767                    return Err(common::Error::HttpError(err));
13768                }
13769                Ok(res) => {
13770                    let (mut parts, body) = res.into_parts();
13771                    let mut body = common::Body::new(body);
13772                    if !parts.status.is_success() {
13773                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13774                        let error = serde_json::from_str(&common::to_string(&bytes));
13775                        let response = common::to_response(parts, bytes.into());
13776
13777                        if let common::Retry::After(d) =
13778                            dlg.http_failure(&response, error.as_ref().ok())
13779                        {
13780                            sleep(d).await;
13781                            continue;
13782                        }
13783
13784                        dlg.finished(false);
13785
13786                        return Err(match error {
13787                            Ok(value) => common::Error::BadRequest(value),
13788                            _ => common::Error::Failure(response),
13789                        });
13790                    }
13791                    let response = {
13792                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13793                        let encoded = common::to_string(&bytes);
13794                        match serde_json::from_str(&encoded) {
13795                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13796                            Err(error) => {
13797                                dlg.response_json_decode_error(&encoded, &error);
13798                                return Err(common::Error::JsonDecodeError(
13799                                    encoded.to_string(),
13800                                    error,
13801                                ));
13802                            }
13803                        }
13804                    };
13805
13806                    dlg.finished(true);
13807                    return Ok(response);
13808                }
13809            }
13810        }
13811    }
13812
13813    ///
13814    /// Sets the *request* property to the given value.
13815    ///
13816    /// Even though the property as already been set when instantiating this call,
13817    /// we provide this method for API completeness.
13818    pub fn request(
13819        mut self,
13820        new_value: OrdersUpdateMerchantOrderIdRequest,
13821    ) -> OrderUpdatemerchantorderidCall<'a, C> {
13822        self._request = new_value;
13823        self
13824    }
13825    /// The ID of the account that manages the order. This cannot be a multi-client account.
13826    ///
13827    /// Sets the *merchant id* path property to the given value.
13828    ///
13829    /// Even though the property as already been set when instantiating this call,
13830    /// we provide this method for API completeness.
13831    pub fn merchant_id(mut self, new_value: u64) -> OrderUpdatemerchantorderidCall<'a, C> {
13832        self._merchant_id = new_value;
13833        self
13834    }
13835    /// The ID of the order.
13836    ///
13837    /// Sets the *order id* path property to the given value.
13838    ///
13839    /// Even though the property as already been set when instantiating this call,
13840    /// we provide this method for API completeness.
13841    pub fn order_id(mut self, new_value: &str) -> OrderUpdatemerchantorderidCall<'a, C> {
13842        self._order_id = new_value.to_string();
13843        self
13844    }
13845    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13846    /// while executing the actual API request.
13847    ///
13848    /// ````text
13849    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13850    /// ````
13851    ///
13852    /// Sets the *delegate* property to the given value.
13853    pub fn delegate(
13854        mut self,
13855        new_value: &'a mut dyn common::Delegate,
13856    ) -> OrderUpdatemerchantorderidCall<'a, C> {
13857        self._delegate = Some(new_value);
13858        self
13859    }
13860
13861    /// Set any additional parameter of the query string used in the request.
13862    /// It should be used to set parameters which are not yet available through their own
13863    /// setters.
13864    ///
13865    /// Please note that this method must not be used to set any of the known parameters
13866    /// which have their own setter method. If done anyway, the request will fail.
13867    ///
13868    /// # Additional Parameters
13869    ///
13870    /// * *alt* (query-string) - Data format for the response.
13871    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13872    /// * *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.
13873    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13874    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13875    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13876    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13877    pub fn param<T>(mut self, name: T, value: T) -> OrderUpdatemerchantorderidCall<'a, C>
13878    where
13879        T: AsRef<str>,
13880    {
13881        self._additional_params
13882            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13883        self
13884    }
13885
13886    /// Identifies the authorization scope for the method you are building.
13887    ///
13888    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13889    /// [`Scope::Full`].
13890    ///
13891    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13892    /// tokens for more than one scope.
13893    ///
13894    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13895    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13896    /// sufficient, a read-write scope will do as well.
13897    pub fn add_scope<St>(mut self, scope: St) -> OrderUpdatemerchantorderidCall<'a, C>
13898    where
13899        St: AsRef<str>,
13900    {
13901        self._scopes.insert(String::from(scope.as_ref()));
13902        self
13903    }
13904    /// Identifies the authorization scope(s) for the method you are building.
13905    ///
13906    /// See [`Self::add_scope()`] for details.
13907    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderUpdatemerchantorderidCall<'a, C>
13908    where
13909        I: IntoIterator<Item = St>,
13910        St: AsRef<str>,
13911    {
13912        self._scopes
13913            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13914        self
13915    }
13916
13917    /// Removes all scopes, and no default scope will be used either.
13918    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13919    /// for details).
13920    pub fn clear_scopes(mut self) -> OrderUpdatemerchantorderidCall<'a, C> {
13921        self._scopes.clear();
13922        self
13923    }
13924}
13925
13926/// Updates a shipment's status, carrier, and/or tracking ID.
13927///
13928/// A builder for the *updateshipment* method supported by a *order* resource.
13929/// It is not used directly, but through a [`OrderMethods`] instance.
13930///
13931/// # Example
13932///
13933/// Instantiate a resource method builder
13934///
13935/// ```test_harness,no_run
13936/// # extern crate hyper;
13937/// # extern crate hyper_rustls;
13938/// # extern crate google_content2_sandbox as content2_sandbox;
13939/// use content2_sandbox::api::OrdersUpdateShipmentRequest;
13940/// # async fn dox() {
13941/// # use content2_sandbox::{ShoppingContent, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13942///
13943/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13944/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13945/// #     .with_native_roots()
13946/// #     .unwrap()
13947/// #     .https_only()
13948/// #     .enable_http2()
13949/// #     .build();
13950///
13951/// # let executor = hyper_util::rt::TokioExecutor::new();
13952/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13953/// #     secret,
13954/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13955/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13956/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13957/// #     ),
13958/// # ).build().await.unwrap();
13959///
13960/// # let client = hyper_util::client::legacy::Client::builder(
13961/// #     hyper_util::rt::TokioExecutor::new()
13962/// # )
13963/// # .build(
13964/// #     hyper_rustls::HttpsConnectorBuilder::new()
13965/// #         .with_native_roots()
13966/// #         .unwrap()
13967/// #         .https_or_http()
13968/// #         .enable_http2()
13969/// #         .build()
13970/// # );
13971/// # let mut hub = ShoppingContent::new(client, auth);
13972/// // As the method needs a request, you would usually fill it with the desired information
13973/// // into the respective structure. Some of the parts shown here might not be applicable !
13974/// // Values shown here are possibly random and not representative !
13975/// let mut req = OrdersUpdateShipmentRequest::default();
13976///
13977/// // You can configure optional parameters by calling the respective setters at will, and
13978/// // execute the final call using `doit()`.
13979/// // Values shown here are possibly random and not representative !
13980/// let result = hub.orders().updateshipment(req, 67, "orderId")
13981///              .doit().await;
13982/// # }
13983/// ```
13984pub struct OrderUpdateshipmentCall<'a, C>
13985where
13986    C: 'a,
13987{
13988    hub: &'a ShoppingContent<C>,
13989    _request: OrdersUpdateShipmentRequest,
13990    _merchant_id: u64,
13991    _order_id: String,
13992    _delegate: Option<&'a mut dyn common::Delegate>,
13993    _additional_params: HashMap<String, String>,
13994    _scopes: BTreeSet<String>,
13995}
13996
13997impl<'a, C> common::CallBuilder for OrderUpdateshipmentCall<'a, C> {}
13998
13999impl<'a, C> OrderUpdateshipmentCall<'a, C>
14000where
14001    C: common::Connector,
14002{
14003    /// Perform the operation you have build so far.
14004    pub async fn doit(
14005        mut self,
14006    ) -> common::Result<(common::Response, OrdersUpdateShipmentResponse)> {
14007        use std::borrow::Cow;
14008        use std::io::{Read, Seek};
14009
14010        use common::{url::Params, ToParts};
14011        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14012
14013        let mut dd = common::DefaultDelegate;
14014        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14015        dlg.begin(common::MethodInfo {
14016            id: "content.orders.updateshipment",
14017            http_method: hyper::Method::POST,
14018        });
14019
14020        for &field in ["alt", "merchantId", "orderId"].iter() {
14021            if self._additional_params.contains_key(field) {
14022                dlg.finished(false);
14023                return Err(common::Error::FieldClash(field));
14024            }
14025        }
14026
14027        let mut params = Params::with_capacity(5 + self._additional_params.len());
14028        params.push("merchantId", self._merchant_id.to_string());
14029        params.push("orderId", self._order_id);
14030
14031        params.extend(self._additional_params.iter());
14032
14033        params.push("alt", "json");
14034        let mut url = self.hub._base_url.clone() + "{merchantId}/orders/{orderId}/updateShipment";
14035        if self._scopes.is_empty() {
14036            self._scopes.insert(Scope::Full.as_ref().to_string());
14037        }
14038
14039        #[allow(clippy::single_element_loop)]
14040        for &(find_this, param_name) in
14041            [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter()
14042        {
14043            url = params.uri_replacement(url, param_name, find_this, false);
14044        }
14045        {
14046            let to_remove = ["orderId", "merchantId"];
14047            params.remove_params(&to_remove);
14048        }
14049
14050        let url = params.parse_with_url(&url);
14051
14052        let mut json_mime_type = mime::APPLICATION_JSON;
14053        let mut request_value_reader = {
14054            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14055            common::remove_json_null_values(&mut value);
14056            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14057            serde_json::to_writer(&mut dst, &value).unwrap();
14058            dst
14059        };
14060        let request_size = request_value_reader
14061            .seek(std::io::SeekFrom::End(0))
14062            .unwrap();
14063        request_value_reader
14064            .seek(std::io::SeekFrom::Start(0))
14065            .unwrap();
14066
14067        loop {
14068            let token = match self
14069                .hub
14070                .auth
14071                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14072                .await
14073            {
14074                Ok(token) => token,
14075                Err(e) => match dlg.token(e) {
14076                    Ok(token) => token,
14077                    Err(e) => {
14078                        dlg.finished(false);
14079                        return Err(common::Error::MissingToken(e));
14080                    }
14081                },
14082            };
14083            request_value_reader
14084                .seek(std::io::SeekFrom::Start(0))
14085                .unwrap();
14086            let mut req_result = {
14087                let client = &self.hub.client;
14088                dlg.pre_request();
14089                let mut req_builder = hyper::Request::builder()
14090                    .method(hyper::Method::POST)
14091                    .uri(url.as_str())
14092                    .header(USER_AGENT, self.hub._user_agent.clone());
14093
14094                if let Some(token) = token.as_ref() {
14095                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14096                }
14097
14098                let request = req_builder
14099                    .header(CONTENT_TYPE, json_mime_type.to_string())
14100                    .header(CONTENT_LENGTH, request_size as u64)
14101                    .body(common::to_body(
14102                        request_value_reader.get_ref().clone().into(),
14103                    ));
14104
14105                client.request(request.unwrap()).await
14106            };
14107
14108            match req_result {
14109                Err(err) => {
14110                    if let common::Retry::After(d) = dlg.http_error(&err) {
14111                        sleep(d).await;
14112                        continue;
14113                    }
14114                    dlg.finished(false);
14115                    return Err(common::Error::HttpError(err));
14116                }
14117                Ok(res) => {
14118                    let (mut parts, body) = res.into_parts();
14119                    let mut body = common::Body::new(body);
14120                    if !parts.status.is_success() {
14121                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14122                        let error = serde_json::from_str(&common::to_string(&bytes));
14123                        let response = common::to_response(parts, bytes.into());
14124
14125                        if let common::Retry::After(d) =
14126                            dlg.http_failure(&response, error.as_ref().ok())
14127                        {
14128                            sleep(d).await;
14129                            continue;
14130                        }
14131
14132                        dlg.finished(false);
14133
14134                        return Err(match error {
14135                            Ok(value) => common::Error::BadRequest(value),
14136                            _ => common::Error::Failure(response),
14137                        });
14138                    }
14139                    let response = {
14140                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14141                        let encoded = common::to_string(&bytes);
14142                        match serde_json::from_str(&encoded) {
14143                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14144                            Err(error) => {
14145                                dlg.response_json_decode_error(&encoded, &error);
14146                                return Err(common::Error::JsonDecodeError(
14147                                    encoded.to_string(),
14148                                    error,
14149                                ));
14150                            }
14151                        }
14152                    };
14153
14154                    dlg.finished(true);
14155                    return Ok(response);
14156                }
14157            }
14158        }
14159    }
14160
14161    ///
14162    /// Sets the *request* property to the given value.
14163    ///
14164    /// Even though the property as already been set when instantiating this call,
14165    /// we provide this method for API completeness.
14166    pub fn request(
14167        mut self,
14168        new_value: OrdersUpdateShipmentRequest,
14169    ) -> OrderUpdateshipmentCall<'a, C> {
14170        self._request = new_value;
14171        self
14172    }
14173    /// The ID of the account that manages the order. This cannot be a multi-client account.
14174    ///
14175    /// Sets the *merchant id* path property to the given value.
14176    ///
14177    /// Even though the property as already been set when instantiating this call,
14178    /// we provide this method for API completeness.
14179    pub fn merchant_id(mut self, new_value: u64) -> OrderUpdateshipmentCall<'a, C> {
14180        self._merchant_id = new_value;
14181        self
14182    }
14183    /// The ID of the order.
14184    ///
14185    /// Sets the *order id* path property to the given value.
14186    ///
14187    /// Even though the property as already been set when instantiating this call,
14188    /// we provide this method for API completeness.
14189    pub fn order_id(mut self, new_value: &str) -> OrderUpdateshipmentCall<'a, C> {
14190        self._order_id = new_value.to_string();
14191        self
14192    }
14193    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14194    /// while executing the actual API request.
14195    ///
14196    /// ````text
14197    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14198    /// ````
14199    ///
14200    /// Sets the *delegate* property to the given value.
14201    pub fn delegate(
14202        mut self,
14203        new_value: &'a mut dyn common::Delegate,
14204    ) -> OrderUpdateshipmentCall<'a, C> {
14205        self._delegate = Some(new_value);
14206        self
14207    }
14208
14209    /// Set any additional parameter of the query string used in the request.
14210    /// It should be used to set parameters which are not yet available through their own
14211    /// setters.
14212    ///
14213    /// Please note that this method must not be used to set any of the known parameters
14214    /// which have their own setter method. If done anyway, the request will fail.
14215    ///
14216    /// # Additional Parameters
14217    ///
14218    /// * *alt* (query-string) - Data format for the response.
14219    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14220    /// * *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.
14221    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14222    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14223    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14224    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14225    pub fn param<T>(mut self, name: T, value: T) -> OrderUpdateshipmentCall<'a, C>
14226    where
14227        T: AsRef<str>,
14228    {
14229        self._additional_params
14230            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14231        self
14232    }
14233
14234    /// Identifies the authorization scope for the method you are building.
14235    ///
14236    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14237    /// [`Scope::Full`].
14238    ///
14239    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14240    /// tokens for more than one scope.
14241    ///
14242    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14243    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14244    /// sufficient, a read-write scope will do as well.
14245    pub fn add_scope<St>(mut self, scope: St) -> OrderUpdateshipmentCall<'a, C>
14246    where
14247        St: AsRef<str>,
14248    {
14249        self._scopes.insert(String::from(scope.as_ref()));
14250        self
14251    }
14252    /// Identifies the authorization scope(s) for the method you are building.
14253    ///
14254    /// See [`Self::add_scope()`] for details.
14255    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderUpdateshipmentCall<'a, C>
14256    where
14257        I: IntoIterator<Item = St>,
14258        St: AsRef<str>,
14259    {
14260        self._scopes
14261            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14262        self
14263    }
14264
14265    /// Removes all scopes, and no default scope will be used either.
14266    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14267    /// for details).
14268    pub fn clear_scopes(mut self) -> OrderUpdateshipmentCall<'a, C> {
14269        self._scopes.clear();
14270        self
14271    }
14272}