google_androidpublisher2/
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    /// View and manage your Google Play Developer account
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/androidpublisher",
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 AndroidPublisher 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_androidpublisher2 as androidpublisher2;
49/// use androidpublisher2::api::InAppProduct;
50/// use androidpublisher2::{Result, Error};
51/// # async fn dox() {
52/// use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = AndroidPublisher::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = InAppProduct::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.inappproducts().patch(req, "packageName", "sku")
99///              .auto_convert_missing_prices(true)
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 AndroidPublisher<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 AndroidPublisher<C> {}
131
132impl<'a, C> AndroidPublisher<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> AndroidPublisher<C> {
137        AndroidPublisher {
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/androidpublisher/v2/applications/".to_string(),
142            _root_url: "https://www.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn edits(&'a self) -> EditMethods<'a, C> {
147        EditMethods { hub: self }
148    }
149    pub fn inappproducts(&'a self) -> InappproductMethods<'a, C> {
150        InappproductMethods { hub: self }
151    }
152    pub fn orders(&'a self) -> OrderMethods<'a, C> {
153        OrderMethods { hub: self }
154    }
155    pub fn purchases(&'a self) -> PurchaseMethods<'a, C> {
156        PurchaseMethods { hub: self }
157    }
158    pub fn reviews(&'a self) -> ReviewMethods<'a, C> {
159        ReviewMethods { hub: self }
160    }
161
162    /// Set the user-agent header field to use in all requests to the server.
163    /// It defaults to `google-api-rust-client/7.0.0`.
164    ///
165    /// Returns the previously set user-agent.
166    pub fn user_agent(&mut self, agent_name: String) -> String {
167        std::mem::replace(&mut self._user_agent, agent_name)
168    }
169
170    /// Set the base url to use in all requests to the server.
171    /// It defaults to `https://www.googleapis.com/androidpublisher/v2/applications/`.
172    ///
173    /// Returns the previously set base url.
174    pub fn base_url(&mut self, new_base_url: String) -> String {
175        std::mem::replace(&mut self._base_url, new_base_url)
176    }
177
178    /// Set the root url to use in all requests to the server.
179    /// It defaults to `https://www.googleapis.com/`.
180    ///
181    /// Returns the previously set root url.
182    pub fn root_url(&mut self, new_root_url: String) -> String {
183        std::mem::replace(&mut self._root_url, new_root_url)
184    }
185}
186
187// ############
188// SCHEMAS ###
189// ##########
190/// There is no detailed description.
191///
192/// # Activities
193///
194/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
195/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
196///
197/// * [apks upload edits](EditApkUploadCall) (response)
198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
199#[serde_with::serde_as]
200#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
201pub struct Apk {
202    /// Information about the binary payload of this APK.
203    pub binary: Option<ApkBinary>,
204    /// The version code of the APK, as specified in the APK's manifest file.
205    #[serde(rename = "versionCode")]
206    pub version_code: Option<i32>,
207}
208
209impl common::ResponseResult for Apk {}
210
211/// Represents the binary payload of an APK.
212///
213/// This type is not used in any activity, and only used as *part* of another schema.
214///
215#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
216#[serde_with::serde_as]
217#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
218pub struct ApkBinary {
219    /// A sha1 hash of the APK payload, encoded as a hex string and matching the output of the sha1sum command.
220    pub sha1: Option<String>,
221    /// A sha256 hash of the APK payload, encoded as a hex string and matching the output of the sha256sum command.
222    pub sha256: Option<String>,
223}
224
225impl common::Part for ApkBinary {}
226
227/// There is no detailed description.
228///
229/// # Activities
230///
231/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
232/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
233///
234/// * [apklistings get edits](EditApklistingGetCall) (response)
235/// * [apklistings patch edits](EditApklistingPatchCall) (request|response)
236/// * [apklistings update edits](EditApklistingUpdateCall) (request|response)
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct ApkListing {
241    /// The language code, in BCP 47 format (eg "en-US").
242    pub language: Option<String>,
243    /// Describe what's new in your APK.
244    #[serde(rename = "recentChanges")]
245    pub recent_changes: Option<String>,
246}
247
248impl common::RequestValue for ApkListing {}
249impl common::ResponseResult for ApkListing {}
250
251/// There is no detailed description.
252///
253/// # Activities
254///
255/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
256/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
257///
258/// * [apklistings list edits](EditApklistingListCall) (response)
259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
260#[serde_with::serde_as]
261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
262pub struct ApkListingsListResponse {
263    /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#apkListingsListResponse".
264    pub kind: Option<String>,
265    /// no description provided
266    pub listings: Option<Vec<ApkListing>>,
267}
268
269impl common::ResponseResult for ApkListingsListResponse {}
270
271/// There is no detailed description.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [apks addexternallyhosted edits](EditApkAddexternallyhostedCall) (request)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct ApksAddExternallyHostedRequest {
283    /// The definition of the externally-hosted APK and where it is located.
284    #[serde(rename = "externallyHostedApk")]
285    pub externally_hosted_apk: Option<ExternallyHostedApk>,
286}
287
288impl common::RequestValue for ApksAddExternallyHostedRequest {}
289
290/// There is no detailed description.
291///
292/// # Activities
293///
294/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
295/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
296///
297/// * [apks addexternallyhosted edits](EditApkAddexternallyhostedCall) (response)
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct ApksAddExternallyHostedResponse {
302    /// The definition of the externally-hosted APK and where it is located.
303    #[serde(rename = "externallyHostedApk")]
304    pub externally_hosted_apk: Option<ExternallyHostedApk>,
305}
306
307impl common::ResponseResult for ApksAddExternallyHostedResponse {}
308
309/// There is no detailed description.
310///
311/// # Activities
312///
313/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
314/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
315///
316/// * [apks list edits](EditApkListCall) (response)
317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
318#[serde_with::serde_as]
319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
320pub struct ApksListResponse {
321    /// no description provided
322    pub apks: Option<Vec<Apk>>,
323    /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#apksListResponse".
324    pub kind: Option<String>,
325}
326
327impl common::ResponseResult for ApksListResponse {}
328
329/// There is no detailed description.
330///
331/// # Activities
332///
333/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
334/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
335///
336/// * [details get edits](EditDetailGetCall) (response)
337/// * [details patch edits](EditDetailPatchCall) (request|response)
338/// * [details update edits](EditDetailUpdateCall) (request|response)
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct AppDetails {
343    /// The user-visible support email for this app.
344    #[serde(rename = "contactEmail")]
345    pub contact_email: Option<String>,
346    /// The user-visible support telephone number for this app.
347    #[serde(rename = "contactPhone")]
348    pub contact_phone: Option<String>,
349    /// The user-visible website for this app.
350    #[serde(rename = "contactWebsite")]
351    pub contact_website: Option<String>,
352    /// Default language code, in BCP 47 format (eg "en-US").
353    #[serde(rename = "defaultLanguage")]
354    pub default_language: Option<String>,
355}
356
357impl common::RequestValue for AppDetails {}
358impl common::ResponseResult for AppDetails {}
359
360/// Represents an edit of an app. An edit allows clients to make multiple changes before committing them in one operation.
361///
362/// # Activities
363///
364/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
365/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
366///
367/// * [commit edits](EditCommitCall) (response)
368/// * [get edits](EditGetCall) (response)
369/// * [insert edits](EditInsertCall) (request|response)
370/// * [validate edits](EditValidateCall) (response)
371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
372#[serde_with::serde_as]
373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
374pub struct AppEdit {
375    /// The time at which the edit will expire and will be no longer valid for use in any subsequent API calls (encoded as seconds since the Epoch).
376    #[serde(rename = "expiryTimeSeconds")]
377    pub expiry_time_seconds: Option<String>,
378    /// The ID of the edit that can be used in subsequent API calls.
379    pub id: Option<String>,
380}
381
382impl common::RequestValue for AppEdit {}
383impl common::ResponseResult for AppEdit {}
384
385/// There is no detailed description.
386///
387/// # Activities
388///
389/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
390/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
391///
392/// * [bundles upload edits](EditBundleUploadCall) (response)
393#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
394#[serde_with::serde_as]
395#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
396pub struct Bundle {
397    /// A sha1 hash of the upload payload, encoded as a hex string and matching the output of the sha1sum command.
398    pub sha1: Option<String>,
399    /// A sha256 hash of the upload payload, encoded as a hex string and matching the output of the sha256sum command.
400    pub sha256: Option<String>,
401    /// The version code of the Android App Bundle. As specified in the Android App Bundle's base module APK manifest file.
402    #[serde(rename = "versionCode")]
403    pub version_code: Option<i32>,
404}
405
406impl common::ResponseResult for Bundle {}
407
408/// There is no detailed description.
409///
410/// # Activities
411///
412/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
413/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
414///
415/// * [bundles list edits](EditBundleListCall) (response)
416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
417#[serde_with::serde_as]
418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
419pub struct BundlesListResponse {
420    /// no description provided
421    pub bundles: Option<Vec<Bundle>>,
422    /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#bundlesListResponse".
423    pub kind: Option<String>,
424}
425
426impl common::ResponseResult for BundlesListResponse {}
427
428/// There is no detailed description.
429///
430/// This type is not used in any activity, and only used as *part* of another schema.
431///
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct Comment {
436    /// A comment from a developer.
437    #[serde(rename = "developerComment")]
438    pub developer_comment: Option<DeveloperComment>,
439    /// A comment from a user.
440    #[serde(rename = "userComment")]
441    pub user_comment: Option<UserComment>,
442}
443
444impl common::Part for Comment {}
445
446/// Represents a deobfuscation file.
447///
448/// This type is not used in any activity, and only used as *part* of another schema.
449///
450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
451#[serde_with::serde_as]
452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
453pub struct DeobfuscationFile {
454    /// The type of the deobfuscation file.
455    #[serde(rename = "symbolType")]
456    pub symbol_type: Option<String>,
457}
458
459impl common::Part for DeobfuscationFile {}
460
461/// There is no detailed description.
462///
463/// # Activities
464///
465/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
466/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
467///
468/// * [deobfuscationfiles upload edits](EditDeobfuscationfileUploadCall) (response)
469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
470#[serde_with::serde_as]
471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
472pub struct DeobfuscationFilesUploadResponse {
473    /// no description provided
474    #[serde(rename = "deobfuscationFile")]
475    pub deobfuscation_file: Option<DeobfuscationFile>,
476}
477
478impl common::ResponseResult for DeobfuscationFilesUploadResponse {}
479
480/// There is no detailed description.
481///
482/// This type is not used in any activity, and only used as *part* of another schema.
483///
484#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
485#[serde_with::serde_as]
486#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
487pub struct DeveloperComment {
488    /// The last time at which this comment was updated.
489    #[serde(rename = "lastModified")]
490    pub last_modified: Option<Timestamp>,
491    /// The content of the comment, i.e. reply body.
492    pub text: Option<String>,
493}
494
495impl common::Part for DeveloperComment {}
496
497/// There is no detailed description.
498///
499/// This type is not used in any activity, and only used as *part* of another schema.
500///
501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
502#[serde_with::serde_as]
503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
504pub struct DeviceMetadata {
505    /// Device CPU make e.g. "Qualcomm"
506    #[serde(rename = "cpuMake")]
507    pub cpu_make: Option<String>,
508    /// Device CPU model e.g. "MSM8974"
509    #[serde(rename = "cpuModel")]
510    pub cpu_model: Option<String>,
511    /// Device class (e.g. tablet)
512    #[serde(rename = "deviceClass")]
513    pub device_class: Option<String>,
514    /// OpenGL version
515    #[serde(rename = "glEsVersion")]
516    pub gl_es_version: Option<i32>,
517    /// Device manufacturer (e.g. Motorola)
518    pub manufacturer: Option<String>,
519    /// Comma separated list of native platforms (e.g. "arm", "arm7")
520    #[serde(rename = "nativePlatform")]
521    pub native_platform: Option<String>,
522    /// Device model name (e.g. Droid)
523    #[serde(rename = "productName")]
524    pub product_name: Option<String>,
525    /// Device RAM in Megabytes e.g. "2048"
526    #[serde(rename = "ramMb")]
527    pub ram_mb: Option<i32>,
528    /// Screen density in DPI
529    #[serde(rename = "screenDensityDpi")]
530    pub screen_density_dpi: Option<i32>,
531    /// Screen height in pixels
532    #[serde(rename = "screenHeightPx")]
533    pub screen_height_px: Option<i32>,
534    /// Screen width in pixels
535    #[serde(rename = "screenWidthPx")]
536    pub screen_width_px: Option<i32>,
537}
538
539impl common::Part for DeviceMetadata {}
540
541/// There is no detailed description.
542///
543/// # Activities
544///
545/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
546/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
547///
548/// * [expansionfiles get edits](EditExpansionfileGetCall) (response)
549/// * [expansionfiles patch edits](EditExpansionfilePatchCall) (request|response)
550/// * [expansionfiles update edits](EditExpansionfileUpdateCall) (request|response)
551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
552#[serde_with::serde_as]
553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
554pub struct ExpansionFile {
555    /// If set this field indicates that this APK has an Expansion File uploaded to it: this APK does not reference another APK's Expansion File. The field's value is the size of the uploaded Expansion File in bytes.
556    #[serde(rename = "fileSize")]
557    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
558    pub file_size: Option<i64>,
559    /// If set this APK's Expansion File references another APK's Expansion File. The file_size field will not be set.
560    #[serde(rename = "referencesVersion")]
561    pub references_version: Option<i32>,
562}
563
564impl common::RequestValue for ExpansionFile {}
565impl common::ResponseResult for ExpansionFile {}
566
567/// There is no detailed description.
568///
569/// # Activities
570///
571/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
572/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
573///
574/// * [expansionfiles upload edits](EditExpansionfileUploadCall) (response)
575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
576#[serde_with::serde_as]
577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
578pub struct ExpansionFilesUploadResponse {
579    /// no description provided
580    #[serde(rename = "expansionFile")]
581    pub expansion_file: Option<ExpansionFile>,
582}
583
584impl common::ResponseResult for ExpansionFilesUploadResponse {}
585
586/// Defines an APK available for this application that is hosted externally and not uploaded to Google Play. This function is only available to enterprises who are using Google Play for Work, and whos application is restricted to the enterprise private channel
587///
588/// This type is not used in any activity, and only used as *part* of another schema.
589///
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct ExternallyHostedApk {
594    /// The application label.
595    #[serde(rename = "applicationLabel")]
596    pub application_label: Option<String>,
597    /// A certificate (or array of certificates if a certificate-chain is used) used to signed this APK, represented as a base64 encoded byte array.
598    #[serde(rename = "certificateBase64s")]
599    pub certificate_base64s: Option<Vec<String>>,
600    /// The URL at which the APK is hosted. This must be an https URL.
601    #[serde(rename = "externallyHostedUrl")]
602    pub externally_hosted_url: Option<String>,
603    /// The SHA1 checksum of this APK, represented as a base64 encoded byte array.
604    #[serde(rename = "fileSha1Base64")]
605    pub file_sha1_base64: Option<String>,
606    /// The SHA256 checksum of this APK, represented as a base64 encoded byte array.
607    #[serde(rename = "fileSha256Base64")]
608    pub file_sha256_base64: Option<String>,
609    /// The file size in bytes of this APK.
610    #[serde(rename = "fileSize")]
611    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
612    pub file_size: Option<i64>,
613    /// The icon image from the APK, as a base64 encoded byte array.
614    #[serde(rename = "iconBase64")]
615    pub icon_base64: Option<String>,
616    /// The maximum SDK supported by this APK (optional).
617    #[serde(rename = "maximumSdk")]
618    pub maximum_sdk: Option<i32>,
619    /// The minimum SDK targeted by this APK.
620    #[serde(rename = "minimumSdk")]
621    pub minimum_sdk: Option<i32>,
622    /// The native code environments supported by this APK (optional).
623    #[serde(rename = "nativeCodes")]
624    pub native_codes: Option<Vec<String>>,
625    /// The package name.
626    #[serde(rename = "packageName")]
627    pub package_name: Option<String>,
628    /// The features required by this APK (optional).
629    #[serde(rename = "usesFeatures")]
630    pub uses_features: Option<Vec<String>>,
631    /// The permissions requested by this APK.
632    #[serde(rename = "usesPermissions")]
633    pub uses_permissions: Option<Vec<ExternallyHostedApkUsesPermission>>,
634    /// The version code of this APK.
635    #[serde(rename = "versionCode")]
636    pub version_code: Option<i32>,
637    /// The version name of this APK.
638    #[serde(rename = "versionName")]
639    pub version_name: Option<String>,
640}
641
642impl common::Part for ExternallyHostedApk {}
643
644/// A permission used by this APK.
645///
646/// This type is not used in any activity, and only used as *part* of another schema.
647///
648#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
649#[serde_with::serde_as]
650#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
651pub struct ExternallyHostedApkUsesPermission {
652    /// Optionally, the maximum SDK version for which the permission is required.
653    #[serde(rename = "maxSdkVersion")]
654    pub max_sdk_version: Option<i32>,
655    /// The name of the permission requested.
656    pub name: Option<String>,
657}
658
659impl common::Part for ExternallyHostedApkUsesPermission {}
660
661/// There is no detailed description.
662///
663/// This type is not used in any activity, and only used as *part* of another schema.
664///
665#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
666#[serde_with::serde_as]
667#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
668pub struct Image {
669    /// A unique id representing this image.
670    pub id: Option<String>,
671    /// A sha1 hash of the image that was uploaded.
672    pub sha1: Option<String>,
673    /// A sha256 hash of the image that was uploaded.
674    pub sha256: Option<String>,
675    /// A URL that will serve a preview of the image.
676    pub url: Option<String>,
677}
678
679impl common::Part for Image {}
680
681/// There is no detailed description.
682///
683/// # Activities
684///
685/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
686/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
687///
688/// * [images deleteall edits](EditImageDeleteallCall) (response)
689#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
690#[serde_with::serde_as]
691#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
692pub struct ImagesDeleteAllResponse {
693    /// no description provided
694    pub deleted: Option<Vec<Image>>,
695}
696
697impl common::ResponseResult for ImagesDeleteAllResponse {}
698
699/// There is no detailed description.
700///
701/// # Activities
702///
703/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
704/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
705///
706/// * [images list edits](EditImageListCall) (response)
707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
708#[serde_with::serde_as]
709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
710pub struct ImagesListResponse {
711    /// no description provided
712    pub images: Option<Vec<Image>>,
713}
714
715impl common::ResponseResult for ImagesListResponse {}
716
717/// There is no detailed description.
718///
719/// # Activities
720///
721/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
722/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
723///
724/// * [images upload edits](EditImageUploadCall) (response)
725#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
726#[serde_with::serde_as]
727#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
728pub struct ImagesUploadResponse {
729    /// no description provided
730    pub image: Option<Image>,
731}
732
733impl common::ResponseResult for ImagesUploadResponse {}
734
735/// There is no detailed description.
736///
737/// # Activities
738///
739/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
740/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
741///
742/// * [get inappproducts](InappproductGetCall) (response)
743/// * [insert inappproducts](InappproductInsertCall) (request|response)
744/// * [patch inappproducts](InappproductPatchCall) (request|response)
745/// * [update inappproducts](InappproductUpdateCall) (request|response)
746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
747#[serde_with::serde_as]
748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
749pub struct InAppProduct {
750    /// The default language of the localized data, as defined by BCP 47. e.g. "en-US", "en-GB".
751    #[serde(rename = "defaultLanguage")]
752    pub default_language: Option<String>,
753    /// Default price cannot be zero. In-app products can never be free. Default price is always in the developer's Checkout merchant currency.
754    #[serde(rename = "defaultPrice")]
755    pub default_price: Option<Price>,
756    /// Grace period of the subscription, specified in ISO 8601 format. It will allow developers to give their subscribers a grace period when the payment for the new recurrence period is declined. Acceptable values = "P3D" (three days), "P7D" (seven days), "P14D" (fourteen days), and "P30D" (thirty days)
757    #[serde(rename = "gracePeriod")]
758    pub grace_period: Option<String>,
759    /// List of localized title and description data.
760    pub listings: Option<HashMap<String, InAppProductListing>>,
761    /// The package name of the parent app.
762    #[serde(rename = "packageName")]
763    pub package_name: Option<String>,
764    /// Prices per buyer region. None of these prices should be zero. In-app products can never be free.
765    pub prices: Option<HashMap<String, Price>>,
766    /// Purchase type enum value. Unmodifiable after creation.
767    #[serde(rename = "purchaseType")]
768    pub purchase_type: Option<String>,
769    /// The stock-keeping-unit (SKU) of the product, unique within an app.
770    pub sku: Option<String>,
771    /// no description provided
772    pub status: Option<String>,
773    /// Subscription period, specified in ISO 8601 format. Acceptable values are "P1W" (one week), "P1M" (one month), "P3M" (three months), "P6M" (six months), and "P1Y" (one year).
774    #[serde(rename = "subscriptionPeriod")]
775    pub subscription_period: Option<String>,
776    /// Trial period, specified in ISO 8601 format. Acceptable values are anything between "P7D" (seven days) and "P999D" (999 days). Seasonal subscriptions cannot have a trial period.
777    #[serde(rename = "trialPeriod")]
778    pub trial_period: Option<String>,
779}
780
781impl common::RequestValue for InAppProduct {}
782impl common::Resource for InAppProduct {}
783impl common::ResponseResult for InAppProduct {}
784
785/// There is no detailed description.
786///
787/// This type is not used in any activity, and only used as *part* of another schema.
788///
789#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
790#[serde_with::serde_as]
791#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
792pub struct InAppProductListing {
793    /// no description provided
794    pub description: Option<String>,
795    /// no description provided
796    pub title: Option<String>,
797}
798
799impl common::Part for InAppProductListing {}
800
801/// There is no detailed description.
802///
803/// # Activities
804///
805/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
806/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
807///
808/// * [list inappproducts](InappproductListCall) (response)
809#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
810#[serde_with::serde_as]
811#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
812pub struct InappproductsListResponse {
813    /// no description provided
814    pub inappproduct: Option<Vec<InAppProduct>>,
815    /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#inappproductsListResponse".
816    pub kind: Option<String>,
817    /// no description provided
818    #[serde(rename = "pageInfo")]
819    pub page_info: Option<PageInfo>,
820    /// no description provided
821    #[serde(rename = "tokenPagination")]
822    pub token_pagination: Option<TokenPagination>,
823}
824
825impl common::ResponseResult for InappproductsListResponse {}
826
827/// There is no detailed description.
828///
829/// # Activities
830///
831/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
832/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
833///
834/// * [listings get edits](EditListingGetCall) (response)
835/// * [listings patch edits](EditListingPatchCall) (request|response)
836/// * [listings update edits](EditListingUpdateCall) (request|response)
837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
838#[serde_with::serde_as]
839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
840pub struct Listing {
841    /// Full description of the app; this may be up to 4000 characters in length.
842    #[serde(rename = "fullDescription")]
843    pub full_description: Option<String>,
844    /// Language localization code (for example, "de-AT" for Austrian German).
845    pub language: Option<String>,
846    /// Short description of the app (previously known as promo text); this may be up to 80 characters in length.
847    #[serde(rename = "shortDescription")]
848    pub short_description: Option<String>,
849    /// App's localized title.
850    pub title: Option<String>,
851    /// URL of a promotional YouTube video for the app.
852    pub video: Option<String>,
853}
854
855impl common::RequestValue for Listing {}
856impl common::ResponseResult for Listing {}
857
858/// There is no detailed description.
859///
860/// # Activities
861///
862/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
863/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
864///
865/// * [listings list edits](EditListingListCall) (response)
866#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
867#[serde_with::serde_as]
868#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
869pub struct ListingsListResponse {
870    /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#listingsListResponse".
871    pub kind: Option<String>,
872    /// no description provided
873    pub listings: Option<Vec<Listing>>,
874}
875
876impl common::ResponseResult for ListingsListResponse {}
877
878/// There is no detailed description.
879///
880/// This type is not used in any activity, and only used as *part* of another schema.
881///
882#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
883#[serde_with::serde_as]
884#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
885pub struct PageInfo {
886    /// no description provided
887    #[serde(rename = "resultPerPage")]
888    pub result_per_page: Option<i32>,
889    /// no description provided
890    #[serde(rename = "startIndex")]
891    pub start_index: Option<i32>,
892    /// no description provided
893    #[serde(rename = "totalResults")]
894    pub total_results: Option<i32>,
895}
896
897impl common::Part for PageInfo {}
898
899/// There is no detailed description.
900///
901/// This type is not used in any activity, and only used as *part* of another schema.
902///
903#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
904#[serde_with::serde_as]
905#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
906pub struct Price {
907    /// 3 letter Currency code, as defined by ISO 4217.
908    pub currency: Option<String>,
909    /// The price in millionths of the currency base unit represented as a string.
910    #[serde(rename = "priceMicros")]
911    pub price_micros: Option<String>,
912}
913
914impl common::Part for Price {}
915
916/// A ProductPurchase resource indicates the status of a user’s inapp product purchase.
917///
918/// # Activities
919///
920/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
921/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
922///
923/// * [products get purchases](PurchaseProductGetCall) (response)
924#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
925#[serde_with::serde_as]
926#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
927pub struct ProductPurchase {
928    /// The consumption state of the inapp product. Possible values are:  
929    /// - Yet to be consumed
930    /// - Consumed
931    #[serde(rename = "consumptionState")]
932    pub consumption_state: Option<i32>,
933    /// A developer-specified string that contains supplemental information about an order.
934    #[serde(rename = "developerPayload")]
935    pub developer_payload: Option<String>,
936    /// This kind represents an inappPurchase object in the androidpublisher service.
937    pub kind: Option<String>,
938    /// The order id associated with the purchase of the inapp product.
939    #[serde(rename = "orderId")]
940    pub order_id: Option<String>,
941    /// The purchase state of the order. Possible values are:  
942    /// - Purchased
943    /// - Canceled
944    /// - Pending
945    #[serde(rename = "purchaseState")]
946    pub purchase_state: Option<i32>,
947    /// The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
948    #[serde(rename = "purchaseTimeMillis")]
949    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
950    pub purchase_time_millis: Option<i64>,
951    /// The type of purchase of the inapp product. This field is only set if this purchase was not made using the standard in-app billing flow. Possible values are:  
952    /// - Test (i.e. purchased from a license testing account)
953    /// - Promo (i.e. purchased using a promo code)
954    /// - Rewarded (i.e. from watching a video ad instead of paying)
955    #[serde(rename = "purchaseType")]
956    pub purchase_type: Option<i32>,
957}
958
959impl common::ResponseResult for ProductPurchase {}
960
961/// There is no detailed description.
962///
963/// # Activities
964///
965/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
966/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
967///
968/// * [get reviews](ReviewGetCall) (response)
969/// * [list reviews](ReviewListCall) (none)
970/// * [reply reviews](ReviewReplyCall) (none)
971#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
972#[serde_with::serde_as]
973#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
974pub struct Review {
975    /// The name of the user who wrote the review.
976    #[serde(rename = "authorName")]
977    pub author_name: Option<String>,
978    /// A repeated field containing comments for the review.
979    pub comments: Option<Vec<Comment>>,
980    /// Unique identifier for this review.
981    #[serde(rename = "reviewId")]
982    pub review_id: Option<String>,
983}
984
985impl common::Resource for Review {}
986impl common::ResponseResult for Review {}
987
988/// There is no detailed description.
989///
990/// This type is not used in any activity, and only used as *part* of another schema.
991///
992#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
993#[serde_with::serde_as]
994#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
995pub struct ReviewReplyResult {
996    /// The time at which the reply took effect.
997    #[serde(rename = "lastEdited")]
998    pub last_edited: Option<Timestamp>,
999    /// The reply text that was applied.
1000    #[serde(rename = "replyText")]
1001    pub reply_text: Option<String>,
1002}
1003
1004impl common::Part for ReviewReplyResult {}
1005
1006/// There is no detailed description.
1007///
1008/// # Activities
1009///
1010/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1011/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1012///
1013/// * [list reviews](ReviewListCall) (response)
1014#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1015#[serde_with::serde_as]
1016#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1017pub struct ReviewsListResponse {
1018    /// no description provided
1019    #[serde(rename = "pageInfo")]
1020    pub page_info: Option<PageInfo>,
1021    /// no description provided
1022    pub reviews: Option<Vec<Review>>,
1023    /// no description provided
1024    #[serde(rename = "tokenPagination")]
1025    pub token_pagination: Option<TokenPagination>,
1026}
1027
1028impl common::ResponseResult for ReviewsListResponse {}
1029
1030/// There is no detailed description.
1031///
1032/// # Activities
1033///
1034/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1035/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1036///
1037/// * [reply reviews](ReviewReplyCall) (request)
1038#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1039#[serde_with::serde_as]
1040#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1041pub struct ReviewsReplyRequest {
1042    /// The text to set as the reply. Replies of more than approximately 350 characters will be rejected. HTML tags will be stripped.
1043    #[serde(rename = "replyText")]
1044    pub reply_text: Option<String>,
1045}
1046
1047impl common::RequestValue for ReviewsReplyRequest {}
1048
1049/// There is no detailed description.
1050///
1051/// # Activities
1052///
1053/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1054/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1055///
1056/// * [reply reviews](ReviewReplyCall) (response)
1057#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1058#[serde_with::serde_as]
1059#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1060pub struct ReviewsReplyResponse {
1061    /// no description provided
1062    pub result: Option<ReviewReplyResult>,
1063}
1064
1065impl common::ResponseResult for ReviewsReplyResponse {}
1066
1067/// Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey).
1068///
1069/// This type is not used in any activity, and only used as *part* of another schema.
1070///
1071#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1072#[serde_with::serde_as]
1073#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1074pub struct SubscriptionCancelSurveyResult {
1075    /// The cancellation reason the user chose in the survey. Possible values are:  
1076    /// - Other
1077    /// - I don't use this service enough
1078    /// - Technical issues
1079    /// - Cost-related reasons
1080    /// - I found a better app
1081    #[serde(rename = "cancelSurveyReason")]
1082    pub cancel_survey_reason: Option<i32>,
1083    /// The customized input cancel reason from the user. Only present when cancelReason is 0.
1084    #[serde(rename = "userInputCancelReason")]
1085    pub user_input_cancel_reason: Option<String>,
1086}
1087
1088impl common::Part for SubscriptionCancelSurveyResult {}
1089
1090/// A SubscriptionDeferralInfo contains the data needed to defer a subscription purchase to a future expiry time.
1091///
1092/// This type is not used in any activity, and only used as *part* of another schema.
1093///
1094#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1095#[serde_with::serde_as]
1096#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1097pub struct SubscriptionDeferralInfo {
1098    /// The desired next expiry time to assign to the subscription, in milliseconds since the Epoch. The given time must be later/greater than the current expiry time for the subscription.
1099    #[serde(rename = "desiredExpiryTimeMillis")]
1100    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1101    pub desired_expiry_time_millis: Option<i64>,
1102    /// The expected expiry time for the subscription. If the current expiry time for the subscription is not the value specified here, the deferral will not occur.
1103    #[serde(rename = "expectedExpiryTimeMillis")]
1104    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1105    pub expected_expiry_time_millis: Option<i64>,
1106}
1107
1108impl common::Part for SubscriptionDeferralInfo {}
1109
1110/// Contains the price change information for a subscription that can be used to control the user journey for the price change in the app. This can be in the form of seeking confirmation from the user or tailoring the experience for a successful conversion.
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 SubscriptionPriceChange {
1118    /// The new price the subscription will renew with if the price change is accepted by the user.
1119    #[serde(rename = "newPrice")]
1120    pub new_price: Option<Price>,
1121    /// The current state of the price change. Possible values are:  
1122    /// - Outstanding: State for a pending price change waiting for the user to agree. In this state, you can optionally seek confirmation from the user using the In-App API.
1123    /// - Accepted: State for an accepted price change that the subscription will renew with unless it's canceled. The price change takes effect on a future date when the subscription renews. Note that the change might not occur when the subscription is renewed next.
1124    pub state: Option<i32>,
1125}
1126
1127impl common::Part for SubscriptionPriceChange {}
1128
1129/// A SubscriptionPurchase resource indicates the status of a user’s subscription purchase.
1130///
1131/// # Activities
1132///
1133/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1134/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1135///
1136/// * [subscriptions get purchases](PurchaseSubscriptionGetCall) (response)
1137#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1138#[serde_with::serde_as]
1139#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1140pub struct SubscriptionPurchase {
1141    /// Whether the subscription will automatically be renewed when it reaches its current expiry time.
1142    #[serde(rename = "autoRenewing")]
1143    pub auto_renewing: Option<bool>,
1144    /// The reason why a subscription was canceled or is not auto-renewing. Possible values are:  
1145    /// - User canceled the subscription
1146    /// - Subscription was canceled by the system, for example because of a billing problem
1147    /// - Subscription was replaced with a new subscription
1148    /// - Subscription was canceled by the developer
1149    #[serde(rename = "cancelReason")]
1150    pub cancel_reason: Option<i32>,
1151    /// Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey).
1152    #[serde(rename = "cancelSurveyResult")]
1153    pub cancel_survey_result: Option<SubscriptionCancelSurveyResult>,
1154    /// ISO 3166-1 alpha-2 billing country/region code of the user at the time the subscription was granted.
1155    #[serde(rename = "countryCode")]
1156    pub country_code: Option<String>,
1157    /// A developer-specified string that contains supplemental information about an order.
1158    #[serde(rename = "developerPayload")]
1159    pub developer_payload: Option<String>,
1160    /// The email address of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
1161    #[serde(rename = "emailAddress")]
1162    pub email_address: Option<String>,
1163    /// Time at which the subscription will expire, in milliseconds since the Epoch.
1164    #[serde(rename = "expiryTimeMillis")]
1165    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1166    pub expiry_time_millis: Option<i64>,
1167    /// The family name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
1168    #[serde(rename = "familyName")]
1169    pub family_name: Option<String>,
1170    /// The given name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
1171    #[serde(rename = "givenName")]
1172    pub given_name: Option<String>,
1173    /// This kind represents a subscriptionPurchase object in the androidpublisher service.
1174    pub kind: Option<String>,
1175    /// The purchase token of the originating purchase if this subscription is one of the following:  
1176    /// - Re-signup of a canceled but non-lapsed subscription
1177    /// - Upgrade/downgrade from a previous subscription  For example, suppose a user originally signs up and you receive purchase token X, then the user cancels and goes through the resignup flow (before their subscription lapses) and you receive purchase token Y, and finally the user upgrades their subscription and you receive purchase token Z. If you call this API with purchase token Z, this field will be set to Y. If you call this API with purchase token Y, this field will be set to X. If you call this API with purchase token X, this field will not be set.
1178    #[serde(rename = "linkedPurchaseToken")]
1179    pub linked_purchase_token: Option<String>,
1180    /// The order id of the latest recurring order associated with the purchase of the subscription.
1181    #[serde(rename = "orderId")]
1182    pub order_id: Option<String>,
1183    /// The payment state of the subscription. Possible values are:  
1184    /// - Payment pending
1185    /// - Payment received
1186    /// - Free trial
1187    /// - Pending deferred upgrade/downgrade
1188    #[serde(rename = "paymentState")]
1189    pub payment_state: Option<i32>,
1190    /// Price of the subscription, not including tax. Price is expressed in micro-units, where 1,000,000 micro-units represents one unit of the currency. For example, if the subscription price is €1.99, price_amount_micros is 1990000.
1191    #[serde(rename = "priceAmountMicros")]
1192    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1193    pub price_amount_micros: Option<i64>,
1194    /// The latest price change information available. This is present only when there is an upcoming price change for the subscription yet to be applied.
1195    ///
1196    /// Once the subscription renews with the new price or the subscription is canceled, no price change information will be returned.
1197    #[serde(rename = "priceChange")]
1198    pub price_change: Option<SubscriptionPriceChange>,
1199    /// ISO 4217 currency code for the subscription price. For example, if the price is specified in British pounds sterling, price_currency_code is "GBP".
1200    #[serde(rename = "priceCurrencyCode")]
1201    pub price_currency_code: Option<String>,
1202    /// The Google profile id of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
1203    #[serde(rename = "profileId")]
1204    pub profile_id: Option<String>,
1205    /// The profile name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
1206    #[serde(rename = "profileName")]
1207    pub profile_name: Option<String>,
1208    /// The type of purchase of the subscription. This field is only set if this purchase was not made using the standard in-app billing flow. Possible values are:  
1209    /// - Test (i.e. purchased from a license testing account)
1210    /// - Promo (i.e. purchased using a promo code)
1211    #[serde(rename = "purchaseType")]
1212    pub purchase_type: Option<i32>,
1213    /// Time at which the subscription was granted, in milliseconds since the Epoch.
1214    #[serde(rename = "startTimeMillis")]
1215    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1216    pub start_time_millis: Option<i64>,
1217    /// The time at which the subscription was canceled by the user, in milliseconds since the epoch. Only present if cancelReason is 0.
1218    #[serde(rename = "userCancellationTimeMillis")]
1219    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1220    pub user_cancellation_time_millis: Option<i64>,
1221}
1222
1223impl common::ResponseResult for SubscriptionPurchase {}
1224
1225/// There is no detailed description.
1226///
1227/// # Activities
1228///
1229/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1230/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1231///
1232/// * [subscriptions defer purchases](PurchaseSubscriptionDeferCall) (request)
1233#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1234#[serde_with::serde_as]
1235#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1236pub struct SubscriptionPurchasesDeferRequest {
1237    /// The information about the new desired expiry time for the subscription.
1238    #[serde(rename = "deferralInfo")]
1239    pub deferral_info: Option<SubscriptionDeferralInfo>,
1240}
1241
1242impl common::RequestValue for SubscriptionPurchasesDeferRequest {}
1243
1244/// There is no detailed description.
1245///
1246/// # Activities
1247///
1248/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1249/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1250///
1251/// * [subscriptions defer purchases](PurchaseSubscriptionDeferCall) (response)
1252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1253#[serde_with::serde_as]
1254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1255pub struct SubscriptionPurchasesDeferResponse {
1256    /// The new expiry time for the subscription in milliseconds since the Epoch.
1257    #[serde(rename = "newExpiryTimeMillis")]
1258    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1259    pub new_expiry_time_millis: Option<i64>,
1260}
1261
1262impl common::ResponseResult for SubscriptionPurchasesDeferResponse {}
1263
1264/// There is no detailed description.
1265///
1266/// # Activities
1267///
1268/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1269/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1270///
1271/// * [testers get edits](EditTesterGetCall) (response)
1272/// * [testers patch edits](EditTesterPatchCall) (request|response)
1273/// * [testers update edits](EditTesterUpdateCall) (request|response)
1274#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1275#[serde_with::serde_as]
1276#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1277pub struct Testers {
1278    /// A list of all Google Groups, as email addresses, that define testers for this track.
1279    #[serde(rename = "googleGroups")]
1280    pub google_groups: Option<Vec<String>>,
1281}
1282
1283impl common::RequestValue for Testers {}
1284impl common::ResponseResult for Testers {}
1285
1286/// There is no detailed description.
1287///
1288/// This type is not used in any activity, and only used as *part* of another schema.
1289///
1290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1291#[serde_with::serde_as]
1292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1293pub struct Timestamp {
1294    /// no description provided
1295    pub nanos: Option<i32>,
1296    /// no description provided
1297    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1298    pub seconds: Option<i64>,
1299}
1300
1301impl common::Part for Timestamp {}
1302
1303/// There is no detailed description.
1304///
1305/// This type is not used in any activity, and only used as *part* of another schema.
1306///
1307#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1308#[serde_with::serde_as]
1309#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1310pub struct TokenPagination {
1311    /// no description provided
1312    #[serde(rename = "nextPageToken")]
1313    pub next_page_token: Option<String>,
1314    /// no description provided
1315    #[serde(rename = "previousPageToken")]
1316    pub previous_page_token: Option<String>,
1317}
1318
1319impl common::Part for TokenPagination {}
1320
1321/// There is no detailed description.
1322///
1323/// # Activities
1324///
1325/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1326/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1327///
1328/// * [tracks get edits](EditTrackGetCall) (response)
1329/// * [tracks patch edits](EditTrackPatchCall) (request|response)
1330/// * [tracks update edits](EditTrackUpdateCall) (request|response)
1331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1332#[serde_with::serde_as]
1333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1334pub struct Track {
1335    /// Identifier for this track.
1336    pub track: Option<String>,
1337    /// no description provided
1338    #[serde(rename = "userFraction")]
1339    pub user_fraction: Option<f64>,
1340    /// Version codes to make active on this track. Note that this list should contain all versions you wish to be active, including those you wish to retain from previous releases.
1341    #[serde(rename = "versionCodes")]
1342    pub version_codes: Option<Vec<i32>>,
1343}
1344
1345impl common::RequestValue for Track {}
1346impl common::ResponseResult for Track {}
1347
1348/// There is no detailed description.
1349///
1350/// # Activities
1351///
1352/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1353/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1354///
1355/// * [tracks list edits](EditTrackListCall) (response)
1356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1357#[serde_with::serde_as]
1358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1359pub struct TracksListResponse {
1360    /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#tracksListResponse".
1361    pub kind: Option<String>,
1362    /// no description provided
1363    pub tracks: Option<Vec<Track>>,
1364}
1365
1366impl common::ResponseResult for TracksListResponse {}
1367
1368/// There is no detailed description.
1369///
1370/// This type is not used in any activity, and only used as *part* of another schema.
1371///
1372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1373#[serde_with::serde_as]
1374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1375pub struct UserComment {
1376    /// Integer Android SDK version of the user's device at the time the review was written, e.g. 23 is Marshmallow. May be absent.
1377    #[serde(rename = "androidOsVersion")]
1378    pub android_os_version: Option<i32>,
1379    /// Integer version code of the app as installed at the time the review was written. May be absent.
1380    #[serde(rename = "appVersionCode")]
1381    pub app_version_code: Option<i32>,
1382    /// String version name of the app as installed at the time the review was written. May be absent.
1383    #[serde(rename = "appVersionName")]
1384    pub app_version_name: Option<String>,
1385    /// Codename for the reviewer's device, e.g. klte, flounder. May be absent.
1386    pub device: Option<String>,
1387    /// Some information about the characteristics of the user's device
1388    #[serde(rename = "deviceMetadata")]
1389    pub device_metadata: Option<DeviceMetadata>,
1390    /// The last time at which this comment was updated.
1391    #[serde(rename = "lastModified")]
1392    pub last_modified: Option<Timestamp>,
1393    /// Untranslated text of the review, in the case where the review has been translated. If the review has not been translated this is left blank.
1394    #[serde(rename = "originalText")]
1395    pub original_text: Option<String>,
1396    /// Language code for the reviewer. This is taken from the device settings so is not guaranteed to match the language the review is written in. May be absent.
1397    #[serde(rename = "reviewerLanguage")]
1398    pub reviewer_language: Option<String>,
1399    /// The star rating associated with the review, from 1 to 5.
1400    #[serde(rename = "starRating")]
1401    pub star_rating: Option<i32>,
1402    /// The content of the comment, i.e. review body. In some cases users have been able to write a review with separate title and body; in those cases the title and body are concatenated and separated by a tab character.
1403    pub text: Option<String>,
1404    /// Number of users who have given this review a thumbs down
1405    #[serde(rename = "thumbsDownCount")]
1406    pub thumbs_down_count: Option<i32>,
1407    /// Number of users who have given this review a thumbs up
1408    #[serde(rename = "thumbsUpCount")]
1409    pub thumbs_up_count: Option<i32>,
1410}
1411
1412impl common::Part for UserComment {}
1413
1414/// A VoidedPurchase resource indicates a purchase that was either canceled/refunded/charged-back.
1415///
1416/// This type is not used in any activity, and only used as *part* of another schema.
1417///
1418#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1419#[serde_with::serde_as]
1420#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1421pub struct VoidedPurchase {
1422    /// This kind represents a voided purchase object in the androidpublisher service.
1423    pub kind: Option<String>,
1424    /// The time at which the purchase was made, in milliseconds since the epoch (Jan 1, 1970).
1425    #[serde(rename = "purchaseTimeMillis")]
1426    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1427    pub purchase_time_millis: Option<i64>,
1428    /// The token which uniquely identifies a one-time purchase or subscription. To uniquely identify subscription renewals use order_id (available starting from version 3 of the API).
1429    #[serde(rename = "purchaseToken")]
1430    pub purchase_token: Option<String>,
1431    /// The time at which the purchase was canceled/refunded/charged-back, in milliseconds since the epoch (Jan 1, 1970).
1432    #[serde(rename = "voidedTimeMillis")]
1433    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1434    pub voided_time_millis: Option<i64>,
1435}
1436
1437impl common::Part for VoidedPurchase {}
1438
1439/// There is no detailed description.
1440///
1441/// # Activities
1442///
1443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1445///
1446/// * [voidedpurchases list purchases](PurchaseVoidedpurchaseListCall) (response)
1447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1448#[serde_with::serde_as]
1449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1450pub struct VoidedPurchasesListResponse {
1451    /// no description provided
1452    #[serde(rename = "pageInfo")]
1453    pub page_info: Option<PageInfo>,
1454    /// no description provided
1455    #[serde(rename = "tokenPagination")]
1456    pub token_pagination: Option<TokenPagination>,
1457    /// no description provided
1458    #[serde(rename = "voidedPurchases")]
1459    pub voided_purchases: Option<Vec<VoidedPurchase>>,
1460}
1461
1462impl common::ResponseResult for VoidedPurchasesListResponse {}
1463
1464// ###################
1465// MethodBuilders ###
1466// #################
1467
1468/// A builder providing access to all methods supported on *edit* resources.
1469/// It is not used directly, but through the [`AndroidPublisher`] hub.
1470///
1471/// # Example
1472///
1473/// Instantiate a resource builder
1474///
1475/// ```test_harness,no_run
1476/// extern crate hyper;
1477/// extern crate hyper_rustls;
1478/// extern crate google_androidpublisher2 as androidpublisher2;
1479///
1480/// # async fn dox() {
1481/// use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1482///
1483/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1484/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1485///     .with_native_roots()
1486///     .unwrap()
1487///     .https_only()
1488///     .enable_http2()
1489///     .build();
1490///
1491/// let executor = hyper_util::rt::TokioExecutor::new();
1492/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1493///     secret,
1494///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1495///     yup_oauth2::client::CustomHyperClientBuilder::from(
1496///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1497///     ),
1498/// ).build().await.unwrap();
1499///
1500/// let client = hyper_util::client::legacy::Client::builder(
1501///     hyper_util::rt::TokioExecutor::new()
1502/// )
1503/// .build(
1504///     hyper_rustls::HttpsConnectorBuilder::new()
1505///         .with_native_roots()
1506///         .unwrap()
1507///         .https_or_http()
1508///         .enable_http2()
1509///         .build()
1510/// );
1511/// let mut hub = AndroidPublisher::new(client, auth);
1512/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1513/// // like `apklistings_delete(...)`, `apklistings_deleteall(...)`, `apklistings_get(...)`, `apklistings_list(...)`, `apklistings_patch(...)`, `apklistings_update(...)`, `apks_addexternallyhosted(...)`, `apks_list(...)`, `apks_upload(...)`, `bundles_list(...)`, `bundles_upload(...)`, `commit(...)`, `delete(...)`, `deobfuscationfiles_upload(...)`, `details_get(...)`, `details_patch(...)`, `details_update(...)`, `expansionfiles_get(...)`, `expansionfiles_patch(...)`, `expansionfiles_update(...)`, `expansionfiles_upload(...)`, `get(...)`, `images_delete(...)`, `images_deleteall(...)`, `images_list(...)`, `images_upload(...)`, `insert(...)`, `listings_delete(...)`, `listings_deleteall(...)`, `listings_get(...)`, `listings_list(...)`, `listings_patch(...)`, `listings_update(...)`, `testers_get(...)`, `testers_patch(...)`, `testers_update(...)`, `tracks_get(...)`, `tracks_list(...)`, `tracks_patch(...)`, `tracks_update(...)` and `validate(...)`
1514/// // to build up your call.
1515/// let rb = hub.edits();
1516/// # }
1517/// ```
1518pub struct EditMethods<'a, C>
1519where
1520    C: 'a,
1521{
1522    hub: &'a AndroidPublisher<C>,
1523}
1524
1525impl<'a, C> common::MethodsBuilder for EditMethods<'a, C> {}
1526
1527impl<'a, C> EditMethods<'a, C> {
1528    /// Create a builder to help you perform the following task:
1529    ///
1530    /// Deletes the APK-specific localized listing for a specified APK and language code.
1531    ///
1532    /// # Arguments
1533    ///
1534    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1535    /// * `editId` - Unique identifier for this edit.
1536    /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
1537    /// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
1538    pub fn apklistings_delete(
1539        &self,
1540        package_name: &str,
1541        edit_id: &str,
1542        apk_version_code: i32,
1543        language: &str,
1544    ) -> EditApklistingDeleteCall<'a, C> {
1545        EditApklistingDeleteCall {
1546            hub: self.hub,
1547            _package_name: package_name.to_string(),
1548            _edit_id: edit_id.to_string(),
1549            _apk_version_code: apk_version_code,
1550            _language: language.to_string(),
1551            _delegate: Default::default(),
1552            _additional_params: Default::default(),
1553            _scopes: Default::default(),
1554        }
1555    }
1556
1557    /// Create a builder to help you perform the following task:
1558    ///
1559    /// Deletes all the APK-specific localized listings for a specified APK.
1560    ///
1561    /// # Arguments
1562    ///
1563    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1564    /// * `editId` - Unique identifier for this edit.
1565    /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
1566    pub fn apklistings_deleteall(
1567        &self,
1568        package_name: &str,
1569        edit_id: &str,
1570        apk_version_code: i32,
1571    ) -> EditApklistingDeleteallCall<'a, C> {
1572        EditApklistingDeleteallCall {
1573            hub: self.hub,
1574            _package_name: package_name.to_string(),
1575            _edit_id: edit_id.to_string(),
1576            _apk_version_code: apk_version_code,
1577            _delegate: Default::default(),
1578            _additional_params: Default::default(),
1579            _scopes: Default::default(),
1580        }
1581    }
1582
1583    /// Create a builder to help you perform the following task:
1584    ///
1585    /// Fetches the APK-specific localized listing for a specified APK and language code.
1586    ///
1587    /// # Arguments
1588    ///
1589    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1590    /// * `editId` - Unique identifier for this edit.
1591    /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
1592    /// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
1593    pub fn apklistings_get(
1594        &self,
1595        package_name: &str,
1596        edit_id: &str,
1597        apk_version_code: i32,
1598        language: &str,
1599    ) -> EditApklistingGetCall<'a, C> {
1600        EditApklistingGetCall {
1601            hub: self.hub,
1602            _package_name: package_name.to_string(),
1603            _edit_id: edit_id.to_string(),
1604            _apk_version_code: apk_version_code,
1605            _language: language.to_string(),
1606            _delegate: Default::default(),
1607            _additional_params: Default::default(),
1608            _scopes: Default::default(),
1609        }
1610    }
1611
1612    /// Create a builder to help you perform the following task:
1613    ///
1614    /// Lists all the APK-specific localized listings for a specified APK.
1615    ///
1616    /// # Arguments
1617    ///
1618    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1619    /// * `editId` - Unique identifier for this edit.
1620    /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
1621    pub fn apklistings_list(
1622        &self,
1623        package_name: &str,
1624        edit_id: &str,
1625        apk_version_code: i32,
1626    ) -> EditApklistingListCall<'a, C> {
1627        EditApklistingListCall {
1628            hub: self.hub,
1629            _package_name: package_name.to_string(),
1630            _edit_id: edit_id.to_string(),
1631            _apk_version_code: apk_version_code,
1632            _delegate: Default::default(),
1633            _additional_params: Default::default(),
1634            _scopes: Default::default(),
1635        }
1636    }
1637
1638    /// Create a builder to help you perform the following task:
1639    ///
1640    /// Updates or creates the APK-specific localized listing for a specified APK and language code. This method supports patch semantics.
1641    ///
1642    /// # Arguments
1643    ///
1644    /// * `request` - No description provided.
1645    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1646    /// * `editId` - Unique identifier for this edit.
1647    /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
1648    /// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
1649    pub fn apklistings_patch(
1650        &self,
1651        request: ApkListing,
1652        package_name: &str,
1653        edit_id: &str,
1654        apk_version_code: i32,
1655        language: &str,
1656    ) -> EditApklistingPatchCall<'a, C> {
1657        EditApklistingPatchCall {
1658            hub: self.hub,
1659            _request: request,
1660            _package_name: package_name.to_string(),
1661            _edit_id: edit_id.to_string(),
1662            _apk_version_code: apk_version_code,
1663            _language: language.to_string(),
1664            _delegate: Default::default(),
1665            _additional_params: Default::default(),
1666            _scopes: Default::default(),
1667        }
1668    }
1669
1670    /// Create a builder to help you perform the following task:
1671    ///
1672    /// Updates or creates the APK-specific localized listing for a specified APK and language code.
1673    ///
1674    /// # Arguments
1675    ///
1676    /// * `request` - No description provided.
1677    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1678    /// * `editId` - Unique identifier for this edit.
1679    /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
1680    /// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
1681    pub fn apklistings_update(
1682        &self,
1683        request: ApkListing,
1684        package_name: &str,
1685        edit_id: &str,
1686        apk_version_code: i32,
1687        language: &str,
1688    ) -> EditApklistingUpdateCall<'a, C> {
1689        EditApklistingUpdateCall {
1690            hub: self.hub,
1691            _request: request,
1692            _package_name: package_name.to_string(),
1693            _edit_id: edit_id.to_string(),
1694            _apk_version_code: apk_version_code,
1695            _language: language.to_string(),
1696            _delegate: Default::default(),
1697            _additional_params: Default::default(),
1698            _scopes: Default::default(),
1699        }
1700    }
1701
1702    /// Create a builder to help you perform the following task:
1703    ///
1704    /// Creates a new APK without uploading the APK itself to Google Play, instead hosting the APK at a specified URL. This function is only available to enterprises using Google Play for Work whose application is configured to restrict distribution to the enterprise domain.
1705    ///
1706    /// # Arguments
1707    ///
1708    /// * `request` - No description provided.
1709    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1710    /// * `editId` - Unique identifier for this edit.
1711    pub fn apks_addexternallyhosted(
1712        &self,
1713        request: ApksAddExternallyHostedRequest,
1714        package_name: &str,
1715        edit_id: &str,
1716    ) -> EditApkAddexternallyhostedCall<'a, C> {
1717        EditApkAddexternallyhostedCall {
1718            hub: self.hub,
1719            _request: request,
1720            _package_name: package_name.to_string(),
1721            _edit_id: edit_id.to_string(),
1722            _delegate: Default::default(),
1723            _additional_params: Default::default(),
1724            _scopes: Default::default(),
1725        }
1726    }
1727
1728    ///
1729    /// # Arguments
1730    ///
1731    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1732    /// * `editId` - Unique identifier for this edit.
1733    pub fn apks_list(&self, package_name: &str, edit_id: &str) -> EditApkListCall<'a, C> {
1734        EditApkListCall {
1735            hub: self.hub,
1736            _package_name: package_name.to_string(),
1737            _edit_id: edit_id.to_string(),
1738            _delegate: Default::default(),
1739            _additional_params: Default::default(),
1740            _scopes: Default::default(),
1741        }
1742    }
1743
1744    ///
1745    /// # Arguments
1746    ///
1747    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1748    /// * `editId` - Unique identifier for this edit.
1749    pub fn apks_upload(&self, package_name: &str, edit_id: &str) -> EditApkUploadCall<'a, C> {
1750        EditApkUploadCall {
1751            hub: self.hub,
1752            _package_name: package_name.to_string(),
1753            _edit_id: edit_id.to_string(),
1754            _delegate: Default::default(),
1755            _additional_params: Default::default(),
1756            _scopes: Default::default(),
1757        }
1758    }
1759
1760    ///
1761    /// # Arguments
1762    ///
1763    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1764    /// * `editId` - Unique identifier for this edit.
1765    pub fn bundles_list(&self, package_name: &str, edit_id: &str) -> EditBundleListCall<'a, C> {
1766        EditBundleListCall {
1767            hub: self.hub,
1768            _package_name: package_name.to_string(),
1769            _edit_id: edit_id.to_string(),
1770            _delegate: Default::default(),
1771            _additional_params: Default::default(),
1772            _scopes: Default::default(),
1773        }
1774    }
1775
1776    /// Create a builder to help you perform the following task:
1777    ///
1778    /// Uploads a new Android App Bundle to this edit. If you are using the Google API client libraries, please increase the timeout of the http request before calling this endpoint (a timeout of 2 minutes is recommended). See: https://developers.google.com/api-client-library/java/google-api-java-client/errors for an example in java.
1779    ///
1780    /// # Arguments
1781    ///
1782    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1783    /// * `editId` - Unique identifier for this edit.
1784    pub fn bundles_upload(&self, package_name: &str, edit_id: &str) -> EditBundleUploadCall<'a, C> {
1785        EditBundleUploadCall {
1786            hub: self.hub,
1787            _package_name: package_name.to_string(),
1788            _edit_id: edit_id.to_string(),
1789            _ack_bundle_installation_warning: Default::default(),
1790            _delegate: Default::default(),
1791            _additional_params: Default::default(),
1792            _scopes: Default::default(),
1793        }
1794    }
1795
1796    /// Create a builder to help you perform the following task:
1797    ///
1798    /// Uploads the deobfuscation file of the specified APK. If a deobfuscation file already exists, it will be replaced.
1799    ///
1800    /// # Arguments
1801    ///
1802    /// * `packageName` - Unique identifier of the Android app for which the deobfuscatiuon files are being uploaded; for example, "com.spiffygame".
1803    /// * `editId` - Unique identifier for this edit.
1804    /// * `apkVersionCode` - The version code of the APK whose deobfuscation file is being uploaded.
1805    /// * `deobfuscationFileType` - No description provided.
1806    pub fn deobfuscationfiles_upload(
1807        &self,
1808        package_name: &str,
1809        edit_id: &str,
1810        apk_version_code: i32,
1811        deobfuscation_file_type: &str,
1812    ) -> EditDeobfuscationfileUploadCall<'a, C> {
1813        EditDeobfuscationfileUploadCall {
1814            hub: self.hub,
1815            _package_name: package_name.to_string(),
1816            _edit_id: edit_id.to_string(),
1817            _apk_version_code: apk_version_code,
1818            _deobfuscation_file_type: deobfuscation_file_type.to_string(),
1819            _delegate: Default::default(),
1820            _additional_params: Default::default(),
1821            _scopes: Default::default(),
1822        }
1823    }
1824
1825    /// Create a builder to help you perform the following task:
1826    ///
1827    /// Fetches app details for this edit. This includes the default language and developer support contact information.
1828    ///
1829    /// # Arguments
1830    ///
1831    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1832    /// * `editId` - Unique identifier for this edit.
1833    pub fn details_get(&self, package_name: &str, edit_id: &str) -> EditDetailGetCall<'a, C> {
1834        EditDetailGetCall {
1835            hub: self.hub,
1836            _package_name: package_name.to_string(),
1837            _edit_id: edit_id.to_string(),
1838            _delegate: Default::default(),
1839            _additional_params: Default::default(),
1840            _scopes: Default::default(),
1841        }
1842    }
1843
1844    /// Create a builder to help you perform the following task:
1845    ///
1846    /// Updates app details for this edit. This method supports patch semantics.
1847    ///
1848    /// # Arguments
1849    ///
1850    /// * `request` - No description provided.
1851    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1852    /// * `editId` - Unique identifier for this edit.
1853    pub fn details_patch(
1854        &self,
1855        request: AppDetails,
1856        package_name: &str,
1857        edit_id: &str,
1858    ) -> EditDetailPatchCall<'a, C> {
1859        EditDetailPatchCall {
1860            hub: self.hub,
1861            _request: request,
1862            _package_name: package_name.to_string(),
1863            _edit_id: edit_id.to_string(),
1864            _delegate: Default::default(),
1865            _additional_params: Default::default(),
1866            _scopes: Default::default(),
1867        }
1868    }
1869
1870    /// Create a builder to help you perform the following task:
1871    ///
1872    /// Updates app details for this edit.
1873    ///
1874    /// # Arguments
1875    ///
1876    /// * `request` - No description provided.
1877    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1878    /// * `editId` - Unique identifier for this edit.
1879    pub fn details_update(
1880        &self,
1881        request: AppDetails,
1882        package_name: &str,
1883        edit_id: &str,
1884    ) -> EditDetailUpdateCall<'a, C> {
1885        EditDetailUpdateCall {
1886            hub: self.hub,
1887            _request: request,
1888            _package_name: package_name.to_string(),
1889            _edit_id: edit_id.to_string(),
1890            _delegate: Default::default(),
1891            _additional_params: Default::default(),
1892            _scopes: Default::default(),
1893        }
1894    }
1895
1896    /// Create a builder to help you perform the following task:
1897    ///
1898    /// Fetches the Expansion File configuration for the APK specified.
1899    ///
1900    /// # Arguments
1901    ///
1902    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1903    /// * `editId` - Unique identifier for this edit.
1904    /// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
1905    /// * `expansionFileType` - No description provided.
1906    pub fn expansionfiles_get(
1907        &self,
1908        package_name: &str,
1909        edit_id: &str,
1910        apk_version_code: i32,
1911        expansion_file_type: &str,
1912    ) -> EditExpansionfileGetCall<'a, C> {
1913        EditExpansionfileGetCall {
1914            hub: self.hub,
1915            _package_name: package_name.to_string(),
1916            _edit_id: edit_id.to_string(),
1917            _apk_version_code: apk_version_code,
1918            _expansion_file_type: expansion_file_type.to_string(),
1919            _delegate: Default::default(),
1920            _additional_params: Default::default(),
1921            _scopes: Default::default(),
1922        }
1923    }
1924
1925    /// Create a builder to help you perform the following task:
1926    ///
1927    /// Updates the APK's Expansion File configuration to reference another APK's Expansion Files. To add a new Expansion File use the Upload method. This method supports patch semantics.
1928    ///
1929    /// # Arguments
1930    ///
1931    /// * `request` - No description provided.
1932    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1933    /// * `editId` - Unique identifier for this edit.
1934    /// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
1935    /// * `expansionFileType` - No description provided.
1936    pub fn expansionfiles_patch(
1937        &self,
1938        request: ExpansionFile,
1939        package_name: &str,
1940        edit_id: &str,
1941        apk_version_code: i32,
1942        expansion_file_type: &str,
1943    ) -> EditExpansionfilePatchCall<'a, C> {
1944        EditExpansionfilePatchCall {
1945            hub: self.hub,
1946            _request: request,
1947            _package_name: package_name.to_string(),
1948            _edit_id: edit_id.to_string(),
1949            _apk_version_code: apk_version_code,
1950            _expansion_file_type: expansion_file_type.to_string(),
1951            _delegate: Default::default(),
1952            _additional_params: Default::default(),
1953            _scopes: Default::default(),
1954        }
1955    }
1956
1957    /// Create a builder to help you perform the following task:
1958    ///
1959    /// Updates the APK's Expansion File configuration to reference another APK's Expansion Files. To add a new Expansion File use the Upload method.
1960    ///
1961    /// # Arguments
1962    ///
1963    /// * `request` - No description provided.
1964    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1965    /// * `editId` - Unique identifier for this edit.
1966    /// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
1967    /// * `expansionFileType` - No description provided.
1968    pub fn expansionfiles_update(
1969        &self,
1970        request: ExpansionFile,
1971        package_name: &str,
1972        edit_id: &str,
1973        apk_version_code: i32,
1974        expansion_file_type: &str,
1975    ) -> EditExpansionfileUpdateCall<'a, C> {
1976        EditExpansionfileUpdateCall {
1977            hub: self.hub,
1978            _request: request,
1979            _package_name: package_name.to_string(),
1980            _edit_id: edit_id.to_string(),
1981            _apk_version_code: apk_version_code,
1982            _expansion_file_type: expansion_file_type.to_string(),
1983            _delegate: Default::default(),
1984            _additional_params: Default::default(),
1985            _scopes: Default::default(),
1986        }
1987    }
1988
1989    /// Create a builder to help you perform the following task:
1990    ///
1991    /// Uploads and attaches a new Expansion File to the APK specified.
1992    ///
1993    /// # Arguments
1994    ///
1995    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
1996    /// * `editId` - Unique identifier for this edit.
1997    /// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
1998    /// * `expansionFileType` - No description provided.
1999    pub fn expansionfiles_upload(
2000        &self,
2001        package_name: &str,
2002        edit_id: &str,
2003        apk_version_code: i32,
2004        expansion_file_type: &str,
2005    ) -> EditExpansionfileUploadCall<'a, C> {
2006        EditExpansionfileUploadCall {
2007            hub: self.hub,
2008            _package_name: package_name.to_string(),
2009            _edit_id: edit_id.to_string(),
2010            _apk_version_code: apk_version_code,
2011            _expansion_file_type: expansion_file_type.to_string(),
2012            _delegate: Default::default(),
2013            _additional_params: Default::default(),
2014            _scopes: Default::default(),
2015        }
2016    }
2017
2018    /// Create a builder to help you perform the following task:
2019    ///
2020    /// Deletes the image (specified by id) from the edit.
2021    ///
2022    /// # Arguments
2023    ///
2024    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2025    /// * `editId` - Unique identifier for this edit.
2026    /// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
2027    /// * `imageType` - No description provided.
2028    /// * `imageId` - Unique identifier an image within the set of images attached to this edit.
2029    pub fn images_delete(
2030        &self,
2031        package_name: &str,
2032        edit_id: &str,
2033        language: &str,
2034        image_type: &str,
2035        image_id: &str,
2036    ) -> EditImageDeleteCall<'a, C> {
2037        EditImageDeleteCall {
2038            hub: self.hub,
2039            _package_name: package_name.to_string(),
2040            _edit_id: edit_id.to_string(),
2041            _language: language.to_string(),
2042            _image_type: image_type.to_string(),
2043            _image_id: image_id.to_string(),
2044            _delegate: Default::default(),
2045            _additional_params: Default::default(),
2046            _scopes: Default::default(),
2047        }
2048    }
2049
2050    /// Create a builder to help you perform the following task:
2051    ///
2052    /// Deletes all images for the specified language and image type.
2053    ///
2054    /// # Arguments
2055    ///
2056    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2057    /// * `editId` - Unique identifier for this edit.
2058    /// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
2059    /// * `imageType` - No description provided.
2060    pub fn images_deleteall(
2061        &self,
2062        package_name: &str,
2063        edit_id: &str,
2064        language: &str,
2065        image_type: &str,
2066    ) -> EditImageDeleteallCall<'a, C> {
2067        EditImageDeleteallCall {
2068            hub: self.hub,
2069            _package_name: package_name.to_string(),
2070            _edit_id: edit_id.to_string(),
2071            _language: language.to_string(),
2072            _image_type: image_type.to_string(),
2073            _delegate: Default::default(),
2074            _additional_params: Default::default(),
2075            _scopes: Default::default(),
2076        }
2077    }
2078
2079    /// Create a builder to help you perform the following task:
2080    ///
2081    /// Lists all images for the specified language and image type.
2082    ///
2083    /// # Arguments
2084    ///
2085    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2086    /// * `editId` - Unique identifier for this edit.
2087    /// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
2088    /// * `imageType` - No description provided.
2089    pub fn images_list(
2090        &self,
2091        package_name: &str,
2092        edit_id: &str,
2093        language: &str,
2094        image_type: &str,
2095    ) -> EditImageListCall<'a, C> {
2096        EditImageListCall {
2097            hub: self.hub,
2098            _package_name: package_name.to_string(),
2099            _edit_id: edit_id.to_string(),
2100            _language: language.to_string(),
2101            _image_type: image_type.to_string(),
2102            _delegate: Default::default(),
2103            _additional_params: Default::default(),
2104            _scopes: Default::default(),
2105        }
2106    }
2107
2108    /// Create a builder to help you perform the following task:
2109    ///
2110    /// Uploads a new image and adds it to the list of images for the specified language and image type.
2111    ///
2112    /// # Arguments
2113    ///
2114    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2115    /// * `editId` - Unique identifier for this edit.
2116    /// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
2117    /// * `imageType` - No description provided.
2118    pub fn images_upload(
2119        &self,
2120        package_name: &str,
2121        edit_id: &str,
2122        language: &str,
2123        image_type: &str,
2124    ) -> EditImageUploadCall<'a, C> {
2125        EditImageUploadCall {
2126            hub: self.hub,
2127            _package_name: package_name.to_string(),
2128            _edit_id: edit_id.to_string(),
2129            _language: language.to_string(),
2130            _image_type: image_type.to_string(),
2131            _delegate: Default::default(),
2132            _additional_params: Default::default(),
2133            _scopes: Default::default(),
2134        }
2135    }
2136
2137    /// Create a builder to help you perform the following task:
2138    ///
2139    /// Deletes the specified localized store listing from an edit.
2140    ///
2141    /// # Arguments
2142    ///
2143    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2144    /// * `editId` - Unique identifier for this edit.
2145    /// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
2146    pub fn listings_delete(
2147        &self,
2148        package_name: &str,
2149        edit_id: &str,
2150        language: &str,
2151    ) -> EditListingDeleteCall<'a, C> {
2152        EditListingDeleteCall {
2153            hub: self.hub,
2154            _package_name: package_name.to_string(),
2155            _edit_id: edit_id.to_string(),
2156            _language: language.to_string(),
2157            _delegate: Default::default(),
2158            _additional_params: Default::default(),
2159            _scopes: Default::default(),
2160        }
2161    }
2162
2163    /// Create a builder to help you perform the following task:
2164    ///
2165    /// Deletes all localized listings from an edit.
2166    ///
2167    /// # Arguments
2168    ///
2169    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2170    /// * `editId` - Unique identifier for this edit.
2171    pub fn listings_deleteall(
2172        &self,
2173        package_name: &str,
2174        edit_id: &str,
2175    ) -> EditListingDeleteallCall<'a, C> {
2176        EditListingDeleteallCall {
2177            hub: self.hub,
2178            _package_name: package_name.to_string(),
2179            _edit_id: edit_id.to_string(),
2180            _delegate: Default::default(),
2181            _additional_params: Default::default(),
2182            _scopes: Default::default(),
2183        }
2184    }
2185
2186    /// Create a builder to help you perform the following task:
2187    ///
2188    /// Fetches information about a localized store listing.
2189    ///
2190    /// # Arguments
2191    ///
2192    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2193    /// * `editId` - Unique identifier for this edit.
2194    /// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
2195    pub fn listings_get(
2196        &self,
2197        package_name: &str,
2198        edit_id: &str,
2199        language: &str,
2200    ) -> EditListingGetCall<'a, C> {
2201        EditListingGetCall {
2202            hub: self.hub,
2203            _package_name: package_name.to_string(),
2204            _edit_id: edit_id.to_string(),
2205            _language: language.to_string(),
2206            _delegate: Default::default(),
2207            _additional_params: Default::default(),
2208            _scopes: Default::default(),
2209        }
2210    }
2211
2212    /// Create a builder to help you perform the following task:
2213    ///
2214    /// Returns all of the localized store listings attached to this edit.
2215    ///
2216    /// # Arguments
2217    ///
2218    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2219    /// * `editId` - Unique identifier for this edit.
2220    pub fn listings_list(&self, package_name: &str, edit_id: &str) -> EditListingListCall<'a, C> {
2221        EditListingListCall {
2222            hub: self.hub,
2223            _package_name: package_name.to_string(),
2224            _edit_id: edit_id.to_string(),
2225            _delegate: Default::default(),
2226            _additional_params: Default::default(),
2227            _scopes: Default::default(),
2228        }
2229    }
2230
2231    /// Create a builder to help you perform the following task:
2232    ///
2233    /// Creates or updates a localized store listing. This method supports patch semantics.
2234    ///
2235    /// # Arguments
2236    ///
2237    /// * `request` - No description provided.
2238    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2239    /// * `editId` - Unique identifier for this edit.
2240    /// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
2241    pub fn listings_patch(
2242        &self,
2243        request: Listing,
2244        package_name: &str,
2245        edit_id: &str,
2246        language: &str,
2247    ) -> EditListingPatchCall<'a, C> {
2248        EditListingPatchCall {
2249            hub: self.hub,
2250            _request: request,
2251            _package_name: package_name.to_string(),
2252            _edit_id: edit_id.to_string(),
2253            _language: language.to_string(),
2254            _delegate: Default::default(),
2255            _additional_params: Default::default(),
2256            _scopes: Default::default(),
2257        }
2258    }
2259
2260    /// Create a builder to help you perform the following task:
2261    ///
2262    /// Creates or updates a localized store listing.
2263    ///
2264    /// # Arguments
2265    ///
2266    /// * `request` - No description provided.
2267    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2268    /// * `editId` - Unique identifier for this edit.
2269    /// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
2270    pub fn listings_update(
2271        &self,
2272        request: Listing,
2273        package_name: &str,
2274        edit_id: &str,
2275        language: &str,
2276    ) -> EditListingUpdateCall<'a, C> {
2277        EditListingUpdateCall {
2278            hub: self.hub,
2279            _request: request,
2280            _package_name: package_name.to_string(),
2281            _edit_id: edit_id.to_string(),
2282            _language: language.to_string(),
2283            _delegate: Default::default(),
2284            _additional_params: Default::default(),
2285            _scopes: Default::default(),
2286        }
2287    }
2288
2289    ///
2290    /// # Arguments
2291    ///
2292    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2293    /// * `editId` - Unique identifier for this edit.
2294    /// * `track` - The track to read or modify.
2295    pub fn testers_get(
2296        &self,
2297        package_name: &str,
2298        edit_id: &str,
2299        track: &str,
2300    ) -> EditTesterGetCall<'a, C> {
2301        EditTesterGetCall {
2302            hub: self.hub,
2303            _package_name: package_name.to_string(),
2304            _edit_id: edit_id.to_string(),
2305            _track: track.to_string(),
2306            _delegate: Default::default(),
2307            _additional_params: Default::default(),
2308            _scopes: Default::default(),
2309        }
2310    }
2311
2312    ///
2313    /// # Arguments
2314    ///
2315    /// * `request` - No description provided.
2316    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2317    /// * `editId` - Unique identifier for this edit.
2318    /// * `track` - The track to read or modify.
2319    pub fn testers_patch(
2320        &self,
2321        request: Testers,
2322        package_name: &str,
2323        edit_id: &str,
2324        track: &str,
2325    ) -> EditTesterPatchCall<'a, C> {
2326        EditTesterPatchCall {
2327            hub: self.hub,
2328            _request: request,
2329            _package_name: package_name.to_string(),
2330            _edit_id: edit_id.to_string(),
2331            _track: track.to_string(),
2332            _delegate: Default::default(),
2333            _additional_params: Default::default(),
2334            _scopes: Default::default(),
2335        }
2336    }
2337
2338    ///
2339    /// # Arguments
2340    ///
2341    /// * `request` - No description provided.
2342    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2343    /// * `editId` - Unique identifier for this edit.
2344    /// * `track` - The track to read or modify.
2345    pub fn testers_update(
2346        &self,
2347        request: Testers,
2348        package_name: &str,
2349        edit_id: &str,
2350        track: &str,
2351    ) -> EditTesterUpdateCall<'a, C> {
2352        EditTesterUpdateCall {
2353            hub: self.hub,
2354            _request: request,
2355            _package_name: package_name.to_string(),
2356            _edit_id: edit_id.to_string(),
2357            _track: track.to_string(),
2358            _delegate: Default::default(),
2359            _additional_params: Default::default(),
2360            _scopes: Default::default(),
2361        }
2362    }
2363
2364    /// Create a builder to help you perform the following task:
2365    ///
2366    /// Fetches the track configuration for the specified track type. Includes the APK version codes that are in this track.
2367    ///
2368    /// # Arguments
2369    ///
2370    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2371    /// * `editId` - Unique identifier for this edit.
2372    /// * `track` - The track to read or modify.
2373    pub fn tracks_get(
2374        &self,
2375        package_name: &str,
2376        edit_id: &str,
2377        track: &str,
2378    ) -> EditTrackGetCall<'a, C> {
2379        EditTrackGetCall {
2380            hub: self.hub,
2381            _package_name: package_name.to_string(),
2382            _edit_id: edit_id.to_string(),
2383            _track: track.to_string(),
2384            _delegate: Default::default(),
2385            _additional_params: Default::default(),
2386            _scopes: Default::default(),
2387        }
2388    }
2389
2390    /// Create a builder to help you perform the following task:
2391    ///
2392    /// Lists all the track configurations for this edit.
2393    ///
2394    /// # Arguments
2395    ///
2396    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2397    /// * `editId` - Unique identifier for this edit.
2398    pub fn tracks_list(&self, package_name: &str, edit_id: &str) -> EditTrackListCall<'a, C> {
2399        EditTrackListCall {
2400            hub: self.hub,
2401            _package_name: package_name.to_string(),
2402            _edit_id: edit_id.to_string(),
2403            _delegate: Default::default(),
2404            _additional_params: Default::default(),
2405            _scopes: Default::default(),
2406        }
2407    }
2408
2409    /// Create a builder to help you perform the following task:
2410    ///
2411    /// Updates the track configuration for the specified track type. This method supports patch semantics.
2412    ///
2413    /// # Arguments
2414    ///
2415    /// * `request` - No description provided.
2416    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2417    /// * `editId` - Unique identifier for this edit.
2418    /// * `track` - The track to read or modify.
2419    pub fn tracks_patch(
2420        &self,
2421        request: Track,
2422        package_name: &str,
2423        edit_id: &str,
2424        track: &str,
2425    ) -> EditTrackPatchCall<'a, C> {
2426        EditTrackPatchCall {
2427            hub: self.hub,
2428            _request: request,
2429            _package_name: package_name.to_string(),
2430            _edit_id: edit_id.to_string(),
2431            _track: track.to_string(),
2432            _delegate: Default::default(),
2433            _additional_params: Default::default(),
2434            _scopes: Default::default(),
2435        }
2436    }
2437
2438    /// Create a builder to help you perform the following task:
2439    ///
2440    /// Updates the track configuration for the specified track type.
2441    ///
2442    /// # Arguments
2443    ///
2444    /// * `request` - No description provided.
2445    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2446    /// * `editId` - Unique identifier for this edit.
2447    /// * `track` - The track to read or modify.
2448    pub fn tracks_update(
2449        &self,
2450        request: Track,
2451        package_name: &str,
2452        edit_id: &str,
2453        track: &str,
2454    ) -> EditTrackUpdateCall<'a, C> {
2455        EditTrackUpdateCall {
2456            hub: self.hub,
2457            _request: request,
2458            _package_name: package_name.to_string(),
2459            _edit_id: edit_id.to_string(),
2460            _track: track.to_string(),
2461            _delegate: Default::default(),
2462            _additional_params: Default::default(),
2463            _scopes: Default::default(),
2464        }
2465    }
2466
2467    /// Create a builder to help you perform the following task:
2468    ///
2469    /// Commits/applies the changes made in this edit back to the app.
2470    ///
2471    /// # Arguments
2472    ///
2473    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2474    /// * `editId` - Unique identifier for this edit.
2475    pub fn commit(&self, package_name: &str, edit_id: &str) -> EditCommitCall<'a, C> {
2476        EditCommitCall {
2477            hub: self.hub,
2478            _package_name: package_name.to_string(),
2479            _edit_id: edit_id.to_string(),
2480            _delegate: Default::default(),
2481            _additional_params: Default::default(),
2482            _scopes: Default::default(),
2483        }
2484    }
2485
2486    /// Create a builder to help you perform the following task:
2487    ///
2488    /// Deletes an edit for an app. Creating a new edit will automatically delete any of your previous edits so this method need only be called if you want to preemptively abandon an edit.
2489    ///
2490    /// # Arguments
2491    ///
2492    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2493    /// * `editId` - Unique identifier for this edit.
2494    pub fn delete(&self, package_name: &str, edit_id: &str) -> EditDeleteCall<'a, C> {
2495        EditDeleteCall {
2496            hub: self.hub,
2497            _package_name: package_name.to_string(),
2498            _edit_id: edit_id.to_string(),
2499            _delegate: Default::default(),
2500            _additional_params: Default::default(),
2501            _scopes: Default::default(),
2502        }
2503    }
2504
2505    /// Create a builder to help you perform the following task:
2506    ///
2507    /// Returns information about the edit specified. Calls will fail if the edit is no long active (e.g. has been deleted, superseded or expired).
2508    ///
2509    /// # Arguments
2510    ///
2511    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2512    /// * `editId` - Unique identifier for this edit.
2513    pub fn get(&self, package_name: &str, edit_id: &str) -> EditGetCall<'a, C> {
2514        EditGetCall {
2515            hub: self.hub,
2516            _package_name: package_name.to_string(),
2517            _edit_id: edit_id.to_string(),
2518            _delegate: Default::default(),
2519            _additional_params: Default::default(),
2520            _scopes: Default::default(),
2521        }
2522    }
2523
2524    /// Create a builder to help you perform the following task:
2525    ///
2526    /// Creates a new edit for an app, populated with the app's current state.
2527    ///
2528    /// # Arguments
2529    ///
2530    /// * `request` - No description provided.
2531    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2532    pub fn insert(&self, request: AppEdit, package_name: &str) -> EditInsertCall<'a, C> {
2533        EditInsertCall {
2534            hub: self.hub,
2535            _request: request,
2536            _package_name: package_name.to_string(),
2537            _delegate: Default::default(),
2538            _additional_params: Default::default(),
2539            _scopes: Default::default(),
2540        }
2541    }
2542
2543    /// Create a builder to help you perform the following task:
2544    ///
2545    /// Checks that the edit can be successfully committed. The edit's changes are not applied to the live app.
2546    ///
2547    /// # Arguments
2548    ///
2549    /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
2550    /// * `editId` - Unique identifier for this edit.
2551    pub fn validate(&self, package_name: &str, edit_id: &str) -> EditValidateCall<'a, C> {
2552        EditValidateCall {
2553            hub: self.hub,
2554            _package_name: package_name.to_string(),
2555            _edit_id: edit_id.to_string(),
2556            _delegate: Default::default(),
2557            _additional_params: Default::default(),
2558            _scopes: Default::default(),
2559        }
2560    }
2561}
2562
2563/// A builder providing access to all methods supported on *inappproduct* resources.
2564/// It is not used directly, but through the [`AndroidPublisher`] hub.
2565///
2566/// # Example
2567///
2568/// Instantiate a resource builder
2569///
2570/// ```test_harness,no_run
2571/// extern crate hyper;
2572/// extern crate hyper_rustls;
2573/// extern crate google_androidpublisher2 as androidpublisher2;
2574///
2575/// # async fn dox() {
2576/// use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2577///
2578/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2579/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2580///     .with_native_roots()
2581///     .unwrap()
2582///     .https_only()
2583///     .enable_http2()
2584///     .build();
2585///
2586/// let executor = hyper_util::rt::TokioExecutor::new();
2587/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2588///     secret,
2589///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2590///     yup_oauth2::client::CustomHyperClientBuilder::from(
2591///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2592///     ),
2593/// ).build().await.unwrap();
2594///
2595/// let client = hyper_util::client::legacy::Client::builder(
2596///     hyper_util::rt::TokioExecutor::new()
2597/// )
2598/// .build(
2599///     hyper_rustls::HttpsConnectorBuilder::new()
2600///         .with_native_roots()
2601///         .unwrap()
2602///         .https_or_http()
2603///         .enable_http2()
2604///         .build()
2605/// );
2606/// let mut hub = AndroidPublisher::new(client, auth);
2607/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2608/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
2609/// // to build up your call.
2610/// let rb = hub.inappproducts();
2611/// # }
2612/// ```
2613pub struct InappproductMethods<'a, C>
2614where
2615    C: 'a,
2616{
2617    hub: &'a AndroidPublisher<C>,
2618}
2619
2620impl<'a, C> common::MethodsBuilder for InappproductMethods<'a, C> {}
2621
2622impl<'a, C> InappproductMethods<'a, C> {
2623    /// Create a builder to help you perform the following task:
2624    ///
2625    /// Delete an in-app product for an app.
2626    ///
2627    /// # Arguments
2628    ///
2629    /// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
2630    /// * `sku` - Unique identifier for the in-app product.
2631    pub fn delete(&self, package_name: &str, sku: &str) -> InappproductDeleteCall<'a, C> {
2632        InappproductDeleteCall {
2633            hub: self.hub,
2634            _package_name: package_name.to_string(),
2635            _sku: sku.to_string(),
2636            _delegate: Default::default(),
2637            _additional_params: Default::default(),
2638            _scopes: Default::default(),
2639        }
2640    }
2641
2642    /// Create a builder to help you perform the following task:
2643    ///
2644    /// Returns information about the in-app product specified.
2645    ///
2646    /// # Arguments
2647    ///
2648    /// * `packageName` - No description provided.
2649    /// * `sku` - Unique identifier for the in-app product.
2650    pub fn get(&self, package_name: &str, sku: &str) -> InappproductGetCall<'a, C> {
2651        InappproductGetCall {
2652            hub: self.hub,
2653            _package_name: package_name.to_string(),
2654            _sku: sku.to_string(),
2655            _delegate: Default::default(),
2656            _additional_params: Default::default(),
2657            _scopes: Default::default(),
2658        }
2659    }
2660
2661    /// Create a builder to help you perform the following task:
2662    ///
2663    /// Creates a new in-app product for an app.
2664    ///
2665    /// # Arguments
2666    ///
2667    /// * `request` - No description provided.
2668    /// * `packageName` - Unique identifier for the Android app; for example, "com.spiffygame".
2669    pub fn insert(
2670        &self,
2671        request: InAppProduct,
2672        package_name: &str,
2673    ) -> InappproductInsertCall<'a, C> {
2674        InappproductInsertCall {
2675            hub: self.hub,
2676            _request: request,
2677            _package_name: package_name.to_string(),
2678            _auto_convert_missing_prices: Default::default(),
2679            _delegate: Default::default(),
2680            _additional_params: Default::default(),
2681            _scopes: Default::default(),
2682        }
2683    }
2684
2685    /// Create a builder to help you perform the following task:
2686    ///
2687    /// List all the in-app products for an Android app, both subscriptions and managed in-app products..
2688    ///
2689    /// # Arguments
2690    ///
2691    /// * `packageName` - Unique identifier for the Android app with in-app products; for example, "com.spiffygame".
2692    pub fn list(&self, package_name: &str) -> InappproductListCall<'a, C> {
2693        InappproductListCall {
2694            hub: self.hub,
2695            _package_name: package_name.to_string(),
2696            _token: Default::default(),
2697            _start_index: Default::default(),
2698            _max_results: Default::default(),
2699            _delegate: Default::default(),
2700            _additional_params: Default::default(),
2701            _scopes: Default::default(),
2702        }
2703    }
2704
2705    /// Create a builder to help you perform the following task:
2706    ///
2707    /// Updates the details of an in-app product. This method supports patch semantics.
2708    ///
2709    /// # Arguments
2710    ///
2711    /// * `request` - No description provided.
2712    /// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
2713    /// * `sku` - Unique identifier for the in-app product.
2714    pub fn patch(
2715        &self,
2716        request: InAppProduct,
2717        package_name: &str,
2718        sku: &str,
2719    ) -> InappproductPatchCall<'a, C> {
2720        InappproductPatchCall {
2721            hub: self.hub,
2722            _request: request,
2723            _package_name: package_name.to_string(),
2724            _sku: sku.to_string(),
2725            _auto_convert_missing_prices: Default::default(),
2726            _delegate: Default::default(),
2727            _additional_params: Default::default(),
2728            _scopes: Default::default(),
2729        }
2730    }
2731
2732    /// Create a builder to help you perform the following task:
2733    ///
2734    /// Updates the details of an in-app product.
2735    ///
2736    /// # Arguments
2737    ///
2738    /// * `request` - No description provided.
2739    /// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
2740    /// * `sku` - Unique identifier for the in-app product.
2741    pub fn update(
2742        &self,
2743        request: InAppProduct,
2744        package_name: &str,
2745        sku: &str,
2746    ) -> InappproductUpdateCall<'a, C> {
2747        InappproductUpdateCall {
2748            hub: self.hub,
2749            _request: request,
2750            _package_name: package_name.to_string(),
2751            _sku: sku.to_string(),
2752            _auto_convert_missing_prices: Default::default(),
2753            _delegate: Default::default(),
2754            _additional_params: Default::default(),
2755            _scopes: Default::default(),
2756        }
2757    }
2758}
2759
2760/// A builder providing access to all methods supported on *order* resources.
2761/// It is not used directly, but through the [`AndroidPublisher`] hub.
2762///
2763/// # Example
2764///
2765/// Instantiate a resource builder
2766///
2767/// ```test_harness,no_run
2768/// extern crate hyper;
2769/// extern crate hyper_rustls;
2770/// extern crate google_androidpublisher2 as androidpublisher2;
2771///
2772/// # async fn dox() {
2773/// use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2774///
2775/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2776/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2777///     .with_native_roots()
2778///     .unwrap()
2779///     .https_only()
2780///     .enable_http2()
2781///     .build();
2782///
2783/// let executor = hyper_util::rt::TokioExecutor::new();
2784/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2785///     secret,
2786///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2787///     yup_oauth2::client::CustomHyperClientBuilder::from(
2788///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2789///     ),
2790/// ).build().await.unwrap();
2791///
2792/// let client = hyper_util::client::legacy::Client::builder(
2793///     hyper_util::rt::TokioExecutor::new()
2794/// )
2795/// .build(
2796///     hyper_rustls::HttpsConnectorBuilder::new()
2797///         .with_native_roots()
2798///         .unwrap()
2799///         .https_or_http()
2800///         .enable_http2()
2801///         .build()
2802/// );
2803/// let mut hub = AndroidPublisher::new(client, auth);
2804/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2805/// // like `refund(...)`
2806/// // to build up your call.
2807/// let rb = hub.orders();
2808/// # }
2809/// ```
2810pub struct OrderMethods<'a, C>
2811where
2812    C: 'a,
2813{
2814    hub: &'a AndroidPublisher<C>,
2815}
2816
2817impl<'a, C> common::MethodsBuilder for OrderMethods<'a, C> {}
2818
2819impl<'a, C> OrderMethods<'a, C> {
2820    /// Create a builder to help you perform the following task:
2821    ///
2822    /// Refund a user's subscription or in-app purchase order.
2823    ///
2824    /// # Arguments
2825    ///
2826    /// * `packageName` - The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
2827    /// * `orderId` - The order ID provided to the user when the subscription or in-app order was purchased.
2828    pub fn refund(&self, package_name: &str, order_id: &str) -> OrderRefundCall<'a, C> {
2829        OrderRefundCall {
2830            hub: self.hub,
2831            _package_name: package_name.to_string(),
2832            _order_id: order_id.to_string(),
2833            _revoke: Default::default(),
2834            _delegate: Default::default(),
2835            _additional_params: Default::default(),
2836            _scopes: Default::default(),
2837        }
2838    }
2839}
2840
2841/// A builder providing access to all methods supported on *purchase* resources.
2842/// It is not used directly, but through the [`AndroidPublisher`] hub.
2843///
2844/// # Example
2845///
2846/// Instantiate a resource builder
2847///
2848/// ```test_harness,no_run
2849/// extern crate hyper;
2850/// extern crate hyper_rustls;
2851/// extern crate google_androidpublisher2 as androidpublisher2;
2852///
2853/// # async fn dox() {
2854/// use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2855///
2856/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2857/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2858///     .with_native_roots()
2859///     .unwrap()
2860///     .https_only()
2861///     .enable_http2()
2862///     .build();
2863///
2864/// let executor = hyper_util::rt::TokioExecutor::new();
2865/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2866///     secret,
2867///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2868///     yup_oauth2::client::CustomHyperClientBuilder::from(
2869///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2870///     ),
2871/// ).build().await.unwrap();
2872///
2873/// let client = hyper_util::client::legacy::Client::builder(
2874///     hyper_util::rt::TokioExecutor::new()
2875/// )
2876/// .build(
2877///     hyper_rustls::HttpsConnectorBuilder::new()
2878///         .with_native_roots()
2879///         .unwrap()
2880///         .https_or_http()
2881///         .enable_http2()
2882///         .build()
2883/// );
2884/// let mut hub = AndroidPublisher::new(client, auth);
2885/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2886/// // like `products_get(...)`, `subscriptions_cancel(...)`, `subscriptions_defer(...)`, `subscriptions_get(...)`, `subscriptions_refund(...)`, `subscriptions_revoke(...)` and `voidedpurchases_list(...)`
2887/// // to build up your call.
2888/// let rb = hub.purchases();
2889/// # }
2890/// ```
2891pub struct PurchaseMethods<'a, C>
2892where
2893    C: 'a,
2894{
2895    hub: &'a AndroidPublisher<C>,
2896}
2897
2898impl<'a, C> common::MethodsBuilder for PurchaseMethods<'a, C> {}
2899
2900impl<'a, C> PurchaseMethods<'a, C> {
2901    /// Create a builder to help you perform the following task:
2902    ///
2903    /// Checks the purchase and consumption status of an inapp item.
2904    ///
2905    /// # Arguments
2906    ///
2907    /// * `packageName` - The package name of the application the inapp product was sold in (for example, 'com.some.thing').
2908    /// * `productId` - The inapp product SKU (for example, 'com.some.thing.inapp1').
2909    /// * `token` - The token provided to the user's device when the inapp product was purchased.
2910    pub fn products_get(
2911        &self,
2912        package_name: &str,
2913        product_id: &str,
2914        token: &str,
2915    ) -> PurchaseProductGetCall<'a, C> {
2916        PurchaseProductGetCall {
2917            hub: self.hub,
2918            _package_name: package_name.to_string(),
2919            _product_id: product_id.to_string(),
2920            _token: token.to_string(),
2921            _delegate: Default::default(),
2922            _additional_params: Default::default(),
2923            _scopes: Default::default(),
2924        }
2925    }
2926
2927    /// Create a builder to help you perform the following task:
2928    ///
2929    /// Cancels a user's subscription purchase. The subscription remains valid until its expiration time.
2930    ///
2931    /// # Arguments
2932    ///
2933    /// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
2934    /// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
2935    /// * `token` - The token provided to the user's device when the subscription was purchased.
2936    pub fn subscriptions_cancel(
2937        &self,
2938        package_name: &str,
2939        subscription_id: &str,
2940        token: &str,
2941    ) -> PurchaseSubscriptionCancelCall<'a, C> {
2942        PurchaseSubscriptionCancelCall {
2943            hub: self.hub,
2944            _package_name: package_name.to_string(),
2945            _subscription_id: subscription_id.to_string(),
2946            _token: token.to_string(),
2947            _delegate: Default::default(),
2948            _additional_params: Default::default(),
2949            _scopes: Default::default(),
2950        }
2951    }
2952
2953    /// Create a builder to help you perform the following task:
2954    ///
2955    /// Defers a user's subscription purchase until a specified future expiration time.
2956    ///
2957    /// # Arguments
2958    ///
2959    /// * `request` - No description provided.
2960    /// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
2961    /// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
2962    /// * `token` - The token provided to the user's device when the subscription was purchased.
2963    pub fn subscriptions_defer(
2964        &self,
2965        request: SubscriptionPurchasesDeferRequest,
2966        package_name: &str,
2967        subscription_id: &str,
2968        token: &str,
2969    ) -> PurchaseSubscriptionDeferCall<'a, C> {
2970        PurchaseSubscriptionDeferCall {
2971            hub: self.hub,
2972            _request: request,
2973            _package_name: package_name.to_string(),
2974            _subscription_id: subscription_id.to_string(),
2975            _token: token.to_string(),
2976            _delegate: Default::default(),
2977            _additional_params: Default::default(),
2978            _scopes: Default::default(),
2979        }
2980    }
2981
2982    /// Create a builder to help you perform the following task:
2983    ///
2984    /// Checks whether a user's subscription purchase is valid and returns its expiry time.
2985    ///
2986    /// # Arguments
2987    ///
2988    /// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
2989    /// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
2990    /// * `token` - The token provided to the user's device when the subscription was purchased.
2991    pub fn subscriptions_get(
2992        &self,
2993        package_name: &str,
2994        subscription_id: &str,
2995        token: &str,
2996    ) -> PurchaseSubscriptionGetCall<'a, C> {
2997        PurchaseSubscriptionGetCall {
2998            hub: self.hub,
2999            _package_name: package_name.to_string(),
3000            _subscription_id: subscription_id.to_string(),
3001            _token: token.to_string(),
3002            _delegate: Default::default(),
3003            _additional_params: Default::default(),
3004            _scopes: Default::default(),
3005        }
3006    }
3007
3008    /// Create a builder to help you perform the following task:
3009    ///
3010    /// Refunds a user's subscription purchase, but the subscription remains valid until its expiration time and it will continue to recur.
3011    ///
3012    /// # Arguments
3013    ///
3014    /// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
3015    /// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
3016    /// * `token` - The token provided to the user's device when the subscription was purchased.
3017    pub fn subscriptions_refund(
3018        &self,
3019        package_name: &str,
3020        subscription_id: &str,
3021        token: &str,
3022    ) -> PurchaseSubscriptionRefundCall<'a, C> {
3023        PurchaseSubscriptionRefundCall {
3024            hub: self.hub,
3025            _package_name: package_name.to_string(),
3026            _subscription_id: subscription_id.to_string(),
3027            _token: token.to_string(),
3028            _delegate: Default::default(),
3029            _additional_params: Default::default(),
3030            _scopes: Default::default(),
3031        }
3032    }
3033
3034    /// Create a builder to help you perform the following task:
3035    ///
3036    /// Refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.
3037    ///
3038    /// # Arguments
3039    ///
3040    /// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
3041    /// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
3042    /// * `token` - The token provided to the user's device when the subscription was purchased.
3043    pub fn subscriptions_revoke(
3044        &self,
3045        package_name: &str,
3046        subscription_id: &str,
3047        token: &str,
3048    ) -> PurchaseSubscriptionRevokeCall<'a, C> {
3049        PurchaseSubscriptionRevokeCall {
3050            hub: self.hub,
3051            _package_name: package_name.to_string(),
3052            _subscription_id: subscription_id.to_string(),
3053            _token: token.to_string(),
3054            _delegate: Default::default(),
3055            _additional_params: Default::default(),
3056            _scopes: Default::default(),
3057        }
3058    }
3059
3060    /// Create a builder to help you perform the following task:
3061    ///
3062    /// Lists the purchases that were canceled, refunded or charged-back.
3063    ///
3064    /// # Arguments
3065    ///
3066    /// * `packageName` - The package name of the application for which voided purchases need to be returned (for example, 'com.some.thing').
3067    pub fn voidedpurchases_list(
3068        &self,
3069        package_name: &str,
3070    ) -> PurchaseVoidedpurchaseListCall<'a, C> {
3071        PurchaseVoidedpurchaseListCall {
3072            hub: self.hub,
3073            _package_name: package_name.to_string(),
3074            _token: Default::default(),
3075            _start_time: Default::default(),
3076            _start_index: Default::default(),
3077            _max_results: Default::default(),
3078            _end_time: Default::default(),
3079            _delegate: Default::default(),
3080            _additional_params: Default::default(),
3081            _scopes: Default::default(),
3082        }
3083    }
3084}
3085
3086/// A builder providing access to all methods supported on *review* resources.
3087/// It is not used directly, but through the [`AndroidPublisher`] hub.
3088///
3089/// # Example
3090///
3091/// Instantiate a resource builder
3092///
3093/// ```test_harness,no_run
3094/// extern crate hyper;
3095/// extern crate hyper_rustls;
3096/// extern crate google_androidpublisher2 as androidpublisher2;
3097///
3098/// # async fn dox() {
3099/// use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3100///
3101/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3102/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3103///     .with_native_roots()
3104///     .unwrap()
3105///     .https_only()
3106///     .enable_http2()
3107///     .build();
3108///
3109/// let executor = hyper_util::rt::TokioExecutor::new();
3110/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3111///     secret,
3112///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3113///     yup_oauth2::client::CustomHyperClientBuilder::from(
3114///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3115///     ),
3116/// ).build().await.unwrap();
3117///
3118/// let client = hyper_util::client::legacy::Client::builder(
3119///     hyper_util::rt::TokioExecutor::new()
3120/// )
3121/// .build(
3122///     hyper_rustls::HttpsConnectorBuilder::new()
3123///         .with_native_roots()
3124///         .unwrap()
3125///         .https_or_http()
3126///         .enable_http2()
3127///         .build()
3128/// );
3129/// let mut hub = AndroidPublisher::new(client, auth);
3130/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3131/// // like `get(...)`, `list(...)` and `reply(...)`
3132/// // to build up your call.
3133/// let rb = hub.reviews();
3134/// # }
3135/// ```
3136pub struct ReviewMethods<'a, C>
3137where
3138    C: 'a,
3139{
3140    hub: &'a AndroidPublisher<C>,
3141}
3142
3143impl<'a, C> common::MethodsBuilder for ReviewMethods<'a, C> {}
3144
3145impl<'a, C> ReviewMethods<'a, C> {
3146    /// Create a builder to help you perform the following task:
3147    ///
3148    /// Returns a single review.
3149    ///
3150    /// # Arguments
3151    ///
3152    /// * `packageName` - Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".
3153    /// * `reviewId` - No description provided.
3154    pub fn get(&self, package_name: &str, review_id: &str) -> ReviewGetCall<'a, C> {
3155        ReviewGetCall {
3156            hub: self.hub,
3157            _package_name: package_name.to_string(),
3158            _review_id: review_id.to_string(),
3159            _translation_language: Default::default(),
3160            _delegate: Default::default(),
3161            _additional_params: Default::default(),
3162            _scopes: Default::default(),
3163        }
3164    }
3165
3166    /// Create a builder to help you perform the following task:
3167    ///
3168    /// Returns a list of reviews. Only reviews from last week will be returned.
3169    ///
3170    /// # Arguments
3171    ///
3172    /// * `packageName` - Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".
3173    pub fn list(&self, package_name: &str) -> ReviewListCall<'a, C> {
3174        ReviewListCall {
3175            hub: self.hub,
3176            _package_name: package_name.to_string(),
3177            _translation_language: Default::default(),
3178            _token: Default::default(),
3179            _start_index: Default::default(),
3180            _max_results: Default::default(),
3181            _delegate: Default::default(),
3182            _additional_params: Default::default(),
3183            _scopes: Default::default(),
3184        }
3185    }
3186
3187    /// Create a builder to help you perform the following task:
3188    ///
3189    /// Reply to a single review, or update an existing reply.
3190    ///
3191    /// # Arguments
3192    ///
3193    /// * `request` - No description provided.
3194    /// * `packageName` - Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".
3195    /// * `reviewId` - No description provided.
3196    pub fn reply(
3197        &self,
3198        request: ReviewsReplyRequest,
3199        package_name: &str,
3200        review_id: &str,
3201    ) -> ReviewReplyCall<'a, C> {
3202        ReviewReplyCall {
3203            hub: self.hub,
3204            _request: request,
3205            _package_name: package_name.to_string(),
3206            _review_id: review_id.to_string(),
3207            _delegate: Default::default(),
3208            _additional_params: Default::default(),
3209            _scopes: Default::default(),
3210        }
3211    }
3212}
3213
3214// ###################
3215// CallBuilders   ###
3216// #################
3217
3218/// Deletes the APK-specific localized listing for a specified APK and language code.
3219///
3220/// A builder for the *apklistings.delete* method supported by a *edit* resource.
3221/// It is not used directly, but through a [`EditMethods`] instance.
3222///
3223/// # Example
3224///
3225/// Instantiate a resource method builder
3226///
3227/// ```test_harness,no_run
3228/// # extern crate hyper;
3229/// # extern crate hyper_rustls;
3230/// # extern crate google_androidpublisher2 as androidpublisher2;
3231/// # async fn dox() {
3232/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3233///
3234/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3235/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3236/// #     .with_native_roots()
3237/// #     .unwrap()
3238/// #     .https_only()
3239/// #     .enable_http2()
3240/// #     .build();
3241///
3242/// # let executor = hyper_util::rt::TokioExecutor::new();
3243/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3244/// #     secret,
3245/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3246/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3247/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3248/// #     ),
3249/// # ).build().await.unwrap();
3250///
3251/// # let client = hyper_util::client::legacy::Client::builder(
3252/// #     hyper_util::rt::TokioExecutor::new()
3253/// # )
3254/// # .build(
3255/// #     hyper_rustls::HttpsConnectorBuilder::new()
3256/// #         .with_native_roots()
3257/// #         .unwrap()
3258/// #         .https_or_http()
3259/// #         .enable_http2()
3260/// #         .build()
3261/// # );
3262/// # let mut hub = AndroidPublisher::new(client, auth);
3263/// // You can configure optional parameters by calling the respective setters at will, and
3264/// // execute the final call using `doit()`.
3265/// // Values shown here are possibly random and not representative !
3266/// let result = hub.edits().apklistings_delete("packageName", "editId", -62, "language")
3267///              .doit().await;
3268/// # }
3269/// ```
3270pub struct EditApklistingDeleteCall<'a, C>
3271where
3272    C: 'a,
3273{
3274    hub: &'a AndroidPublisher<C>,
3275    _package_name: String,
3276    _edit_id: String,
3277    _apk_version_code: i32,
3278    _language: String,
3279    _delegate: Option<&'a mut dyn common::Delegate>,
3280    _additional_params: HashMap<String, String>,
3281    _scopes: BTreeSet<String>,
3282}
3283
3284impl<'a, C> common::CallBuilder for EditApklistingDeleteCall<'a, C> {}
3285
3286impl<'a, C> EditApklistingDeleteCall<'a, C>
3287where
3288    C: common::Connector,
3289{
3290    /// Perform the operation you have build so far.
3291    pub async fn doit(mut self) -> common::Result<common::Response> {
3292        use std::borrow::Cow;
3293        use std::io::{Read, Seek};
3294
3295        use common::{url::Params, ToParts};
3296        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3297
3298        let mut dd = common::DefaultDelegate;
3299        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3300        dlg.begin(common::MethodInfo {
3301            id: "androidpublisher.edits.apklistings.delete",
3302            http_method: hyper::Method::DELETE,
3303        });
3304
3305        for &field in ["packageName", "editId", "apkVersionCode", "language"].iter() {
3306            if self._additional_params.contains_key(field) {
3307                dlg.finished(false);
3308                return Err(common::Error::FieldClash(field));
3309            }
3310        }
3311
3312        let mut params = Params::with_capacity(5 + self._additional_params.len());
3313        params.push("packageName", self._package_name);
3314        params.push("editId", self._edit_id);
3315        params.push("apkVersionCode", self._apk_version_code.to_string());
3316        params.push("language", self._language);
3317
3318        params.extend(self._additional_params.iter());
3319
3320        let mut url = self.hub._base_url.clone()
3321            + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}";
3322        if self._scopes.is_empty() {
3323            self._scopes.insert(Scope::Full.as_ref().to_string());
3324        }
3325
3326        #[allow(clippy::single_element_loop)]
3327        for &(find_this, param_name) in [
3328            ("{packageName}", "packageName"),
3329            ("{editId}", "editId"),
3330            ("{apkVersionCode}", "apkVersionCode"),
3331            ("{language}", "language"),
3332        ]
3333        .iter()
3334        {
3335            url = params.uri_replacement(url, param_name, find_this, false);
3336        }
3337        {
3338            let to_remove = ["language", "apkVersionCode", "editId", "packageName"];
3339            params.remove_params(&to_remove);
3340        }
3341
3342        let url = params.parse_with_url(&url);
3343
3344        loop {
3345            let token = match self
3346                .hub
3347                .auth
3348                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3349                .await
3350            {
3351                Ok(token) => token,
3352                Err(e) => match dlg.token(e) {
3353                    Ok(token) => token,
3354                    Err(e) => {
3355                        dlg.finished(false);
3356                        return Err(common::Error::MissingToken(e));
3357                    }
3358                },
3359            };
3360            let mut req_result = {
3361                let client = &self.hub.client;
3362                dlg.pre_request();
3363                let mut req_builder = hyper::Request::builder()
3364                    .method(hyper::Method::DELETE)
3365                    .uri(url.as_str())
3366                    .header(USER_AGENT, self.hub._user_agent.clone());
3367
3368                if let Some(token) = token.as_ref() {
3369                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3370                }
3371
3372                let request = req_builder
3373                    .header(CONTENT_LENGTH, 0_u64)
3374                    .body(common::to_body::<String>(None));
3375
3376                client.request(request.unwrap()).await
3377            };
3378
3379            match req_result {
3380                Err(err) => {
3381                    if let common::Retry::After(d) = dlg.http_error(&err) {
3382                        sleep(d).await;
3383                        continue;
3384                    }
3385                    dlg.finished(false);
3386                    return Err(common::Error::HttpError(err));
3387                }
3388                Ok(res) => {
3389                    let (mut parts, body) = res.into_parts();
3390                    let mut body = common::Body::new(body);
3391                    if !parts.status.is_success() {
3392                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3393                        let error = serde_json::from_str(&common::to_string(&bytes));
3394                        let response = common::to_response(parts, bytes.into());
3395
3396                        if let common::Retry::After(d) =
3397                            dlg.http_failure(&response, error.as_ref().ok())
3398                        {
3399                            sleep(d).await;
3400                            continue;
3401                        }
3402
3403                        dlg.finished(false);
3404
3405                        return Err(match error {
3406                            Ok(value) => common::Error::BadRequest(value),
3407                            _ => common::Error::Failure(response),
3408                        });
3409                    }
3410                    let response = common::Response::from_parts(parts, body);
3411
3412                    dlg.finished(true);
3413                    return Ok(response);
3414                }
3415            }
3416        }
3417    }
3418
3419    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
3420    ///
3421    /// Sets the *package name* path property to the given value.
3422    ///
3423    /// Even though the property as already been set when instantiating this call,
3424    /// we provide this method for API completeness.
3425    pub fn package_name(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, C> {
3426        self._package_name = new_value.to_string();
3427        self
3428    }
3429    /// Unique identifier for this edit.
3430    ///
3431    /// Sets the *edit id* path property to the given value.
3432    ///
3433    /// Even though the property as already been set when instantiating this call,
3434    /// we provide this method for API completeness.
3435    pub fn edit_id(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, C> {
3436        self._edit_id = new_value.to_string();
3437        self
3438    }
3439    /// The APK version code whose APK-specific listings should be read or modified.
3440    ///
3441    /// Sets the *apk version code* path property to the given value.
3442    ///
3443    /// Even though the property as already been set when instantiating this call,
3444    /// we provide this method for API completeness.
3445    pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingDeleteCall<'a, C> {
3446        self._apk_version_code = new_value;
3447        self
3448    }
3449    /// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
3450    ///
3451    /// Sets the *language* path property to the given value.
3452    ///
3453    /// Even though the property as already been set when instantiating this call,
3454    /// we provide this method for API completeness.
3455    pub fn language(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, C> {
3456        self._language = new_value.to_string();
3457        self
3458    }
3459    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3460    /// while executing the actual API request.
3461    ///
3462    /// ````text
3463    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3464    /// ````
3465    ///
3466    /// Sets the *delegate* property to the given value.
3467    pub fn delegate(
3468        mut self,
3469        new_value: &'a mut dyn common::Delegate,
3470    ) -> EditApklistingDeleteCall<'a, C> {
3471        self._delegate = Some(new_value);
3472        self
3473    }
3474
3475    /// Set any additional parameter of the query string used in the request.
3476    /// It should be used to set parameters which are not yet available through their own
3477    /// setters.
3478    ///
3479    /// Please note that this method must not be used to set any of the known parameters
3480    /// which have their own setter method. If done anyway, the request will fail.
3481    ///
3482    /// # Additional Parameters
3483    ///
3484    /// * *alt* (query-string) - Data format for the response.
3485    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3486    /// * *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.
3487    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3488    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3489    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3490    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3491    pub fn param<T>(mut self, name: T, value: T) -> EditApklistingDeleteCall<'a, C>
3492    where
3493        T: AsRef<str>,
3494    {
3495        self._additional_params
3496            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3497        self
3498    }
3499
3500    /// Identifies the authorization scope for the method you are building.
3501    ///
3502    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3503    /// [`Scope::Full`].
3504    ///
3505    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3506    /// tokens for more than one scope.
3507    ///
3508    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3509    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3510    /// sufficient, a read-write scope will do as well.
3511    pub fn add_scope<St>(mut self, scope: St) -> EditApklistingDeleteCall<'a, C>
3512    where
3513        St: AsRef<str>,
3514    {
3515        self._scopes.insert(String::from(scope.as_ref()));
3516        self
3517    }
3518    /// Identifies the authorization scope(s) for the method you are building.
3519    ///
3520    /// See [`Self::add_scope()`] for details.
3521    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApklistingDeleteCall<'a, C>
3522    where
3523        I: IntoIterator<Item = St>,
3524        St: AsRef<str>,
3525    {
3526        self._scopes
3527            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3528        self
3529    }
3530
3531    /// Removes all scopes, and no default scope will be used either.
3532    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3533    /// for details).
3534    pub fn clear_scopes(mut self) -> EditApklistingDeleteCall<'a, C> {
3535        self._scopes.clear();
3536        self
3537    }
3538}
3539
3540/// Deletes all the APK-specific localized listings for a specified APK.
3541///
3542/// A builder for the *apklistings.deleteall* method supported by a *edit* resource.
3543/// It is not used directly, but through a [`EditMethods`] instance.
3544///
3545/// # Example
3546///
3547/// Instantiate a resource method builder
3548///
3549/// ```test_harness,no_run
3550/// # extern crate hyper;
3551/// # extern crate hyper_rustls;
3552/// # extern crate google_androidpublisher2 as androidpublisher2;
3553/// # async fn dox() {
3554/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3555///
3556/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3557/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3558/// #     .with_native_roots()
3559/// #     .unwrap()
3560/// #     .https_only()
3561/// #     .enable_http2()
3562/// #     .build();
3563///
3564/// # let executor = hyper_util::rt::TokioExecutor::new();
3565/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3566/// #     secret,
3567/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3568/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3569/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3570/// #     ),
3571/// # ).build().await.unwrap();
3572///
3573/// # let client = hyper_util::client::legacy::Client::builder(
3574/// #     hyper_util::rt::TokioExecutor::new()
3575/// # )
3576/// # .build(
3577/// #     hyper_rustls::HttpsConnectorBuilder::new()
3578/// #         .with_native_roots()
3579/// #         .unwrap()
3580/// #         .https_or_http()
3581/// #         .enable_http2()
3582/// #         .build()
3583/// # );
3584/// # let mut hub = AndroidPublisher::new(client, auth);
3585/// // You can configure optional parameters by calling the respective setters at will, and
3586/// // execute the final call using `doit()`.
3587/// // Values shown here are possibly random and not representative !
3588/// let result = hub.edits().apklistings_deleteall("packageName", "editId", -4)
3589///              .doit().await;
3590/// # }
3591/// ```
3592pub struct EditApklistingDeleteallCall<'a, C>
3593where
3594    C: 'a,
3595{
3596    hub: &'a AndroidPublisher<C>,
3597    _package_name: String,
3598    _edit_id: String,
3599    _apk_version_code: i32,
3600    _delegate: Option<&'a mut dyn common::Delegate>,
3601    _additional_params: HashMap<String, String>,
3602    _scopes: BTreeSet<String>,
3603}
3604
3605impl<'a, C> common::CallBuilder for EditApklistingDeleteallCall<'a, C> {}
3606
3607impl<'a, C> EditApklistingDeleteallCall<'a, C>
3608where
3609    C: common::Connector,
3610{
3611    /// Perform the operation you have build so far.
3612    pub async fn doit(mut self) -> common::Result<common::Response> {
3613        use std::borrow::Cow;
3614        use std::io::{Read, Seek};
3615
3616        use common::{url::Params, ToParts};
3617        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3618
3619        let mut dd = common::DefaultDelegate;
3620        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3621        dlg.begin(common::MethodInfo {
3622            id: "androidpublisher.edits.apklistings.deleteall",
3623            http_method: hyper::Method::DELETE,
3624        });
3625
3626        for &field in ["packageName", "editId", "apkVersionCode"].iter() {
3627            if self._additional_params.contains_key(field) {
3628                dlg.finished(false);
3629                return Err(common::Error::FieldClash(field));
3630            }
3631        }
3632
3633        let mut params = Params::with_capacity(4 + self._additional_params.len());
3634        params.push("packageName", self._package_name);
3635        params.push("editId", self._edit_id);
3636        params.push("apkVersionCode", self._apk_version_code.to_string());
3637
3638        params.extend(self._additional_params.iter());
3639
3640        let mut url = self.hub._base_url.clone()
3641            + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings";
3642        if self._scopes.is_empty() {
3643            self._scopes.insert(Scope::Full.as_ref().to_string());
3644        }
3645
3646        #[allow(clippy::single_element_loop)]
3647        for &(find_this, param_name) in [
3648            ("{packageName}", "packageName"),
3649            ("{editId}", "editId"),
3650            ("{apkVersionCode}", "apkVersionCode"),
3651        ]
3652        .iter()
3653        {
3654            url = params.uri_replacement(url, param_name, find_this, false);
3655        }
3656        {
3657            let to_remove = ["apkVersionCode", "editId", "packageName"];
3658            params.remove_params(&to_remove);
3659        }
3660
3661        let url = params.parse_with_url(&url);
3662
3663        loop {
3664            let token = match self
3665                .hub
3666                .auth
3667                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3668                .await
3669            {
3670                Ok(token) => token,
3671                Err(e) => match dlg.token(e) {
3672                    Ok(token) => token,
3673                    Err(e) => {
3674                        dlg.finished(false);
3675                        return Err(common::Error::MissingToken(e));
3676                    }
3677                },
3678            };
3679            let mut req_result = {
3680                let client = &self.hub.client;
3681                dlg.pre_request();
3682                let mut req_builder = hyper::Request::builder()
3683                    .method(hyper::Method::DELETE)
3684                    .uri(url.as_str())
3685                    .header(USER_AGENT, self.hub._user_agent.clone());
3686
3687                if let Some(token) = token.as_ref() {
3688                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3689                }
3690
3691                let request = req_builder
3692                    .header(CONTENT_LENGTH, 0_u64)
3693                    .body(common::to_body::<String>(None));
3694
3695                client.request(request.unwrap()).await
3696            };
3697
3698            match req_result {
3699                Err(err) => {
3700                    if let common::Retry::After(d) = dlg.http_error(&err) {
3701                        sleep(d).await;
3702                        continue;
3703                    }
3704                    dlg.finished(false);
3705                    return Err(common::Error::HttpError(err));
3706                }
3707                Ok(res) => {
3708                    let (mut parts, body) = res.into_parts();
3709                    let mut body = common::Body::new(body);
3710                    if !parts.status.is_success() {
3711                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3712                        let error = serde_json::from_str(&common::to_string(&bytes));
3713                        let response = common::to_response(parts, bytes.into());
3714
3715                        if let common::Retry::After(d) =
3716                            dlg.http_failure(&response, error.as_ref().ok())
3717                        {
3718                            sleep(d).await;
3719                            continue;
3720                        }
3721
3722                        dlg.finished(false);
3723
3724                        return Err(match error {
3725                            Ok(value) => common::Error::BadRequest(value),
3726                            _ => common::Error::Failure(response),
3727                        });
3728                    }
3729                    let response = common::Response::from_parts(parts, body);
3730
3731                    dlg.finished(true);
3732                    return Ok(response);
3733                }
3734            }
3735        }
3736    }
3737
3738    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
3739    ///
3740    /// Sets the *package name* path property to the given value.
3741    ///
3742    /// Even though the property as already been set when instantiating this call,
3743    /// we provide this method for API completeness.
3744    pub fn package_name(mut self, new_value: &str) -> EditApklistingDeleteallCall<'a, C> {
3745        self._package_name = new_value.to_string();
3746        self
3747    }
3748    /// Unique identifier for this edit.
3749    ///
3750    /// Sets the *edit id* path property to the given value.
3751    ///
3752    /// Even though the property as already been set when instantiating this call,
3753    /// we provide this method for API completeness.
3754    pub fn edit_id(mut self, new_value: &str) -> EditApklistingDeleteallCall<'a, C> {
3755        self._edit_id = new_value.to_string();
3756        self
3757    }
3758    /// The APK version code whose APK-specific listings should be read or modified.
3759    ///
3760    /// Sets the *apk version code* path property to the given value.
3761    ///
3762    /// Even though the property as already been set when instantiating this call,
3763    /// we provide this method for API completeness.
3764    pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingDeleteallCall<'a, C> {
3765        self._apk_version_code = new_value;
3766        self
3767    }
3768    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3769    /// while executing the actual API request.
3770    ///
3771    /// ````text
3772    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3773    /// ````
3774    ///
3775    /// Sets the *delegate* property to the given value.
3776    pub fn delegate(
3777        mut self,
3778        new_value: &'a mut dyn common::Delegate,
3779    ) -> EditApklistingDeleteallCall<'a, C> {
3780        self._delegate = Some(new_value);
3781        self
3782    }
3783
3784    /// Set any additional parameter of the query string used in the request.
3785    /// It should be used to set parameters which are not yet available through their own
3786    /// setters.
3787    ///
3788    /// Please note that this method must not be used to set any of the known parameters
3789    /// which have their own setter method. If done anyway, the request will fail.
3790    ///
3791    /// # Additional Parameters
3792    ///
3793    /// * *alt* (query-string) - Data format for the response.
3794    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3795    /// * *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.
3796    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3797    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3798    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3799    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3800    pub fn param<T>(mut self, name: T, value: T) -> EditApklistingDeleteallCall<'a, C>
3801    where
3802        T: AsRef<str>,
3803    {
3804        self._additional_params
3805            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3806        self
3807    }
3808
3809    /// Identifies the authorization scope for the method you are building.
3810    ///
3811    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3812    /// [`Scope::Full`].
3813    ///
3814    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3815    /// tokens for more than one scope.
3816    ///
3817    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3818    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3819    /// sufficient, a read-write scope will do as well.
3820    pub fn add_scope<St>(mut self, scope: St) -> EditApklistingDeleteallCall<'a, C>
3821    where
3822        St: AsRef<str>,
3823    {
3824        self._scopes.insert(String::from(scope.as_ref()));
3825        self
3826    }
3827    /// Identifies the authorization scope(s) for the method you are building.
3828    ///
3829    /// See [`Self::add_scope()`] for details.
3830    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApklistingDeleteallCall<'a, C>
3831    where
3832        I: IntoIterator<Item = St>,
3833        St: AsRef<str>,
3834    {
3835        self._scopes
3836            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3837        self
3838    }
3839
3840    /// Removes all scopes, and no default scope will be used either.
3841    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3842    /// for details).
3843    pub fn clear_scopes(mut self) -> EditApklistingDeleteallCall<'a, C> {
3844        self._scopes.clear();
3845        self
3846    }
3847}
3848
3849/// Fetches the APK-specific localized listing for a specified APK and language code.
3850///
3851/// A builder for the *apklistings.get* method supported by a *edit* resource.
3852/// It is not used directly, but through a [`EditMethods`] instance.
3853///
3854/// # Example
3855///
3856/// Instantiate a resource method builder
3857///
3858/// ```test_harness,no_run
3859/// # extern crate hyper;
3860/// # extern crate hyper_rustls;
3861/// # extern crate google_androidpublisher2 as androidpublisher2;
3862/// # async fn dox() {
3863/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3864///
3865/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3866/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3867/// #     .with_native_roots()
3868/// #     .unwrap()
3869/// #     .https_only()
3870/// #     .enable_http2()
3871/// #     .build();
3872///
3873/// # let executor = hyper_util::rt::TokioExecutor::new();
3874/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3875/// #     secret,
3876/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3877/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3878/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3879/// #     ),
3880/// # ).build().await.unwrap();
3881///
3882/// # let client = hyper_util::client::legacy::Client::builder(
3883/// #     hyper_util::rt::TokioExecutor::new()
3884/// # )
3885/// # .build(
3886/// #     hyper_rustls::HttpsConnectorBuilder::new()
3887/// #         .with_native_roots()
3888/// #         .unwrap()
3889/// #         .https_or_http()
3890/// #         .enable_http2()
3891/// #         .build()
3892/// # );
3893/// # let mut hub = AndroidPublisher::new(client, auth);
3894/// // You can configure optional parameters by calling the respective setters at will, and
3895/// // execute the final call using `doit()`.
3896/// // Values shown here are possibly random and not representative !
3897/// let result = hub.edits().apklistings_get("packageName", "editId", -88, "language")
3898///              .doit().await;
3899/// # }
3900/// ```
3901pub struct EditApklistingGetCall<'a, C>
3902where
3903    C: 'a,
3904{
3905    hub: &'a AndroidPublisher<C>,
3906    _package_name: String,
3907    _edit_id: String,
3908    _apk_version_code: i32,
3909    _language: String,
3910    _delegate: Option<&'a mut dyn common::Delegate>,
3911    _additional_params: HashMap<String, String>,
3912    _scopes: BTreeSet<String>,
3913}
3914
3915impl<'a, C> common::CallBuilder for EditApklistingGetCall<'a, C> {}
3916
3917impl<'a, C> EditApklistingGetCall<'a, C>
3918where
3919    C: common::Connector,
3920{
3921    /// Perform the operation you have build so far.
3922    pub async fn doit(mut self) -> common::Result<(common::Response, ApkListing)> {
3923        use std::borrow::Cow;
3924        use std::io::{Read, Seek};
3925
3926        use common::{url::Params, ToParts};
3927        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3928
3929        let mut dd = common::DefaultDelegate;
3930        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3931        dlg.begin(common::MethodInfo {
3932            id: "androidpublisher.edits.apklistings.get",
3933            http_method: hyper::Method::GET,
3934        });
3935
3936        for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() {
3937            if self._additional_params.contains_key(field) {
3938                dlg.finished(false);
3939                return Err(common::Error::FieldClash(field));
3940            }
3941        }
3942
3943        let mut params = Params::with_capacity(6 + self._additional_params.len());
3944        params.push("packageName", self._package_name);
3945        params.push("editId", self._edit_id);
3946        params.push("apkVersionCode", self._apk_version_code.to_string());
3947        params.push("language", self._language);
3948
3949        params.extend(self._additional_params.iter());
3950
3951        params.push("alt", "json");
3952        let mut url = self.hub._base_url.clone()
3953            + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}";
3954        if self._scopes.is_empty() {
3955            self._scopes.insert(Scope::Full.as_ref().to_string());
3956        }
3957
3958        #[allow(clippy::single_element_loop)]
3959        for &(find_this, param_name) in [
3960            ("{packageName}", "packageName"),
3961            ("{editId}", "editId"),
3962            ("{apkVersionCode}", "apkVersionCode"),
3963            ("{language}", "language"),
3964        ]
3965        .iter()
3966        {
3967            url = params.uri_replacement(url, param_name, find_this, false);
3968        }
3969        {
3970            let to_remove = ["language", "apkVersionCode", "editId", "packageName"];
3971            params.remove_params(&to_remove);
3972        }
3973
3974        let url = params.parse_with_url(&url);
3975
3976        loop {
3977            let token = match self
3978                .hub
3979                .auth
3980                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3981                .await
3982            {
3983                Ok(token) => token,
3984                Err(e) => match dlg.token(e) {
3985                    Ok(token) => token,
3986                    Err(e) => {
3987                        dlg.finished(false);
3988                        return Err(common::Error::MissingToken(e));
3989                    }
3990                },
3991            };
3992            let mut req_result = {
3993                let client = &self.hub.client;
3994                dlg.pre_request();
3995                let mut req_builder = hyper::Request::builder()
3996                    .method(hyper::Method::GET)
3997                    .uri(url.as_str())
3998                    .header(USER_AGENT, self.hub._user_agent.clone());
3999
4000                if let Some(token) = token.as_ref() {
4001                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4002                }
4003
4004                let request = req_builder
4005                    .header(CONTENT_LENGTH, 0_u64)
4006                    .body(common::to_body::<String>(None));
4007
4008                client.request(request.unwrap()).await
4009            };
4010
4011            match req_result {
4012                Err(err) => {
4013                    if let common::Retry::After(d) = dlg.http_error(&err) {
4014                        sleep(d).await;
4015                        continue;
4016                    }
4017                    dlg.finished(false);
4018                    return Err(common::Error::HttpError(err));
4019                }
4020                Ok(res) => {
4021                    let (mut parts, body) = res.into_parts();
4022                    let mut body = common::Body::new(body);
4023                    if !parts.status.is_success() {
4024                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4025                        let error = serde_json::from_str(&common::to_string(&bytes));
4026                        let response = common::to_response(parts, bytes.into());
4027
4028                        if let common::Retry::After(d) =
4029                            dlg.http_failure(&response, error.as_ref().ok())
4030                        {
4031                            sleep(d).await;
4032                            continue;
4033                        }
4034
4035                        dlg.finished(false);
4036
4037                        return Err(match error {
4038                            Ok(value) => common::Error::BadRequest(value),
4039                            _ => common::Error::Failure(response),
4040                        });
4041                    }
4042                    let response = {
4043                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4044                        let encoded = common::to_string(&bytes);
4045                        match serde_json::from_str(&encoded) {
4046                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4047                            Err(error) => {
4048                                dlg.response_json_decode_error(&encoded, &error);
4049                                return Err(common::Error::JsonDecodeError(
4050                                    encoded.to_string(),
4051                                    error,
4052                                ));
4053                            }
4054                        }
4055                    };
4056
4057                    dlg.finished(true);
4058                    return Ok(response);
4059                }
4060            }
4061        }
4062    }
4063
4064    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
4065    ///
4066    /// Sets the *package name* path property to the given value.
4067    ///
4068    /// Even though the property as already been set when instantiating this call,
4069    /// we provide this method for API completeness.
4070    pub fn package_name(mut self, new_value: &str) -> EditApklistingGetCall<'a, C> {
4071        self._package_name = new_value.to_string();
4072        self
4073    }
4074    /// Unique identifier for this edit.
4075    ///
4076    /// Sets the *edit id* path property to the given value.
4077    ///
4078    /// Even though the property as already been set when instantiating this call,
4079    /// we provide this method for API completeness.
4080    pub fn edit_id(mut self, new_value: &str) -> EditApklistingGetCall<'a, C> {
4081        self._edit_id = new_value.to_string();
4082        self
4083    }
4084    /// The APK version code whose APK-specific listings should be read or modified.
4085    ///
4086    /// Sets the *apk version code* path property to the given value.
4087    ///
4088    /// Even though the property as already been set when instantiating this call,
4089    /// we provide this method for API completeness.
4090    pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingGetCall<'a, C> {
4091        self._apk_version_code = new_value;
4092        self
4093    }
4094    /// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
4095    ///
4096    /// Sets the *language* path property to the given value.
4097    ///
4098    /// Even though the property as already been set when instantiating this call,
4099    /// we provide this method for API completeness.
4100    pub fn language(mut self, new_value: &str) -> EditApklistingGetCall<'a, C> {
4101        self._language = new_value.to_string();
4102        self
4103    }
4104    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4105    /// while executing the actual API request.
4106    ///
4107    /// ````text
4108    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4109    /// ````
4110    ///
4111    /// Sets the *delegate* property to the given value.
4112    pub fn delegate(
4113        mut self,
4114        new_value: &'a mut dyn common::Delegate,
4115    ) -> EditApklistingGetCall<'a, C> {
4116        self._delegate = Some(new_value);
4117        self
4118    }
4119
4120    /// Set any additional parameter of the query string used in the request.
4121    /// It should be used to set parameters which are not yet available through their own
4122    /// setters.
4123    ///
4124    /// Please note that this method must not be used to set any of the known parameters
4125    /// which have their own setter method. If done anyway, the request will fail.
4126    ///
4127    /// # Additional Parameters
4128    ///
4129    /// * *alt* (query-string) - Data format for the response.
4130    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4131    /// * *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.
4132    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4133    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4134    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4135    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4136    pub fn param<T>(mut self, name: T, value: T) -> EditApklistingGetCall<'a, C>
4137    where
4138        T: AsRef<str>,
4139    {
4140        self._additional_params
4141            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4142        self
4143    }
4144
4145    /// Identifies the authorization scope for the method you are building.
4146    ///
4147    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4148    /// [`Scope::Full`].
4149    ///
4150    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4151    /// tokens for more than one scope.
4152    ///
4153    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4154    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4155    /// sufficient, a read-write scope will do as well.
4156    pub fn add_scope<St>(mut self, scope: St) -> EditApklistingGetCall<'a, C>
4157    where
4158        St: AsRef<str>,
4159    {
4160        self._scopes.insert(String::from(scope.as_ref()));
4161        self
4162    }
4163    /// Identifies the authorization scope(s) for the method you are building.
4164    ///
4165    /// See [`Self::add_scope()`] for details.
4166    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApklistingGetCall<'a, C>
4167    where
4168        I: IntoIterator<Item = St>,
4169        St: AsRef<str>,
4170    {
4171        self._scopes
4172            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4173        self
4174    }
4175
4176    /// Removes all scopes, and no default scope will be used either.
4177    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4178    /// for details).
4179    pub fn clear_scopes(mut self) -> EditApklistingGetCall<'a, C> {
4180        self._scopes.clear();
4181        self
4182    }
4183}
4184
4185/// Lists all the APK-specific localized listings for a specified APK.
4186///
4187/// A builder for the *apklistings.list* method supported by a *edit* resource.
4188/// It is not used directly, but through a [`EditMethods`] instance.
4189///
4190/// # Example
4191///
4192/// Instantiate a resource method builder
4193///
4194/// ```test_harness,no_run
4195/// # extern crate hyper;
4196/// # extern crate hyper_rustls;
4197/// # extern crate google_androidpublisher2 as androidpublisher2;
4198/// # async fn dox() {
4199/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4200///
4201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4202/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4203/// #     .with_native_roots()
4204/// #     .unwrap()
4205/// #     .https_only()
4206/// #     .enable_http2()
4207/// #     .build();
4208///
4209/// # let executor = hyper_util::rt::TokioExecutor::new();
4210/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4211/// #     secret,
4212/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4213/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4214/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4215/// #     ),
4216/// # ).build().await.unwrap();
4217///
4218/// # let client = hyper_util::client::legacy::Client::builder(
4219/// #     hyper_util::rt::TokioExecutor::new()
4220/// # )
4221/// # .build(
4222/// #     hyper_rustls::HttpsConnectorBuilder::new()
4223/// #         .with_native_roots()
4224/// #         .unwrap()
4225/// #         .https_or_http()
4226/// #         .enable_http2()
4227/// #         .build()
4228/// # );
4229/// # let mut hub = AndroidPublisher::new(client, auth);
4230/// // You can configure optional parameters by calling the respective setters at will, and
4231/// // execute the final call using `doit()`.
4232/// // Values shown here are possibly random and not representative !
4233/// let result = hub.edits().apklistings_list("packageName", "editId", -93)
4234///              .doit().await;
4235/// # }
4236/// ```
4237pub struct EditApklistingListCall<'a, C>
4238where
4239    C: 'a,
4240{
4241    hub: &'a AndroidPublisher<C>,
4242    _package_name: String,
4243    _edit_id: String,
4244    _apk_version_code: i32,
4245    _delegate: Option<&'a mut dyn common::Delegate>,
4246    _additional_params: HashMap<String, String>,
4247    _scopes: BTreeSet<String>,
4248}
4249
4250impl<'a, C> common::CallBuilder for EditApklistingListCall<'a, C> {}
4251
4252impl<'a, C> EditApklistingListCall<'a, C>
4253where
4254    C: common::Connector,
4255{
4256    /// Perform the operation you have build so far.
4257    pub async fn doit(mut self) -> common::Result<(common::Response, ApkListingsListResponse)> {
4258        use std::borrow::Cow;
4259        use std::io::{Read, Seek};
4260
4261        use common::{url::Params, ToParts};
4262        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4263
4264        let mut dd = common::DefaultDelegate;
4265        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4266        dlg.begin(common::MethodInfo {
4267            id: "androidpublisher.edits.apklistings.list",
4268            http_method: hyper::Method::GET,
4269        });
4270
4271        for &field in ["alt", "packageName", "editId", "apkVersionCode"].iter() {
4272            if self._additional_params.contains_key(field) {
4273                dlg.finished(false);
4274                return Err(common::Error::FieldClash(field));
4275            }
4276        }
4277
4278        let mut params = Params::with_capacity(5 + self._additional_params.len());
4279        params.push("packageName", self._package_name);
4280        params.push("editId", self._edit_id);
4281        params.push("apkVersionCode", self._apk_version_code.to_string());
4282
4283        params.extend(self._additional_params.iter());
4284
4285        params.push("alt", "json");
4286        let mut url = self.hub._base_url.clone()
4287            + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings";
4288        if self._scopes.is_empty() {
4289            self._scopes.insert(Scope::Full.as_ref().to_string());
4290        }
4291
4292        #[allow(clippy::single_element_loop)]
4293        for &(find_this, param_name) in [
4294            ("{packageName}", "packageName"),
4295            ("{editId}", "editId"),
4296            ("{apkVersionCode}", "apkVersionCode"),
4297        ]
4298        .iter()
4299        {
4300            url = params.uri_replacement(url, param_name, find_this, false);
4301        }
4302        {
4303            let to_remove = ["apkVersionCode", "editId", "packageName"];
4304            params.remove_params(&to_remove);
4305        }
4306
4307        let url = params.parse_with_url(&url);
4308
4309        loop {
4310            let token = match self
4311                .hub
4312                .auth
4313                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4314                .await
4315            {
4316                Ok(token) => token,
4317                Err(e) => match dlg.token(e) {
4318                    Ok(token) => token,
4319                    Err(e) => {
4320                        dlg.finished(false);
4321                        return Err(common::Error::MissingToken(e));
4322                    }
4323                },
4324            };
4325            let mut req_result = {
4326                let client = &self.hub.client;
4327                dlg.pre_request();
4328                let mut req_builder = hyper::Request::builder()
4329                    .method(hyper::Method::GET)
4330                    .uri(url.as_str())
4331                    .header(USER_AGENT, self.hub._user_agent.clone());
4332
4333                if let Some(token) = token.as_ref() {
4334                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4335                }
4336
4337                let request = req_builder
4338                    .header(CONTENT_LENGTH, 0_u64)
4339                    .body(common::to_body::<String>(None));
4340
4341                client.request(request.unwrap()).await
4342            };
4343
4344            match req_result {
4345                Err(err) => {
4346                    if let common::Retry::After(d) = dlg.http_error(&err) {
4347                        sleep(d).await;
4348                        continue;
4349                    }
4350                    dlg.finished(false);
4351                    return Err(common::Error::HttpError(err));
4352                }
4353                Ok(res) => {
4354                    let (mut parts, body) = res.into_parts();
4355                    let mut body = common::Body::new(body);
4356                    if !parts.status.is_success() {
4357                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4358                        let error = serde_json::from_str(&common::to_string(&bytes));
4359                        let response = common::to_response(parts, bytes.into());
4360
4361                        if let common::Retry::After(d) =
4362                            dlg.http_failure(&response, error.as_ref().ok())
4363                        {
4364                            sleep(d).await;
4365                            continue;
4366                        }
4367
4368                        dlg.finished(false);
4369
4370                        return Err(match error {
4371                            Ok(value) => common::Error::BadRequest(value),
4372                            _ => common::Error::Failure(response),
4373                        });
4374                    }
4375                    let response = {
4376                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4377                        let encoded = common::to_string(&bytes);
4378                        match serde_json::from_str(&encoded) {
4379                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4380                            Err(error) => {
4381                                dlg.response_json_decode_error(&encoded, &error);
4382                                return Err(common::Error::JsonDecodeError(
4383                                    encoded.to_string(),
4384                                    error,
4385                                ));
4386                            }
4387                        }
4388                    };
4389
4390                    dlg.finished(true);
4391                    return Ok(response);
4392                }
4393            }
4394        }
4395    }
4396
4397    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
4398    ///
4399    /// Sets the *package name* path property to the given value.
4400    ///
4401    /// Even though the property as already been set when instantiating this call,
4402    /// we provide this method for API completeness.
4403    pub fn package_name(mut self, new_value: &str) -> EditApklistingListCall<'a, C> {
4404        self._package_name = new_value.to_string();
4405        self
4406    }
4407    /// Unique identifier for this edit.
4408    ///
4409    /// Sets the *edit id* path property to the given value.
4410    ///
4411    /// Even though the property as already been set when instantiating this call,
4412    /// we provide this method for API completeness.
4413    pub fn edit_id(mut self, new_value: &str) -> EditApklistingListCall<'a, C> {
4414        self._edit_id = new_value.to_string();
4415        self
4416    }
4417    /// The APK version code whose APK-specific listings should be read or modified.
4418    ///
4419    /// Sets the *apk version code* path property to the given value.
4420    ///
4421    /// Even though the property as already been set when instantiating this call,
4422    /// we provide this method for API completeness.
4423    pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingListCall<'a, C> {
4424        self._apk_version_code = new_value;
4425        self
4426    }
4427    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4428    /// while executing the actual API request.
4429    ///
4430    /// ````text
4431    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4432    /// ````
4433    ///
4434    /// Sets the *delegate* property to the given value.
4435    pub fn delegate(
4436        mut self,
4437        new_value: &'a mut dyn common::Delegate,
4438    ) -> EditApklistingListCall<'a, C> {
4439        self._delegate = Some(new_value);
4440        self
4441    }
4442
4443    /// Set any additional parameter of the query string used in the request.
4444    /// It should be used to set parameters which are not yet available through their own
4445    /// setters.
4446    ///
4447    /// Please note that this method must not be used to set any of the known parameters
4448    /// which have their own setter method. If done anyway, the request will fail.
4449    ///
4450    /// # Additional Parameters
4451    ///
4452    /// * *alt* (query-string) - Data format for the response.
4453    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4454    /// * *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.
4455    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4456    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4457    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4458    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4459    pub fn param<T>(mut self, name: T, value: T) -> EditApklistingListCall<'a, C>
4460    where
4461        T: AsRef<str>,
4462    {
4463        self._additional_params
4464            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4465        self
4466    }
4467
4468    /// Identifies the authorization scope for the method you are building.
4469    ///
4470    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4471    /// [`Scope::Full`].
4472    ///
4473    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4474    /// tokens for more than one scope.
4475    ///
4476    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4477    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4478    /// sufficient, a read-write scope will do as well.
4479    pub fn add_scope<St>(mut self, scope: St) -> EditApklistingListCall<'a, C>
4480    where
4481        St: AsRef<str>,
4482    {
4483        self._scopes.insert(String::from(scope.as_ref()));
4484        self
4485    }
4486    /// Identifies the authorization scope(s) for the method you are building.
4487    ///
4488    /// See [`Self::add_scope()`] for details.
4489    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApklistingListCall<'a, C>
4490    where
4491        I: IntoIterator<Item = St>,
4492        St: AsRef<str>,
4493    {
4494        self._scopes
4495            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4496        self
4497    }
4498
4499    /// Removes all scopes, and no default scope will be used either.
4500    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4501    /// for details).
4502    pub fn clear_scopes(mut self) -> EditApklistingListCall<'a, C> {
4503        self._scopes.clear();
4504        self
4505    }
4506}
4507
4508/// Updates or creates the APK-specific localized listing for a specified APK and language code. This method supports patch semantics.
4509///
4510/// A builder for the *apklistings.patch* method supported by a *edit* resource.
4511/// It is not used directly, but through a [`EditMethods`] instance.
4512///
4513/// # Example
4514///
4515/// Instantiate a resource method builder
4516///
4517/// ```test_harness,no_run
4518/// # extern crate hyper;
4519/// # extern crate hyper_rustls;
4520/// # extern crate google_androidpublisher2 as androidpublisher2;
4521/// use androidpublisher2::api::ApkListing;
4522/// # async fn dox() {
4523/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4524///
4525/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4526/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4527/// #     .with_native_roots()
4528/// #     .unwrap()
4529/// #     .https_only()
4530/// #     .enable_http2()
4531/// #     .build();
4532///
4533/// # let executor = hyper_util::rt::TokioExecutor::new();
4534/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4535/// #     secret,
4536/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4537/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4538/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4539/// #     ),
4540/// # ).build().await.unwrap();
4541///
4542/// # let client = hyper_util::client::legacy::Client::builder(
4543/// #     hyper_util::rt::TokioExecutor::new()
4544/// # )
4545/// # .build(
4546/// #     hyper_rustls::HttpsConnectorBuilder::new()
4547/// #         .with_native_roots()
4548/// #         .unwrap()
4549/// #         .https_or_http()
4550/// #         .enable_http2()
4551/// #         .build()
4552/// # );
4553/// # let mut hub = AndroidPublisher::new(client, auth);
4554/// // As the method needs a request, you would usually fill it with the desired information
4555/// // into the respective structure. Some of the parts shown here might not be applicable !
4556/// // Values shown here are possibly random and not representative !
4557/// let mut req = ApkListing::default();
4558///
4559/// // You can configure optional parameters by calling the respective setters at will, and
4560/// // execute the final call using `doit()`.
4561/// // Values shown here are possibly random and not representative !
4562/// let result = hub.edits().apklistings_patch(req, "packageName", "editId", -16, "language")
4563///              .doit().await;
4564/// # }
4565/// ```
4566pub struct EditApklistingPatchCall<'a, C>
4567where
4568    C: 'a,
4569{
4570    hub: &'a AndroidPublisher<C>,
4571    _request: ApkListing,
4572    _package_name: String,
4573    _edit_id: String,
4574    _apk_version_code: i32,
4575    _language: String,
4576    _delegate: Option<&'a mut dyn common::Delegate>,
4577    _additional_params: HashMap<String, String>,
4578    _scopes: BTreeSet<String>,
4579}
4580
4581impl<'a, C> common::CallBuilder for EditApklistingPatchCall<'a, C> {}
4582
4583impl<'a, C> EditApklistingPatchCall<'a, C>
4584where
4585    C: common::Connector,
4586{
4587    /// Perform the operation you have build so far.
4588    pub async fn doit(mut self) -> common::Result<(common::Response, ApkListing)> {
4589        use std::borrow::Cow;
4590        use std::io::{Read, Seek};
4591
4592        use common::{url::Params, ToParts};
4593        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4594
4595        let mut dd = common::DefaultDelegate;
4596        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4597        dlg.begin(common::MethodInfo {
4598            id: "androidpublisher.edits.apklistings.patch",
4599            http_method: hyper::Method::PATCH,
4600        });
4601
4602        for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() {
4603            if self._additional_params.contains_key(field) {
4604                dlg.finished(false);
4605                return Err(common::Error::FieldClash(field));
4606            }
4607        }
4608
4609        let mut params = Params::with_capacity(7 + self._additional_params.len());
4610        params.push("packageName", self._package_name);
4611        params.push("editId", self._edit_id);
4612        params.push("apkVersionCode", self._apk_version_code.to_string());
4613        params.push("language", self._language);
4614
4615        params.extend(self._additional_params.iter());
4616
4617        params.push("alt", "json");
4618        let mut url = self.hub._base_url.clone()
4619            + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}";
4620        if self._scopes.is_empty() {
4621            self._scopes.insert(Scope::Full.as_ref().to_string());
4622        }
4623
4624        #[allow(clippy::single_element_loop)]
4625        for &(find_this, param_name) in [
4626            ("{packageName}", "packageName"),
4627            ("{editId}", "editId"),
4628            ("{apkVersionCode}", "apkVersionCode"),
4629            ("{language}", "language"),
4630        ]
4631        .iter()
4632        {
4633            url = params.uri_replacement(url, param_name, find_this, false);
4634        }
4635        {
4636            let to_remove = ["language", "apkVersionCode", "editId", "packageName"];
4637            params.remove_params(&to_remove);
4638        }
4639
4640        let url = params.parse_with_url(&url);
4641
4642        let mut json_mime_type = mime::APPLICATION_JSON;
4643        let mut request_value_reader = {
4644            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4645            common::remove_json_null_values(&mut value);
4646            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4647            serde_json::to_writer(&mut dst, &value).unwrap();
4648            dst
4649        };
4650        let request_size = request_value_reader
4651            .seek(std::io::SeekFrom::End(0))
4652            .unwrap();
4653        request_value_reader
4654            .seek(std::io::SeekFrom::Start(0))
4655            .unwrap();
4656
4657        loop {
4658            let token = match self
4659                .hub
4660                .auth
4661                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4662                .await
4663            {
4664                Ok(token) => token,
4665                Err(e) => match dlg.token(e) {
4666                    Ok(token) => token,
4667                    Err(e) => {
4668                        dlg.finished(false);
4669                        return Err(common::Error::MissingToken(e));
4670                    }
4671                },
4672            };
4673            request_value_reader
4674                .seek(std::io::SeekFrom::Start(0))
4675                .unwrap();
4676            let mut req_result = {
4677                let client = &self.hub.client;
4678                dlg.pre_request();
4679                let mut req_builder = hyper::Request::builder()
4680                    .method(hyper::Method::PATCH)
4681                    .uri(url.as_str())
4682                    .header(USER_AGENT, self.hub._user_agent.clone());
4683
4684                if let Some(token) = token.as_ref() {
4685                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4686                }
4687
4688                let request = req_builder
4689                    .header(CONTENT_TYPE, json_mime_type.to_string())
4690                    .header(CONTENT_LENGTH, request_size as u64)
4691                    .body(common::to_body(
4692                        request_value_reader.get_ref().clone().into(),
4693                    ));
4694
4695                client.request(request.unwrap()).await
4696            };
4697
4698            match req_result {
4699                Err(err) => {
4700                    if let common::Retry::After(d) = dlg.http_error(&err) {
4701                        sleep(d).await;
4702                        continue;
4703                    }
4704                    dlg.finished(false);
4705                    return Err(common::Error::HttpError(err));
4706                }
4707                Ok(res) => {
4708                    let (mut parts, body) = res.into_parts();
4709                    let mut body = common::Body::new(body);
4710                    if !parts.status.is_success() {
4711                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4712                        let error = serde_json::from_str(&common::to_string(&bytes));
4713                        let response = common::to_response(parts, bytes.into());
4714
4715                        if let common::Retry::After(d) =
4716                            dlg.http_failure(&response, error.as_ref().ok())
4717                        {
4718                            sleep(d).await;
4719                            continue;
4720                        }
4721
4722                        dlg.finished(false);
4723
4724                        return Err(match error {
4725                            Ok(value) => common::Error::BadRequest(value),
4726                            _ => common::Error::Failure(response),
4727                        });
4728                    }
4729                    let response = {
4730                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4731                        let encoded = common::to_string(&bytes);
4732                        match serde_json::from_str(&encoded) {
4733                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4734                            Err(error) => {
4735                                dlg.response_json_decode_error(&encoded, &error);
4736                                return Err(common::Error::JsonDecodeError(
4737                                    encoded.to_string(),
4738                                    error,
4739                                ));
4740                            }
4741                        }
4742                    };
4743
4744                    dlg.finished(true);
4745                    return Ok(response);
4746                }
4747            }
4748        }
4749    }
4750
4751    ///
4752    /// Sets the *request* property to the given value.
4753    ///
4754    /// Even though the property as already been set when instantiating this call,
4755    /// we provide this method for API completeness.
4756    pub fn request(mut self, new_value: ApkListing) -> EditApklistingPatchCall<'a, C> {
4757        self._request = new_value;
4758        self
4759    }
4760    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
4761    ///
4762    /// Sets the *package name* path property to the given value.
4763    ///
4764    /// Even though the property as already been set when instantiating this call,
4765    /// we provide this method for API completeness.
4766    pub fn package_name(mut self, new_value: &str) -> EditApklistingPatchCall<'a, C> {
4767        self._package_name = new_value.to_string();
4768        self
4769    }
4770    /// Unique identifier for this edit.
4771    ///
4772    /// Sets the *edit id* path property to the given value.
4773    ///
4774    /// Even though the property as already been set when instantiating this call,
4775    /// we provide this method for API completeness.
4776    pub fn edit_id(mut self, new_value: &str) -> EditApklistingPatchCall<'a, C> {
4777        self._edit_id = new_value.to_string();
4778        self
4779    }
4780    /// The APK version code whose APK-specific listings should be read or modified.
4781    ///
4782    /// Sets the *apk version code* path property to the given value.
4783    ///
4784    /// Even though the property as already been set when instantiating this call,
4785    /// we provide this method for API completeness.
4786    pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingPatchCall<'a, C> {
4787        self._apk_version_code = new_value;
4788        self
4789    }
4790    /// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
4791    ///
4792    /// Sets the *language* path property to the given value.
4793    ///
4794    /// Even though the property as already been set when instantiating this call,
4795    /// we provide this method for API completeness.
4796    pub fn language(mut self, new_value: &str) -> EditApklistingPatchCall<'a, C> {
4797        self._language = new_value.to_string();
4798        self
4799    }
4800    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4801    /// while executing the actual API request.
4802    ///
4803    /// ````text
4804    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4805    /// ````
4806    ///
4807    /// Sets the *delegate* property to the given value.
4808    pub fn delegate(
4809        mut self,
4810        new_value: &'a mut dyn common::Delegate,
4811    ) -> EditApklistingPatchCall<'a, C> {
4812        self._delegate = Some(new_value);
4813        self
4814    }
4815
4816    /// Set any additional parameter of the query string used in the request.
4817    /// It should be used to set parameters which are not yet available through their own
4818    /// setters.
4819    ///
4820    /// Please note that this method must not be used to set any of the known parameters
4821    /// which have their own setter method. If done anyway, the request will fail.
4822    ///
4823    /// # Additional Parameters
4824    ///
4825    /// * *alt* (query-string) - Data format for the response.
4826    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4827    /// * *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.
4828    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4829    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4830    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4831    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4832    pub fn param<T>(mut self, name: T, value: T) -> EditApklistingPatchCall<'a, C>
4833    where
4834        T: AsRef<str>,
4835    {
4836        self._additional_params
4837            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4838        self
4839    }
4840
4841    /// Identifies the authorization scope for the method you are building.
4842    ///
4843    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4844    /// [`Scope::Full`].
4845    ///
4846    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4847    /// tokens for more than one scope.
4848    ///
4849    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4850    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4851    /// sufficient, a read-write scope will do as well.
4852    pub fn add_scope<St>(mut self, scope: St) -> EditApklistingPatchCall<'a, C>
4853    where
4854        St: AsRef<str>,
4855    {
4856        self._scopes.insert(String::from(scope.as_ref()));
4857        self
4858    }
4859    /// Identifies the authorization scope(s) for the method you are building.
4860    ///
4861    /// See [`Self::add_scope()`] for details.
4862    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApklistingPatchCall<'a, C>
4863    where
4864        I: IntoIterator<Item = St>,
4865        St: AsRef<str>,
4866    {
4867        self._scopes
4868            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4869        self
4870    }
4871
4872    /// Removes all scopes, and no default scope will be used either.
4873    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4874    /// for details).
4875    pub fn clear_scopes(mut self) -> EditApklistingPatchCall<'a, C> {
4876        self._scopes.clear();
4877        self
4878    }
4879}
4880
4881/// Updates or creates the APK-specific localized listing for a specified APK and language code.
4882///
4883/// A builder for the *apklistings.update* method supported by a *edit* resource.
4884/// It is not used directly, but through a [`EditMethods`] instance.
4885///
4886/// # Example
4887///
4888/// Instantiate a resource method builder
4889///
4890/// ```test_harness,no_run
4891/// # extern crate hyper;
4892/// # extern crate hyper_rustls;
4893/// # extern crate google_androidpublisher2 as androidpublisher2;
4894/// use androidpublisher2::api::ApkListing;
4895/// # async fn dox() {
4896/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4897///
4898/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4899/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4900/// #     .with_native_roots()
4901/// #     .unwrap()
4902/// #     .https_only()
4903/// #     .enable_http2()
4904/// #     .build();
4905///
4906/// # let executor = hyper_util::rt::TokioExecutor::new();
4907/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4908/// #     secret,
4909/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4910/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4911/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4912/// #     ),
4913/// # ).build().await.unwrap();
4914///
4915/// # let client = hyper_util::client::legacy::Client::builder(
4916/// #     hyper_util::rt::TokioExecutor::new()
4917/// # )
4918/// # .build(
4919/// #     hyper_rustls::HttpsConnectorBuilder::new()
4920/// #         .with_native_roots()
4921/// #         .unwrap()
4922/// #         .https_or_http()
4923/// #         .enable_http2()
4924/// #         .build()
4925/// # );
4926/// # let mut hub = AndroidPublisher::new(client, auth);
4927/// // As the method needs a request, you would usually fill it with the desired information
4928/// // into the respective structure. Some of the parts shown here might not be applicable !
4929/// // Values shown here are possibly random and not representative !
4930/// let mut req = ApkListing::default();
4931///
4932/// // You can configure optional parameters by calling the respective setters at will, and
4933/// // execute the final call using `doit()`.
4934/// // Values shown here are possibly random and not representative !
4935/// let result = hub.edits().apklistings_update(req, "packageName", "editId", -7, "language")
4936///              .doit().await;
4937/// # }
4938/// ```
4939pub struct EditApklistingUpdateCall<'a, C>
4940where
4941    C: 'a,
4942{
4943    hub: &'a AndroidPublisher<C>,
4944    _request: ApkListing,
4945    _package_name: String,
4946    _edit_id: String,
4947    _apk_version_code: i32,
4948    _language: String,
4949    _delegate: Option<&'a mut dyn common::Delegate>,
4950    _additional_params: HashMap<String, String>,
4951    _scopes: BTreeSet<String>,
4952}
4953
4954impl<'a, C> common::CallBuilder for EditApklistingUpdateCall<'a, C> {}
4955
4956impl<'a, C> EditApklistingUpdateCall<'a, C>
4957where
4958    C: common::Connector,
4959{
4960    /// Perform the operation you have build so far.
4961    pub async fn doit(mut self) -> common::Result<(common::Response, ApkListing)> {
4962        use std::borrow::Cow;
4963        use std::io::{Read, Seek};
4964
4965        use common::{url::Params, ToParts};
4966        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4967
4968        let mut dd = common::DefaultDelegate;
4969        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4970        dlg.begin(common::MethodInfo {
4971            id: "androidpublisher.edits.apklistings.update",
4972            http_method: hyper::Method::PUT,
4973        });
4974
4975        for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() {
4976            if self._additional_params.contains_key(field) {
4977                dlg.finished(false);
4978                return Err(common::Error::FieldClash(field));
4979            }
4980        }
4981
4982        let mut params = Params::with_capacity(7 + self._additional_params.len());
4983        params.push("packageName", self._package_name);
4984        params.push("editId", self._edit_id);
4985        params.push("apkVersionCode", self._apk_version_code.to_string());
4986        params.push("language", self._language);
4987
4988        params.extend(self._additional_params.iter());
4989
4990        params.push("alt", "json");
4991        let mut url = self.hub._base_url.clone()
4992            + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}";
4993        if self._scopes.is_empty() {
4994            self._scopes.insert(Scope::Full.as_ref().to_string());
4995        }
4996
4997        #[allow(clippy::single_element_loop)]
4998        for &(find_this, param_name) in [
4999            ("{packageName}", "packageName"),
5000            ("{editId}", "editId"),
5001            ("{apkVersionCode}", "apkVersionCode"),
5002            ("{language}", "language"),
5003        ]
5004        .iter()
5005        {
5006            url = params.uri_replacement(url, param_name, find_this, false);
5007        }
5008        {
5009            let to_remove = ["language", "apkVersionCode", "editId", "packageName"];
5010            params.remove_params(&to_remove);
5011        }
5012
5013        let url = params.parse_with_url(&url);
5014
5015        let mut json_mime_type = mime::APPLICATION_JSON;
5016        let mut request_value_reader = {
5017            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5018            common::remove_json_null_values(&mut value);
5019            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5020            serde_json::to_writer(&mut dst, &value).unwrap();
5021            dst
5022        };
5023        let request_size = request_value_reader
5024            .seek(std::io::SeekFrom::End(0))
5025            .unwrap();
5026        request_value_reader
5027            .seek(std::io::SeekFrom::Start(0))
5028            .unwrap();
5029
5030        loop {
5031            let token = match self
5032                .hub
5033                .auth
5034                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5035                .await
5036            {
5037                Ok(token) => token,
5038                Err(e) => match dlg.token(e) {
5039                    Ok(token) => token,
5040                    Err(e) => {
5041                        dlg.finished(false);
5042                        return Err(common::Error::MissingToken(e));
5043                    }
5044                },
5045            };
5046            request_value_reader
5047                .seek(std::io::SeekFrom::Start(0))
5048                .unwrap();
5049            let mut req_result = {
5050                let client = &self.hub.client;
5051                dlg.pre_request();
5052                let mut req_builder = hyper::Request::builder()
5053                    .method(hyper::Method::PUT)
5054                    .uri(url.as_str())
5055                    .header(USER_AGENT, self.hub._user_agent.clone());
5056
5057                if let Some(token) = token.as_ref() {
5058                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5059                }
5060
5061                let request = req_builder
5062                    .header(CONTENT_TYPE, json_mime_type.to_string())
5063                    .header(CONTENT_LENGTH, request_size as u64)
5064                    .body(common::to_body(
5065                        request_value_reader.get_ref().clone().into(),
5066                    ));
5067
5068                client.request(request.unwrap()).await
5069            };
5070
5071            match req_result {
5072                Err(err) => {
5073                    if let common::Retry::After(d) = dlg.http_error(&err) {
5074                        sleep(d).await;
5075                        continue;
5076                    }
5077                    dlg.finished(false);
5078                    return Err(common::Error::HttpError(err));
5079                }
5080                Ok(res) => {
5081                    let (mut parts, body) = res.into_parts();
5082                    let mut body = common::Body::new(body);
5083                    if !parts.status.is_success() {
5084                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5085                        let error = serde_json::from_str(&common::to_string(&bytes));
5086                        let response = common::to_response(parts, bytes.into());
5087
5088                        if let common::Retry::After(d) =
5089                            dlg.http_failure(&response, error.as_ref().ok())
5090                        {
5091                            sleep(d).await;
5092                            continue;
5093                        }
5094
5095                        dlg.finished(false);
5096
5097                        return Err(match error {
5098                            Ok(value) => common::Error::BadRequest(value),
5099                            _ => common::Error::Failure(response),
5100                        });
5101                    }
5102                    let response = {
5103                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5104                        let encoded = common::to_string(&bytes);
5105                        match serde_json::from_str(&encoded) {
5106                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5107                            Err(error) => {
5108                                dlg.response_json_decode_error(&encoded, &error);
5109                                return Err(common::Error::JsonDecodeError(
5110                                    encoded.to_string(),
5111                                    error,
5112                                ));
5113                            }
5114                        }
5115                    };
5116
5117                    dlg.finished(true);
5118                    return Ok(response);
5119                }
5120            }
5121        }
5122    }
5123
5124    ///
5125    /// Sets the *request* property to the given value.
5126    ///
5127    /// Even though the property as already been set when instantiating this call,
5128    /// we provide this method for API completeness.
5129    pub fn request(mut self, new_value: ApkListing) -> EditApklistingUpdateCall<'a, C> {
5130        self._request = new_value;
5131        self
5132    }
5133    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
5134    ///
5135    /// Sets the *package name* path property to the given value.
5136    ///
5137    /// Even though the property as already been set when instantiating this call,
5138    /// we provide this method for API completeness.
5139    pub fn package_name(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, C> {
5140        self._package_name = new_value.to_string();
5141        self
5142    }
5143    /// Unique identifier for this edit.
5144    ///
5145    /// Sets the *edit id* path property to the given value.
5146    ///
5147    /// Even though the property as already been set when instantiating this call,
5148    /// we provide this method for API completeness.
5149    pub fn edit_id(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, C> {
5150        self._edit_id = new_value.to_string();
5151        self
5152    }
5153    /// The APK version code whose APK-specific listings should be read or modified.
5154    ///
5155    /// Sets the *apk version code* path property to the given value.
5156    ///
5157    /// Even though the property as already been set when instantiating this call,
5158    /// we provide this method for API completeness.
5159    pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingUpdateCall<'a, C> {
5160        self._apk_version_code = new_value;
5161        self
5162    }
5163    /// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
5164    ///
5165    /// Sets the *language* path property to the given value.
5166    ///
5167    /// Even though the property as already been set when instantiating this call,
5168    /// we provide this method for API completeness.
5169    pub fn language(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, C> {
5170        self._language = new_value.to_string();
5171        self
5172    }
5173    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5174    /// while executing the actual API request.
5175    ///
5176    /// ````text
5177    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5178    /// ````
5179    ///
5180    /// Sets the *delegate* property to the given value.
5181    pub fn delegate(
5182        mut self,
5183        new_value: &'a mut dyn common::Delegate,
5184    ) -> EditApklistingUpdateCall<'a, C> {
5185        self._delegate = Some(new_value);
5186        self
5187    }
5188
5189    /// Set any additional parameter of the query string used in the request.
5190    /// It should be used to set parameters which are not yet available through their own
5191    /// setters.
5192    ///
5193    /// Please note that this method must not be used to set any of the known parameters
5194    /// which have their own setter method. If done anyway, the request will fail.
5195    ///
5196    /// # Additional Parameters
5197    ///
5198    /// * *alt* (query-string) - Data format for the response.
5199    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5200    /// * *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.
5201    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5202    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5203    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5204    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5205    pub fn param<T>(mut self, name: T, value: T) -> EditApklistingUpdateCall<'a, C>
5206    where
5207        T: AsRef<str>,
5208    {
5209        self._additional_params
5210            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5211        self
5212    }
5213
5214    /// Identifies the authorization scope for the method you are building.
5215    ///
5216    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5217    /// [`Scope::Full`].
5218    ///
5219    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5220    /// tokens for more than one scope.
5221    ///
5222    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5223    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5224    /// sufficient, a read-write scope will do as well.
5225    pub fn add_scope<St>(mut self, scope: St) -> EditApklistingUpdateCall<'a, C>
5226    where
5227        St: AsRef<str>,
5228    {
5229        self._scopes.insert(String::from(scope.as_ref()));
5230        self
5231    }
5232    /// Identifies the authorization scope(s) for the method you are building.
5233    ///
5234    /// See [`Self::add_scope()`] for details.
5235    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApklistingUpdateCall<'a, C>
5236    where
5237        I: IntoIterator<Item = St>,
5238        St: AsRef<str>,
5239    {
5240        self._scopes
5241            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5242        self
5243    }
5244
5245    /// Removes all scopes, and no default scope will be used either.
5246    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5247    /// for details).
5248    pub fn clear_scopes(mut self) -> EditApklistingUpdateCall<'a, C> {
5249        self._scopes.clear();
5250        self
5251    }
5252}
5253
5254/// Creates a new APK without uploading the APK itself to Google Play, instead hosting the APK at a specified URL. This function is only available to enterprises using Google Play for Work whose application is configured to restrict distribution to the enterprise domain.
5255///
5256/// A builder for the *apks.addexternallyhosted* method supported by a *edit* resource.
5257/// It is not used directly, but through a [`EditMethods`] instance.
5258///
5259/// # Example
5260///
5261/// Instantiate a resource method builder
5262///
5263/// ```test_harness,no_run
5264/// # extern crate hyper;
5265/// # extern crate hyper_rustls;
5266/// # extern crate google_androidpublisher2 as androidpublisher2;
5267/// use androidpublisher2::api::ApksAddExternallyHostedRequest;
5268/// # async fn dox() {
5269/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5270///
5271/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5272/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5273/// #     .with_native_roots()
5274/// #     .unwrap()
5275/// #     .https_only()
5276/// #     .enable_http2()
5277/// #     .build();
5278///
5279/// # let executor = hyper_util::rt::TokioExecutor::new();
5280/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5281/// #     secret,
5282/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5283/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5284/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5285/// #     ),
5286/// # ).build().await.unwrap();
5287///
5288/// # let client = hyper_util::client::legacy::Client::builder(
5289/// #     hyper_util::rt::TokioExecutor::new()
5290/// # )
5291/// # .build(
5292/// #     hyper_rustls::HttpsConnectorBuilder::new()
5293/// #         .with_native_roots()
5294/// #         .unwrap()
5295/// #         .https_or_http()
5296/// #         .enable_http2()
5297/// #         .build()
5298/// # );
5299/// # let mut hub = AndroidPublisher::new(client, auth);
5300/// // As the method needs a request, you would usually fill it with the desired information
5301/// // into the respective structure. Some of the parts shown here might not be applicable !
5302/// // Values shown here are possibly random and not representative !
5303/// let mut req = ApksAddExternallyHostedRequest::default();
5304///
5305/// // You can configure optional parameters by calling the respective setters at will, and
5306/// // execute the final call using `doit()`.
5307/// // Values shown here are possibly random and not representative !
5308/// let result = hub.edits().apks_addexternallyhosted(req, "packageName", "editId")
5309///              .doit().await;
5310/// # }
5311/// ```
5312pub struct EditApkAddexternallyhostedCall<'a, C>
5313where
5314    C: 'a,
5315{
5316    hub: &'a AndroidPublisher<C>,
5317    _request: ApksAddExternallyHostedRequest,
5318    _package_name: String,
5319    _edit_id: String,
5320    _delegate: Option<&'a mut dyn common::Delegate>,
5321    _additional_params: HashMap<String, String>,
5322    _scopes: BTreeSet<String>,
5323}
5324
5325impl<'a, C> common::CallBuilder for EditApkAddexternallyhostedCall<'a, C> {}
5326
5327impl<'a, C> EditApkAddexternallyhostedCall<'a, C>
5328where
5329    C: common::Connector,
5330{
5331    /// Perform the operation you have build so far.
5332    pub async fn doit(
5333        mut self,
5334    ) -> common::Result<(common::Response, ApksAddExternallyHostedResponse)> {
5335        use std::borrow::Cow;
5336        use std::io::{Read, Seek};
5337
5338        use common::{url::Params, ToParts};
5339        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5340
5341        let mut dd = common::DefaultDelegate;
5342        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5343        dlg.begin(common::MethodInfo {
5344            id: "androidpublisher.edits.apks.addexternallyhosted",
5345            http_method: hyper::Method::POST,
5346        });
5347
5348        for &field in ["alt", "packageName", "editId"].iter() {
5349            if self._additional_params.contains_key(field) {
5350                dlg.finished(false);
5351                return Err(common::Error::FieldClash(field));
5352            }
5353        }
5354
5355        let mut params = Params::with_capacity(5 + self._additional_params.len());
5356        params.push("packageName", self._package_name);
5357        params.push("editId", self._edit_id);
5358
5359        params.extend(self._additional_params.iter());
5360
5361        params.push("alt", "json");
5362        let mut url =
5363            self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/externallyHosted";
5364        if self._scopes.is_empty() {
5365            self._scopes.insert(Scope::Full.as_ref().to_string());
5366        }
5367
5368        #[allow(clippy::single_element_loop)]
5369        for &(find_this, param_name) in
5370            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
5371        {
5372            url = params.uri_replacement(url, param_name, find_this, false);
5373        }
5374        {
5375            let to_remove = ["editId", "packageName"];
5376            params.remove_params(&to_remove);
5377        }
5378
5379        let url = params.parse_with_url(&url);
5380
5381        let mut json_mime_type = mime::APPLICATION_JSON;
5382        let mut request_value_reader = {
5383            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5384            common::remove_json_null_values(&mut value);
5385            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5386            serde_json::to_writer(&mut dst, &value).unwrap();
5387            dst
5388        };
5389        let request_size = request_value_reader
5390            .seek(std::io::SeekFrom::End(0))
5391            .unwrap();
5392        request_value_reader
5393            .seek(std::io::SeekFrom::Start(0))
5394            .unwrap();
5395
5396        loop {
5397            let token = match self
5398                .hub
5399                .auth
5400                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5401                .await
5402            {
5403                Ok(token) => token,
5404                Err(e) => match dlg.token(e) {
5405                    Ok(token) => token,
5406                    Err(e) => {
5407                        dlg.finished(false);
5408                        return Err(common::Error::MissingToken(e));
5409                    }
5410                },
5411            };
5412            request_value_reader
5413                .seek(std::io::SeekFrom::Start(0))
5414                .unwrap();
5415            let mut req_result = {
5416                let client = &self.hub.client;
5417                dlg.pre_request();
5418                let mut req_builder = hyper::Request::builder()
5419                    .method(hyper::Method::POST)
5420                    .uri(url.as_str())
5421                    .header(USER_AGENT, self.hub._user_agent.clone());
5422
5423                if let Some(token) = token.as_ref() {
5424                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5425                }
5426
5427                let request = req_builder
5428                    .header(CONTENT_TYPE, json_mime_type.to_string())
5429                    .header(CONTENT_LENGTH, request_size as u64)
5430                    .body(common::to_body(
5431                        request_value_reader.get_ref().clone().into(),
5432                    ));
5433
5434                client.request(request.unwrap()).await
5435            };
5436
5437            match req_result {
5438                Err(err) => {
5439                    if let common::Retry::After(d) = dlg.http_error(&err) {
5440                        sleep(d).await;
5441                        continue;
5442                    }
5443                    dlg.finished(false);
5444                    return Err(common::Error::HttpError(err));
5445                }
5446                Ok(res) => {
5447                    let (mut parts, body) = res.into_parts();
5448                    let mut body = common::Body::new(body);
5449                    if !parts.status.is_success() {
5450                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5451                        let error = serde_json::from_str(&common::to_string(&bytes));
5452                        let response = common::to_response(parts, bytes.into());
5453
5454                        if let common::Retry::After(d) =
5455                            dlg.http_failure(&response, error.as_ref().ok())
5456                        {
5457                            sleep(d).await;
5458                            continue;
5459                        }
5460
5461                        dlg.finished(false);
5462
5463                        return Err(match error {
5464                            Ok(value) => common::Error::BadRequest(value),
5465                            _ => common::Error::Failure(response),
5466                        });
5467                    }
5468                    let response = {
5469                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5470                        let encoded = common::to_string(&bytes);
5471                        match serde_json::from_str(&encoded) {
5472                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5473                            Err(error) => {
5474                                dlg.response_json_decode_error(&encoded, &error);
5475                                return Err(common::Error::JsonDecodeError(
5476                                    encoded.to_string(),
5477                                    error,
5478                                ));
5479                            }
5480                        }
5481                    };
5482
5483                    dlg.finished(true);
5484                    return Ok(response);
5485                }
5486            }
5487        }
5488    }
5489
5490    ///
5491    /// Sets the *request* property to the given value.
5492    ///
5493    /// Even though the property as already been set when instantiating this call,
5494    /// we provide this method for API completeness.
5495    pub fn request(
5496        mut self,
5497        new_value: ApksAddExternallyHostedRequest,
5498    ) -> EditApkAddexternallyhostedCall<'a, C> {
5499        self._request = new_value;
5500        self
5501    }
5502    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
5503    ///
5504    /// Sets the *package name* path property to the given value.
5505    ///
5506    /// Even though the property as already been set when instantiating this call,
5507    /// we provide this method for API completeness.
5508    pub fn package_name(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, C> {
5509        self._package_name = new_value.to_string();
5510        self
5511    }
5512    /// Unique identifier for this edit.
5513    ///
5514    /// Sets the *edit id* path property to the given value.
5515    ///
5516    /// Even though the property as already been set when instantiating this call,
5517    /// we provide this method for API completeness.
5518    pub fn edit_id(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, C> {
5519        self._edit_id = new_value.to_string();
5520        self
5521    }
5522    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5523    /// while executing the actual API request.
5524    ///
5525    /// ````text
5526    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5527    /// ````
5528    ///
5529    /// Sets the *delegate* property to the given value.
5530    pub fn delegate(
5531        mut self,
5532        new_value: &'a mut dyn common::Delegate,
5533    ) -> EditApkAddexternallyhostedCall<'a, C> {
5534        self._delegate = Some(new_value);
5535        self
5536    }
5537
5538    /// Set any additional parameter of the query string used in the request.
5539    /// It should be used to set parameters which are not yet available through their own
5540    /// setters.
5541    ///
5542    /// Please note that this method must not be used to set any of the known parameters
5543    /// which have their own setter method. If done anyway, the request will fail.
5544    ///
5545    /// # Additional Parameters
5546    ///
5547    /// * *alt* (query-string) - Data format for the response.
5548    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5549    /// * *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.
5550    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5551    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5552    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5553    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5554    pub fn param<T>(mut self, name: T, value: T) -> EditApkAddexternallyhostedCall<'a, C>
5555    where
5556        T: AsRef<str>,
5557    {
5558        self._additional_params
5559            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5560        self
5561    }
5562
5563    /// Identifies the authorization scope for the method you are building.
5564    ///
5565    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5566    /// [`Scope::Full`].
5567    ///
5568    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5569    /// tokens for more than one scope.
5570    ///
5571    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5572    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5573    /// sufficient, a read-write scope will do as well.
5574    pub fn add_scope<St>(mut self, scope: St) -> EditApkAddexternallyhostedCall<'a, C>
5575    where
5576        St: AsRef<str>,
5577    {
5578        self._scopes.insert(String::from(scope.as_ref()));
5579        self
5580    }
5581    /// Identifies the authorization scope(s) for the method you are building.
5582    ///
5583    /// See [`Self::add_scope()`] for details.
5584    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApkAddexternallyhostedCall<'a, C>
5585    where
5586        I: IntoIterator<Item = St>,
5587        St: AsRef<str>,
5588    {
5589        self._scopes
5590            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5591        self
5592    }
5593
5594    /// Removes all scopes, and no default scope will be used either.
5595    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5596    /// for details).
5597    pub fn clear_scopes(mut self) -> EditApkAddexternallyhostedCall<'a, C> {
5598        self._scopes.clear();
5599        self
5600    }
5601}
5602
5603/// A builder for the *apks.list* method supported by a *edit* resource.
5604/// It is not used directly, but through a [`EditMethods`] instance.
5605///
5606/// # Example
5607///
5608/// Instantiate a resource method builder
5609///
5610/// ```test_harness,no_run
5611/// # extern crate hyper;
5612/// # extern crate hyper_rustls;
5613/// # extern crate google_androidpublisher2 as androidpublisher2;
5614/// # async fn dox() {
5615/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5616///
5617/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5618/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5619/// #     .with_native_roots()
5620/// #     .unwrap()
5621/// #     .https_only()
5622/// #     .enable_http2()
5623/// #     .build();
5624///
5625/// # let executor = hyper_util::rt::TokioExecutor::new();
5626/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5627/// #     secret,
5628/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5629/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5630/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5631/// #     ),
5632/// # ).build().await.unwrap();
5633///
5634/// # let client = hyper_util::client::legacy::Client::builder(
5635/// #     hyper_util::rt::TokioExecutor::new()
5636/// # )
5637/// # .build(
5638/// #     hyper_rustls::HttpsConnectorBuilder::new()
5639/// #         .with_native_roots()
5640/// #         .unwrap()
5641/// #         .https_or_http()
5642/// #         .enable_http2()
5643/// #         .build()
5644/// # );
5645/// # let mut hub = AndroidPublisher::new(client, auth);
5646/// // You can configure optional parameters by calling the respective setters at will, and
5647/// // execute the final call using `doit()`.
5648/// // Values shown here are possibly random and not representative !
5649/// let result = hub.edits().apks_list("packageName", "editId")
5650///              .doit().await;
5651/// # }
5652/// ```
5653pub struct EditApkListCall<'a, C>
5654where
5655    C: 'a,
5656{
5657    hub: &'a AndroidPublisher<C>,
5658    _package_name: String,
5659    _edit_id: String,
5660    _delegate: Option<&'a mut dyn common::Delegate>,
5661    _additional_params: HashMap<String, String>,
5662    _scopes: BTreeSet<String>,
5663}
5664
5665impl<'a, C> common::CallBuilder for EditApkListCall<'a, C> {}
5666
5667impl<'a, C> EditApkListCall<'a, C>
5668where
5669    C: common::Connector,
5670{
5671    /// Perform the operation you have build so far.
5672    pub async fn doit(mut self) -> common::Result<(common::Response, ApksListResponse)> {
5673        use std::borrow::Cow;
5674        use std::io::{Read, Seek};
5675
5676        use common::{url::Params, ToParts};
5677        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5678
5679        let mut dd = common::DefaultDelegate;
5680        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5681        dlg.begin(common::MethodInfo {
5682            id: "androidpublisher.edits.apks.list",
5683            http_method: hyper::Method::GET,
5684        });
5685
5686        for &field in ["alt", "packageName", "editId"].iter() {
5687            if self._additional_params.contains_key(field) {
5688                dlg.finished(false);
5689                return Err(common::Error::FieldClash(field));
5690            }
5691        }
5692
5693        let mut params = Params::with_capacity(4 + self._additional_params.len());
5694        params.push("packageName", self._package_name);
5695        params.push("editId", self._edit_id);
5696
5697        params.extend(self._additional_params.iter());
5698
5699        params.push("alt", "json");
5700        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks";
5701        if self._scopes.is_empty() {
5702            self._scopes.insert(Scope::Full.as_ref().to_string());
5703        }
5704
5705        #[allow(clippy::single_element_loop)]
5706        for &(find_this, param_name) in
5707            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
5708        {
5709            url = params.uri_replacement(url, param_name, find_this, false);
5710        }
5711        {
5712            let to_remove = ["editId", "packageName"];
5713            params.remove_params(&to_remove);
5714        }
5715
5716        let url = params.parse_with_url(&url);
5717
5718        loop {
5719            let token = match self
5720                .hub
5721                .auth
5722                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5723                .await
5724            {
5725                Ok(token) => token,
5726                Err(e) => match dlg.token(e) {
5727                    Ok(token) => token,
5728                    Err(e) => {
5729                        dlg.finished(false);
5730                        return Err(common::Error::MissingToken(e));
5731                    }
5732                },
5733            };
5734            let mut req_result = {
5735                let client = &self.hub.client;
5736                dlg.pre_request();
5737                let mut req_builder = hyper::Request::builder()
5738                    .method(hyper::Method::GET)
5739                    .uri(url.as_str())
5740                    .header(USER_AGENT, self.hub._user_agent.clone());
5741
5742                if let Some(token) = token.as_ref() {
5743                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5744                }
5745
5746                let request = req_builder
5747                    .header(CONTENT_LENGTH, 0_u64)
5748                    .body(common::to_body::<String>(None));
5749
5750                client.request(request.unwrap()).await
5751            };
5752
5753            match req_result {
5754                Err(err) => {
5755                    if let common::Retry::After(d) = dlg.http_error(&err) {
5756                        sleep(d).await;
5757                        continue;
5758                    }
5759                    dlg.finished(false);
5760                    return Err(common::Error::HttpError(err));
5761                }
5762                Ok(res) => {
5763                    let (mut parts, body) = res.into_parts();
5764                    let mut body = common::Body::new(body);
5765                    if !parts.status.is_success() {
5766                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5767                        let error = serde_json::from_str(&common::to_string(&bytes));
5768                        let response = common::to_response(parts, bytes.into());
5769
5770                        if let common::Retry::After(d) =
5771                            dlg.http_failure(&response, error.as_ref().ok())
5772                        {
5773                            sleep(d).await;
5774                            continue;
5775                        }
5776
5777                        dlg.finished(false);
5778
5779                        return Err(match error {
5780                            Ok(value) => common::Error::BadRequest(value),
5781                            _ => common::Error::Failure(response),
5782                        });
5783                    }
5784                    let response = {
5785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5786                        let encoded = common::to_string(&bytes);
5787                        match serde_json::from_str(&encoded) {
5788                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5789                            Err(error) => {
5790                                dlg.response_json_decode_error(&encoded, &error);
5791                                return Err(common::Error::JsonDecodeError(
5792                                    encoded.to_string(),
5793                                    error,
5794                                ));
5795                            }
5796                        }
5797                    };
5798
5799                    dlg.finished(true);
5800                    return Ok(response);
5801                }
5802            }
5803        }
5804    }
5805
5806    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
5807    ///
5808    /// Sets the *package name* path property to the given value.
5809    ///
5810    /// Even though the property as already been set when instantiating this call,
5811    /// we provide this method for API completeness.
5812    pub fn package_name(mut self, new_value: &str) -> EditApkListCall<'a, C> {
5813        self._package_name = new_value.to_string();
5814        self
5815    }
5816    /// Unique identifier for this edit.
5817    ///
5818    /// Sets the *edit id* path property to the given value.
5819    ///
5820    /// Even though the property as already been set when instantiating this call,
5821    /// we provide this method for API completeness.
5822    pub fn edit_id(mut self, new_value: &str) -> EditApkListCall<'a, C> {
5823        self._edit_id = new_value.to_string();
5824        self
5825    }
5826    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5827    /// while executing the actual API request.
5828    ///
5829    /// ````text
5830    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5831    /// ````
5832    ///
5833    /// Sets the *delegate* property to the given value.
5834    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditApkListCall<'a, C> {
5835        self._delegate = Some(new_value);
5836        self
5837    }
5838
5839    /// Set any additional parameter of the query string used in the request.
5840    /// It should be used to set parameters which are not yet available through their own
5841    /// setters.
5842    ///
5843    /// Please note that this method must not be used to set any of the known parameters
5844    /// which have their own setter method. If done anyway, the request will fail.
5845    ///
5846    /// # Additional Parameters
5847    ///
5848    /// * *alt* (query-string) - Data format for the response.
5849    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5850    /// * *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.
5851    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5852    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5853    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5854    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5855    pub fn param<T>(mut self, name: T, value: T) -> EditApkListCall<'a, C>
5856    where
5857        T: AsRef<str>,
5858    {
5859        self._additional_params
5860            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5861        self
5862    }
5863
5864    /// Identifies the authorization scope for the method you are building.
5865    ///
5866    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5867    /// [`Scope::Full`].
5868    ///
5869    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5870    /// tokens for more than one scope.
5871    ///
5872    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5873    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5874    /// sufficient, a read-write scope will do as well.
5875    pub fn add_scope<St>(mut self, scope: St) -> EditApkListCall<'a, C>
5876    where
5877        St: AsRef<str>,
5878    {
5879        self._scopes.insert(String::from(scope.as_ref()));
5880        self
5881    }
5882    /// Identifies the authorization scope(s) for the method you are building.
5883    ///
5884    /// See [`Self::add_scope()`] for details.
5885    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApkListCall<'a, C>
5886    where
5887        I: IntoIterator<Item = St>,
5888        St: AsRef<str>,
5889    {
5890        self._scopes
5891            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5892        self
5893    }
5894
5895    /// Removes all scopes, and no default scope will be used either.
5896    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5897    /// for details).
5898    pub fn clear_scopes(mut self) -> EditApkListCall<'a, C> {
5899        self._scopes.clear();
5900        self
5901    }
5902}
5903
5904/// A builder for the *apks.upload* method supported by a *edit* resource.
5905/// It is not used directly, but through a [`EditMethods`] instance.
5906///
5907/// # Example
5908///
5909/// Instantiate a resource method builder
5910///
5911/// ```test_harness,no_run
5912/// # extern crate hyper;
5913/// # extern crate hyper_rustls;
5914/// # extern crate google_androidpublisher2 as androidpublisher2;
5915/// use std::fs;
5916/// # async fn dox() {
5917/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5918///
5919/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5920/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5921/// #     .with_native_roots()
5922/// #     .unwrap()
5923/// #     .https_only()
5924/// #     .enable_http2()
5925/// #     .build();
5926///
5927/// # let executor = hyper_util::rt::TokioExecutor::new();
5928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5929/// #     secret,
5930/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5931/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5932/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5933/// #     ),
5934/// # ).build().await.unwrap();
5935///
5936/// # let client = hyper_util::client::legacy::Client::builder(
5937/// #     hyper_util::rt::TokioExecutor::new()
5938/// # )
5939/// # .build(
5940/// #     hyper_rustls::HttpsConnectorBuilder::new()
5941/// #         .with_native_roots()
5942/// #         .unwrap()
5943/// #         .https_or_http()
5944/// #         .enable_http2()
5945/// #         .build()
5946/// # );
5947/// # let mut hub = AndroidPublisher::new(client, auth);
5948/// // You can configure optional parameters by calling the respective setters at will, and
5949/// // execute the final call using `upload(...)`.
5950/// // Values shown here are possibly random and not representative !
5951/// let result = hub.edits().apks_upload("packageName", "editId")
5952///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
5953/// # }
5954/// ```
5955pub struct EditApkUploadCall<'a, C>
5956where
5957    C: 'a,
5958{
5959    hub: &'a AndroidPublisher<C>,
5960    _package_name: String,
5961    _edit_id: String,
5962    _delegate: Option<&'a mut dyn common::Delegate>,
5963    _additional_params: HashMap<String, String>,
5964    _scopes: BTreeSet<String>,
5965}
5966
5967impl<'a, C> common::CallBuilder for EditApkUploadCall<'a, C> {}
5968
5969impl<'a, C> EditApkUploadCall<'a, C>
5970where
5971    C: common::Connector,
5972{
5973    /// Perform the operation you have build so far.
5974    async fn doit<RS>(
5975        mut self,
5976        mut reader: RS,
5977        reader_mime_type: mime::Mime,
5978        protocol: common::UploadProtocol,
5979    ) -> common::Result<(common::Response, Apk)>
5980    where
5981        RS: common::ReadSeek,
5982    {
5983        use std::borrow::Cow;
5984        use std::io::{Read, Seek};
5985
5986        use common::{url::Params, ToParts};
5987        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5988
5989        let mut dd = common::DefaultDelegate;
5990        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5991        dlg.begin(common::MethodInfo {
5992            id: "androidpublisher.edits.apks.upload",
5993            http_method: hyper::Method::POST,
5994        });
5995
5996        for &field in ["alt", "packageName", "editId"].iter() {
5997            if self._additional_params.contains_key(field) {
5998                dlg.finished(false);
5999                return Err(common::Error::FieldClash(field));
6000            }
6001        }
6002
6003        let mut params = Params::with_capacity(4 + self._additional_params.len());
6004        params.push("packageName", self._package_name);
6005        params.push("editId", self._edit_id);
6006
6007        params.extend(self._additional_params.iter());
6008
6009        params.push("alt", "json");
6010        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
6011            (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks", "resumable")
6012        } else if protocol == common::UploadProtocol::Simple {
6013            (
6014                self.hub._root_url.clone()
6015                    + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks",
6016                "multipart",
6017            )
6018        } else {
6019            unreachable!()
6020        };
6021        params.push("uploadType", upload_type);
6022        if self._scopes.is_empty() {
6023            self._scopes.insert(Scope::Full.as_ref().to_string());
6024        }
6025
6026        #[allow(clippy::single_element_loop)]
6027        for &(find_this, param_name) in
6028            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
6029        {
6030            url = params.uri_replacement(url, param_name, find_this, false);
6031        }
6032        {
6033            let to_remove = ["editId", "packageName"];
6034            params.remove_params(&to_remove);
6035        }
6036
6037        let url = params.parse_with_url(&url);
6038
6039        let mut upload_url_from_server;
6040
6041        loop {
6042            let token = match self
6043                .hub
6044                .auth
6045                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6046                .await
6047            {
6048                Ok(token) => token,
6049                Err(e) => match dlg.token(e) {
6050                    Ok(token) => token,
6051                    Err(e) => {
6052                        dlg.finished(false);
6053                        return Err(common::Error::MissingToken(e));
6054                    }
6055                },
6056            };
6057            let mut req_result = {
6058                let client = &self.hub.client;
6059                dlg.pre_request();
6060                let mut req_builder = hyper::Request::builder()
6061                    .method(hyper::Method::POST)
6062                    .uri(url.as_str())
6063                    .header(USER_AGENT, self.hub._user_agent.clone());
6064
6065                if let Some(token) = token.as_ref() {
6066                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6067                }
6068
6069                upload_url_from_server = true;
6070                if protocol == common::UploadProtocol::Resumable {
6071                    req_builder = req_builder
6072                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
6073                }
6074
6075                let request = if protocol == common::UploadProtocol::Simple {
6076                    let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
6077                    reader.seek(std::io::SeekFrom::Start(0)).unwrap();
6078                    if size > 1073741824 {
6079                        return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
6080                    }
6081                    let mut bytes = Vec::with_capacity(size as usize);
6082                    reader.read_to_end(&mut bytes)?;
6083                    req_builder
6084                        .header(CONTENT_TYPE, reader_mime_type.to_string())
6085                        .header(CONTENT_LENGTH, size)
6086                        .body(common::to_body(bytes.into()))
6087                } else {
6088                    req_builder.body(common::to_body::<String>(None))
6089                };
6090
6091                client.request(request.unwrap()).await
6092            };
6093
6094            match req_result {
6095                Err(err) => {
6096                    if let common::Retry::After(d) = dlg.http_error(&err) {
6097                        sleep(d).await;
6098                        continue;
6099                    }
6100                    dlg.finished(false);
6101                    return Err(common::Error::HttpError(err));
6102                }
6103                Ok(res) => {
6104                    let (mut parts, body) = res.into_parts();
6105                    let mut body = common::Body::new(body);
6106                    if !parts.status.is_success() {
6107                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6108                        let error = serde_json::from_str(&common::to_string(&bytes));
6109                        let response = common::to_response(parts, bytes.into());
6110
6111                        if let common::Retry::After(d) =
6112                            dlg.http_failure(&response, error.as_ref().ok())
6113                        {
6114                            sleep(d).await;
6115                            continue;
6116                        }
6117
6118                        dlg.finished(false);
6119
6120                        return Err(match error {
6121                            Ok(value) => common::Error::BadRequest(value),
6122                            _ => common::Error::Failure(response),
6123                        });
6124                    }
6125                    if protocol == common::UploadProtocol::Resumable {
6126                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
6127                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
6128                        if size > 1073741824 {
6129                            return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
6130                        }
6131                        let upload_result = {
6132                            let url_str = &parts
6133                                .headers
6134                                .get("Location")
6135                                .expect("LOCATION header is part of protocol")
6136                                .to_str()
6137                                .unwrap();
6138                            if upload_url_from_server {
6139                                dlg.store_upload_url(Some(url_str));
6140                            }
6141
6142                            common::ResumableUploadHelper {
6143                                client: &self.hub.client,
6144                                delegate: dlg,
6145                                start_at: if upload_url_from_server {
6146                                    Some(0)
6147                                } else {
6148                                    None
6149                                },
6150                                auth: &self.hub.auth,
6151                                user_agent: &self.hub._user_agent,
6152                                // TODO: Check this assumption
6153                                auth_header: format!(
6154                                    "Bearer {}",
6155                                    token
6156                                        .ok_or_else(|| common::Error::MissingToken(
6157                                            "resumable upload requires token".into()
6158                                        ))?
6159                                        .as_str()
6160                                ),
6161                                url: url_str,
6162                                reader: &mut reader,
6163                                media_type: reader_mime_type.clone(),
6164                                content_length: size,
6165                            }
6166                            .upload()
6167                            .await
6168                        };
6169                        match upload_result {
6170                            None => {
6171                                dlg.finished(false);
6172                                return Err(common::Error::Cancelled);
6173                            }
6174                            Some(Err(err)) => {
6175                                dlg.finished(false);
6176                                return Err(common::Error::HttpError(err));
6177                            }
6178                            Some(Ok(response)) => {
6179                                (parts, body) = response.into_parts();
6180                                if !parts.status.is_success() {
6181                                    dlg.store_upload_url(None);
6182                                    dlg.finished(false);
6183                                    return Err(common::Error::Failure(
6184                                        common::Response::from_parts(parts, body),
6185                                    ));
6186                                }
6187                            }
6188                        }
6189                    }
6190                    let response = {
6191                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6192                        let encoded = common::to_string(&bytes);
6193                        match serde_json::from_str(&encoded) {
6194                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6195                            Err(error) => {
6196                                dlg.response_json_decode_error(&encoded, &error);
6197                                return Err(common::Error::JsonDecodeError(
6198                                    encoded.to_string(),
6199                                    error,
6200                                ));
6201                            }
6202                        }
6203                    };
6204
6205                    dlg.finished(true);
6206                    return Ok(response);
6207                }
6208            }
6209        }
6210    }
6211
6212    /// Upload media in a resumable fashion.
6213    /// Even if the upload fails or is interrupted, it can be resumed for a
6214    /// certain amount of time as the server maintains state temporarily.
6215    ///
6216    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
6217    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
6218    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
6219    /// `cancel_chunk_upload(...)`.
6220    ///
6221    /// * *multipart*: yes
6222    /// * *max size*: 1GB
6223    /// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
6224    pub async fn upload_resumable<RS>(
6225        self,
6226        resumeable_stream: RS,
6227        mime_type: mime::Mime,
6228    ) -> common::Result<(common::Response, Apk)>
6229    where
6230        RS: common::ReadSeek,
6231    {
6232        self.doit(
6233            resumeable_stream,
6234            mime_type,
6235            common::UploadProtocol::Resumable,
6236        )
6237        .await
6238    }
6239    /// Upload media all at once.
6240    /// If the upload fails for whichever reason, all progress is lost.
6241    ///
6242    /// * *multipart*: yes
6243    /// * *max size*: 1GB
6244    /// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
6245    pub async fn upload<RS>(
6246        self,
6247        stream: RS,
6248        mime_type: mime::Mime,
6249    ) -> common::Result<(common::Response, Apk)>
6250    where
6251        RS: common::ReadSeek,
6252    {
6253        self.doit(stream, mime_type, common::UploadProtocol::Simple)
6254            .await
6255    }
6256
6257    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
6258    ///
6259    /// Sets the *package name* path property to the given value.
6260    ///
6261    /// Even though the property as already been set when instantiating this call,
6262    /// we provide this method for API completeness.
6263    pub fn package_name(mut self, new_value: &str) -> EditApkUploadCall<'a, C> {
6264        self._package_name = new_value.to_string();
6265        self
6266    }
6267    /// Unique identifier for this edit.
6268    ///
6269    /// Sets the *edit id* path property to the given value.
6270    ///
6271    /// Even though the property as already been set when instantiating this call,
6272    /// we provide this method for API completeness.
6273    pub fn edit_id(mut self, new_value: &str) -> EditApkUploadCall<'a, C> {
6274        self._edit_id = new_value.to_string();
6275        self
6276    }
6277    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6278    /// while executing the actual API request.
6279    ///
6280    /// ````text
6281    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6282    /// ````
6283    ///
6284    /// Sets the *delegate* property to the given value.
6285    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditApkUploadCall<'a, C> {
6286        self._delegate = Some(new_value);
6287        self
6288    }
6289
6290    /// Set any additional parameter of the query string used in the request.
6291    /// It should be used to set parameters which are not yet available through their own
6292    /// setters.
6293    ///
6294    /// Please note that this method must not be used to set any of the known parameters
6295    /// which have their own setter method. If done anyway, the request will fail.
6296    ///
6297    /// # Additional Parameters
6298    ///
6299    /// * *alt* (query-string) - Data format for the response.
6300    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6301    /// * *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.
6302    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6303    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6304    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6305    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6306    pub fn param<T>(mut self, name: T, value: T) -> EditApkUploadCall<'a, C>
6307    where
6308        T: AsRef<str>,
6309    {
6310        self._additional_params
6311            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6312        self
6313    }
6314
6315    /// Identifies the authorization scope for the method you are building.
6316    ///
6317    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6318    /// [`Scope::Full`].
6319    ///
6320    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6321    /// tokens for more than one scope.
6322    ///
6323    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6324    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6325    /// sufficient, a read-write scope will do as well.
6326    pub fn add_scope<St>(mut self, scope: St) -> EditApkUploadCall<'a, C>
6327    where
6328        St: AsRef<str>,
6329    {
6330        self._scopes.insert(String::from(scope.as_ref()));
6331        self
6332    }
6333    /// Identifies the authorization scope(s) for the method you are building.
6334    ///
6335    /// See [`Self::add_scope()`] for details.
6336    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApkUploadCall<'a, C>
6337    where
6338        I: IntoIterator<Item = St>,
6339        St: AsRef<str>,
6340    {
6341        self._scopes
6342            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6343        self
6344    }
6345
6346    /// Removes all scopes, and no default scope will be used either.
6347    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6348    /// for details).
6349    pub fn clear_scopes(mut self) -> EditApkUploadCall<'a, C> {
6350        self._scopes.clear();
6351        self
6352    }
6353}
6354
6355/// A builder for the *bundles.list* method supported by a *edit* resource.
6356/// It is not used directly, but through a [`EditMethods`] instance.
6357///
6358/// # Example
6359///
6360/// Instantiate a resource method builder
6361///
6362/// ```test_harness,no_run
6363/// # extern crate hyper;
6364/// # extern crate hyper_rustls;
6365/// # extern crate google_androidpublisher2 as androidpublisher2;
6366/// # async fn dox() {
6367/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6368///
6369/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6370/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6371/// #     .with_native_roots()
6372/// #     .unwrap()
6373/// #     .https_only()
6374/// #     .enable_http2()
6375/// #     .build();
6376///
6377/// # let executor = hyper_util::rt::TokioExecutor::new();
6378/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6379/// #     secret,
6380/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6381/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6382/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6383/// #     ),
6384/// # ).build().await.unwrap();
6385///
6386/// # let client = hyper_util::client::legacy::Client::builder(
6387/// #     hyper_util::rt::TokioExecutor::new()
6388/// # )
6389/// # .build(
6390/// #     hyper_rustls::HttpsConnectorBuilder::new()
6391/// #         .with_native_roots()
6392/// #         .unwrap()
6393/// #         .https_or_http()
6394/// #         .enable_http2()
6395/// #         .build()
6396/// # );
6397/// # let mut hub = AndroidPublisher::new(client, auth);
6398/// // You can configure optional parameters by calling the respective setters at will, and
6399/// // execute the final call using `doit()`.
6400/// // Values shown here are possibly random and not representative !
6401/// let result = hub.edits().bundles_list("packageName", "editId")
6402///              .doit().await;
6403/// # }
6404/// ```
6405pub struct EditBundleListCall<'a, C>
6406where
6407    C: 'a,
6408{
6409    hub: &'a AndroidPublisher<C>,
6410    _package_name: String,
6411    _edit_id: String,
6412    _delegate: Option<&'a mut dyn common::Delegate>,
6413    _additional_params: HashMap<String, String>,
6414    _scopes: BTreeSet<String>,
6415}
6416
6417impl<'a, C> common::CallBuilder for EditBundleListCall<'a, C> {}
6418
6419impl<'a, C> EditBundleListCall<'a, C>
6420where
6421    C: common::Connector,
6422{
6423    /// Perform the operation you have build so far.
6424    pub async fn doit(mut self) -> common::Result<(common::Response, BundlesListResponse)> {
6425        use std::borrow::Cow;
6426        use std::io::{Read, Seek};
6427
6428        use common::{url::Params, ToParts};
6429        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6430
6431        let mut dd = common::DefaultDelegate;
6432        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6433        dlg.begin(common::MethodInfo {
6434            id: "androidpublisher.edits.bundles.list",
6435            http_method: hyper::Method::GET,
6436        });
6437
6438        for &field in ["alt", "packageName", "editId"].iter() {
6439            if self._additional_params.contains_key(field) {
6440                dlg.finished(false);
6441                return Err(common::Error::FieldClash(field));
6442            }
6443        }
6444
6445        let mut params = Params::with_capacity(4 + self._additional_params.len());
6446        params.push("packageName", self._package_name);
6447        params.push("editId", self._edit_id);
6448
6449        params.extend(self._additional_params.iter());
6450
6451        params.push("alt", "json");
6452        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/bundles";
6453        if self._scopes.is_empty() {
6454            self._scopes.insert(Scope::Full.as_ref().to_string());
6455        }
6456
6457        #[allow(clippy::single_element_loop)]
6458        for &(find_this, param_name) in
6459            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
6460        {
6461            url = params.uri_replacement(url, param_name, find_this, false);
6462        }
6463        {
6464            let to_remove = ["editId", "packageName"];
6465            params.remove_params(&to_remove);
6466        }
6467
6468        let url = params.parse_with_url(&url);
6469
6470        loop {
6471            let token = match self
6472                .hub
6473                .auth
6474                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6475                .await
6476            {
6477                Ok(token) => token,
6478                Err(e) => match dlg.token(e) {
6479                    Ok(token) => token,
6480                    Err(e) => {
6481                        dlg.finished(false);
6482                        return Err(common::Error::MissingToken(e));
6483                    }
6484                },
6485            };
6486            let mut req_result = {
6487                let client = &self.hub.client;
6488                dlg.pre_request();
6489                let mut req_builder = hyper::Request::builder()
6490                    .method(hyper::Method::GET)
6491                    .uri(url.as_str())
6492                    .header(USER_AGENT, self.hub._user_agent.clone());
6493
6494                if let Some(token) = token.as_ref() {
6495                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6496                }
6497
6498                let request = req_builder
6499                    .header(CONTENT_LENGTH, 0_u64)
6500                    .body(common::to_body::<String>(None));
6501
6502                client.request(request.unwrap()).await
6503            };
6504
6505            match req_result {
6506                Err(err) => {
6507                    if let common::Retry::After(d) = dlg.http_error(&err) {
6508                        sleep(d).await;
6509                        continue;
6510                    }
6511                    dlg.finished(false);
6512                    return Err(common::Error::HttpError(err));
6513                }
6514                Ok(res) => {
6515                    let (mut parts, body) = res.into_parts();
6516                    let mut body = common::Body::new(body);
6517                    if !parts.status.is_success() {
6518                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6519                        let error = serde_json::from_str(&common::to_string(&bytes));
6520                        let response = common::to_response(parts, bytes.into());
6521
6522                        if let common::Retry::After(d) =
6523                            dlg.http_failure(&response, error.as_ref().ok())
6524                        {
6525                            sleep(d).await;
6526                            continue;
6527                        }
6528
6529                        dlg.finished(false);
6530
6531                        return Err(match error {
6532                            Ok(value) => common::Error::BadRequest(value),
6533                            _ => common::Error::Failure(response),
6534                        });
6535                    }
6536                    let response = {
6537                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6538                        let encoded = common::to_string(&bytes);
6539                        match serde_json::from_str(&encoded) {
6540                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6541                            Err(error) => {
6542                                dlg.response_json_decode_error(&encoded, &error);
6543                                return Err(common::Error::JsonDecodeError(
6544                                    encoded.to_string(),
6545                                    error,
6546                                ));
6547                            }
6548                        }
6549                    };
6550
6551                    dlg.finished(true);
6552                    return Ok(response);
6553                }
6554            }
6555        }
6556    }
6557
6558    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
6559    ///
6560    /// Sets the *package name* path property to the given value.
6561    ///
6562    /// Even though the property as already been set when instantiating this call,
6563    /// we provide this method for API completeness.
6564    pub fn package_name(mut self, new_value: &str) -> EditBundleListCall<'a, C> {
6565        self._package_name = new_value.to_string();
6566        self
6567    }
6568    /// Unique identifier for this edit.
6569    ///
6570    /// Sets the *edit id* path property to the given value.
6571    ///
6572    /// Even though the property as already been set when instantiating this call,
6573    /// we provide this method for API completeness.
6574    pub fn edit_id(mut self, new_value: &str) -> EditBundleListCall<'a, C> {
6575        self._edit_id = new_value.to_string();
6576        self
6577    }
6578    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6579    /// while executing the actual API request.
6580    ///
6581    /// ````text
6582    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6583    /// ````
6584    ///
6585    /// Sets the *delegate* property to the given value.
6586    pub fn delegate(
6587        mut self,
6588        new_value: &'a mut dyn common::Delegate,
6589    ) -> EditBundleListCall<'a, C> {
6590        self._delegate = Some(new_value);
6591        self
6592    }
6593
6594    /// Set any additional parameter of the query string used in the request.
6595    /// It should be used to set parameters which are not yet available through their own
6596    /// setters.
6597    ///
6598    /// Please note that this method must not be used to set any of the known parameters
6599    /// which have their own setter method. If done anyway, the request will fail.
6600    ///
6601    /// # Additional Parameters
6602    ///
6603    /// * *alt* (query-string) - Data format for the response.
6604    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6605    /// * *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.
6606    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6607    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6608    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6609    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6610    pub fn param<T>(mut self, name: T, value: T) -> EditBundleListCall<'a, C>
6611    where
6612        T: AsRef<str>,
6613    {
6614        self._additional_params
6615            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6616        self
6617    }
6618
6619    /// Identifies the authorization scope for the method you are building.
6620    ///
6621    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6622    /// [`Scope::Full`].
6623    ///
6624    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6625    /// tokens for more than one scope.
6626    ///
6627    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6628    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6629    /// sufficient, a read-write scope will do as well.
6630    pub fn add_scope<St>(mut self, scope: St) -> EditBundleListCall<'a, C>
6631    where
6632        St: AsRef<str>,
6633    {
6634        self._scopes.insert(String::from(scope.as_ref()));
6635        self
6636    }
6637    /// Identifies the authorization scope(s) for the method you are building.
6638    ///
6639    /// See [`Self::add_scope()`] for details.
6640    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditBundleListCall<'a, C>
6641    where
6642        I: IntoIterator<Item = St>,
6643        St: AsRef<str>,
6644    {
6645        self._scopes
6646            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6647        self
6648    }
6649
6650    /// Removes all scopes, and no default scope will be used either.
6651    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6652    /// for details).
6653    pub fn clear_scopes(mut self) -> EditBundleListCall<'a, C> {
6654        self._scopes.clear();
6655        self
6656    }
6657}
6658
6659/// Uploads a new Android App Bundle to this edit. If you are using the Google API client libraries, please increase the timeout of the http request before calling this endpoint (a timeout of 2 minutes is recommended). See: https://developers.google.com/api-client-library/java/google-api-java-client/errors for an example in java.
6660///
6661/// A builder for the *bundles.upload* method supported by a *edit* resource.
6662/// It is not used directly, but through a [`EditMethods`] instance.
6663///
6664/// # Example
6665///
6666/// Instantiate a resource method builder
6667///
6668/// ```test_harness,no_run
6669/// # extern crate hyper;
6670/// # extern crate hyper_rustls;
6671/// # extern crate google_androidpublisher2 as androidpublisher2;
6672/// use std::fs;
6673/// # async fn dox() {
6674/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6675///
6676/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6677/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6678/// #     .with_native_roots()
6679/// #     .unwrap()
6680/// #     .https_only()
6681/// #     .enable_http2()
6682/// #     .build();
6683///
6684/// # let executor = hyper_util::rt::TokioExecutor::new();
6685/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6686/// #     secret,
6687/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6688/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6689/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6690/// #     ),
6691/// # ).build().await.unwrap();
6692///
6693/// # let client = hyper_util::client::legacy::Client::builder(
6694/// #     hyper_util::rt::TokioExecutor::new()
6695/// # )
6696/// # .build(
6697/// #     hyper_rustls::HttpsConnectorBuilder::new()
6698/// #         .with_native_roots()
6699/// #         .unwrap()
6700/// #         .https_or_http()
6701/// #         .enable_http2()
6702/// #         .build()
6703/// # );
6704/// # let mut hub = AndroidPublisher::new(client, auth);
6705/// // You can configure optional parameters by calling the respective setters at will, and
6706/// // execute the final call using `upload(...)`.
6707/// // Values shown here are possibly random and not representative !
6708/// let result = hub.edits().bundles_upload("packageName", "editId")
6709///              .ack_bundle_installation_warning(true)
6710///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
6711/// # }
6712/// ```
6713pub struct EditBundleUploadCall<'a, C>
6714where
6715    C: 'a,
6716{
6717    hub: &'a AndroidPublisher<C>,
6718    _package_name: String,
6719    _edit_id: String,
6720    _ack_bundle_installation_warning: Option<bool>,
6721    _delegate: Option<&'a mut dyn common::Delegate>,
6722    _additional_params: HashMap<String, String>,
6723    _scopes: BTreeSet<String>,
6724}
6725
6726impl<'a, C> common::CallBuilder for EditBundleUploadCall<'a, C> {}
6727
6728impl<'a, C> EditBundleUploadCall<'a, C>
6729where
6730    C: common::Connector,
6731{
6732    /// Perform the operation you have build so far.
6733    async fn doit<RS>(
6734        mut self,
6735        mut reader: RS,
6736        reader_mime_type: mime::Mime,
6737        protocol: common::UploadProtocol,
6738    ) -> common::Result<(common::Response, Bundle)>
6739    where
6740        RS: common::ReadSeek,
6741    {
6742        use std::borrow::Cow;
6743        use std::io::{Read, Seek};
6744
6745        use common::{url::Params, ToParts};
6746        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6747
6748        let mut dd = common::DefaultDelegate;
6749        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6750        dlg.begin(common::MethodInfo {
6751            id: "androidpublisher.edits.bundles.upload",
6752            http_method: hyper::Method::POST,
6753        });
6754
6755        for &field in [
6756            "alt",
6757            "packageName",
6758            "editId",
6759            "ackBundleInstallationWarning",
6760        ]
6761        .iter()
6762        {
6763            if self._additional_params.contains_key(field) {
6764                dlg.finished(false);
6765                return Err(common::Error::FieldClash(field));
6766            }
6767        }
6768
6769        let mut params = Params::with_capacity(5 + self._additional_params.len());
6770        params.push("packageName", self._package_name);
6771        params.push("editId", self._edit_id);
6772        if let Some(value) = self._ack_bundle_installation_warning.as_ref() {
6773            params.push("ackBundleInstallationWarning", value.to_string());
6774        }
6775
6776        params.extend(self._additional_params.iter());
6777
6778        params.push("alt", "json");
6779        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
6780            (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/bundles", "resumable")
6781        } else if protocol == common::UploadProtocol::Simple {
6782            (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/bundles", "multipart")
6783        } else {
6784            unreachable!()
6785        };
6786        params.push("uploadType", upload_type);
6787        if self._scopes.is_empty() {
6788            self._scopes.insert(Scope::Full.as_ref().to_string());
6789        }
6790
6791        #[allow(clippy::single_element_loop)]
6792        for &(find_this, param_name) in
6793            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
6794        {
6795            url = params.uri_replacement(url, param_name, find_this, false);
6796        }
6797        {
6798            let to_remove = ["editId", "packageName"];
6799            params.remove_params(&to_remove);
6800        }
6801
6802        let url = params.parse_with_url(&url);
6803
6804        let mut upload_url_from_server;
6805
6806        loop {
6807            let token = match self
6808                .hub
6809                .auth
6810                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6811                .await
6812            {
6813                Ok(token) => token,
6814                Err(e) => match dlg.token(e) {
6815                    Ok(token) => token,
6816                    Err(e) => {
6817                        dlg.finished(false);
6818                        return Err(common::Error::MissingToken(e));
6819                    }
6820                },
6821            };
6822            let mut req_result = {
6823                let client = &self.hub.client;
6824                dlg.pre_request();
6825                let mut req_builder = hyper::Request::builder()
6826                    .method(hyper::Method::POST)
6827                    .uri(url.as_str())
6828                    .header(USER_AGENT, self.hub._user_agent.clone());
6829
6830                if let Some(token) = token.as_ref() {
6831                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6832                }
6833
6834                upload_url_from_server = true;
6835                if protocol == common::UploadProtocol::Resumable {
6836                    req_builder = req_builder
6837                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
6838                }
6839
6840                let request = if protocol == common::UploadProtocol::Simple {
6841                    let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
6842                    reader.seek(std::io::SeekFrom::Start(0)).unwrap();
6843                    if size > 2147483648 {
6844                        return Err(common::Error::UploadSizeLimitExceeded(size, 2147483648));
6845                    }
6846                    let mut bytes = Vec::with_capacity(size as usize);
6847                    reader.read_to_end(&mut bytes)?;
6848                    req_builder
6849                        .header(CONTENT_TYPE, reader_mime_type.to_string())
6850                        .header(CONTENT_LENGTH, size)
6851                        .body(common::to_body(bytes.into()))
6852                } else {
6853                    req_builder.body(common::to_body::<String>(None))
6854                };
6855
6856                client.request(request.unwrap()).await
6857            };
6858
6859            match req_result {
6860                Err(err) => {
6861                    if let common::Retry::After(d) = dlg.http_error(&err) {
6862                        sleep(d).await;
6863                        continue;
6864                    }
6865                    dlg.finished(false);
6866                    return Err(common::Error::HttpError(err));
6867                }
6868                Ok(res) => {
6869                    let (mut parts, body) = res.into_parts();
6870                    let mut body = common::Body::new(body);
6871                    if !parts.status.is_success() {
6872                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6873                        let error = serde_json::from_str(&common::to_string(&bytes));
6874                        let response = common::to_response(parts, bytes.into());
6875
6876                        if let common::Retry::After(d) =
6877                            dlg.http_failure(&response, error.as_ref().ok())
6878                        {
6879                            sleep(d).await;
6880                            continue;
6881                        }
6882
6883                        dlg.finished(false);
6884
6885                        return Err(match error {
6886                            Ok(value) => common::Error::BadRequest(value),
6887                            _ => common::Error::Failure(response),
6888                        });
6889                    }
6890                    if protocol == common::UploadProtocol::Resumable {
6891                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
6892                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
6893                        if size > 2147483648 {
6894                            return Err(common::Error::UploadSizeLimitExceeded(size, 2147483648));
6895                        }
6896                        let upload_result = {
6897                            let url_str = &parts
6898                                .headers
6899                                .get("Location")
6900                                .expect("LOCATION header is part of protocol")
6901                                .to_str()
6902                                .unwrap();
6903                            if upload_url_from_server {
6904                                dlg.store_upload_url(Some(url_str));
6905                            }
6906
6907                            common::ResumableUploadHelper {
6908                                client: &self.hub.client,
6909                                delegate: dlg,
6910                                start_at: if upload_url_from_server {
6911                                    Some(0)
6912                                } else {
6913                                    None
6914                                },
6915                                auth: &self.hub.auth,
6916                                user_agent: &self.hub._user_agent,
6917                                // TODO: Check this assumption
6918                                auth_header: format!(
6919                                    "Bearer {}",
6920                                    token
6921                                        .ok_or_else(|| common::Error::MissingToken(
6922                                            "resumable upload requires token".into()
6923                                        ))?
6924                                        .as_str()
6925                                ),
6926                                url: url_str,
6927                                reader: &mut reader,
6928                                media_type: reader_mime_type.clone(),
6929                                content_length: size,
6930                            }
6931                            .upload()
6932                            .await
6933                        };
6934                        match upload_result {
6935                            None => {
6936                                dlg.finished(false);
6937                                return Err(common::Error::Cancelled);
6938                            }
6939                            Some(Err(err)) => {
6940                                dlg.finished(false);
6941                                return Err(common::Error::HttpError(err));
6942                            }
6943                            Some(Ok(response)) => {
6944                                (parts, body) = response.into_parts();
6945                                if !parts.status.is_success() {
6946                                    dlg.store_upload_url(None);
6947                                    dlg.finished(false);
6948                                    return Err(common::Error::Failure(
6949                                        common::Response::from_parts(parts, body),
6950                                    ));
6951                                }
6952                            }
6953                        }
6954                    }
6955                    let response = {
6956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6957                        let encoded = common::to_string(&bytes);
6958                        match serde_json::from_str(&encoded) {
6959                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6960                            Err(error) => {
6961                                dlg.response_json_decode_error(&encoded, &error);
6962                                return Err(common::Error::JsonDecodeError(
6963                                    encoded.to_string(),
6964                                    error,
6965                                ));
6966                            }
6967                        }
6968                    };
6969
6970                    dlg.finished(true);
6971                    return Ok(response);
6972                }
6973            }
6974        }
6975    }
6976
6977    /// Upload media in a resumable fashion.
6978    /// Even if the upload fails or is interrupted, it can be resumed for a
6979    /// certain amount of time as the server maintains state temporarily.
6980    ///
6981    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
6982    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
6983    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
6984    /// `cancel_chunk_upload(...)`.
6985    ///
6986    /// * *multipart*: yes
6987    /// * *max size*: 2GB
6988    /// * *valid mime types*: 'application/octet-stream'
6989    pub async fn upload_resumable<RS>(
6990        self,
6991        resumeable_stream: RS,
6992        mime_type: mime::Mime,
6993    ) -> common::Result<(common::Response, Bundle)>
6994    where
6995        RS: common::ReadSeek,
6996    {
6997        self.doit(
6998            resumeable_stream,
6999            mime_type,
7000            common::UploadProtocol::Resumable,
7001        )
7002        .await
7003    }
7004    /// Upload media all at once.
7005    /// If the upload fails for whichever reason, all progress is lost.
7006    ///
7007    /// * *multipart*: yes
7008    /// * *max size*: 2GB
7009    /// * *valid mime types*: 'application/octet-stream'
7010    pub async fn upload<RS>(
7011        self,
7012        stream: RS,
7013        mime_type: mime::Mime,
7014    ) -> common::Result<(common::Response, Bundle)>
7015    where
7016        RS: common::ReadSeek,
7017    {
7018        self.doit(stream, mime_type, common::UploadProtocol::Simple)
7019            .await
7020    }
7021
7022    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
7023    ///
7024    /// Sets the *package name* path property to the given value.
7025    ///
7026    /// Even though the property as already been set when instantiating this call,
7027    /// we provide this method for API completeness.
7028    pub fn package_name(mut self, new_value: &str) -> EditBundleUploadCall<'a, C> {
7029        self._package_name = new_value.to_string();
7030        self
7031    }
7032    /// Unique identifier for this edit.
7033    ///
7034    /// Sets the *edit id* path property to the given value.
7035    ///
7036    /// Even though the property as already been set when instantiating this call,
7037    /// we provide this method for API completeness.
7038    pub fn edit_id(mut self, new_value: &str) -> EditBundleUploadCall<'a, C> {
7039        self._edit_id = new_value.to_string();
7040        self
7041    }
7042    /// Must be set to true if the bundle installation may trigger a warning on user devices (for example, if installation size may be over a threshold, typically 100 MB).
7043    ///
7044    /// Sets the *ack bundle installation warning* query property to the given value.
7045    pub fn ack_bundle_installation_warning(
7046        mut self,
7047        new_value: bool,
7048    ) -> EditBundleUploadCall<'a, C> {
7049        self._ack_bundle_installation_warning = Some(new_value);
7050        self
7051    }
7052    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7053    /// while executing the actual API request.
7054    ///
7055    /// ````text
7056    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7057    /// ````
7058    ///
7059    /// Sets the *delegate* property to the given value.
7060    pub fn delegate(
7061        mut self,
7062        new_value: &'a mut dyn common::Delegate,
7063    ) -> EditBundleUploadCall<'a, C> {
7064        self._delegate = Some(new_value);
7065        self
7066    }
7067
7068    /// Set any additional parameter of the query string used in the request.
7069    /// It should be used to set parameters which are not yet available through their own
7070    /// setters.
7071    ///
7072    /// Please note that this method must not be used to set any of the known parameters
7073    /// which have their own setter method. If done anyway, the request will fail.
7074    ///
7075    /// # Additional Parameters
7076    ///
7077    /// * *alt* (query-string) - Data format for the response.
7078    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7079    /// * *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.
7080    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7081    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7082    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7083    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7084    pub fn param<T>(mut self, name: T, value: T) -> EditBundleUploadCall<'a, C>
7085    where
7086        T: AsRef<str>,
7087    {
7088        self._additional_params
7089            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7090        self
7091    }
7092
7093    /// Identifies the authorization scope for the method you are building.
7094    ///
7095    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7096    /// [`Scope::Full`].
7097    ///
7098    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7099    /// tokens for more than one scope.
7100    ///
7101    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7102    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7103    /// sufficient, a read-write scope will do as well.
7104    pub fn add_scope<St>(mut self, scope: St) -> EditBundleUploadCall<'a, C>
7105    where
7106        St: AsRef<str>,
7107    {
7108        self._scopes.insert(String::from(scope.as_ref()));
7109        self
7110    }
7111    /// Identifies the authorization scope(s) for the method you are building.
7112    ///
7113    /// See [`Self::add_scope()`] for details.
7114    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditBundleUploadCall<'a, C>
7115    where
7116        I: IntoIterator<Item = St>,
7117        St: AsRef<str>,
7118    {
7119        self._scopes
7120            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7121        self
7122    }
7123
7124    /// Removes all scopes, and no default scope will be used either.
7125    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7126    /// for details).
7127    pub fn clear_scopes(mut self) -> EditBundleUploadCall<'a, C> {
7128        self._scopes.clear();
7129        self
7130    }
7131}
7132
7133/// Uploads the deobfuscation file of the specified APK. If a deobfuscation file already exists, it will be replaced.
7134///
7135/// A builder for the *deobfuscationfiles.upload* method supported by a *edit* resource.
7136/// It is not used directly, but through a [`EditMethods`] instance.
7137///
7138/// # Example
7139///
7140/// Instantiate a resource method builder
7141///
7142/// ```test_harness,no_run
7143/// # extern crate hyper;
7144/// # extern crate hyper_rustls;
7145/// # extern crate google_androidpublisher2 as androidpublisher2;
7146/// use std::fs;
7147/// # async fn dox() {
7148/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7149///
7150/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7151/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7152/// #     .with_native_roots()
7153/// #     .unwrap()
7154/// #     .https_only()
7155/// #     .enable_http2()
7156/// #     .build();
7157///
7158/// # let executor = hyper_util::rt::TokioExecutor::new();
7159/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7160/// #     secret,
7161/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7162/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7163/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7164/// #     ),
7165/// # ).build().await.unwrap();
7166///
7167/// # let client = hyper_util::client::legacy::Client::builder(
7168/// #     hyper_util::rt::TokioExecutor::new()
7169/// # )
7170/// # .build(
7171/// #     hyper_rustls::HttpsConnectorBuilder::new()
7172/// #         .with_native_roots()
7173/// #         .unwrap()
7174/// #         .https_or_http()
7175/// #         .enable_http2()
7176/// #         .build()
7177/// # );
7178/// # let mut hub = AndroidPublisher::new(client, auth);
7179/// // You can configure optional parameters by calling the respective setters at will, and
7180/// // execute the final call using `upload(...)`.
7181/// // Values shown here are possibly random and not representative !
7182/// let result = hub.edits().deobfuscationfiles_upload("packageName", "editId", -76, "deobfuscationFileType")
7183///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
7184/// # }
7185/// ```
7186pub struct EditDeobfuscationfileUploadCall<'a, C>
7187where
7188    C: 'a,
7189{
7190    hub: &'a AndroidPublisher<C>,
7191    _package_name: String,
7192    _edit_id: String,
7193    _apk_version_code: i32,
7194    _deobfuscation_file_type: String,
7195    _delegate: Option<&'a mut dyn common::Delegate>,
7196    _additional_params: HashMap<String, String>,
7197    _scopes: BTreeSet<String>,
7198}
7199
7200impl<'a, C> common::CallBuilder for EditDeobfuscationfileUploadCall<'a, C> {}
7201
7202impl<'a, C> EditDeobfuscationfileUploadCall<'a, C>
7203where
7204    C: common::Connector,
7205{
7206    /// Perform the operation you have build so far.
7207    async fn doit<RS>(
7208        mut self,
7209        mut reader: RS,
7210        reader_mime_type: mime::Mime,
7211        protocol: common::UploadProtocol,
7212    ) -> common::Result<(common::Response, DeobfuscationFilesUploadResponse)>
7213    where
7214        RS: common::ReadSeek,
7215    {
7216        use std::borrow::Cow;
7217        use std::io::{Read, Seek};
7218
7219        use common::{url::Params, ToParts};
7220        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7221
7222        let mut dd = common::DefaultDelegate;
7223        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7224        dlg.begin(common::MethodInfo {
7225            id: "androidpublisher.edits.deobfuscationfiles.upload",
7226            http_method: hyper::Method::POST,
7227        });
7228
7229        for &field in [
7230            "alt",
7231            "packageName",
7232            "editId",
7233            "apkVersionCode",
7234            "deobfuscationFileType",
7235        ]
7236        .iter()
7237        {
7238            if self._additional_params.contains_key(field) {
7239                dlg.finished(false);
7240                return Err(common::Error::FieldClash(field));
7241            }
7242        }
7243
7244        let mut params = Params::with_capacity(6 + self._additional_params.len());
7245        params.push("packageName", self._package_name);
7246        params.push("editId", self._edit_id);
7247        params.push("apkVersionCode", self._apk_version_code.to_string());
7248        params.push("deobfuscationFileType", self._deobfuscation_file_type);
7249
7250        params.extend(self._additional_params.iter());
7251
7252        params.push("alt", "json");
7253        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
7254            (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/deobfuscationFiles/{deobfuscationFileType}", "resumable")
7255        } else if protocol == common::UploadProtocol::Simple {
7256            (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/deobfuscationFiles/{deobfuscationFileType}", "multipart")
7257        } else {
7258            unreachable!()
7259        };
7260        params.push("uploadType", upload_type);
7261        if self._scopes.is_empty() {
7262            self._scopes.insert(Scope::Full.as_ref().to_string());
7263        }
7264
7265        #[allow(clippy::single_element_loop)]
7266        for &(find_this, param_name) in [
7267            ("{packageName}", "packageName"),
7268            ("{editId}", "editId"),
7269            ("{apkVersionCode}", "apkVersionCode"),
7270            ("{deobfuscationFileType}", "deobfuscationFileType"),
7271        ]
7272        .iter()
7273        {
7274            url = params.uri_replacement(url, param_name, find_this, false);
7275        }
7276        {
7277            let to_remove = [
7278                "deobfuscationFileType",
7279                "apkVersionCode",
7280                "editId",
7281                "packageName",
7282            ];
7283            params.remove_params(&to_remove);
7284        }
7285
7286        let url = params.parse_with_url(&url);
7287
7288        let mut upload_url_from_server;
7289
7290        loop {
7291            let token = match self
7292                .hub
7293                .auth
7294                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7295                .await
7296            {
7297                Ok(token) => token,
7298                Err(e) => match dlg.token(e) {
7299                    Ok(token) => token,
7300                    Err(e) => {
7301                        dlg.finished(false);
7302                        return Err(common::Error::MissingToken(e));
7303                    }
7304                },
7305            };
7306            let mut req_result = {
7307                let client = &self.hub.client;
7308                dlg.pre_request();
7309                let mut req_builder = hyper::Request::builder()
7310                    .method(hyper::Method::POST)
7311                    .uri(url.as_str())
7312                    .header(USER_AGENT, self.hub._user_agent.clone());
7313
7314                if let Some(token) = token.as_ref() {
7315                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7316                }
7317
7318                upload_url_from_server = true;
7319                if protocol == common::UploadProtocol::Resumable {
7320                    req_builder = req_builder
7321                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
7322                }
7323
7324                let request = if protocol == common::UploadProtocol::Simple {
7325                    let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
7326                    reader.seek(std::io::SeekFrom::Start(0)).unwrap();
7327                    if size > 314572800 {
7328                        return Err(common::Error::UploadSizeLimitExceeded(size, 314572800));
7329                    }
7330                    let mut bytes = Vec::with_capacity(size as usize);
7331                    reader.read_to_end(&mut bytes)?;
7332                    req_builder
7333                        .header(CONTENT_TYPE, reader_mime_type.to_string())
7334                        .header(CONTENT_LENGTH, size)
7335                        .body(common::to_body(bytes.into()))
7336                } else {
7337                    req_builder.body(common::to_body::<String>(None))
7338                };
7339
7340                client.request(request.unwrap()).await
7341            };
7342
7343            match req_result {
7344                Err(err) => {
7345                    if let common::Retry::After(d) = dlg.http_error(&err) {
7346                        sleep(d).await;
7347                        continue;
7348                    }
7349                    dlg.finished(false);
7350                    return Err(common::Error::HttpError(err));
7351                }
7352                Ok(res) => {
7353                    let (mut parts, body) = res.into_parts();
7354                    let mut body = common::Body::new(body);
7355                    if !parts.status.is_success() {
7356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7357                        let error = serde_json::from_str(&common::to_string(&bytes));
7358                        let response = common::to_response(parts, bytes.into());
7359
7360                        if let common::Retry::After(d) =
7361                            dlg.http_failure(&response, error.as_ref().ok())
7362                        {
7363                            sleep(d).await;
7364                            continue;
7365                        }
7366
7367                        dlg.finished(false);
7368
7369                        return Err(match error {
7370                            Ok(value) => common::Error::BadRequest(value),
7371                            _ => common::Error::Failure(response),
7372                        });
7373                    }
7374                    if protocol == common::UploadProtocol::Resumable {
7375                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
7376                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
7377                        if size > 314572800 {
7378                            return Err(common::Error::UploadSizeLimitExceeded(size, 314572800));
7379                        }
7380                        let upload_result = {
7381                            let url_str = &parts
7382                                .headers
7383                                .get("Location")
7384                                .expect("LOCATION header is part of protocol")
7385                                .to_str()
7386                                .unwrap();
7387                            if upload_url_from_server {
7388                                dlg.store_upload_url(Some(url_str));
7389                            }
7390
7391                            common::ResumableUploadHelper {
7392                                client: &self.hub.client,
7393                                delegate: dlg,
7394                                start_at: if upload_url_from_server {
7395                                    Some(0)
7396                                } else {
7397                                    None
7398                                },
7399                                auth: &self.hub.auth,
7400                                user_agent: &self.hub._user_agent,
7401                                // TODO: Check this assumption
7402                                auth_header: format!(
7403                                    "Bearer {}",
7404                                    token
7405                                        .ok_or_else(|| common::Error::MissingToken(
7406                                            "resumable upload requires token".into()
7407                                        ))?
7408                                        .as_str()
7409                                ),
7410                                url: url_str,
7411                                reader: &mut reader,
7412                                media_type: reader_mime_type.clone(),
7413                                content_length: size,
7414                            }
7415                            .upload()
7416                            .await
7417                        };
7418                        match upload_result {
7419                            None => {
7420                                dlg.finished(false);
7421                                return Err(common::Error::Cancelled);
7422                            }
7423                            Some(Err(err)) => {
7424                                dlg.finished(false);
7425                                return Err(common::Error::HttpError(err));
7426                            }
7427                            Some(Ok(response)) => {
7428                                (parts, body) = response.into_parts();
7429                                if !parts.status.is_success() {
7430                                    dlg.store_upload_url(None);
7431                                    dlg.finished(false);
7432                                    return Err(common::Error::Failure(
7433                                        common::Response::from_parts(parts, body),
7434                                    ));
7435                                }
7436                            }
7437                        }
7438                    }
7439                    let response = {
7440                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7441                        let encoded = common::to_string(&bytes);
7442                        match serde_json::from_str(&encoded) {
7443                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7444                            Err(error) => {
7445                                dlg.response_json_decode_error(&encoded, &error);
7446                                return Err(common::Error::JsonDecodeError(
7447                                    encoded.to_string(),
7448                                    error,
7449                                ));
7450                            }
7451                        }
7452                    };
7453
7454                    dlg.finished(true);
7455                    return Ok(response);
7456                }
7457            }
7458        }
7459    }
7460
7461    /// Upload media in a resumable fashion.
7462    /// Even if the upload fails or is interrupted, it can be resumed for a
7463    /// certain amount of time as the server maintains state temporarily.
7464    ///
7465    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
7466    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
7467    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
7468    /// `cancel_chunk_upload(...)`.
7469    ///
7470    /// * *multipart*: yes
7471    /// * *max size*: 300MB
7472    /// * *valid mime types*: 'application/octet-stream'
7473    pub async fn upload_resumable<RS>(
7474        self,
7475        resumeable_stream: RS,
7476        mime_type: mime::Mime,
7477    ) -> common::Result<(common::Response, DeobfuscationFilesUploadResponse)>
7478    where
7479        RS: common::ReadSeek,
7480    {
7481        self.doit(
7482            resumeable_stream,
7483            mime_type,
7484            common::UploadProtocol::Resumable,
7485        )
7486        .await
7487    }
7488    /// Upload media all at once.
7489    /// If the upload fails for whichever reason, all progress is lost.
7490    ///
7491    /// * *multipart*: yes
7492    /// * *max size*: 300MB
7493    /// * *valid mime types*: 'application/octet-stream'
7494    pub async fn upload<RS>(
7495        self,
7496        stream: RS,
7497        mime_type: mime::Mime,
7498    ) -> common::Result<(common::Response, DeobfuscationFilesUploadResponse)>
7499    where
7500        RS: common::ReadSeek,
7501    {
7502        self.doit(stream, mime_type, common::UploadProtocol::Simple)
7503            .await
7504    }
7505
7506    /// Unique identifier of the Android app for which the deobfuscatiuon files are being uploaded; for example, "com.spiffygame".
7507    ///
7508    /// Sets the *package name* path property to the given value.
7509    ///
7510    /// Even though the property as already been set when instantiating this call,
7511    /// we provide this method for API completeness.
7512    pub fn package_name(mut self, new_value: &str) -> EditDeobfuscationfileUploadCall<'a, C> {
7513        self._package_name = new_value.to_string();
7514        self
7515    }
7516    /// Unique identifier for this edit.
7517    ///
7518    /// Sets the *edit id* path property to the given value.
7519    ///
7520    /// Even though the property as already been set when instantiating this call,
7521    /// we provide this method for API completeness.
7522    pub fn edit_id(mut self, new_value: &str) -> EditDeobfuscationfileUploadCall<'a, C> {
7523        self._edit_id = new_value.to_string();
7524        self
7525    }
7526    /// The version code of the APK whose deobfuscation file is being uploaded.
7527    ///
7528    /// Sets the *apk version code* path property to the given value.
7529    ///
7530    /// Even though the property as already been set when instantiating this call,
7531    /// we provide this method for API completeness.
7532    pub fn apk_version_code(mut self, new_value: i32) -> EditDeobfuscationfileUploadCall<'a, C> {
7533        self._apk_version_code = new_value;
7534        self
7535    }
7536    ///
7537    /// Sets the *deobfuscation file type* path property to the given value.
7538    ///
7539    /// Even though the property as already been set when instantiating this call,
7540    /// we provide this method for API completeness.
7541    pub fn deobfuscation_file_type(
7542        mut self,
7543        new_value: &str,
7544    ) -> EditDeobfuscationfileUploadCall<'a, C> {
7545        self._deobfuscation_file_type = new_value.to_string();
7546        self
7547    }
7548    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7549    /// while executing the actual API request.
7550    ///
7551    /// ````text
7552    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7553    /// ````
7554    ///
7555    /// Sets the *delegate* property to the given value.
7556    pub fn delegate(
7557        mut self,
7558        new_value: &'a mut dyn common::Delegate,
7559    ) -> EditDeobfuscationfileUploadCall<'a, C> {
7560        self._delegate = Some(new_value);
7561        self
7562    }
7563
7564    /// Set any additional parameter of the query string used in the request.
7565    /// It should be used to set parameters which are not yet available through their own
7566    /// setters.
7567    ///
7568    /// Please note that this method must not be used to set any of the known parameters
7569    /// which have their own setter method. If done anyway, the request will fail.
7570    ///
7571    /// # Additional Parameters
7572    ///
7573    /// * *alt* (query-string) - Data format for the response.
7574    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7575    /// * *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.
7576    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7577    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7578    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7579    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7580    pub fn param<T>(mut self, name: T, value: T) -> EditDeobfuscationfileUploadCall<'a, C>
7581    where
7582        T: AsRef<str>,
7583    {
7584        self._additional_params
7585            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7586        self
7587    }
7588
7589    /// Identifies the authorization scope for the method you are building.
7590    ///
7591    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7592    /// [`Scope::Full`].
7593    ///
7594    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7595    /// tokens for more than one scope.
7596    ///
7597    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7598    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7599    /// sufficient, a read-write scope will do as well.
7600    pub fn add_scope<St>(mut self, scope: St) -> EditDeobfuscationfileUploadCall<'a, C>
7601    where
7602        St: AsRef<str>,
7603    {
7604        self._scopes.insert(String::from(scope.as_ref()));
7605        self
7606    }
7607    /// Identifies the authorization scope(s) for the method you are building.
7608    ///
7609    /// See [`Self::add_scope()`] for details.
7610    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDeobfuscationfileUploadCall<'a, C>
7611    where
7612        I: IntoIterator<Item = St>,
7613        St: AsRef<str>,
7614    {
7615        self._scopes
7616            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7617        self
7618    }
7619
7620    /// Removes all scopes, and no default scope will be used either.
7621    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7622    /// for details).
7623    pub fn clear_scopes(mut self) -> EditDeobfuscationfileUploadCall<'a, C> {
7624        self._scopes.clear();
7625        self
7626    }
7627}
7628
7629/// Fetches app details for this edit. This includes the default language and developer support contact information.
7630///
7631/// A builder for the *details.get* method supported by a *edit* resource.
7632/// It is not used directly, but through a [`EditMethods`] instance.
7633///
7634/// # Example
7635///
7636/// Instantiate a resource method builder
7637///
7638/// ```test_harness,no_run
7639/// # extern crate hyper;
7640/// # extern crate hyper_rustls;
7641/// # extern crate google_androidpublisher2 as androidpublisher2;
7642/// # async fn dox() {
7643/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7644///
7645/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7646/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7647/// #     .with_native_roots()
7648/// #     .unwrap()
7649/// #     .https_only()
7650/// #     .enable_http2()
7651/// #     .build();
7652///
7653/// # let executor = hyper_util::rt::TokioExecutor::new();
7654/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7655/// #     secret,
7656/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7657/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7658/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7659/// #     ),
7660/// # ).build().await.unwrap();
7661///
7662/// # let client = hyper_util::client::legacy::Client::builder(
7663/// #     hyper_util::rt::TokioExecutor::new()
7664/// # )
7665/// # .build(
7666/// #     hyper_rustls::HttpsConnectorBuilder::new()
7667/// #         .with_native_roots()
7668/// #         .unwrap()
7669/// #         .https_or_http()
7670/// #         .enable_http2()
7671/// #         .build()
7672/// # );
7673/// # let mut hub = AndroidPublisher::new(client, auth);
7674/// // You can configure optional parameters by calling the respective setters at will, and
7675/// // execute the final call using `doit()`.
7676/// // Values shown here are possibly random and not representative !
7677/// let result = hub.edits().details_get("packageName", "editId")
7678///              .doit().await;
7679/// # }
7680/// ```
7681pub struct EditDetailGetCall<'a, C>
7682where
7683    C: 'a,
7684{
7685    hub: &'a AndroidPublisher<C>,
7686    _package_name: String,
7687    _edit_id: String,
7688    _delegate: Option<&'a mut dyn common::Delegate>,
7689    _additional_params: HashMap<String, String>,
7690    _scopes: BTreeSet<String>,
7691}
7692
7693impl<'a, C> common::CallBuilder for EditDetailGetCall<'a, C> {}
7694
7695impl<'a, C> EditDetailGetCall<'a, C>
7696where
7697    C: common::Connector,
7698{
7699    /// Perform the operation you have build so far.
7700    pub async fn doit(mut self) -> common::Result<(common::Response, AppDetails)> {
7701        use std::borrow::Cow;
7702        use std::io::{Read, Seek};
7703
7704        use common::{url::Params, ToParts};
7705        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7706
7707        let mut dd = common::DefaultDelegate;
7708        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7709        dlg.begin(common::MethodInfo {
7710            id: "androidpublisher.edits.details.get",
7711            http_method: hyper::Method::GET,
7712        });
7713
7714        for &field in ["alt", "packageName", "editId"].iter() {
7715            if self._additional_params.contains_key(field) {
7716                dlg.finished(false);
7717                return Err(common::Error::FieldClash(field));
7718            }
7719        }
7720
7721        let mut params = Params::with_capacity(4 + self._additional_params.len());
7722        params.push("packageName", self._package_name);
7723        params.push("editId", self._edit_id);
7724
7725        params.extend(self._additional_params.iter());
7726
7727        params.push("alt", "json");
7728        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/details";
7729        if self._scopes.is_empty() {
7730            self._scopes.insert(Scope::Full.as_ref().to_string());
7731        }
7732
7733        #[allow(clippy::single_element_loop)]
7734        for &(find_this, param_name) in
7735            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
7736        {
7737            url = params.uri_replacement(url, param_name, find_this, false);
7738        }
7739        {
7740            let to_remove = ["editId", "packageName"];
7741            params.remove_params(&to_remove);
7742        }
7743
7744        let url = params.parse_with_url(&url);
7745
7746        loop {
7747            let token = match self
7748                .hub
7749                .auth
7750                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7751                .await
7752            {
7753                Ok(token) => token,
7754                Err(e) => match dlg.token(e) {
7755                    Ok(token) => token,
7756                    Err(e) => {
7757                        dlg.finished(false);
7758                        return Err(common::Error::MissingToken(e));
7759                    }
7760                },
7761            };
7762            let mut req_result = {
7763                let client = &self.hub.client;
7764                dlg.pre_request();
7765                let mut req_builder = hyper::Request::builder()
7766                    .method(hyper::Method::GET)
7767                    .uri(url.as_str())
7768                    .header(USER_AGENT, self.hub._user_agent.clone());
7769
7770                if let Some(token) = token.as_ref() {
7771                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7772                }
7773
7774                let request = req_builder
7775                    .header(CONTENT_LENGTH, 0_u64)
7776                    .body(common::to_body::<String>(None));
7777
7778                client.request(request.unwrap()).await
7779            };
7780
7781            match req_result {
7782                Err(err) => {
7783                    if let common::Retry::After(d) = dlg.http_error(&err) {
7784                        sleep(d).await;
7785                        continue;
7786                    }
7787                    dlg.finished(false);
7788                    return Err(common::Error::HttpError(err));
7789                }
7790                Ok(res) => {
7791                    let (mut parts, body) = res.into_parts();
7792                    let mut body = common::Body::new(body);
7793                    if !parts.status.is_success() {
7794                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7795                        let error = serde_json::from_str(&common::to_string(&bytes));
7796                        let response = common::to_response(parts, bytes.into());
7797
7798                        if let common::Retry::After(d) =
7799                            dlg.http_failure(&response, error.as_ref().ok())
7800                        {
7801                            sleep(d).await;
7802                            continue;
7803                        }
7804
7805                        dlg.finished(false);
7806
7807                        return Err(match error {
7808                            Ok(value) => common::Error::BadRequest(value),
7809                            _ => common::Error::Failure(response),
7810                        });
7811                    }
7812                    let response = {
7813                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7814                        let encoded = common::to_string(&bytes);
7815                        match serde_json::from_str(&encoded) {
7816                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7817                            Err(error) => {
7818                                dlg.response_json_decode_error(&encoded, &error);
7819                                return Err(common::Error::JsonDecodeError(
7820                                    encoded.to_string(),
7821                                    error,
7822                                ));
7823                            }
7824                        }
7825                    };
7826
7827                    dlg.finished(true);
7828                    return Ok(response);
7829                }
7830            }
7831        }
7832    }
7833
7834    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
7835    ///
7836    /// Sets the *package name* path property to the given value.
7837    ///
7838    /// Even though the property as already been set when instantiating this call,
7839    /// we provide this method for API completeness.
7840    pub fn package_name(mut self, new_value: &str) -> EditDetailGetCall<'a, C> {
7841        self._package_name = new_value.to_string();
7842        self
7843    }
7844    /// Unique identifier for this edit.
7845    ///
7846    /// Sets the *edit id* path property to the given value.
7847    ///
7848    /// Even though the property as already been set when instantiating this call,
7849    /// we provide this method for API completeness.
7850    pub fn edit_id(mut self, new_value: &str) -> EditDetailGetCall<'a, C> {
7851        self._edit_id = new_value.to_string();
7852        self
7853    }
7854    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7855    /// while executing the actual API request.
7856    ///
7857    /// ````text
7858    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7859    /// ````
7860    ///
7861    /// Sets the *delegate* property to the given value.
7862    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditDetailGetCall<'a, C> {
7863        self._delegate = Some(new_value);
7864        self
7865    }
7866
7867    /// Set any additional parameter of the query string used in the request.
7868    /// It should be used to set parameters which are not yet available through their own
7869    /// setters.
7870    ///
7871    /// Please note that this method must not be used to set any of the known parameters
7872    /// which have their own setter method. If done anyway, the request will fail.
7873    ///
7874    /// # Additional Parameters
7875    ///
7876    /// * *alt* (query-string) - Data format for the response.
7877    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7878    /// * *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.
7879    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7880    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7881    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7882    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7883    pub fn param<T>(mut self, name: T, value: T) -> EditDetailGetCall<'a, C>
7884    where
7885        T: AsRef<str>,
7886    {
7887        self._additional_params
7888            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7889        self
7890    }
7891
7892    /// Identifies the authorization scope for the method you are building.
7893    ///
7894    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7895    /// [`Scope::Full`].
7896    ///
7897    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7898    /// tokens for more than one scope.
7899    ///
7900    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7901    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7902    /// sufficient, a read-write scope will do as well.
7903    pub fn add_scope<St>(mut self, scope: St) -> EditDetailGetCall<'a, C>
7904    where
7905        St: AsRef<str>,
7906    {
7907        self._scopes.insert(String::from(scope.as_ref()));
7908        self
7909    }
7910    /// Identifies the authorization scope(s) for the method you are building.
7911    ///
7912    /// See [`Self::add_scope()`] for details.
7913    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDetailGetCall<'a, C>
7914    where
7915        I: IntoIterator<Item = St>,
7916        St: AsRef<str>,
7917    {
7918        self._scopes
7919            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7920        self
7921    }
7922
7923    /// Removes all scopes, and no default scope will be used either.
7924    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7925    /// for details).
7926    pub fn clear_scopes(mut self) -> EditDetailGetCall<'a, C> {
7927        self._scopes.clear();
7928        self
7929    }
7930}
7931
7932/// Updates app details for this edit. This method supports patch semantics.
7933///
7934/// A builder for the *details.patch* method supported by a *edit* resource.
7935/// It is not used directly, but through a [`EditMethods`] instance.
7936///
7937/// # Example
7938///
7939/// Instantiate a resource method builder
7940///
7941/// ```test_harness,no_run
7942/// # extern crate hyper;
7943/// # extern crate hyper_rustls;
7944/// # extern crate google_androidpublisher2 as androidpublisher2;
7945/// use androidpublisher2::api::AppDetails;
7946/// # async fn dox() {
7947/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7948///
7949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7950/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7951/// #     .with_native_roots()
7952/// #     .unwrap()
7953/// #     .https_only()
7954/// #     .enable_http2()
7955/// #     .build();
7956///
7957/// # let executor = hyper_util::rt::TokioExecutor::new();
7958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7959/// #     secret,
7960/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7961/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7962/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7963/// #     ),
7964/// # ).build().await.unwrap();
7965///
7966/// # let client = hyper_util::client::legacy::Client::builder(
7967/// #     hyper_util::rt::TokioExecutor::new()
7968/// # )
7969/// # .build(
7970/// #     hyper_rustls::HttpsConnectorBuilder::new()
7971/// #         .with_native_roots()
7972/// #         .unwrap()
7973/// #         .https_or_http()
7974/// #         .enable_http2()
7975/// #         .build()
7976/// # );
7977/// # let mut hub = AndroidPublisher::new(client, auth);
7978/// // As the method needs a request, you would usually fill it with the desired information
7979/// // into the respective structure. Some of the parts shown here might not be applicable !
7980/// // Values shown here are possibly random and not representative !
7981/// let mut req = AppDetails::default();
7982///
7983/// // You can configure optional parameters by calling the respective setters at will, and
7984/// // execute the final call using `doit()`.
7985/// // Values shown here are possibly random and not representative !
7986/// let result = hub.edits().details_patch(req, "packageName", "editId")
7987///              .doit().await;
7988/// # }
7989/// ```
7990pub struct EditDetailPatchCall<'a, C>
7991where
7992    C: 'a,
7993{
7994    hub: &'a AndroidPublisher<C>,
7995    _request: AppDetails,
7996    _package_name: String,
7997    _edit_id: String,
7998    _delegate: Option<&'a mut dyn common::Delegate>,
7999    _additional_params: HashMap<String, String>,
8000    _scopes: BTreeSet<String>,
8001}
8002
8003impl<'a, C> common::CallBuilder for EditDetailPatchCall<'a, C> {}
8004
8005impl<'a, C> EditDetailPatchCall<'a, C>
8006where
8007    C: common::Connector,
8008{
8009    /// Perform the operation you have build so far.
8010    pub async fn doit(mut self) -> common::Result<(common::Response, AppDetails)> {
8011        use std::borrow::Cow;
8012        use std::io::{Read, Seek};
8013
8014        use common::{url::Params, ToParts};
8015        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8016
8017        let mut dd = common::DefaultDelegate;
8018        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8019        dlg.begin(common::MethodInfo {
8020            id: "androidpublisher.edits.details.patch",
8021            http_method: hyper::Method::PATCH,
8022        });
8023
8024        for &field in ["alt", "packageName", "editId"].iter() {
8025            if self._additional_params.contains_key(field) {
8026                dlg.finished(false);
8027                return Err(common::Error::FieldClash(field));
8028            }
8029        }
8030
8031        let mut params = Params::with_capacity(5 + self._additional_params.len());
8032        params.push("packageName", self._package_name);
8033        params.push("editId", self._edit_id);
8034
8035        params.extend(self._additional_params.iter());
8036
8037        params.push("alt", "json");
8038        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/details";
8039        if self._scopes.is_empty() {
8040            self._scopes.insert(Scope::Full.as_ref().to_string());
8041        }
8042
8043        #[allow(clippy::single_element_loop)]
8044        for &(find_this, param_name) in
8045            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
8046        {
8047            url = params.uri_replacement(url, param_name, find_this, false);
8048        }
8049        {
8050            let to_remove = ["editId", "packageName"];
8051            params.remove_params(&to_remove);
8052        }
8053
8054        let url = params.parse_with_url(&url);
8055
8056        let mut json_mime_type = mime::APPLICATION_JSON;
8057        let mut request_value_reader = {
8058            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8059            common::remove_json_null_values(&mut value);
8060            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8061            serde_json::to_writer(&mut dst, &value).unwrap();
8062            dst
8063        };
8064        let request_size = request_value_reader
8065            .seek(std::io::SeekFrom::End(0))
8066            .unwrap();
8067        request_value_reader
8068            .seek(std::io::SeekFrom::Start(0))
8069            .unwrap();
8070
8071        loop {
8072            let token = match self
8073                .hub
8074                .auth
8075                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8076                .await
8077            {
8078                Ok(token) => token,
8079                Err(e) => match dlg.token(e) {
8080                    Ok(token) => token,
8081                    Err(e) => {
8082                        dlg.finished(false);
8083                        return Err(common::Error::MissingToken(e));
8084                    }
8085                },
8086            };
8087            request_value_reader
8088                .seek(std::io::SeekFrom::Start(0))
8089                .unwrap();
8090            let mut req_result = {
8091                let client = &self.hub.client;
8092                dlg.pre_request();
8093                let mut req_builder = hyper::Request::builder()
8094                    .method(hyper::Method::PATCH)
8095                    .uri(url.as_str())
8096                    .header(USER_AGENT, self.hub._user_agent.clone());
8097
8098                if let Some(token) = token.as_ref() {
8099                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8100                }
8101
8102                let request = req_builder
8103                    .header(CONTENT_TYPE, json_mime_type.to_string())
8104                    .header(CONTENT_LENGTH, request_size as u64)
8105                    .body(common::to_body(
8106                        request_value_reader.get_ref().clone().into(),
8107                    ));
8108
8109                client.request(request.unwrap()).await
8110            };
8111
8112            match req_result {
8113                Err(err) => {
8114                    if let common::Retry::After(d) = dlg.http_error(&err) {
8115                        sleep(d).await;
8116                        continue;
8117                    }
8118                    dlg.finished(false);
8119                    return Err(common::Error::HttpError(err));
8120                }
8121                Ok(res) => {
8122                    let (mut parts, body) = res.into_parts();
8123                    let mut body = common::Body::new(body);
8124                    if !parts.status.is_success() {
8125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8126                        let error = serde_json::from_str(&common::to_string(&bytes));
8127                        let response = common::to_response(parts, bytes.into());
8128
8129                        if let common::Retry::After(d) =
8130                            dlg.http_failure(&response, error.as_ref().ok())
8131                        {
8132                            sleep(d).await;
8133                            continue;
8134                        }
8135
8136                        dlg.finished(false);
8137
8138                        return Err(match error {
8139                            Ok(value) => common::Error::BadRequest(value),
8140                            _ => common::Error::Failure(response),
8141                        });
8142                    }
8143                    let response = {
8144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8145                        let encoded = common::to_string(&bytes);
8146                        match serde_json::from_str(&encoded) {
8147                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8148                            Err(error) => {
8149                                dlg.response_json_decode_error(&encoded, &error);
8150                                return Err(common::Error::JsonDecodeError(
8151                                    encoded.to_string(),
8152                                    error,
8153                                ));
8154                            }
8155                        }
8156                    };
8157
8158                    dlg.finished(true);
8159                    return Ok(response);
8160                }
8161            }
8162        }
8163    }
8164
8165    ///
8166    /// Sets the *request* property to the given value.
8167    ///
8168    /// Even though the property as already been set when instantiating this call,
8169    /// we provide this method for API completeness.
8170    pub fn request(mut self, new_value: AppDetails) -> EditDetailPatchCall<'a, C> {
8171        self._request = new_value;
8172        self
8173    }
8174    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
8175    ///
8176    /// Sets the *package name* path property to the given value.
8177    ///
8178    /// Even though the property as already been set when instantiating this call,
8179    /// we provide this method for API completeness.
8180    pub fn package_name(mut self, new_value: &str) -> EditDetailPatchCall<'a, C> {
8181        self._package_name = new_value.to_string();
8182        self
8183    }
8184    /// Unique identifier for this edit.
8185    ///
8186    /// Sets the *edit id* path property to the given value.
8187    ///
8188    /// Even though the property as already been set when instantiating this call,
8189    /// we provide this method for API completeness.
8190    pub fn edit_id(mut self, new_value: &str) -> EditDetailPatchCall<'a, C> {
8191        self._edit_id = new_value.to_string();
8192        self
8193    }
8194    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8195    /// while executing the actual API request.
8196    ///
8197    /// ````text
8198    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8199    /// ````
8200    ///
8201    /// Sets the *delegate* property to the given value.
8202    pub fn delegate(
8203        mut self,
8204        new_value: &'a mut dyn common::Delegate,
8205    ) -> EditDetailPatchCall<'a, C> {
8206        self._delegate = Some(new_value);
8207        self
8208    }
8209
8210    /// Set any additional parameter of the query string used in the request.
8211    /// It should be used to set parameters which are not yet available through their own
8212    /// setters.
8213    ///
8214    /// Please note that this method must not be used to set any of the known parameters
8215    /// which have their own setter method. If done anyway, the request will fail.
8216    ///
8217    /// # Additional Parameters
8218    ///
8219    /// * *alt* (query-string) - Data format for the response.
8220    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8221    /// * *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.
8222    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8223    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8224    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8225    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8226    pub fn param<T>(mut self, name: T, value: T) -> EditDetailPatchCall<'a, C>
8227    where
8228        T: AsRef<str>,
8229    {
8230        self._additional_params
8231            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8232        self
8233    }
8234
8235    /// Identifies the authorization scope for the method you are building.
8236    ///
8237    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8238    /// [`Scope::Full`].
8239    ///
8240    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8241    /// tokens for more than one scope.
8242    ///
8243    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8244    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8245    /// sufficient, a read-write scope will do as well.
8246    pub fn add_scope<St>(mut self, scope: St) -> EditDetailPatchCall<'a, C>
8247    where
8248        St: AsRef<str>,
8249    {
8250        self._scopes.insert(String::from(scope.as_ref()));
8251        self
8252    }
8253    /// Identifies the authorization scope(s) for the method you are building.
8254    ///
8255    /// See [`Self::add_scope()`] for details.
8256    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDetailPatchCall<'a, C>
8257    where
8258        I: IntoIterator<Item = St>,
8259        St: AsRef<str>,
8260    {
8261        self._scopes
8262            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8263        self
8264    }
8265
8266    /// Removes all scopes, and no default scope will be used either.
8267    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8268    /// for details).
8269    pub fn clear_scopes(mut self) -> EditDetailPatchCall<'a, C> {
8270        self._scopes.clear();
8271        self
8272    }
8273}
8274
8275/// Updates app details for this edit.
8276///
8277/// A builder for the *details.update* method supported by a *edit* resource.
8278/// It is not used directly, but through a [`EditMethods`] instance.
8279///
8280/// # Example
8281///
8282/// Instantiate a resource method builder
8283///
8284/// ```test_harness,no_run
8285/// # extern crate hyper;
8286/// # extern crate hyper_rustls;
8287/// # extern crate google_androidpublisher2 as androidpublisher2;
8288/// use androidpublisher2::api::AppDetails;
8289/// # async fn dox() {
8290/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8291///
8292/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8293/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8294/// #     .with_native_roots()
8295/// #     .unwrap()
8296/// #     .https_only()
8297/// #     .enable_http2()
8298/// #     .build();
8299///
8300/// # let executor = hyper_util::rt::TokioExecutor::new();
8301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8302/// #     secret,
8303/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8304/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8305/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8306/// #     ),
8307/// # ).build().await.unwrap();
8308///
8309/// # let client = hyper_util::client::legacy::Client::builder(
8310/// #     hyper_util::rt::TokioExecutor::new()
8311/// # )
8312/// # .build(
8313/// #     hyper_rustls::HttpsConnectorBuilder::new()
8314/// #         .with_native_roots()
8315/// #         .unwrap()
8316/// #         .https_or_http()
8317/// #         .enable_http2()
8318/// #         .build()
8319/// # );
8320/// # let mut hub = AndroidPublisher::new(client, auth);
8321/// // As the method needs a request, you would usually fill it with the desired information
8322/// // into the respective structure. Some of the parts shown here might not be applicable !
8323/// // Values shown here are possibly random and not representative !
8324/// let mut req = AppDetails::default();
8325///
8326/// // You can configure optional parameters by calling the respective setters at will, and
8327/// // execute the final call using `doit()`.
8328/// // Values shown here are possibly random and not representative !
8329/// let result = hub.edits().details_update(req, "packageName", "editId")
8330///              .doit().await;
8331/// # }
8332/// ```
8333pub struct EditDetailUpdateCall<'a, C>
8334where
8335    C: 'a,
8336{
8337    hub: &'a AndroidPublisher<C>,
8338    _request: AppDetails,
8339    _package_name: String,
8340    _edit_id: String,
8341    _delegate: Option<&'a mut dyn common::Delegate>,
8342    _additional_params: HashMap<String, String>,
8343    _scopes: BTreeSet<String>,
8344}
8345
8346impl<'a, C> common::CallBuilder for EditDetailUpdateCall<'a, C> {}
8347
8348impl<'a, C> EditDetailUpdateCall<'a, C>
8349where
8350    C: common::Connector,
8351{
8352    /// Perform the operation you have build so far.
8353    pub async fn doit(mut self) -> common::Result<(common::Response, AppDetails)> {
8354        use std::borrow::Cow;
8355        use std::io::{Read, Seek};
8356
8357        use common::{url::Params, ToParts};
8358        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8359
8360        let mut dd = common::DefaultDelegate;
8361        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8362        dlg.begin(common::MethodInfo {
8363            id: "androidpublisher.edits.details.update",
8364            http_method: hyper::Method::PUT,
8365        });
8366
8367        for &field in ["alt", "packageName", "editId"].iter() {
8368            if self._additional_params.contains_key(field) {
8369                dlg.finished(false);
8370                return Err(common::Error::FieldClash(field));
8371            }
8372        }
8373
8374        let mut params = Params::with_capacity(5 + self._additional_params.len());
8375        params.push("packageName", self._package_name);
8376        params.push("editId", self._edit_id);
8377
8378        params.extend(self._additional_params.iter());
8379
8380        params.push("alt", "json");
8381        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/details";
8382        if self._scopes.is_empty() {
8383            self._scopes.insert(Scope::Full.as_ref().to_string());
8384        }
8385
8386        #[allow(clippy::single_element_loop)]
8387        for &(find_this, param_name) in
8388            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
8389        {
8390            url = params.uri_replacement(url, param_name, find_this, false);
8391        }
8392        {
8393            let to_remove = ["editId", "packageName"];
8394            params.remove_params(&to_remove);
8395        }
8396
8397        let url = params.parse_with_url(&url);
8398
8399        let mut json_mime_type = mime::APPLICATION_JSON;
8400        let mut request_value_reader = {
8401            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8402            common::remove_json_null_values(&mut value);
8403            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8404            serde_json::to_writer(&mut dst, &value).unwrap();
8405            dst
8406        };
8407        let request_size = request_value_reader
8408            .seek(std::io::SeekFrom::End(0))
8409            .unwrap();
8410        request_value_reader
8411            .seek(std::io::SeekFrom::Start(0))
8412            .unwrap();
8413
8414        loop {
8415            let token = match self
8416                .hub
8417                .auth
8418                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8419                .await
8420            {
8421                Ok(token) => token,
8422                Err(e) => match dlg.token(e) {
8423                    Ok(token) => token,
8424                    Err(e) => {
8425                        dlg.finished(false);
8426                        return Err(common::Error::MissingToken(e));
8427                    }
8428                },
8429            };
8430            request_value_reader
8431                .seek(std::io::SeekFrom::Start(0))
8432                .unwrap();
8433            let mut req_result = {
8434                let client = &self.hub.client;
8435                dlg.pre_request();
8436                let mut req_builder = hyper::Request::builder()
8437                    .method(hyper::Method::PUT)
8438                    .uri(url.as_str())
8439                    .header(USER_AGENT, self.hub._user_agent.clone());
8440
8441                if let Some(token) = token.as_ref() {
8442                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8443                }
8444
8445                let request = req_builder
8446                    .header(CONTENT_TYPE, json_mime_type.to_string())
8447                    .header(CONTENT_LENGTH, request_size as u64)
8448                    .body(common::to_body(
8449                        request_value_reader.get_ref().clone().into(),
8450                    ));
8451
8452                client.request(request.unwrap()).await
8453            };
8454
8455            match req_result {
8456                Err(err) => {
8457                    if let common::Retry::After(d) = dlg.http_error(&err) {
8458                        sleep(d).await;
8459                        continue;
8460                    }
8461                    dlg.finished(false);
8462                    return Err(common::Error::HttpError(err));
8463                }
8464                Ok(res) => {
8465                    let (mut parts, body) = res.into_parts();
8466                    let mut body = common::Body::new(body);
8467                    if !parts.status.is_success() {
8468                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8469                        let error = serde_json::from_str(&common::to_string(&bytes));
8470                        let response = common::to_response(parts, bytes.into());
8471
8472                        if let common::Retry::After(d) =
8473                            dlg.http_failure(&response, error.as_ref().ok())
8474                        {
8475                            sleep(d).await;
8476                            continue;
8477                        }
8478
8479                        dlg.finished(false);
8480
8481                        return Err(match error {
8482                            Ok(value) => common::Error::BadRequest(value),
8483                            _ => common::Error::Failure(response),
8484                        });
8485                    }
8486                    let response = {
8487                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8488                        let encoded = common::to_string(&bytes);
8489                        match serde_json::from_str(&encoded) {
8490                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8491                            Err(error) => {
8492                                dlg.response_json_decode_error(&encoded, &error);
8493                                return Err(common::Error::JsonDecodeError(
8494                                    encoded.to_string(),
8495                                    error,
8496                                ));
8497                            }
8498                        }
8499                    };
8500
8501                    dlg.finished(true);
8502                    return Ok(response);
8503                }
8504            }
8505        }
8506    }
8507
8508    ///
8509    /// Sets the *request* property to the given value.
8510    ///
8511    /// Even though the property as already been set when instantiating this call,
8512    /// we provide this method for API completeness.
8513    pub fn request(mut self, new_value: AppDetails) -> EditDetailUpdateCall<'a, C> {
8514        self._request = new_value;
8515        self
8516    }
8517    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
8518    ///
8519    /// Sets the *package name* path property to the given value.
8520    ///
8521    /// Even though the property as already been set when instantiating this call,
8522    /// we provide this method for API completeness.
8523    pub fn package_name(mut self, new_value: &str) -> EditDetailUpdateCall<'a, C> {
8524        self._package_name = new_value.to_string();
8525        self
8526    }
8527    /// Unique identifier for this edit.
8528    ///
8529    /// Sets the *edit id* path property to the given value.
8530    ///
8531    /// Even though the property as already been set when instantiating this call,
8532    /// we provide this method for API completeness.
8533    pub fn edit_id(mut self, new_value: &str) -> EditDetailUpdateCall<'a, C> {
8534        self._edit_id = new_value.to_string();
8535        self
8536    }
8537    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8538    /// while executing the actual API request.
8539    ///
8540    /// ````text
8541    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8542    /// ````
8543    ///
8544    /// Sets the *delegate* property to the given value.
8545    pub fn delegate(
8546        mut self,
8547        new_value: &'a mut dyn common::Delegate,
8548    ) -> EditDetailUpdateCall<'a, C> {
8549        self._delegate = Some(new_value);
8550        self
8551    }
8552
8553    /// Set any additional parameter of the query string used in the request.
8554    /// It should be used to set parameters which are not yet available through their own
8555    /// setters.
8556    ///
8557    /// Please note that this method must not be used to set any of the known parameters
8558    /// which have their own setter method. If done anyway, the request will fail.
8559    ///
8560    /// # Additional Parameters
8561    ///
8562    /// * *alt* (query-string) - Data format for the response.
8563    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8564    /// * *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.
8565    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8566    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8567    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8568    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8569    pub fn param<T>(mut self, name: T, value: T) -> EditDetailUpdateCall<'a, C>
8570    where
8571        T: AsRef<str>,
8572    {
8573        self._additional_params
8574            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8575        self
8576    }
8577
8578    /// Identifies the authorization scope for the method you are building.
8579    ///
8580    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8581    /// [`Scope::Full`].
8582    ///
8583    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8584    /// tokens for more than one scope.
8585    ///
8586    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8587    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8588    /// sufficient, a read-write scope will do as well.
8589    pub fn add_scope<St>(mut self, scope: St) -> EditDetailUpdateCall<'a, C>
8590    where
8591        St: AsRef<str>,
8592    {
8593        self._scopes.insert(String::from(scope.as_ref()));
8594        self
8595    }
8596    /// Identifies the authorization scope(s) for the method you are building.
8597    ///
8598    /// See [`Self::add_scope()`] for details.
8599    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDetailUpdateCall<'a, C>
8600    where
8601        I: IntoIterator<Item = St>,
8602        St: AsRef<str>,
8603    {
8604        self._scopes
8605            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8606        self
8607    }
8608
8609    /// Removes all scopes, and no default scope will be used either.
8610    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8611    /// for details).
8612    pub fn clear_scopes(mut self) -> EditDetailUpdateCall<'a, C> {
8613        self._scopes.clear();
8614        self
8615    }
8616}
8617
8618/// Fetches the Expansion File configuration for the APK specified.
8619///
8620/// A builder for the *expansionfiles.get* method supported by a *edit* resource.
8621/// It is not used directly, but through a [`EditMethods`] instance.
8622///
8623/// # Example
8624///
8625/// Instantiate a resource method builder
8626///
8627/// ```test_harness,no_run
8628/// # extern crate hyper;
8629/// # extern crate hyper_rustls;
8630/// # extern crate google_androidpublisher2 as androidpublisher2;
8631/// # async fn dox() {
8632/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8633///
8634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8635/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8636/// #     .with_native_roots()
8637/// #     .unwrap()
8638/// #     .https_only()
8639/// #     .enable_http2()
8640/// #     .build();
8641///
8642/// # let executor = hyper_util::rt::TokioExecutor::new();
8643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8644/// #     secret,
8645/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8646/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8647/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8648/// #     ),
8649/// # ).build().await.unwrap();
8650///
8651/// # let client = hyper_util::client::legacy::Client::builder(
8652/// #     hyper_util::rt::TokioExecutor::new()
8653/// # )
8654/// # .build(
8655/// #     hyper_rustls::HttpsConnectorBuilder::new()
8656/// #         .with_native_roots()
8657/// #         .unwrap()
8658/// #         .https_or_http()
8659/// #         .enable_http2()
8660/// #         .build()
8661/// # );
8662/// # let mut hub = AndroidPublisher::new(client, auth);
8663/// // You can configure optional parameters by calling the respective setters at will, and
8664/// // execute the final call using `doit()`.
8665/// // Values shown here are possibly random and not representative !
8666/// let result = hub.edits().expansionfiles_get("packageName", "editId", -49, "expansionFileType")
8667///              .doit().await;
8668/// # }
8669/// ```
8670pub struct EditExpansionfileGetCall<'a, C>
8671where
8672    C: 'a,
8673{
8674    hub: &'a AndroidPublisher<C>,
8675    _package_name: String,
8676    _edit_id: String,
8677    _apk_version_code: i32,
8678    _expansion_file_type: String,
8679    _delegate: Option<&'a mut dyn common::Delegate>,
8680    _additional_params: HashMap<String, String>,
8681    _scopes: BTreeSet<String>,
8682}
8683
8684impl<'a, C> common::CallBuilder for EditExpansionfileGetCall<'a, C> {}
8685
8686impl<'a, C> EditExpansionfileGetCall<'a, C>
8687where
8688    C: common::Connector,
8689{
8690    /// Perform the operation you have build so far.
8691    pub async fn doit(mut self) -> common::Result<(common::Response, ExpansionFile)> {
8692        use std::borrow::Cow;
8693        use std::io::{Read, Seek};
8694
8695        use common::{url::Params, ToParts};
8696        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8697
8698        let mut dd = common::DefaultDelegate;
8699        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8700        dlg.begin(common::MethodInfo {
8701            id: "androidpublisher.edits.expansionfiles.get",
8702            http_method: hyper::Method::GET,
8703        });
8704
8705        for &field in [
8706            "alt",
8707            "packageName",
8708            "editId",
8709            "apkVersionCode",
8710            "expansionFileType",
8711        ]
8712        .iter()
8713        {
8714            if self._additional_params.contains_key(field) {
8715                dlg.finished(false);
8716                return Err(common::Error::FieldClash(field));
8717            }
8718        }
8719
8720        let mut params = Params::with_capacity(6 + self._additional_params.len());
8721        params.push("packageName", self._package_name);
8722        params.push("editId", self._edit_id);
8723        params.push("apkVersionCode", self._apk_version_code.to_string());
8724        params.push("expansionFileType", self._expansion_file_type);
8725
8726        params.extend(self._additional_params.iter());
8727
8728        params.push("alt", "json");
8729        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}";
8730        if self._scopes.is_empty() {
8731            self._scopes.insert(Scope::Full.as_ref().to_string());
8732        }
8733
8734        #[allow(clippy::single_element_loop)]
8735        for &(find_this, param_name) in [
8736            ("{packageName}", "packageName"),
8737            ("{editId}", "editId"),
8738            ("{apkVersionCode}", "apkVersionCode"),
8739            ("{expansionFileType}", "expansionFileType"),
8740        ]
8741        .iter()
8742        {
8743            url = params.uri_replacement(url, param_name, find_this, false);
8744        }
8745        {
8746            let to_remove = [
8747                "expansionFileType",
8748                "apkVersionCode",
8749                "editId",
8750                "packageName",
8751            ];
8752            params.remove_params(&to_remove);
8753        }
8754
8755        let url = params.parse_with_url(&url);
8756
8757        loop {
8758            let token = match self
8759                .hub
8760                .auth
8761                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8762                .await
8763            {
8764                Ok(token) => token,
8765                Err(e) => match dlg.token(e) {
8766                    Ok(token) => token,
8767                    Err(e) => {
8768                        dlg.finished(false);
8769                        return Err(common::Error::MissingToken(e));
8770                    }
8771                },
8772            };
8773            let mut req_result = {
8774                let client = &self.hub.client;
8775                dlg.pre_request();
8776                let mut req_builder = hyper::Request::builder()
8777                    .method(hyper::Method::GET)
8778                    .uri(url.as_str())
8779                    .header(USER_AGENT, self.hub._user_agent.clone());
8780
8781                if let Some(token) = token.as_ref() {
8782                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8783                }
8784
8785                let request = req_builder
8786                    .header(CONTENT_LENGTH, 0_u64)
8787                    .body(common::to_body::<String>(None));
8788
8789                client.request(request.unwrap()).await
8790            };
8791
8792            match req_result {
8793                Err(err) => {
8794                    if let common::Retry::After(d) = dlg.http_error(&err) {
8795                        sleep(d).await;
8796                        continue;
8797                    }
8798                    dlg.finished(false);
8799                    return Err(common::Error::HttpError(err));
8800                }
8801                Ok(res) => {
8802                    let (mut parts, body) = res.into_parts();
8803                    let mut body = common::Body::new(body);
8804                    if !parts.status.is_success() {
8805                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8806                        let error = serde_json::from_str(&common::to_string(&bytes));
8807                        let response = common::to_response(parts, bytes.into());
8808
8809                        if let common::Retry::After(d) =
8810                            dlg.http_failure(&response, error.as_ref().ok())
8811                        {
8812                            sleep(d).await;
8813                            continue;
8814                        }
8815
8816                        dlg.finished(false);
8817
8818                        return Err(match error {
8819                            Ok(value) => common::Error::BadRequest(value),
8820                            _ => common::Error::Failure(response),
8821                        });
8822                    }
8823                    let response = {
8824                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8825                        let encoded = common::to_string(&bytes);
8826                        match serde_json::from_str(&encoded) {
8827                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8828                            Err(error) => {
8829                                dlg.response_json_decode_error(&encoded, &error);
8830                                return Err(common::Error::JsonDecodeError(
8831                                    encoded.to_string(),
8832                                    error,
8833                                ));
8834                            }
8835                        }
8836                    };
8837
8838                    dlg.finished(true);
8839                    return Ok(response);
8840                }
8841            }
8842        }
8843    }
8844
8845    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
8846    ///
8847    /// Sets the *package name* path property to the given value.
8848    ///
8849    /// Even though the property as already been set when instantiating this call,
8850    /// we provide this method for API completeness.
8851    pub fn package_name(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C> {
8852        self._package_name = new_value.to_string();
8853        self
8854    }
8855    /// Unique identifier for this edit.
8856    ///
8857    /// Sets the *edit id* path property to the given value.
8858    ///
8859    /// Even though the property as already been set when instantiating this call,
8860    /// we provide this method for API completeness.
8861    pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C> {
8862        self._edit_id = new_value.to_string();
8863        self
8864    }
8865    /// The version code of the APK whose Expansion File configuration is being read or modified.
8866    ///
8867    /// Sets the *apk version code* path property to the given value.
8868    ///
8869    /// Even though the property as already been set when instantiating this call,
8870    /// we provide this method for API completeness.
8871    pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileGetCall<'a, C> {
8872        self._apk_version_code = new_value;
8873        self
8874    }
8875    ///
8876    /// Sets the *expansion file type* path property to the given value.
8877    ///
8878    /// Even though the property as already been set when instantiating this call,
8879    /// we provide this method for API completeness.
8880    pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C> {
8881        self._expansion_file_type = new_value.to_string();
8882        self
8883    }
8884    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8885    /// while executing the actual API request.
8886    ///
8887    /// ````text
8888    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8889    /// ````
8890    ///
8891    /// Sets the *delegate* property to the given value.
8892    pub fn delegate(
8893        mut self,
8894        new_value: &'a mut dyn common::Delegate,
8895    ) -> EditExpansionfileGetCall<'a, C> {
8896        self._delegate = Some(new_value);
8897        self
8898    }
8899
8900    /// Set any additional parameter of the query string used in the request.
8901    /// It should be used to set parameters which are not yet available through their own
8902    /// setters.
8903    ///
8904    /// Please note that this method must not be used to set any of the known parameters
8905    /// which have their own setter method. If done anyway, the request will fail.
8906    ///
8907    /// # Additional Parameters
8908    ///
8909    /// * *alt* (query-string) - Data format for the response.
8910    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8911    /// * *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.
8912    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8913    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8914    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8915    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8916    pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileGetCall<'a, C>
8917    where
8918        T: AsRef<str>,
8919    {
8920        self._additional_params
8921            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8922        self
8923    }
8924
8925    /// Identifies the authorization scope for the method you are building.
8926    ///
8927    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8928    /// [`Scope::Full`].
8929    ///
8930    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8931    /// tokens for more than one scope.
8932    ///
8933    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8934    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8935    /// sufficient, a read-write scope will do as well.
8936    pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfileGetCall<'a, C>
8937    where
8938        St: AsRef<str>,
8939    {
8940        self._scopes.insert(String::from(scope.as_ref()));
8941        self
8942    }
8943    /// Identifies the authorization scope(s) for the method you are building.
8944    ///
8945    /// See [`Self::add_scope()`] for details.
8946    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfileGetCall<'a, C>
8947    where
8948        I: IntoIterator<Item = St>,
8949        St: AsRef<str>,
8950    {
8951        self._scopes
8952            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8953        self
8954    }
8955
8956    /// Removes all scopes, and no default scope will be used either.
8957    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8958    /// for details).
8959    pub fn clear_scopes(mut self) -> EditExpansionfileGetCall<'a, C> {
8960        self._scopes.clear();
8961        self
8962    }
8963}
8964
8965/// Updates the APK's Expansion File configuration to reference another APK's Expansion Files. To add a new Expansion File use the Upload method. This method supports patch semantics.
8966///
8967/// A builder for the *expansionfiles.patch* method supported by a *edit* resource.
8968/// It is not used directly, but through a [`EditMethods`] instance.
8969///
8970/// # Example
8971///
8972/// Instantiate a resource method builder
8973///
8974/// ```test_harness,no_run
8975/// # extern crate hyper;
8976/// # extern crate hyper_rustls;
8977/// # extern crate google_androidpublisher2 as androidpublisher2;
8978/// use androidpublisher2::api::ExpansionFile;
8979/// # async fn dox() {
8980/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8981///
8982/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8983/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8984/// #     .with_native_roots()
8985/// #     .unwrap()
8986/// #     .https_only()
8987/// #     .enable_http2()
8988/// #     .build();
8989///
8990/// # let executor = hyper_util::rt::TokioExecutor::new();
8991/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8992/// #     secret,
8993/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8994/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8995/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8996/// #     ),
8997/// # ).build().await.unwrap();
8998///
8999/// # let client = hyper_util::client::legacy::Client::builder(
9000/// #     hyper_util::rt::TokioExecutor::new()
9001/// # )
9002/// # .build(
9003/// #     hyper_rustls::HttpsConnectorBuilder::new()
9004/// #         .with_native_roots()
9005/// #         .unwrap()
9006/// #         .https_or_http()
9007/// #         .enable_http2()
9008/// #         .build()
9009/// # );
9010/// # let mut hub = AndroidPublisher::new(client, auth);
9011/// // As the method needs a request, you would usually fill it with the desired information
9012/// // into the respective structure. Some of the parts shown here might not be applicable !
9013/// // Values shown here are possibly random and not representative !
9014/// let mut req = ExpansionFile::default();
9015///
9016/// // You can configure optional parameters by calling the respective setters at will, and
9017/// // execute the final call using `doit()`.
9018/// // Values shown here are possibly random and not representative !
9019/// let result = hub.edits().expansionfiles_patch(req, "packageName", "editId", -15, "expansionFileType")
9020///              .doit().await;
9021/// # }
9022/// ```
9023pub struct EditExpansionfilePatchCall<'a, C>
9024where
9025    C: 'a,
9026{
9027    hub: &'a AndroidPublisher<C>,
9028    _request: ExpansionFile,
9029    _package_name: String,
9030    _edit_id: String,
9031    _apk_version_code: i32,
9032    _expansion_file_type: String,
9033    _delegate: Option<&'a mut dyn common::Delegate>,
9034    _additional_params: HashMap<String, String>,
9035    _scopes: BTreeSet<String>,
9036}
9037
9038impl<'a, C> common::CallBuilder for EditExpansionfilePatchCall<'a, C> {}
9039
9040impl<'a, C> EditExpansionfilePatchCall<'a, C>
9041where
9042    C: common::Connector,
9043{
9044    /// Perform the operation you have build so far.
9045    pub async fn doit(mut self) -> common::Result<(common::Response, ExpansionFile)> {
9046        use std::borrow::Cow;
9047        use std::io::{Read, Seek};
9048
9049        use common::{url::Params, ToParts};
9050        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9051
9052        let mut dd = common::DefaultDelegate;
9053        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9054        dlg.begin(common::MethodInfo {
9055            id: "androidpublisher.edits.expansionfiles.patch",
9056            http_method: hyper::Method::PATCH,
9057        });
9058
9059        for &field in [
9060            "alt",
9061            "packageName",
9062            "editId",
9063            "apkVersionCode",
9064            "expansionFileType",
9065        ]
9066        .iter()
9067        {
9068            if self._additional_params.contains_key(field) {
9069                dlg.finished(false);
9070                return Err(common::Error::FieldClash(field));
9071            }
9072        }
9073
9074        let mut params = Params::with_capacity(7 + self._additional_params.len());
9075        params.push("packageName", self._package_name);
9076        params.push("editId", self._edit_id);
9077        params.push("apkVersionCode", self._apk_version_code.to_string());
9078        params.push("expansionFileType", self._expansion_file_type);
9079
9080        params.extend(self._additional_params.iter());
9081
9082        params.push("alt", "json");
9083        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}";
9084        if self._scopes.is_empty() {
9085            self._scopes.insert(Scope::Full.as_ref().to_string());
9086        }
9087
9088        #[allow(clippy::single_element_loop)]
9089        for &(find_this, param_name) in [
9090            ("{packageName}", "packageName"),
9091            ("{editId}", "editId"),
9092            ("{apkVersionCode}", "apkVersionCode"),
9093            ("{expansionFileType}", "expansionFileType"),
9094        ]
9095        .iter()
9096        {
9097            url = params.uri_replacement(url, param_name, find_this, false);
9098        }
9099        {
9100            let to_remove = [
9101                "expansionFileType",
9102                "apkVersionCode",
9103                "editId",
9104                "packageName",
9105            ];
9106            params.remove_params(&to_remove);
9107        }
9108
9109        let url = params.parse_with_url(&url);
9110
9111        let mut json_mime_type = mime::APPLICATION_JSON;
9112        let mut request_value_reader = {
9113            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9114            common::remove_json_null_values(&mut value);
9115            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9116            serde_json::to_writer(&mut dst, &value).unwrap();
9117            dst
9118        };
9119        let request_size = request_value_reader
9120            .seek(std::io::SeekFrom::End(0))
9121            .unwrap();
9122        request_value_reader
9123            .seek(std::io::SeekFrom::Start(0))
9124            .unwrap();
9125
9126        loop {
9127            let token = match self
9128                .hub
9129                .auth
9130                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9131                .await
9132            {
9133                Ok(token) => token,
9134                Err(e) => match dlg.token(e) {
9135                    Ok(token) => token,
9136                    Err(e) => {
9137                        dlg.finished(false);
9138                        return Err(common::Error::MissingToken(e));
9139                    }
9140                },
9141            };
9142            request_value_reader
9143                .seek(std::io::SeekFrom::Start(0))
9144                .unwrap();
9145            let mut req_result = {
9146                let client = &self.hub.client;
9147                dlg.pre_request();
9148                let mut req_builder = hyper::Request::builder()
9149                    .method(hyper::Method::PATCH)
9150                    .uri(url.as_str())
9151                    .header(USER_AGENT, self.hub._user_agent.clone());
9152
9153                if let Some(token) = token.as_ref() {
9154                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9155                }
9156
9157                let request = req_builder
9158                    .header(CONTENT_TYPE, json_mime_type.to_string())
9159                    .header(CONTENT_LENGTH, request_size as u64)
9160                    .body(common::to_body(
9161                        request_value_reader.get_ref().clone().into(),
9162                    ));
9163
9164                client.request(request.unwrap()).await
9165            };
9166
9167            match req_result {
9168                Err(err) => {
9169                    if let common::Retry::After(d) = dlg.http_error(&err) {
9170                        sleep(d).await;
9171                        continue;
9172                    }
9173                    dlg.finished(false);
9174                    return Err(common::Error::HttpError(err));
9175                }
9176                Ok(res) => {
9177                    let (mut parts, body) = res.into_parts();
9178                    let mut body = common::Body::new(body);
9179                    if !parts.status.is_success() {
9180                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9181                        let error = serde_json::from_str(&common::to_string(&bytes));
9182                        let response = common::to_response(parts, bytes.into());
9183
9184                        if let common::Retry::After(d) =
9185                            dlg.http_failure(&response, error.as_ref().ok())
9186                        {
9187                            sleep(d).await;
9188                            continue;
9189                        }
9190
9191                        dlg.finished(false);
9192
9193                        return Err(match error {
9194                            Ok(value) => common::Error::BadRequest(value),
9195                            _ => common::Error::Failure(response),
9196                        });
9197                    }
9198                    let response = {
9199                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9200                        let encoded = common::to_string(&bytes);
9201                        match serde_json::from_str(&encoded) {
9202                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9203                            Err(error) => {
9204                                dlg.response_json_decode_error(&encoded, &error);
9205                                return Err(common::Error::JsonDecodeError(
9206                                    encoded.to_string(),
9207                                    error,
9208                                ));
9209                            }
9210                        }
9211                    };
9212
9213                    dlg.finished(true);
9214                    return Ok(response);
9215                }
9216            }
9217        }
9218    }
9219
9220    ///
9221    /// Sets the *request* property to the given value.
9222    ///
9223    /// Even though the property as already been set when instantiating this call,
9224    /// we provide this method for API completeness.
9225    pub fn request(mut self, new_value: ExpansionFile) -> EditExpansionfilePatchCall<'a, C> {
9226        self._request = new_value;
9227        self
9228    }
9229    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
9230    ///
9231    /// Sets the *package name* path property to the given value.
9232    ///
9233    /// Even though the property as already been set when instantiating this call,
9234    /// we provide this method for API completeness.
9235    pub fn package_name(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C> {
9236        self._package_name = new_value.to_string();
9237        self
9238    }
9239    /// Unique identifier for this edit.
9240    ///
9241    /// Sets the *edit id* path property to the given value.
9242    ///
9243    /// Even though the property as already been set when instantiating this call,
9244    /// we provide this method for API completeness.
9245    pub fn edit_id(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C> {
9246        self._edit_id = new_value.to_string();
9247        self
9248    }
9249    /// The version code of the APK whose Expansion File configuration is being read or modified.
9250    ///
9251    /// Sets the *apk version code* path property to the given value.
9252    ///
9253    /// Even though the property as already been set when instantiating this call,
9254    /// we provide this method for API completeness.
9255    pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfilePatchCall<'a, C> {
9256        self._apk_version_code = new_value;
9257        self
9258    }
9259    ///
9260    /// Sets the *expansion file type* path property to the given value.
9261    ///
9262    /// Even though the property as already been set when instantiating this call,
9263    /// we provide this method for API completeness.
9264    pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C> {
9265        self._expansion_file_type = new_value.to_string();
9266        self
9267    }
9268    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9269    /// while executing the actual API request.
9270    ///
9271    /// ````text
9272    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9273    /// ````
9274    ///
9275    /// Sets the *delegate* property to the given value.
9276    pub fn delegate(
9277        mut self,
9278        new_value: &'a mut dyn common::Delegate,
9279    ) -> EditExpansionfilePatchCall<'a, C> {
9280        self._delegate = Some(new_value);
9281        self
9282    }
9283
9284    /// Set any additional parameter of the query string used in the request.
9285    /// It should be used to set parameters which are not yet available through their own
9286    /// setters.
9287    ///
9288    /// Please note that this method must not be used to set any of the known parameters
9289    /// which have their own setter method. If done anyway, the request will fail.
9290    ///
9291    /// # Additional Parameters
9292    ///
9293    /// * *alt* (query-string) - Data format for the response.
9294    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9295    /// * *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.
9296    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9297    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9298    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9299    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9300    pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfilePatchCall<'a, C>
9301    where
9302        T: AsRef<str>,
9303    {
9304        self._additional_params
9305            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9306        self
9307    }
9308
9309    /// Identifies the authorization scope for the method you are building.
9310    ///
9311    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9312    /// [`Scope::Full`].
9313    ///
9314    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9315    /// tokens for more than one scope.
9316    ///
9317    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9318    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9319    /// sufficient, a read-write scope will do as well.
9320    pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfilePatchCall<'a, C>
9321    where
9322        St: AsRef<str>,
9323    {
9324        self._scopes.insert(String::from(scope.as_ref()));
9325        self
9326    }
9327    /// Identifies the authorization scope(s) for the method you are building.
9328    ///
9329    /// See [`Self::add_scope()`] for details.
9330    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfilePatchCall<'a, C>
9331    where
9332        I: IntoIterator<Item = St>,
9333        St: AsRef<str>,
9334    {
9335        self._scopes
9336            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9337        self
9338    }
9339
9340    /// Removes all scopes, and no default scope will be used either.
9341    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9342    /// for details).
9343    pub fn clear_scopes(mut self) -> EditExpansionfilePatchCall<'a, C> {
9344        self._scopes.clear();
9345        self
9346    }
9347}
9348
9349/// Updates the APK's Expansion File configuration to reference another APK's Expansion Files. To add a new Expansion File use the Upload method.
9350///
9351/// A builder for the *expansionfiles.update* method supported by a *edit* resource.
9352/// It is not used directly, but through a [`EditMethods`] instance.
9353///
9354/// # Example
9355///
9356/// Instantiate a resource method builder
9357///
9358/// ```test_harness,no_run
9359/// # extern crate hyper;
9360/// # extern crate hyper_rustls;
9361/// # extern crate google_androidpublisher2 as androidpublisher2;
9362/// use androidpublisher2::api::ExpansionFile;
9363/// # async fn dox() {
9364/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9365///
9366/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9367/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9368/// #     .with_native_roots()
9369/// #     .unwrap()
9370/// #     .https_only()
9371/// #     .enable_http2()
9372/// #     .build();
9373///
9374/// # let executor = hyper_util::rt::TokioExecutor::new();
9375/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9376/// #     secret,
9377/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9378/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9379/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9380/// #     ),
9381/// # ).build().await.unwrap();
9382///
9383/// # let client = hyper_util::client::legacy::Client::builder(
9384/// #     hyper_util::rt::TokioExecutor::new()
9385/// # )
9386/// # .build(
9387/// #     hyper_rustls::HttpsConnectorBuilder::new()
9388/// #         .with_native_roots()
9389/// #         .unwrap()
9390/// #         .https_or_http()
9391/// #         .enable_http2()
9392/// #         .build()
9393/// # );
9394/// # let mut hub = AndroidPublisher::new(client, auth);
9395/// // As the method needs a request, you would usually fill it with the desired information
9396/// // into the respective structure. Some of the parts shown here might not be applicable !
9397/// // Values shown here are possibly random and not representative !
9398/// let mut req = ExpansionFile::default();
9399///
9400/// // You can configure optional parameters by calling the respective setters at will, and
9401/// // execute the final call using `doit()`.
9402/// // Values shown here are possibly random and not representative !
9403/// let result = hub.edits().expansionfiles_update(req, "packageName", "editId", -76, "expansionFileType")
9404///              .doit().await;
9405/// # }
9406/// ```
9407pub struct EditExpansionfileUpdateCall<'a, C>
9408where
9409    C: 'a,
9410{
9411    hub: &'a AndroidPublisher<C>,
9412    _request: ExpansionFile,
9413    _package_name: String,
9414    _edit_id: String,
9415    _apk_version_code: i32,
9416    _expansion_file_type: String,
9417    _delegate: Option<&'a mut dyn common::Delegate>,
9418    _additional_params: HashMap<String, String>,
9419    _scopes: BTreeSet<String>,
9420}
9421
9422impl<'a, C> common::CallBuilder for EditExpansionfileUpdateCall<'a, C> {}
9423
9424impl<'a, C> EditExpansionfileUpdateCall<'a, C>
9425where
9426    C: common::Connector,
9427{
9428    /// Perform the operation you have build so far.
9429    pub async fn doit(mut self) -> common::Result<(common::Response, ExpansionFile)> {
9430        use std::borrow::Cow;
9431        use std::io::{Read, Seek};
9432
9433        use common::{url::Params, ToParts};
9434        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9435
9436        let mut dd = common::DefaultDelegate;
9437        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9438        dlg.begin(common::MethodInfo {
9439            id: "androidpublisher.edits.expansionfiles.update",
9440            http_method: hyper::Method::PUT,
9441        });
9442
9443        for &field in [
9444            "alt",
9445            "packageName",
9446            "editId",
9447            "apkVersionCode",
9448            "expansionFileType",
9449        ]
9450        .iter()
9451        {
9452            if self._additional_params.contains_key(field) {
9453                dlg.finished(false);
9454                return Err(common::Error::FieldClash(field));
9455            }
9456        }
9457
9458        let mut params = Params::with_capacity(7 + self._additional_params.len());
9459        params.push("packageName", self._package_name);
9460        params.push("editId", self._edit_id);
9461        params.push("apkVersionCode", self._apk_version_code.to_string());
9462        params.push("expansionFileType", self._expansion_file_type);
9463
9464        params.extend(self._additional_params.iter());
9465
9466        params.push("alt", "json");
9467        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}";
9468        if self._scopes.is_empty() {
9469            self._scopes.insert(Scope::Full.as_ref().to_string());
9470        }
9471
9472        #[allow(clippy::single_element_loop)]
9473        for &(find_this, param_name) in [
9474            ("{packageName}", "packageName"),
9475            ("{editId}", "editId"),
9476            ("{apkVersionCode}", "apkVersionCode"),
9477            ("{expansionFileType}", "expansionFileType"),
9478        ]
9479        .iter()
9480        {
9481            url = params.uri_replacement(url, param_name, find_this, false);
9482        }
9483        {
9484            let to_remove = [
9485                "expansionFileType",
9486                "apkVersionCode",
9487                "editId",
9488                "packageName",
9489            ];
9490            params.remove_params(&to_remove);
9491        }
9492
9493        let url = params.parse_with_url(&url);
9494
9495        let mut json_mime_type = mime::APPLICATION_JSON;
9496        let mut request_value_reader = {
9497            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9498            common::remove_json_null_values(&mut value);
9499            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9500            serde_json::to_writer(&mut dst, &value).unwrap();
9501            dst
9502        };
9503        let request_size = request_value_reader
9504            .seek(std::io::SeekFrom::End(0))
9505            .unwrap();
9506        request_value_reader
9507            .seek(std::io::SeekFrom::Start(0))
9508            .unwrap();
9509
9510        loop {
9511            let token = match self
9512                .hub
9513                .auth
9514                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9515                .await
9516            {
9517                Ok(token) => token,
9518                Err(e) => match dlg.token(e) {
9519                    Ok(token) => token,
9520                    Err(e) => {
9521                        dlg.finished(false);
9522                        return Err(common::Error::MissingToken(e));
9523                    }
9524                },
9525            };
9526            request_value_reader
9527                .seek(std::io::SeekFrom::Start(0))
9528                .unwrap();
9529            let mut req_result = {
9530                let client = &self.hub.client;
9531                dlg.pre_request();
9532                let mut req_builder = hyper::Request::builder()
9533                    .method(hyper::Method::PUT)
9534                    .uri(url.as_str())
9535                    .header(USER_AGENT, self.hub._user_agent.clone());
9536
9537                if let Some(token) = token.as_ref() {
9538                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9539                }
9540
9541                let request = req_builder
9542                    .header(CONTENT_TYPE, json_mime_type.to_string())
9543                    .header(CONTENT_LENGTH, request_size as u64)
9544                    .body(common::to_body(
9545                        request_value_reader.get_ref().clone().into(),
9546                    ));
9547
9548                client.request(request.unwrap()).await
9549            };
9550
9551            match req_result {
9552                Err(err) => {
9553                    if let common::Retry::After(d) = dlg.http_error(&err) {
9554                        sleep(d).await;
9555                        continue;
9556                    }
9557                    dlg.finished(false);
9558                    return Err(common::Error::HttpError(err));
9559                }
9560                Ok(res) => {
9561                    let (mut parts, body) = res.into_parts();
9562                    let mut body = common::Body::new(body);
9563                    if !parts.status.is_success() {
9564                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9565                        let error = serde_json::from_str(&common::to_string(&bytes));
9566                        let response = common::to_response(parts, bytes.into());
9567
9568                        if let common::Retry::After(d) =
9569                            dlg.http_failure(&response, error.as_ref().ok())
9570                        {
9571                            sleep(d).await;
9572                            continue;
9573                        }
9574
9575                        dlg.finished(false);
9576
9577                        return Err(match error {
9578                            Ok(value) => common::Error::BadRequest(value),
9579                            _ => common::Error::Failure(response),
9580                        });
9581                    }
9582                    let response = {
9583                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9584                        let encoded = common::to_string(&bytes);
9585                        match serde_json::from_str(&encoded) {
9586                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9587                            Err(error) => {
9588                                dlg.response_json_decode_error(&encoded, &error);
9589                                return Err(common::Error::JsonDecodeError(
9590                                    encoded.to_string(),
9591                                    error,
9592                                ));
9593                            }
9594                        }
9595                    };
9596
9597                    dlg.finished(true);
9598                    return Ok(response);
9599                }
9600            }
9601        }
9602    }
9603
9604    ///
9605    /// Sets the *request* property to the given value.
9606    ///
9607    /// Even though the property as already been set when instantiating this call,
9608    /// we provide this method for API completeness.
9609    pub fn request(mut self, new_value: ExpansionFile) -> EditExpansionfileUpdateCall<'a, C> {
9610        self._request = new_value;
9611        self
9612    }
9613    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
9614    ///
9615    /// Sets the *package name* path property to the given value.
9616    ///
9617    /// Even though the property as already been set when instantiating this call,
9618    /// we provide this method for API completeness.
9619    pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C> {
9620        self._package_name = new_value.to_string();
9621        self
9622    }
9623    /// Unique identifier for this edit.
9624    ///
9625    /// Sets the *edit id* path property to the given value.
9626    ///
9627    /// Even though the property as already been set when instantiating this call,
9628    /// we provide this method for API completeness.
9629    pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C> {
9630        self._edit_id = new_value.to_string();
9631        self
9632    }
9633    /// The version code of the APK whose Expansion File configuration is being read or modified.
9634    ///
9635    /// Sets the *apk version code* path property to the given value.
9636    ///
9637    /// Even though the property as already been set when instantiating this call,
9638    /// we provide this method for API completeness.
9639    pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUpdateCall<'a, C> {
9640        self._apk_version_code = new_value;
9641        self
9642    }
9643    ///
9644    /// Sets the *expansion file type* path property to the given value.
9645    ///
9646    /// Even though the property as already been set when instantiating this call,
9647    /// we provide this method for API completeness.
9648    pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C> {
9649        self._expansion_file_type = new_value.to_string();
9650        self
9651    }
9652    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9653    /// while executing the actual API request.
9654    ///
9655    /// ````text
9656    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9657    /// ````
9658    ///
9659    /// Sets the *delegate* property to the given value.
9660    pub fn delegate(
9661        mut self,
9662        new_value: &'a mut dyn common::Delegate,
9663    ) -> EditExpansionfileUpdateCall<'a, C> {
9664        self._delegate = Some(new_value);
9665        self
9666    }
9667
9668    /// Set any additional parameter of the query string used in the request.
9669    /// It should be used to set parameters which are not yet available through their own
9670    /// setters.
9671    ///
9672    /// Please note that this method must not be used to set any of the known parameters
9673    /// which have their own setter method. If done anyway, the request will fail.
9674    ///
9675    /// # Additional Parameters
9676    ///
9677    /// * *alt* (query-string) - Data format for the response.
9678    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9679    /// * *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.
9680    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9681    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9682    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9683    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9684    pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileUpdateCall<'a, C>
9685    where
9686        T: AsRef<str>,
9687    {
9688        self._additional_params
9689            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9690        self
9691    }
9692
9693    /// Identifies the authorization scope for the method you are building.
9694    ///
9695    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9696    /// [`Scope::Full`].
9697    ///
9698    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9699    /// tokens for more than one scope.
9700    ///
9701    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9702    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9703    /// sufficient, a read-write scope will do as well.
9704    pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfileUpdateCall<'a, C>
9705    where
9706        St: AsRef<str>,
9707    {
9708        self._scopes.insert(String::from(scope.as_ref()));
9709        self
9710    }
9711    /// Identifies the authorization scope(s) for the method you are building.
9712    ///
9713    /// See [`Self::add_scope()`] for details.
9714    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfileUpdateCall<'a, C>
9715    where
9716        I: IntoIterator<Item = St>,
9717        St: AsRef<str>,
9718    {
9719        self._scopes
9720            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9721        self
9722    }
9723
9724    /// Removes all scopes, and no default scope will be used either.
9725    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9726    /// for details).
9727    pub fn clear_scopes(mut self) -> EditExpansionfileUpdateCall<'a, C> {
9728        self._scopes.clear();
9729        self
9730    }
9731}
9732
9733/// Uploads and attaches a new Expansion File to the APK specified.
9734///
9735/// A builder for the *expansionfiles.upload* method supported by a *edit* resource.
9736/// It is not used directly, but through a [`EditMethods`] instance.
9737///
9738/// # Example
9739///
9740/// Instantiate a resource method builder
9741///
9742/// ```test_harness,no_run
9743/// # extern crate hyper;
9744/// # extern crate hyper_rustls;
9745/// # extern crate google_androidpublisher2 as androidpublisher2;
9746/// use std::fs;
9747/// # async fn dox() {
9748/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9749///
9750/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9751/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9752/// #     .with_native_roots()
9753/// #     .unwrap()
9754/// #     .https_only()
9755/// #     .enable_http2()
9756/// #     .build();
9757///
9758/// # let executor = hyper_util::rt::TokioExecutor::new();
9759/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9760/// #     secret,
9761/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9762/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9763/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9764/// #     ),
9765/// # ).build().await.unwrap();
9766///
9767/// # let client = hyper_util::client::legacy::Client::builder(
9768/// #     hyper_util::rt::TokioExecutor::new()
9769/// # )
9770/// # .build(
9771/// #     hyper_rustls::HttpsConnectorBuilder::new()
9772/// #         .with_native_roots()
9773/// #         .unwrap()
9774/// #         .https_or_http()
9775/// #         .enable_http2()
9776/// #         .build()
9777/// # );
9778/// # let mut hub = AndroidPublisher::new(client, auth);
9779/// // You can configure optional parameters by calling the respective setters at will, and
9780/// // execute the final call using `upload(...)`.
9781/// // Values shown here are possibly random and not representative !
9782/// let result = hub.edits().expansionfiles_upload("packageName", "editId", -44, "expansionFileType")
9783///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
9784/// # }
9785/// ```
9786pub struct EditExpansionfileUploadCall<'a, C>
9787where
9788    C: 'a,
9789{
9790    hub: &'a AndroidPublisher<C>,
9791    _package_name: String,
9792    _edit_id: String,
9793    _apk_version_code: i32,
9794    _expansion_file_type: String,
9795    _delegate: Option<&'a mut dyn common::Delegate>,
9796    _additional_params: HashMap<String, String>,
9797    _scopes: BTreeSet<String>,
9798}
9799
9800impl<'a, C> common::CallBuilder for EditExpansionfileUploadCall<'a, C> {}
9801
9802impl<'a, C> EditExpansionfileUploadCall<'a, C>
9803where
9804    C: common::Connector,
9805{
9806    /// Perform the operation you have build so far.
9807    async fn doit<RS>(
9808        mut self,
9809        mut reader: RS,
9810        reader_mime_type: mime::Mime,
9811        protocol: common::UploadProtocol,
9812    ) -> common::Result<(common::Response, ExpansionFilesUploadResponse)>
9813    where
9814        RS: common::ReadSeek,
9815    {
9816        use std::borrow::Cow;
9817        use std::io::{Read, Seek};
9818
9819        use common::{url::Params, ToParts};
9820        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9821
9822        let mut dd = common::DefaultDelegate;
9823        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9824        dlg.begin(common::MethodInfo {
9825            id: "androidpublisher.edits.expansionfiles.upload",
9826            http_method: hyper::Method::POST,
9827        });
9828
9829        for &field in [
9830            "alt",
9831            "packageName",
9832            "editId",
9833            "apkVersionCode",
9834            "expansionFileType",
9835        ]
9836        .iter()
9837        {
9838            if self._additional_params.contains_key(field) {
9839                dlg.finished(false);
9840                return Err(common::Error::FieldClash(field));
9841            }
9842        }
9843
9844        let mut params = Params::with_capacity(6 + self._additional_params.len());
9845        params.push("packageName", self._package_name);
9846        params.push("editId", self._edit_id);
9847        params.push("apkVersionCode", self._apk_version_code.to_string());
9848        params.push("expansionFileType", self._expansion_file_type);
9849
9850        params.extend(self._additional_params.iter());
9851
9852        params.push("alt", "json");
9853        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
9854            (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}", "resumable")
9855        } else if protocol == common::UploadProtocol::Simple {
9856            (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}", "multipart")
9857        } else {
9858            unreachable!()
9859        };
9860        params.push("uploadType", upload_type);
9861        if self._scopes.is_empty() {
9862            self._scopes.insert(Scope::Full.as_ref().to_string());
9863        }
9864
9865        #[allow(clippy::single_element_loop)]
9866        for &(find_this, param_name) in [
9867            ("{packageName}", "packageName"),
9868            ("{editId}", "editId"),
9869            ("{apkVersionCode}", "apkVersionCode"),
9870            ("{expansionFileType}", "expansionFileType"),
9871        ]
9872        .iter()
9873        {
9874            url = params.uri_replacement(url, param_name, find_this, false);
9875        }
9876        {
9877            let to_remove = [
9878                "expansionFileType",
9879                "apkVersionCode",
9880                "editId",
9881                "packageName",
9882            ];
9883            params.remove_params(&to_remove);
9884        }
9885
9886        let url = params.parse_with_url(&url);
9887
9888        let mut upload_url_from_server;
9889
9890        loop {
9891            let token = match self
9892                .hub
9893                .auth
9894                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9895                .await
9896            {
9897                Ok(token) => token,
9898                Err(e) => match dlg.token(e) {
9899                    Ok(token) => token,
9900                    Err(e) => {
9901                        dlg.finished(false);
9902                        return Err(common::Error::MissingToken(e));
9903                    }
9904                },
9905            };
9906            let mut req_result = {
9907                let client = &self.hub.client;
9908                dlg.pre_request();
9909                let mut req_builder = hyper::Request::builder()
9910                    .method(hyper::Method::POST)
9911                    .uri(url.as_str())
9912                    .header(USER_AGENT, self.hub._user_agent.clone());
9913
9914                if let Some(token) = token.as_ref() {
9915                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9916                }
9917
9918                upload_url_from_server = true;
9919                if protocol == common::UploadProtocol::Resumable {
9920                    req_builder = req_builder
9921                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
9922                }
9923
9924                let request = if protocol == common::UploadProtocol::Simple {
9925                    let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
9926                    reader.seek(std::io::SeekFrom::Start(0)).unwrap();
9927                    if size > 2147483648 {
9928                        return Err(common::Error::UploadSizeLimitExceeded(size, 2147483648));
9929                    }
9930                    let mut bytes = Vec::with_capacity(size as usize);
9931                    reader.read_to_end(&mut bytes)?;
9932                    req_builder
9933                        .header(CONTENT_TYPE, reader_mime_type.to_string())
9934                        .header(CONTENT_LENGTH, size)
9935                        .body(common::to_body(bytes.into()))
9936                } else {
9937                    req_builder.body(common::to_body::<String>(None))
9938                };
9939
9940                client.request(request.unwrap()).await
9941            };
9942
9943            match req_result {
9944                Err(err) => {
9945                    if let common::Retry::After(d) = dlg.http_error(&err) {
9946                        sleep(d).await;
9947                        continue;
9948                    }
9949                    dlg.finished(false);
9950                    return Err(common::Error::HttpError(err));
9951                }
9952                Ok(res) => {
9953                    let (mut parts, body) = res.into_parts();
9954                    let mut body = common::Body::new(body);
9955                    if !parts.status.is_success() {
9956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9957                        let error = serde_json::from_str(&common::to_string(&bytes));
9958                        let response = common::to_response(parts, bytes.into());
9959
9960                        if let common::Retry::After(d) =
9961                            dlg.http_failure(&response, error.as_ref().ok())
9962                        {
9963                            sleep(d).await;
9964                            continue;
9965                        }
9966
9967                        dlg.finished(false);
9968
9969                        return Err(match error {
9970                            Ok(value) => common::Error::BadRequest(value),
9971                            _ => common::Error::Failure(response),
9972                        });
9973                    }
9974                    if protocol == common::UploadProtocol::Resumable {
9975                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
9976                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
9977                        if size > 2147483648 {
9978                            return Err(common::Error::UploadSizeLimitExceeded(size, 2147483648));
9979                        }
9980                        let upload_result = {
9981                            let url_str = &parts
9982                                .headers
9983                                .get("Location")
9984                                .expect("LOCATION header is part of protocol")
9985                                .to_str()
9986                                .unwrap();
9987                            if upload_url_from_server {
9988                                dlg.store_upload_url(Some(url_str));
9989                            }
9990
9991                            common::ResumableUploadHelper {
9992                                client: &self.hub.client,
9993                                delegate: dlg,
9994                                start_at: if upload_url_from_server {
9995                                    Some(0)
9996                                } else {
9997                                    None
9998                                },
9999                                auth: &self.hub.auth,
10000                                user_agent: &self.hub._user_agent,
10001                                // TODO: Check this assumption
10002                                auth_header: format!(
10003                                    "Bearer {}",
10004                                    token
10005                                        .ok_or_else(|| common::Error::MissingToken(
10006                                            "resumable upload requires token".into()
10007                                        ))?
10008                                        .as_str()
10009                                ),
10010                                url: url_str,
10011                                reader: &mut reader,
10012                                media_type: reader_mime_type.clone(),
10013                                content_length: size,
10014                            }
10015                            .upload()
10016                            .await
10017                        };
10018                        match upload_result {
10019                            None => {
10020                                dlg.finished(false);
10021                                return Err(common::Error::Cancelled);
10022                            }
10023                            Some(Err(err)) => {
10024                                dlg.finished(false);
10025                                return Err(common::Error::HttpError(err));
10026                            }
10027                            Some(Ok(response)) => {
10028                                (parts, body) = response.into_parts();
10029                                if !parts.status.is_success() {
10030                                    dlg.store_upload_url(None);
10031                                    dlg.finished(false);
10032                                    return Err(common::Error::Failure(
10033                                        common::Response::from_parts(parts, body),
10034                                    ));
10035                                }
10036                            }
10037                        }
10038                    }
10039                    let response = {
10040                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10041                        let encoded = common::to_string(&bytes);
10042                        match serde_json::from_str(&encoded) {
10043                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10044                            Err(error) => {
10045                                dlg.response_json_decode_error(&encoded, &error);
10046                                return Err(common::Error::JsonDecodeError(
10047                                    encoded.to_string(),
10048                                    error,
10049                                ));
10050                            }
10051                        }
10052                    };
10053
10054                    dlg.finished(true);
10055                    return Ok(response);
10056                }
10057            }
10058        }
10059    }
10060
10061    /// Upload media in a resumable fashion.
10062    /// Even if the upload fails or is interrupted, it can be resumed for a
10063    /// certain amount of time as the server maintains state temporarily.
10064    ///
10065    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
10066    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
10067    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
10068    /// `cancel_chunk_upload(...)`.
10069    ///
10070    /// * *multipart*: yes
10071    /// * *max size*: 2048MB
10072    /// * *valid mime types*: 'application/octet-stream'
10073    pub async fn upload_resumable<RS>(
10074        self,
10075        resumeable_stream: RS,
10076        mime_type: mime::Mime,
10077    ) -> common::Result<(common::Response, ExpansionFilesUploadResponse)>
10078    where
10079        RS: common::ReadSeek,
10080    {
10081        self.doit(
10082            resumeable_stream,
10083            mime_type,
10084            common::UploadProtocol::Resumable,
10085        )
10086        .await
10087    }
10088    /// Upload media all at once.
10089    /// If the upload fails for whichever reason, all progress is lost.
10090    ///
10091    /// * *multipart*: yes
10092    /// * *max size*: 2048MB
10093    /// * *valid mime types*: 'application/octet-stream'
10094    pub async fn upload<RS>(
10095        self,
10096        stream: RS,
10097        mime_type: mime::Mime,
10098    ) -> common::Result<(common::Response, ExpansionFilesUploadResponse)>
10099    where
10100        RS: common::ReadSeek,
10101    {
10102        self.doit(stream, mime_type, common::UploadProtocol::Simple)
10103            .await
10104    }
10105
10106    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
10107    ///
10108    /// Sets the *package name* path property to the given value.
10109    ///
10110    /// Even though the property as already been set when instantiating this call,
10111    /// we provide this method for API completeness.
10112    pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C> {
10113        self._package_name = new_value.to_string();
10114        self
10115    }
10116    /// Unique identifier for this edit.
10117    ///
10118    /// Sets the *edit id* path property to the given value.
10119    ///
10120    /// Even though the property as already been set when instantiating this call,
10121    /// we provide this method for API completeness.
10122    pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C> {
10123        self._edit_id = new_value.to_string();
10124        self
10125    }
10126    /// The version code of the APK whose Expansion File configuration is being read or modified.
10127    ///
10128    /// Sets the *apk version code* path property to the given value.
10129    ///
10130    /// Even though the property as already been set when instantiating this call,
10131    /// we provide this method for API completeness.
10132    pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUploadCall<'a, C> {
10133        self._apk_version_code = new_value;
10134        self
10135    }
10136    ///
10137    /// Sets the *expansion file type* path property to the given value.
10138    ///
10139    /// Even though the property as already been set when instantiating this call,
10140    /// we provide this method for API completeness.
10141    pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C> {
10142        self._expansion_file_type = new_value.to_string();
10143        self
10144    }
10145    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10146    /// while executing the actual API request.
10147    ///
10148    /// ````text
10149    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10150    /// ````
10151    ///
10152    /// Sets the *delegate* property to the given value.
10153    pub fn delegate(
10154        mut self,
10155        new_value: &'a mut dyn common::Delegate,
10156    ) -> EditExpansionfileUploadCall<'a, C> {
10157        self._delegate = Some(new_value);
10158        self
10159    }
10160
10161    /// Set any additional parameter of the query string used in the request.
10162    /// It should be used to set parameters which are not yet available through their own
10163    /// setters.
10164    ///
10165    /// Please note that this method must not be used to set any of the known parameters
10166    /// which have their own setter method. If done anyway, the request will fail.
10167    ///
10168    /// # Additional Parameters
10169    ///
10170    /// * *alt* (query-string) - Data format for the response.
10171    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10172    /// * *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.
10173    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10174    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10175    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10176    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10177    pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileUploadCall<'a, C>
10178    where
10179        T: AsRef<str>,
10180    {
10181        self._additional_params
10182            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10183        self
10184    }
10185
10186    /// Identifies the authorization scope for the method you are building.
10187    ///
10188    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10189    /// [`Scope::Full`].
10190    ///
10191    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10192    /// tokens for more than one scope.
10193    ///
10194    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10195    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10196    /// sufficient, a read-write scope will do as well.
10197    pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfileUploadCall<'a, C>
10198    where
10199        St: AsRef<str>,
10200    {
10201        self._scopes.insert(String::from(scope.as_ref()));
10202        self
10203    }
10204    /// Identifies the authorization scope(s) for the method you are building.
10205    ///
10206    /// See [`Self::add_scope()`] for details.
10207    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfileUploadCall<'a, C>
10208    where
10209        I: IntoIterator<Item = St>,
10210        St: AsRef<str>,
10211    {
10212        self._scopes
10213            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10214        self
10215    }
10216
10217    /// Removes all scopes, and no default scope will be used either.
10218    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10219    /// for details).
10220    pub fn clear_scopes(mut self) -> EditExpansionfileUploadCall<'a, C> {
10221        self._scopes.clear();
10222        self
10223    }
10224}
10225
10226/// Deletes the image (specified by id) from the edit.
10227///
10228/// A builder for the *images.delete* method supported by a *edit* resource.
10229/// It is not used directly, but through a [`EditMethods`] instance.
10230///
10231/// # Example
10232///
10233/// Instantiate a resource method builder
10234///
10235/// ```test_harness,no_run
10236/// # extern crate hyper;
10237/// # extern crate hyper_rustls;
10238/// # extern crate google_androidpublisher2 as androidpublisher2;
10239/// # async fn dox() {
10240/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10241///
10242/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10243/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10244/// #     .with_native_roots()
10245/// #     .unwrap()
10246/// #     .https_only()
10247/// #     .enable_http2()
10248/// #     .build();
10249///
10250/// # let executor = hyper_util::rt::TokioExecutor::new();
10251/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10252/// #     secret,
10253/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10254/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10255/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10256/// #     ),
10257/// # ).build().await.unwrap();
10258///
10259/// # let client = hyper_util::client::legacy::Client::builder(
10260/// #     hyper_util::rt::TokioExecutor::new()
10261/// # )
10262/// # .build(
10263/// #     hyper_rustls::HttpsConnectorBuilder::new()
10264/// #         .with_native_roots()
10265/// #         .unwrap()
10266/// #         .https_or_http()
10267/// #         .enable_http2()
10268/// #         .build()
10269/// # );
10270/// # let mut hub = AndroidPublisher::new(client, auth);
10271/// // You can configure optional parameters by calling the respective setters at will, and
10272/// // execute the final call using `doit()`.
10273/// // Values shown here are possibly random and not representative !
10274/// let result = hub.edits().images_delete("packageName", "editId", "language", "imageType", "imageId")
10275///              .doit().await;
10276/// # }
10277/// ```
10278pub struct EditImageDeleteCall<'a, C>
10279where
10280    C: 'a,
10281{
10282    hub: &'a AndroidPublisher<C>,
10283    _package_name: String,
10284    _edit_id: String,
10285    _language: String,
10286    _image_type: String,
10287    _image_id: String,
10288    _delegate: Option<&'a mut dyn common::Delegate>,
10289    _additional_params: HashMap<String, String>,
10290    _scopes: BTreeSet<String>,
10291}
10292
10293impl<'a, C> common::CallBuilder for EditImageDeleteCall<'a, C> {}
10294
10295impl<'a, C> EditImageDeleteCall<'a, C>
10296where
10297    C: common::Connector,
10298{
10299    /// Perform the operation you have build so far.
10300    pub async fn doit(mut self) -> common::Result<common::Response> {
10301        use std::borrow::Cow;
10302        use std::io::{Read, Seek};
10303
10304        use common::{url::Params, ToParts};
10305        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10306
10307        let mut dd = common::DefaultDelegate;
10308        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10309        dlg.begin(common::MethodInfo {
10310            id: "androidpublisher.edits.images.delete",
10311            http_method: hyper::Method::DELETE,
10312        });
10313
10314        for &field in ["packageName", "editId", "language", "imageType", "imageId"].iter() {
10315            if self._additional_params.contains_key(field) {
10316                dlg.finished(false);
10317                return Err(common::Error::FieldClash(field));
10318            }
10319        }
10320
10321        let mut params = Params::with_capacity(6 + self._additional_params.len());
10322        params.push("packageName", self._package_name);
10323        params.push("editId", self._edit_id);
10324        params.push("language", self._language);
10325        params.push("imageType", self._image_type);
10326        params.push("imageId", self._image_id);
10327
10328        params.extend(self._additional_params.iter());
10329
10330        let mut url = self.hub._base_url.clone()
10331            + "{packageName}/edits/{editId}/listings/{language}/{imageType}/{imageId}";
10332        if self._scopes.is_empty() {
10333            self._scopes.insert(Scope::Full.as_ref().to_string());
10334        }
10335
10336        #[allow(clippy::single_element_loop)]
10337        for &(find_this, param_name) in [
10338            ("{packageName}", "packageName"),
10339            ("{editId}", "editId"),
10340            ("{language}", "language"),
10341            ("{imageType}", "imageType"),
10342            ("{imageId}", "imageId"),
10343        ]
10344        .iter()
10345        {
10346            url = params.uri_replacement(url, param_name, find_this, false);
10347        }
10348        {
10349            let to_remove = ["imageId", "imageType", "language", "editId", "packageName"];
10350            params.remove_params(&to_remove);
10351        }
10352
10353        let url = params.parse_with_url(&url);
10354
10355        loop {
10356            let token = match self
10357                .hub
10358                .auth
10359                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10360                .await
10361            {
10362                Ok(token) => token,
10363                Err(e) => match dlg.token(e) {
10364                    Ok(token) => token,
10365                    Err(e) => {
10366                        dlg.finished(false);
10367                        return Err(common::Error::MissingToken(e));
10368                    }
10369                },
10370            };
10371            let mut req_result = {
10372                let client = &self.hub.client;
10373                dlg.pre_request();
10374                let mut req_builder = hyper::Request::builder()
10375                    .method(hyper::Method::DELETE)
10376                    .uri(url.as_str())
10377                    .header(USER_AGENT, self.hub._user_agent.clone());
10378
10379                if let Some(token) = token.as_ref() {
10380                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10381                }
10382
10383                let request = req_builder
10384                    .header(CONTENT_LENGTH, 0_u64)
10385                    .body(common::to_body::<String>(None));
10386
10387                client.request(request.unwrap()).await
10388            };
10389
10390            match req_result {
10391                Err(err) => {
10392                    if let common::Retry::After(d) = dlg.http_error(&err) {
10393                        sleep(d).await;
10394                        continue;
10395                    }
10396                    dlg.finished(false);
10397                    return Err(common::Error::HttpError(err));
10398                }
10399                Ok(res) => {
10400                    let (mut parts, body) = res.into_parts();
10401                    let mut body = common::Body::new(body);
10402                    if !parts.status.is_success() {
10403                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10404                        let error = serde_json::from_str(&common::to_string(&bytes));
10405                        let response = common::to_response(parts, bytes.into());
10406
10407                        if let common::Retry::After(d) =
10408                            dlg.http_failure(&response, error.as_ref().ok())
10409                        {
10410                            sleep(d).await;
10411                            continue;
10412                        }
10413
10414                        dlg.finished(false);
10415
10416                        return Err(match error {
10417                            Ok(value) => common::Error::BadRequest(value),
10418                            _ => common::Error::Failure(response),
10419                        });
10420                    }
10421                    let response = common::Response::from_parts(parts, body);
10422
10423                    dlg.finished(true);
10424                    return Ok(response);
10425                }
10426            }
10427        }
10428    }
10429
10430    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
10431    ///
10432    /// Sets the *package name* path property to the given value.
10433    ///
10434    /// Even though the property as already been set when instantiating this call,
10435    /// we provide this method for API completeness.
10436    pub fn package_name(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
10437        self._package_name = new_value.to_string();
10438        self
10439    }
10440    /// Unique identifier for this edit.
10441    ///
10442    /// Sets the *edit id* path property to the given value.
10443    ///
10444    /// Even though the property as already been set when instantiating this call,
10445    /// we provide this method for API completeness.
10446    pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
10447        self._edit_id = new_value.to_string();
10448        self
10449    }
10450    /// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
10451    ///
10452    /// Sets the *language* path property to the given value.
10453    ///
10454    /// Even though the property as already been set when instantiating this call,
10455    /// we provide this method for API completeness.
10456    pub fn language(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
10457        self._language = new_value.to_string();
10458        self
10459    }
10460    ///
10461    /// Sets the *image type* path property to the given value.
10462    ///
10463    /// Even though the property as already been set when instantiating this call,
10464    /// we provide this method for API completeness.
10465    pub fn image_type(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
10466        self._image_type = new_value.to_string();
10467        self
10468    }
10469    /// Unique identifier an image within the set of images attached to this edit.
10470    ///
10471    /// Sets the *image id* path property to the given value.
10472    ///
10473    /// Even though the property as already been set when instantiating this call,
10474    /// we provide this method for API completeness.
10475    pub fn image_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
10476        self._image_id = new_value.to_string();
10477        self
10478    }
10479    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10480    /// while executing the actual API request.
10481    ///
10482    /// ````text
10483    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10484    /// ````
10485    ///
10486    /// Sets the *delegate* property to the given value.
10487    pub fn delegate(
10488        mut self,
10489        new_value: &'a mut dyn common::Delegate,
10490    ) -> EditImageDeleteCall<'a, C> {
10491        self._delegate = Some(new_value);
10492        self
10493    }
10494
10495    /// Set any additional parameter of the query string used in the request.
10496    /// It should be used to set parameters which are not yet available through their own
10497    /// setters.
10498    ///
10499    /// Please note that this method must not be used to set any of the known parameters
10500    /// which have their own setter method. If done anyway, the request will fail.
10501    ///
10502    /// # Additional Parameters
10503    ///
10504    /// * *alt* (query-string) - Data format for the response.
10505    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10506    /// * *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.
10507    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10508    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10509    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10510    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10511    pub fn param<T>(mut self, name: T, value: T) -> EditImageDeleteCall<'a, C>
10512    where
10513        T: AsRef<str>,
10514    {
10515        self._additional_params
10516            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10517        self
10518    }
10519
10520    /// Identifies the authorization scope for the method you are building.
10521    ///
10522    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10523    /// [`Scope::Full`].
10524    ///
10525    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10526    /// tokens for more than one scope.
10527    ///
10528    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10529    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10530    /// sufficient, a read-write scope will do as well.
10531    pub fn add_scope<St>(mut self, scope: St) -> EditImageDeleteCall<'a, C>
10532    where
10533        St: AsRef<str>,
10534    {
10535        self._scopes.insert(String::from(scope.as_ref()));
10536        self
10537    }
10538    /// Identifies the authorization scope(s) for the method you are building.
10539    ///
10540    /// See [`Self::add_scope()`] for details.
10541    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageDeleteCall<'a, C>
10542    where
10543        I: IntoIterator<Item = St>,
10544        St: AsRef<str>,
10545    {
10546        self._scopes
10547            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10548        self
10549    }
10550
10551    /// Removes all scopes, and no default scope will be used either.
10552    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10553    /// for details).
10554    pub fn clear_scopes(mut self) -> EditImageDeleteCall<'a, C> {
10555        self._scopes.clear();
10556        self
10557    }
10558}
10559
10560/// Deletes all images for the specified language and image type.
10561///
10562/// A builder for the *images.deleteall* method supported by a *edit* resource.
10563/// It is not used directly, but through a [`EditMethods`] instance.
10564///
10565/// # Example
10566///
10567/// Instantiate a resource method builder
10568///
10569/// ```test_harness,no_run
10570/// # extern crate hyper;
10571/// # extern crate hyper_rustls;
10572/// # extern crate google_androidpublisher2 as androidpublisher2;
10573/// # async fn dox() {
10574/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10575///
10576/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10577/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10578/// #     .with_native_roots()
10579/// #     .unwrap()
10580/// #     .https_only()
10581/// #     .enable_http2()
10582/// #     .build();
10583///
10584/// # let executor = hyper_util::rt::TokioExecutor::new();
10585/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10586/// #     secret,
10587/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10588/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10589/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10590/// #     ),
10591/// # ).build().await.unwrap();
10592///
10593/// # let client = hyper_util::client::legacy::Client::builder(
10594/// #     hyper_util::rt::TokioExecutor::new()
10595/// # )
10596/// # .build(
10597/// #     hyper_rustls::HttpsConnectorBuilder::new()
10598/// #         .with_native_roots()
10599/// #         .unwrap()
10600/// #         .https_or_http()
10601/// #         .enable_http2()
10602/// #         .build()
10603/// # );
10604/// # let mut hub = AndroidPublisher::new(client, auth);
10605/// // You can configure optional parameters by calling the respective setters at will, and
10606/// // execute the final call using `doit()`.
10607/// // Values shown here are possibly random and not representative !
10608/// let result = hub.edits().images_deleteall("packageName", "editId", "language", "imageType")
10609///              .doit().await;
10610/// # }
10611/// ```
10612pub struct EditImageDeleteallCall<'a, C>
10613where
10614    C: 'a,
10615{
10616    hub: &'a AndroidPublisher<C>,
10617    _package_name: String,
10618    _edit_id: String,
10619    _language: String,
10620    _image_type: String,
10621    _delegate: Option<&'a mut dyn common::Delegate>,
10622    _additional_params: HashMap<String, String>,
10623    _scopes: BTreeSet<String>,
10624}
10625
10626impl<'a, C> common::CallBuilder for EditImageDeleteallCall<'a, C> {}
10627
10628impl<'a, C> EditImageDeleteallCall<'a, C>
10629where
10630    C: common::Connector,
10631{
10632    /// Perform the operation you have build so far.
10633    pub async fn doit(mut self) -> common::Result<(common::Response, ImagesDeleteAllResponse)> {
10634        use std::borrow::Cow;
10635        use std::io::{Read, Seek};
10636
10637        use common::{url::Params, ToParts};
10638        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10639
10640        let mut dd = common::DefaultDelegate;
10641        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10642        dlg.begin(common::MethodInfo {
10643            id: "androidpublisher.edits.images.deleteall",
10644            http_method: hyper::Method::DELETE,
10645        });
10646
10647        for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
10648            if self._additional_params.contains_key(field) {
10649                dlg.finished(false);
10650                return Err(common::Error::FieldClash(field));
10651            }
10652        }
10653
10654        let mut params = Params::with_capacity(6 + self._additional_params.len());
10655        params.push("packageName", self._package_name);
10656        params.push("editId", self._edit_id);
10657        params.push("language", self._language);
10658        params.push("imageType", self._image_type);
10659
10660        params.extend(self._additional_params.iter());
10661
10662        params.push("alt", "json");
10663        let mut url = self.hub._base_url.clone()
10664            + "{packageName}/edits/{editId}/listings/{language}/{imageType}";
10665        if self._scopes.is_empty() {
10666            self._scopes.insert(Scope::Full.as_ref().to_string());
10667        }
10668
10669        #[allow(clippy::single_element_loop)]
10670        for &(find_this, param_name) in [
10671            ("{packageName}", "packageName"),
10672            ("{editId}", "editId"),
10673            ("{language}", "language"),
10674            ("{imageType}", "imageType"),
10675        ]
10676        .iter()
10677        {
10678            url = params.uri_replacement(url, param_name, find_this, false);
10679        }
10680        {
10681            let to_remove = ["imageType", "language", "editId", "packageName"];
10682            params.remove_params(&to_remove);
10683        }
10684
10685        let url = params.parse_with_url(&url);
10686
10687        loop {
10688            let token = match self
10689                .hub
10690                .auth
10691                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10692                .await
10693            {
10694                Ok(token) => token,
10695                Err(e) => match dlg.token(e) {
10696                    Ok(token) => token,
10697                    Err(e) => {
10698                        dlg.finished(false);
10699                        return Err(common::Error::MissingToken(e));
10700                    }
10701                },
10702            };
10703            let mut req_result = {
10704                let client = &self.hub.client;
10705                dlg.pre_request();
10706                let mut req_builder = hyper::Request::builder()
10707                    .method(hyper::Method::DELETE)
10708                    .uri(url.as_str())
10709                    .header(USER_AGENT, self.hub._user_agent.clone());
10710
10711                if let Some(token) = token.as_ref() {
10712                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10713                }
10714
10715                let request = req_builder
10716                    .header(CONTENT_LENGTH, 0_u64)
10717                    .body(common::to_body::<String>(None));
10718
10719                client.request(request.unwrap()).await
10720            };
10721
10722            match req_result {
10723                Err(err) => {
10724                    if let common::Retry::After(d) = dlg.http_error(&err) {
10725                        sleep(d).await;
10726                        continue;
10727                    }
10728                    dlg.finished(false);
10729                    return Err(common::Error::HttpError(err));
10730                }
10731                Ok(res) => {
10732                    let (mut parts, body) = res.into_parts();
10733                    let mut body = common::Body::new(body);
10734                    if !parts.status.is_success() {
10735                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10736                        let error = serde_json::from_str(&common::to_string(&bytes));
10737                        let response = common::to_response(parts, bytes.into());
10738
10739                        if let common::Retry::After(d) =
10740                            dlg.http_failure(&response, error.as_ref().ok())
10741                        {
10742                            sleep(d).await;
10743                            continue;
10744                        }
10745
10746                        dlg.finished(false);
10747
10748                        return Err(match error {
10749                            Ok(value) => common::Error::BadRequest(value),
10750                            _ => common::Error::Failure(response),
10751                        });
10752                    }
10753                    let response = {
10754                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10755                        let encoded = common::to_string(&bytes);
10756                        match serde_json::from_str(&encoded) {
10757                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10758                            Err(error) => {
10759                                dlg.response_json_decode_error(&encoded, &error);
10760                                return Err(common::Error::JsonDecodeError(
10761                                    encoded.to_string(),
10762                                    error,
10763                                ));
10764                            }
10765                        }
10766                    };
10767
10768                    dlg.finished(true);
10769                    return Ok(response);
10770                }
10771            }
10772        }
10773    }
10774
10775    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
10776    ///
10777    /// Sets the *package name* path property to the given value.
10778    ///
10779    /// Even though the property as already been set when instantiating this call,
10780    /// we provide this method for API completeness.
10781    pub fn package_name(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
10782        self._package_name = new_value.to_string();
10783        self
10784    }
10785    /// Unique identifier for this edit.
10786    ///
10787    /// Sets the *edit id* path property to the given value.
10788    ///
10789    /// Even though the property as already been set when instantiating this call,
10790    /// we provide this method for API completeness.
10791    pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
10792        self._edit_id = new_value.to_string();
10793        self
10794    }
10795    /// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
10796    ///
10797    /// Sets the *language* path property to the given value.
10798    ///
10799    /// Even though the property as already been set when instantiating this call,
10800    /// we provide this method for API completeness.
10801    pub fn language(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
10802        self._language = new_value.to_string();
10803        self
10804    }
10805    ///
10806    /// Sets the *image type* path property to the given value.
10807    ///
10808    /// Even though the property as already been set when instantiating this call,
10809    /// we provide this method for API completeness.
10810    pub fn image_type(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
10811        self._image_type = new_value.to_string();
10812        self
10813    }
10814    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10815    /// while executing the actual API request.
10816    ///
10817    /// ````text
10818    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10819    /// ````
10820    ///
10821    /// Sets the *delegate* property to the given value.
10822    pub fn delegate(
10823        mut self,
10824        new_value: &'a mut dyn common::Delegate,
10825    ) -> EditImageDeleteallCall<'a, C> {
10826        self._delegate = Some(new_value);
10827        self
10828    }
10829
10830    /// Set any additional parameter of the query string used in the request.
10831    /// It should be used to set parameters which are not yet available through their own
10832    /// setters.
10833    ///
10834    /// Please note that this method must not be used to set any of the known parameters
10835    /// which have their own setter method. If done anyway, the request will fail.
10836    ///
10837    /// # Additional Parameters
10838    ///
10839    /// * *alt* (query-string) - Data format for the response.
10840    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10841    /// * *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.
10842    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10843    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10844    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10845    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10846    pub fn param<T>(mut self, name: T, value: T) -> EditImageDeleteallCall<'a, C>
10847    where
10848        T: AsRef<str>,
10849    {
10850        self._additional_params
10851            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10852        self
10853    }
10854
10855    /// Identifies the authorization scope for the method you are building.
10856    ///
10857    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10858    /// [`Scope::Full`].
10859    ///
10860    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10861    /// tokens for more than one scope.
10862    ///
10863    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10864    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10865    /// sufficient, a read-write scope will do as well.
10866    pub fn add_scope<St>(mut self, scope: St) -> EditImageDeleteallCall<'a, C>
10867    where
10868        St: AsRef<str>,
10869    {
10870        self._scopes.insert(String::from(scope.as_ref()));
10871        self
10872    }
10873    /// Identifies the authorization scope(s) for the method you are building.
10874    ///
10875    /// See [`Self::add_scope()`] for details.
10876    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageDeleteallCall<'a, C>
10877    where
10878        I: IntoIterator<Item = St>,
10879        St: AsRef<str>,
10880    {
10881        self._scopes
10882            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10883        self
10884    }
10885
10886    /// Removes all scopes, and no default scope will be used either.
10887    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10888    /// for details).
10889    pub fn clear_scopes(mut self) -> EditImageDeleteallCall<'a, C> {
10890        self._scopes.clear();
10891        self
10892    }
10893}
10894
10895/// Lists all images for the specified language and image type.
10896///
10897/// A builder for the *images.list* method supported by a *edit* resource.
10898/// It is not used directly, but through a [`EditMethods`] instance.
10899///
10900/// # Example
10901///
10902/// Instantiate a resource method builder
10903///
10904/// ```test_harness,no_run
10905/// # extern crate hyper;
10906/// # extern crate hyper_rustls;
10907/// # extern crate google_androidpublisher2 as androidpublisher2;
10908/// # async fn dox() {
10909/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10910///
10911/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10912/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10913/// #     .with_native_roots()
10914/// #     .unwrap()
10915/// #     .https_only()
10916/// #     .enable_http2()
10917/// #     .build();
10918///
10919/// # let executor = hyper_util::rt::TokioExecutor::new();
10920/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10921/// #     secret,
10922/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10923/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10924/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10925/// #     ),
10926/// # ).build().await.unwrap();
10927///
10928/// # let client = hyper_util::client::legacy::Client::builder(
10929/// #     hyper_util::rt::TokioExecutor::new()
10930/// # )
10931/// # .build(
10932/// #     hyper_rustls::HttpsConnectorBuilder::new()
10933/// #         .with_native_roots()
10934/// #         .unwrap()
10935/// #         .https_or_http()
10936/// #         .enable_http2()
10937/// #         .build()
10938/// # );
10939/// # let mut hub = AndroidPublisher::new(client, auth);
10940/// // You can configure optional parameters by calling the respective setters at will, and
10941/// // execute the final call using `doit()`.
10942/// // Values shown here are possibly random and not representative !
10943/// let result = hub.edits().images_list("packageName", "editId", "language", "imageType")
10944///              .doit().await;
10945/// # }
10946/// ```
10947pub struct EditImageListCall<'a, C>
10948where
10949    C: 'a,
10950{
10951    hub: &'a AndroidPublisher<C>,
10952    _package_name: String,
10953    _edit_id: String,
10954    _language: String,
10955    _image_type: String,
10956    _delegate: Option<&'a mut dyn common::Delegate>,
10957    _additional_params: HashMap<String, String>,
10958    _scopes: BTreeSet<String>,
10959}
10960
10961impl<'a, C> common::CallBuilder for EditImageListCall<'a, C> {}
10962
10963impl<'a, C> EditImageListCall<'a, C>
10964where
10965    C: common::Connector,
10966{
10967    /// Perform the operation you have build so far.
10968    pub async fn doit(mut self) -> common::Result<(common::Response, ImagesListResponse)> {
10969        use std::borrow::Cow;
10970        use std::io::{Read, Seek};
10971
10972        use common::{url::Params, ToParts};
10973        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10974
10975        let mut dd = common::DefaultDelegate;
10976        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10977        dlg.begin(common::MethodInfo {
10978            id: "androidpublisher.edits.images.list",
10979            http_method: hyper::Method::GET,
10980        });
10981
10982        for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
10983            if self._additional_params.contains_key(field) {
10984                dlg.finished(false);
10985                return Err(common::Error::FieldClash(field));
10986            }
10987        }
10988
10989        let mut params = Params::with_capacity(6 + self._additional_params.len());
10990        params.push("packageName", self._package_name);
10991        params.push("editId", self._edit_id);
10992        params.push("language", self._language);
10993        params.push("imageType", self._image_type);
10994
10995        params.extend(self._additional_params.iter());
10996
10997        params.push("alt", "json");
10998        let mut url = self.hub._base_url.clone()
10999            + "{packageName}/edits/{editId}/listings/{language}/{imageType}";
11000        if self._scopes.is_empty() {
11001            self._scopes.insert(Scope::Full.as_ref().to_string());
11002        }
11003
11004        #[allow(clippy::single_element_loop)]
11005        for &(find_this, param_name) in [
11006            ("{packageName}", "packageName"),
11007            ("{editId}", "editId"),
11008            ("{language}", "language"),
11009            ("{imageType}", "imageType"),
11010        ]
11011        .iter()
11012        {
11013            url = params.uri_replacement(url, param_name, find_this, false);
11014        }
11015        {
11016            let to_remove = ["imageType", "language", "editId", "packageName"];
11017            params.remove_params(&to_remove);
11018        }
11019
11020        let url = params.parse_with_url(&url);
11021
11022        loop {
11023            let token = match self
11024                .hub
11025                .auth
11026                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11027                .await
11028            {
11029                Ok(token) => token,
11030                Err(e) => match dlg.token(e) {
11031                    Ok(token) => token,
11032                    Err(e) => {
11033                        dlg.finished(false);
11034                        return Err(common::Error::MissingToken(e));
11035                    }
11036                },
11037            };
11038            let mut req_result = {
11039                let client = &self.hub.client;
11040                dlg.pre_request();
11041                let mut req_builder = hyper::Request::builder()
11042                    .method(hyper::Method::GET)
11043                    .uri(url.as_str())
11044                    .header(USER_AGENT, self.hub._user_agent.clone());
11045
11046                if let Some(token) = token.as_ref() {
11047                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11048                }
11049
11050                let request = req_builder
11051                    .header(CONTENT_LENGTH, 0_u64)
11052                    .body(common::to_body::<String>(None));
11053
11054                client.request(request.unwrap()).await
11055            };
11056
11057            match req_result {
11058                Err(err) => {
11059                    if let common::Retry::After(d) = dlg.http_error(&err) {
11060                        sleep(d).await;
11061                        continue;
11062                    }
11063                    dlg.finished(false);
11064                    return Err(common::Error::HttpError(err));
11065                }
11066                Ok(res) => {
11067                    let (mut parts, body) = res.into_parts();
11068                    let mut body = common::Body::new(body);
11069                    if !parts.status.is_success() {
11070                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11071                        let error = serde_json::from_str(&common::to_string(&bytes));
11072                        let response = common::to_response(parts, bytes.into());
11073
11074                        if let common::Retry::After(d) =
11075                            dlg.http_failure(&response, error.as_ref().ok())
11076                        {
11077                            sleep(d).await;
11078                            continue;
11079                        }
11080
11081                        dlg.finished(false);
11082
11083                        return Err(match error {
11084                            Ok(value) => common::Error::BadRequest(value),
11085                            _ => common::Error::Failure(response),
11086                        });
11087                    }
11088                    let response = {
11089                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11090                        let encoded = common::to_string(&bytes);
11091                        match serde_json::from_str(&encoded) {
11092                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11093                            Err(error) => {
11094                                dlg.response_json_decode_error(&encoded, &error);
11095                                return Err(common::Error::JsonDecodeError(
11096                                    encoded.to_string(),
11097                                    error,
11098                                ));
11099                            }
11100                        }
11101                    };
11102
11103                    dlg.finished(true);
11104                    return Ok(response);
11105                }
11106            }
11107        }
11108    }
11109
11110    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
11111    ///
11112    /// Sets the *package name* path property to the given value.
11113    ///
11114    /// Even though the property as already been set when instantiating this call,
11115    /// we provide this method for API completeness.
11116    pub fn package_name(mut self, new_value: &str) -> EditImageListCall<'a, C> {
11117        self._package_name = new_value.to_string();
11118        self
11119    }
11120    /// Unique identifier for this edit.
11121    ///
11122    /// Sets the *edit id* path property to the given value.
11123    ///
11124    /// Even though the property as already been set when instantiating this call,
11125    /// we provide this method for API completeness.
11126    pub fn edit_id(mut self, new_value: &str) -> EditImageListCall<'a, C> {
11127        self._edit_id = new_value.to_string();
11128        self
11129    }
11130    /// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
11131    ///
11132    /// Sets the *language* path property to the given value.
11133    ///
11134    /// Even though the property as already been set when instantiating this call,
11135    /// we provide this method for API completeness.
11136    pub fn language(mut self, new_value: &str) -> EditImageListCall<'a, C> {
11137        self._language = new_value.to_string();
11138        self
11139    }
11140    ///
11141    /// Sets the *image type* path property to the given value.
11142    ///
11143    /// Even though the property as already been set when instantiating this call,
11144    /// we provide this method for API completeness.
11145    pub fn image_type(mut self, new_value: &str) -> EditImageListCall<'a, C> {
11146        self._image_type = new_value.to_string();
11147        self
11148    }
11149    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11150    /// while executing the actual API request.
11151    ///
11152    /// ````text
11153    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11154    /// ````
11155    ///
11156    /// Sets the *delegate* property to the given value.
11157    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditImageListCall<'a, C> {
11158        self._delegate = Some(new_value);
11159        self
11160    }
11161
11162    /// Set any additional parameter of the query string used in the request.
11163    /// It should be used to set parameters which are not yet available through their own
11164    /// setters.
11165    ///
11166    /// Please note that this method must not be used to set any of the known parameters
11167    /// which have their own setter method. If done anyway, the request will fail.
11168    ///
11169    /// # Additional Parameters
11170    ///
11171    /// * *alt* (query-string) - Data format for the response.
11172    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11173    /// * *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.
11174    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11175    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11176    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11177    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11178    pub fn param<T>(mut self, name: T, value: T) -> EditImageListCall<'a, C>
11179    where
11180        T: AsRef<str>,
11181    {
11182        self._additional_params
11183            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11184        self
11185    }
11186
11187    /// Identifies the authorization scope for the method you are building.
11188    ///
11189    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11190    /// [`Scope::Full`].
11191    ///
11192    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11193    /// tokens for more than one scope.
11194    ///
11195    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11196    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11197    /// sufficient, a read-write scope will do as well.
11198    pub fn add_scope<St>(mut self, scope: St) -> EditImageListCall<'a, C>
11199    where
11200        St: AsRef<str>,
11201    {
11202        self._scopes.insert(String::from(scope.as_ref()));
11203        self
11204    }
11205    /// Identifies the authorization scope(s) for the method you are building.
11206    ///
11207    /// See [`Self::add_scope()`] for details.
11208    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageListCall<'a, C>
11209    where
11210        I: IntoIterator<Item = St>,
11211        St: AsRef<str>,
11212    {
11213        self._scopes
11214            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11215        self
11216    }
11217
11218    /// Removes all scopes, and no default scope will be used either.
11219    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11220    /// for details).
11221    pub fn clear_scopes(mut self) -> EditImageListCall<'a, C> {
11222        self._scopes.clear();
11223        self
11224    }
11225}
11226
11227/// Uploads a new image and adds it to the list of images for the specified language and image type.
11228///
11229/// A builder for the *images.upload* method supported by a *edit* resource.
11230/// It is not used directly, but through a [`EditMethods`] instance.
11231///
11232/// # Example
11233///
11234/// Instantiate a resource method builder
11235///
11236/// ```test_harness,no_run
11237/// # extern crate hyper;
11238/// # extern crate hyper_rustls;
11239/// # extern crate google_androidpublisher2 as androidpublisher2;
11240/// use std::fs;
11241/// # async fn dox() {
11242/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11243///
11244/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11245/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11246/// #     .with_native_roots()
11247/// #     .unwrap()
11248/// #     .https_only()
11249/// #     .enable_http2()
11250/// #     .build();
11251///
11252/// # let executor = hyper_util::rt::TokioExecutor::new();
11253/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11254/// #     secret,
11255/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11256/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11257/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11258/// #     ),
11259/// # ).build().await.unwrap();
11260///
11261/// # let client = hyper_util::client::legacy::Client::builder(
11262/// #     hyper_util::rt::TokioExecutor::new()
11263/// # )
11264/// # .build(
11265/// #     hyper_rustls::HttpsConnectorBuilder::new()
11266/// #         .with_native_roots()
11267/// #         .unwrap()
11268/// #         .https_or_http()
11269/// #         .enable_http2()
11270/// #         .build()
11271/// # );
11272/// # let mut hub = AndroidPublisher::new(client, auth);
11273/// // You can configure optional parameters by calling the respective setters at will, and
11274/// // execute the final call using `upload_resumable(...)`.
11275/// // Values shown here are possibly random and not representative !
11276/// let result = hub.edits().images_upload("packageName", "editId", "language", "imageType")
11277///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
11278/// # }
11279/// ```
11280pub struct EditImageUploadCall<'a, C>
11281where
11282    C: 'a,
11283{
11284    hub: &'a AndroidPublisher<C>,
11285    _package_name: String,
11286    _edit_id: String,
11287    _language: String,
11288    _image_type: String,
11289    _delegate: Option<&'a mut dyn common::Delegate>,
11290    _additional_params: HashMap<String, String>,
11291    _scopes: BTreeSet<String>,
11292}
11293
11294impl<'a, C> common::CallBuilder for EditImageUploadCall<'a, C> {}
11295
11296impl<'a, C> EditImageUploadCall<'a, C>
11297where
11298    C: common::Connector,
11299{
11300    /// Perform the operation you have build so far.
11301    async fn doit<RS>(
11302        mut self,
11303        mut reader: RS,
11304        reader_mime_type: mime::Mime,
11305        protocol: common::UploadProtocol,
11306    ) -> common::Result<(common::Response, ImagesUploadResponse)>
11307    where
11308        RS: common::ReadSeek,
11309    {
11310        use std::borrow::Cow;
11311        use std::io::{Read, Seek};
11312
11313        use common::{url::Params, ToParts};
11314        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11315
11316        let mut dd = common::DefaultDelegate;
11317        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11318        dlg.begin(common::MethodInfo {
11319            id: "androidpublisher.edits.images.upload",
11320            http_method: hyper::Method::POST,
11321        });
11322
11323        for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
11324            if self._additional_params.contains_key(field) {
11325                dlg.finished(false);
11326                return Err(common::Error::FieldClash(field));
11327            }
11328        }
11329
11330        let mut params = Params::with_capacity(6 + self._additional_params.len());
11331        params.push("packageName", self._package_name);
11332        params.push("editId", self._edit_id);
11333        params.push("language", self._language);
11334        params.push("imageType", self._image_type);
11335
11336        params.extend(self._additional_params.iter());
11337
11338        params.push("alt", "json");
11339        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
11340            (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}", "resumable")
11341        } else if protocol == common::UploadProtocol::Simple {
11342            (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}", "multipart")
11343        } else {
11344            unreachable!()
11345        };
11346        params.push("uploadType", upload_type);
11347        if self._scopes.is_empty() {
11348            self._scopes.insert(Scope::Full.as_ref().to_string());
11349        }
11350
11351        #[allow(clippy::single_element_loop)]
11352        for &(find_this, param_name) in [
11353            ("{packageName}", "packageName"),
11354            ("{editId}", "editId"),
11355            ("{language}", "language"),
11356            ("{imageType}", "imageType"),
11357        ]
11358        .iter()
11359        {
11360            url = params.uri_replacement(url, param_name, find_this, false);
11361        }
11362        {
11363            let to_remove = ["imageType", "language", "editId", "packageName"];
11364            params.remove_params(&to_remove);
11365        }
11366
11367        let url = params.parse_with_url(&url);
11368
11369        let mut upload_url_from_server;
11370
11371        loop {
11372            let token = match self
11373                .hub
11374                .auth
11375                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11376                .await
11377            {
11378                Ok(token) => token,
11379                Err(e) => match dlg.token(e) {
11380                    Ok(token) => token,
11381                    Err(e) => {
11382                        dlg.finished(false);
11383                        return Err(common::Error::MissingToken(e));
11384                    }
11385                },
11386            };
11387            let mut req_result = {
11388                let client = &self.hub.client;
11389                dlg.pre_request();
11390                let mut req_builder = hyper::Request::builder()
11391                    .method(hyper::Method::POST)
11392                    .uri(url.as_str())
11393                    .header(USER_AGENT, self.hub._user_agent.clone());
11394
11395                if let Some(token) = token.as_ref() {
11396                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11397                }
11398
11399                upload_url_from_server = true;
11400                if protocol == common::UploadProtocol::Resumable {
11401                    req_builder = req_builder
11402                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
11403                }
11404
11405                let request = if protocol == common::UploadProtocol::Simple {
11406                    let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
11407                    reader.seek(std::io::SeekFrom::Start(0)).unwrap();
11408                    if size > 15728640 {
11409                        return Err(common::Error::UploadSizeLimitExceeded(size, 15728640));
11410                    }
11411                    let mut bytes = Vec::with_capacity(size as usize);
11412                    reader.read_to_end(&mut bytes)?;
11413                    req_builder
11414                        .header(CONTENT_TYPE, reader_mime_type.to_string())
11415                        .header(CONTENT_LENGTH, size)
11416                        .body(common::to_body(bytes.into()))
11417                } else {
11418                    req_builder.body(common::to_body::<String>(None))
11419                };
11420
11421                client.request(request.unwrap()).await
11422            };
11423
11424            match req_result {
11425                Err(err) => {
11426                    if let common::Retry::After(d) = dlg.http_error(&err) {
11427                        sleep(d).await;
11428                        continue;
11429                    }
11430                    dlg.finished(false);
11431                    return Err(common::Error::HttpError(err));
11432                }
11433                Ok(res) => {
11434                    let (mut parts, body) = res.into_parts();
11435                    let mut body = common::Body::new(body);
11436                    if !parts.status.is_success() {
11437                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11438                        let error = serde_json::from_str(&common::to_string(&bytes));
11439                        let response = common::to_response(parts, bytes.into());
11440
11441                        if let common::Retry::After(d) =
11442                            dlg.http_failure(&response, error.as_ref().ok())
11443                        {
11444                            sleep(d).await;
11445                            continue;
11446                        }
11447
11448                        dlg.finished(false);
11449
11450                        return Err(match error {
11451                            Ok(value) => common::Error::BadRequest(value),
11452                            _ => common::Error::Failure(response),
11453                        });
11454                    }
11455                    if protocol == common::UploadProtocol::Resumable {
11456                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
11457                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
11458                        if size > 15728640 {
11459                            return Err(common::Error::UploadSizeLimitExceeded(size, 15728640));
11460                        }
11461                        let upload_result = {
11462                            let url_str = &parts
11463                                .headers
11464                                .get("Location")
11465                                .expect("LOCATION header is part of protocol")
11466                                .to_str()
11467                                .unwrap();
11468                            if upload_url_from_server {
11469                                dlg.store_upload_url(Some(url_str));
11470                            }
11471
11472                            common::ResumableUploadHelper {
11473                                client: &self.hub.client,
11474                                delegate: dlg,
11475                                start_at: if upload_url_from_server {
11476                                    Some(0)
11477                                } else {
11478                                    None
11479                                },
11480                                auth: &self.hub.auth,
11481                                user_agent: &self.hub._user_agent,
11482                                // TODO: Check this assumption
11483                                auth_header: format!(
11484                                    "Bearer {}",
11485                                    token
11486                                        .ok_or_else(|| common::Error::MissingToken(
11487                                            "resumable upload requires token".into()
11488                                        ))?
11489                                        .as_str()
11490                                ),
11491                                url: url_str,
11492                                reader: &mut reader,
11493                                media_type: reader_mime_type.clone(),
11494                                content_length: size,
11495                            }
11496                            .upload()
11497                            .await
11498                        };
11499                        match upload_result {
11500                            None => {
11501                                dlg.finished(false);
11502                                return Err(common::Error::Cancelled);
11503                            }
11504                            Some(Err(err)) => {
11505                                dlg.finished(false);
11506                                return Err(common::Error::HttpError(err));
11507                            }
11508                            Some(Ok(response)) => {
11509                                (parts, body) = response.into_parts();
11510                                if !parts.status.is_success() {
11511                                    dlg.store_upload_url(None);
11512                                    dlg.finished(false);
11513                                    return Err(common::Error::Failure(
11514                                        common::Response::from_parts(parts, body),
11515                                    ));
11516                                }
11517                            }
11518                        }
11519                    }
11520                    let response = {
11521                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11522                        let encoded = common::to_string(&bytes);
11523                        match serde_json::from_str(&encoded) {
11524                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11525                            Err(error) => {
11526                                dlg.response_json_decode_error(&encoded, &error);
11527                                return Err(common::Error::JsonDecodeError(
11528                                    encoded.to_string(),
11529                                    error,
11530                                ));
11531                            }
11532                        }
11533                    };
11534
11535                    dlg.finished(true);
11536                    return Ok(response);
11537                }
11538            }
11539        }
11540    }
11541
11542    /// Upload media in a resumable fashion.
11543    /// Even if the upload fails or is interrupted, it can be resumed for a
11544    /// certain amount of time as the server maintains state temporarily.
11545    ///
11546    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
11547    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
11548    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
11549    /// `cancel_chunk_upload(...)`.
11550    ///
11551    /// * *multipart*: yes
11552    /// * *max size*: 15MB
11553    /// * *valid mime types*: 'image/*'
11554    pub async fn upload_resumable<RS>(
11555        self,
11556        resumeable_stream: RS,
11557        mime_type: mime::Mime,
11558    ) -> common::Result<(common::Response, ImagesUploadResponse)>
11559    where
11560        RS: common::ReadSeek,
11561    {
11562        self.doit(
11563            resumeable_stream,
11564            mime_type,
11565            common::UploadProtocol::Resumable,
11566        )
11567        .await
11568    }
11569    /// Upload media all at once.
11570    /// If the upload fails for whichever reason, all progress is lost.
11571    ///
11572    /// * *multipart*: yes
11573    /// * *max size*: 15MB
11574    /// * *valid mime types*: 'image/*'
11575    pub async fn upload<RS>(
11576        self,
11577        stream: RS,
11578        mime_type: mime::Mime,
11579    ) -> common::Result<(common::Response, ImagesUploadResponse)>
11580    where
11581        RS: common::ReadSeek,
11582    {
11583        self.doit(stream, mime_type, common::UploadProtocol::Simple)
11584            .await
11585    }
11586
11587    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
11588    ///
11589    /// Sets the *package name* path property to the given value.
11590    ///
11591    /// Even though the property as already been set when instantiating this call,
11592    /// we provide this method for API completeness.
11593    pub fn package_name(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
11594        self._package_name = new_value.to_string();
11595        self
11596    }
11597    /// Unique identifier for this edit.
11598    ///
11599    /// Sets the *edit id* path property to the given value.
11600    ///
11601    /// Even though the property as already been set when instantiating this call,
11602    /// we provide this method for API completeness.
11603    pub fn edit_id(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
11604        self._edit_id = new_value.to_string();
11605        self
11606    }
11607    /// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
11608    ///
11609    /// Sets the *language* path property to the given value.
11610    ///
11611    /// Even though the property as already been set when instantiating this call,
11612    /// we provide this method for API completeness.
11613    pub fn language(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
11614        self._language = new_value.to_string();
11615        self
11616    }
11617    ///
11618    /// Sets the *image type* path property to the given value.
11619    ///
11620    /// Even though the property as already been set when instantiating this call,
11621    /// we provide this method for API completeness.
11622    pub fn image_type(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
11623        self._image_type = new_value.to_string();
11624        self
11625    }
11626    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11627    /// while executing the actual API request.
11628    ///
11629    /// ````text
11630    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11631    /// ````
11632    ///
11633    /// Sets the *delegate* property to the given value.
11634    pub fn delegate(
11635        mut self,
11636        new_value: &'a mut dyn common::Delegate,
11637    ) -> EditImageUploadCall<'a, C> {
11638        self._delegate = Some(new_value);
11639        self
11640    }
11641
11642    /// Set any additional parameter of the query string used in the request.
11643    /// It should be used to set parameters which are not yet available through their own
11644    /// setters.
11645    ///
11646    /// Please note that this method must not be used to set any of the known parameters
11647    /// which have their own setter method. If done anyway, the request will fail.
11648    ///
11649    /// # Additional Parameters
11650    ///
11651    /// * *alt* (query-string) - Data format for the response.
11652    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11653    /// * *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.
11654    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11655    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11656    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11657    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11658    pub fn param<T>(mut self, name: T, value: T) -> EditImageUploadCall<'a, C>
11659    where
11660        T: AsRef<str>,
11661    {
11662        self._additional_params
11663            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11664        self
11665    }
11666
11667    /// Identifies the authorization scope for the method you are building.
11668    ///
11669    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11670    /// [`Scope::Full`].
11671    ///
11672    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11673    /// tokens for more than one scope.
11674    ///
11675    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11676    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11677    /// sufficient, a read-write scope will do as well.
11678    pub fn add_scope<St>(mut self, scope: St) -> EditImageUploadCall<'a, C>
11679    where
11680        St: AsRef<str>,
11681    {
11682        self._scopes.insert(String::from(scope.as_ref()));
11683        self
11684    }
11685    /// Identifies the authorization scope(s) for the method you are building.
11686    ///
11687    /// See [`Self::add_scope()`] for details.
11688    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageUploadCall<'a, C>
11689    where
11690        I: IntoIterator<Item = St>,
11691        St: AsRef<str>,
11692    {
11693        self._scopes
11694            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11695        self
11696    }
11697
11698    /// Removes all scopes, and no default scope will be used either.
11699    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11700    /// for details).
11701    pub fn clear_scopes(mut self) -> EditImageUploadCall<'a, C> {
11702        self._scopes.clear();
11703        self
11704    }
11705}
11706
11707/// Deletes the specified localized store listing from an edit.
11708///
11709/// A builder for the *listings.delete* method supported by a *edit* resource.
11710/// It is not used directly, but through a [`EditMethods`] instance.
11711///
11712/// # Example
11713///
11714/// Instantiate a resource method builder
11715///
11716/// ```test_harness,no_run
11717/// # extern crate hyper;
11718/// # extern crate hyper_rustls;
11719/// # extern crate google_androidpublisher2 as androidpublisher2;
11720/// # async fn dox() {
11721/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11722///
11723/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11724/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11725/// #     .with_native_roots()
11726/// #     .unwrap()
11727/// #     .https_only()
11728/// #     .enable_http2()
11729/// #     .build();
11730///
11731/// # let executor = hyper_util::rt::TokioExecutor::new();
11732/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11733/// #     secret,
11734/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11735/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11736/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11737/// #     ),
11738/// # ).build().await.unwrap();
11739///
11740/// # let client = hyper_util::client::legacy::Client::builder(
11741/// #     hyper_util::rt::TokioExecutor::new()
11742/// # )
11743/// # .build(
11744/// #     hyper_rustls::HttpsConnectorBuilder::new()
11745/// #         .with_native_roots()
11746/// #         .unwrap()
11747/// #         .https_or_http()
11748/// #         .enable_http2()
11749/// #         .build()
11750/// # );
11751/// # let mut hub = AndroidPublisher::new(client, auth);
11752/// // You can configure optional parameters by calling the respective setters at will, and
11753/// // execute the final call using `doit()`.
11754/// // Values shown here are possibly random and not representative !
11755/// let result = hub.edits().listings_delete("packageName", "editId", "language")
11756///              .doit().await;
11757/// # }
11758/// ```
11759pub struct EditListingDeleteCall<'a, C>
11760where
11761    C: 'a,
11762{
11763    hub: &'a AndroidPublisher<C>,
11764    _package_name: String,
11765    _edit_id: String,
11766    _language: String,
11767    _delegate: Option<&'a mut dyn common::Delegate>,
11768    _additional_params: HashMap<String, String>,
11769    _scopes: BTreeSet<String>,
11770}
11771
11772impl<'a, C> common::CallBuilder for EditListingDeleteCall<'a, C> {}
11773
11774impl<'a, C> EditListingDeleteCall<'a, C>
11775where
11776    C: common::Connector,
11777{
11778    /// Perform the operation you have build so far.
11779    pub async fn doit(mut self) -> common::Result<common::Response> {
11780        use std::borrow::Cow;
11781        use std::io::{Read, Seek};
11782
11783        use common::{url::Params, ToParts};
11784        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11785
11786        let mut dd = common::DefaultDelegate;
11787        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11788        dlg.begin(common::MethodInfo {
11789            id: "androidpublisher.edits.listings.delete",
11790            http_method: hyper::Method::DELETE,
11791        });
11792
11793        for &field in ["packageName", "editId", "language"].iter() {
11794            if self._additional_params.contains_key(field) {
11795                dlg.finished(false);
11796                return Err(common::Error::FieldClash(field));
11797            }
11798        }
11799
11800        let mut params = Params::with_capacity(4 + self._additional_params.len());
11801        params.push("packageName", self._package_name);
11802        params.push("editId", self._edit_id);
11803        params.push("language", self._language);
11804
11805        params.extend(self._additional_params.iter());
11806
11807        let mut url =
11808            self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}";
11809        if self._scopes.is_empty() {
11810            self._scopes.insert(Scope::Full.as_ref().to_string());
11811        }
11812
11813        #[allow(clippy::single_element_loop)]
11814        for &(find_this, param_name) in [
11815            ("{packageName}", "packageName"),
11816            ("{editId}", "editId"),
11817            ("{language}", "language"),
11818        ]
11819        .iter()
11820        {
11821            url = params.uri_replacement(url, param_name, find_this, false);
11822        }
11823        {
11824            let to_remove = ["language", "editId", "packageName"];
11825            params.remove_params(&to_remove);
11826        }
11827
11828        let url = params.parse_with_url(&url);
11829
11830        loop {
11831            let token = match self
11832                .hub
11833                .auth
11834                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11835                .await
11836            {
11837                Ok(token) => token,
11838                Err(e) => match dlg.token(e) {
11839                    Ok(token) => token,
11840                    Err(e) => {
11841                        dlg.finished(false);
11842                        return Err(common::Error::MissingToken(e));
11843                    }
11844                },
11845            };
11846            let mut req_result = {
11847                let client = &self.hub.client;
11848                dlg.pre_request();
11849                let mut req_builder = hyper::Request::builder()
11850                    .method(hyper::Method::DELETE)
11851                    .uri(url.as_str())
11852                    .header(USER_AGENT, self.hub._user_agent.clone());
11853
11854                if let Some(token) = token.as_ref() {
11855                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11856                }
11857
11858                let request = req_builder
11859                    .header(CONTENT_LENGTH, 0_u64)
11860                    .body(common::to_body::<String>(None));
11861
11862                client.request(request.unwrap()).await
11863            };
11864
11865            match req_result {
11866                Err(err) => {
11867                    if let common::Retry::After(d) = dlg.http_error(&err) {
11868                        sleep(d).await;
11869                        continue;
11870                    }
11871                    dlg.finished(false);
11872                    return Err(common::Error::HttpError(err));
11873                }
11874                Ok(res) => {
11875                    let (mut parts, body) = res.into_parts();
11876                    let mut body = common::Body::new(body);
11877                    if !parts.status.is_success() {
11878                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11879                        let error = serde_json::from_str(&common::to_string(&bytes));
11880                        let response = common::to_response(parts, bytes.into());
11881
11882                        if let common::Retry::After(d) =
11883                            dlg.http_failure(&response, error.as_ref().ok())
11884                        {
11885                            sleep(d).await;
11886                            continue;
11887                        }
11888
11889                        dlg.finished(false);
11890
11891                        return Err(match error {
11892                            Ok(value) => common::Error::BadRequest(value),
11893                            _ => common::Error::Failure(response),
11894                        });
11895                    }
11896                    let response = common::Response::from_parts(parts, body);
11897
11898                    dlg.finished(true);
11899                    return Ok(response);
11900                }
11901            }
11902        }
11903    }
11904
11905    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
11906    ///
11907    /// Sets the *package name* path property to the given value.
11908    ///
11909    /// Even though the property as already been set when instantiating this call,
11910    /// we provide this method for API completeness.
11911    pub fn package_name(mut self, new_value: &str) -> EditListingDeleteCall<'a, C> {
11912        self._package_name = new_value.to_string();
11913        self
11914    }
11915    /// Unique identifier for this edit.
11916    ///
11917    /// Sets the *edit id* path property to the given value.
11918    ///
11919    /// Even though the property as already been set when instantiating this call,
11920    /// we provide this method for API completeness.
11921    pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteCall<'a, C> {
11922        self._edit_id = new_value.to_string();
11923        self
11924    }
11925    /// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
11926    ///
11927    /// Sets the *language* path property to the given value.
11928    ///
11929    /// Even though the property as already been set when instantiating this call,
11930    /// we provide this method for API completeness.
11931    pub fn language(mut self, new_value: &str) -> EditListingDeleteCall<'a, C> {
11932        self._language = new_value.to_string();
11933        self
11934    }
11935    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11936    /// while executing the actual API request.
11937    ///
11938    /// ````text
11939    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11940    /// ````
11941    ///
11942    /// Sets the *delegate* property to the given value.
11943    pub fn delegate(
11944        mut self,
11945        new_value: &'a mut dyn common::Delegate,
11946    ) -> EditListingDeleteCall<'a, C> {
11947        self._delegate = Some(new_value);
11948        self
11949    }
11950
11951    /// Set any additional parameter of the query string used in the request.
11952    /// It should be used to set parameters which are not yet available through their own
11953    /// setters.
11954    ///
11955    /// Please note that this method must not be used to set any of the known parameters
11956    /// which have their own setter method. If done anyway, the request will fail.
11957    ///
11958    /// # Additional Parameters
11959    ///
11960    /// * *alt* (query-string) - Data format for the response.
11961    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11962    /// * *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.
11963    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11964    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11965    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11966    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11967    pub fn param<T>(mut self, name: T, value: T) -> EditListingDeleteCall<'a, C>
11968    where
11969        T: AsRef<str>,
11970    {
11971        self._additional_params
11972            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11973        self
11974    }
11975
11976    /// Identifies the authorization scope for the method you are building.
11977    ///
11978    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11979    /// [`Scope::Full`].
11980    ///
11981    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11982    /// tokens for more than one scope.
11983    ///
11984    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11985    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11986    /// sufficient, a read-write scope will do as well.
11987    pub fn add_scope<St>(mut self, scope: St) -> EditListingDeleteCall<'a, C>
11988    where
11989        St: AsRef<str>,
11990    {
11991        self._scopes.insert(String::from(scope.as_ref()));
11992        self
11993    }
11994    /// Identifies the authorization scope(s) for the method you are building.
11995    ///
11996    /// See [`Self::add_scope()`] for details.
11997    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingDeleteCall<'a, C>
11998    where
11999        I: IntoIterator<Item = St>,
12000        St: AsRef<str>,
12001    {
12002        self._scopes
12003            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12004        self
12005    }
12006
12007    /// Removes all scopes, and no default scope will be used either.
12008    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12009    /// for details).
12010    pub fn clear_scopes(mut self) -> EditListingDeleteCall<'a, C> {
12011        self._scopes.clear();
12012        self
12013    }
12014}
12015
12016/// Deletes all localized listings from an edit.
12017///
12018/// A builder for the *listings.deleteall* method supported by a *edit* resource.
12019/// It is not used directly, but through a [`EditMethods`] instance.
12020///
12021/// # Example
12022///
12023/// Instantiate a resource method builder
12024///
12025/// ```test_harness,no_run
12026/// # extern crate hyper;
12027/// # extern crate hyper_rustls;
12028/// # extern crate google_androidpublisher2 as androidpublisher2;
12029/// # async fn dox() {
12030/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12031///
12032/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12033/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12034/// #     .with_native_roots()
12035/// #     .unwrap()
12036/// #     .https_only()
12037/// #     .enable_http2()
12038/// #     .build();
12039///
12040/// # let executor = hyper_util::rt::TokioExecutor::new();
12041/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12042/// #     secret,
12043/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12044/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12045/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12046/// #     ),
12047/// # ).build().await.unwrap();
12048///
12049/// # let client = hyper_util::client::legacy::Client::builder(
12050/// #     hyper_util::rt::TokioExecutor::new()
12051/// # )
12052/// # .build(
12053/// #     hyper_rustls::HttpsConnectorBuilder::new()
12054/// #         .with_native_roots()
12055/// #         .unwrap()
12056/// #         .https_or_http()
12057/// #         .enable_http2()
12058/// #         .build()
12059/// # );
12060/// # let mut hub = AndroidPublisher::new(client, auth);
12061/// // You can configure optional parameters by calling the respective setters at will, and
12062/// // execute the final call using `doit()`.
12063/// // Values shown here are possibly random and not representative !
12064/// let result = hub.edits().listings_deleteall("packageName", "editId")
12065///              .doit().await;
12066/// # }
12067/// ```
12068pub struct EditListingDeleteallCall<'a, C>
12069where
12070    C: 'a,
12071{
12072    hub: &'a AndroidPublisher<C>,
12073    _package_name: String,
12074    _edit_id: String,
12075    _delegate: Option<&'a mut dyn common::Delegate>,
12076    _additional_params: HashMap<String, String>,
12077    _scopes: BTreeSet<String>,
12078}
12079
12080impl<'a, C> common::CallBuilder for EditListingDeleteallCall<'a, C> {}
12081
12082impl<'a, C> EditListingDeleteallCall<'a, C>
12083where
12084    C: common::Connector,
12085{
12086    /// Perform the operation you have build so far.
12087    pub async fn doit(mut self) -> common::Result<common::Response> {
12088        use std::borrow::Cow;
12089        use std::io::{Read, Seek};
12090
12091        use common::{url::Params, ToParts};
12092        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12093
12094        let mut dd = common::DefaultDelegate;
12095        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12096        dlg.begin(common::MethodInfo {
12097            id: "androidpublisher.edits.listings.deleteall",
12098            http_method: hyper::Method::DELETE,
12099        });
12100
12101        for &field in ["packageName", "editId"].iter() {
12102            if self._additional_params.contains_key(field) {
12103                dlg.finished(false);
12104                return Err(common::Error::FieldClash(field));
12105            }
12106        }
12107
12108        let mut params = Params::with_capacity(3 + self._additional_params.len());
12109        params.push("packageName", self._package_name);
12110        params.push("editId", self._edit_id);
12111
12112        params.extend(self._additional_params.iter());
12113
12114        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings";
12115        if self._scopes.is_empty() {
12116            self._scopes.insert(Scope::Full.as_ref().to_string());
12117        }
12118
12119        #[allow(clippy::single_element_loop)]
12120        for &(find_this, param_name) in
12121            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
12122        {
12123            url = params.uri_replacement(url, param_name, find_this, false);
12124        }
12125        {
12126            let to_remove = ["editId", "packageName"];
12127            params.remove_params(&to_remove);
12128        }
12129
12130        let url = params.parse_with_url(&url);
12131
12132        loop {
12133            let token = match self
12134                .hub
12135                .auth
12136                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12137                .await
12138            {
12139                Ok(token) => token,
12140                Err(e) => match dlg.token(e) {
12141                    Ok(token) => token,
12142                    Err(e) => {
12143                        dlg.finished(false);
12144                        return Err(common::Error::MissingToken(e));
12145                    }
12146                },
12147            };
12148            let mut req_result = {
12149                let client = &self.hub.client;
12150                dlg.pre_request();
12151                let mut req_builder = hyper::Request::builder()
12152                    .method(hyper::Method::DELETE)
12153                    .uri(url.as_str())
12154                    .header(USER_AGENT, self.hub._user_agent.clone());
12155
12156                if let Some(token) = token.as_ref() {
12157                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12158                }
12159
12160                let request = req_builder
12161                    .header(CONTENT_LENGTH, 0_u64)
12162                    .body(common::to_body::<String>(None));
12163
12164                client.request(request.unwrap()).await
12165            };
12166
12167            match req_result {
12168                Err(err) => {
12169                    if let common::Retry::After(d) = dlg.http_error(&err) {
12170                        sleep(d).await;
12171                        continue;
12172                    }
12173                    dlg.finished(false);
12174                    return Err(common::Error::HttpError(err));
12175                }
12176                Ok(res) => {
12177                    let (mut parts, body) = res.into_parts();
12178                    let mut body = common::Body::new(body);
12179                    if !parts.status.is_success() {
12180                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12181                        let error = serde_json::from_str(&common::to_string(&bytes));
12182                        let response = common::to_response(parts, bytes.into());
12183
12184                        if let common::Retry::After(d) =
12185                            dlg.http_failure(&response, error.as_ref().ok())
12186                        {
12187                            sleep(d).await;
12188                            continue;
12189                        }
12190
12191                        dlg.finished(false);
12192
12193                        return Err(match error {
12194                            Ok(value) => common::Error::BadRequest(value),
12195                            _ => common::Error::Failure(response),
12196                        });
12197                    }
12198                    let response = common::Response::from_parts(parts, body);
12199
12200                    dlg.finished(true);
12201                    return Ok(response);
12202                }
12203            }
12204        }
12205    }
12206
12207    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
12208    ///
12209    /// Sets the *package name* path property to the given value.
12210    ///
12211    /// Even though the property as already been set when instantiating this call,
12212    /// we provide this method for API completeness.
12213    pub fn package_name(mut self, new_value: &str) -> EditListingDeleteallCall<'a, C> {
12214        self._package_name = new_value.to_string();
12215        self
12216    }
12217    /// Unique identifier for this edit.
12218    ///
12219    /// Sets the *edit id* path property to the given value.
12220    ///
12221    /// Even though the property as already been set when instantiating this call,
12222    /// we provide this method for API completeness.
12223    pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteallCall<'a, C> {
12224        self._edit_id = new_value.to_string();
12225        self
12226    }
12227    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12228    /// while executing the actual API request.
12229    ///
12230    /// ````text
12231    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12232    /// ````
12233    ///
12234    /// Sets the *delegate* property to the given value.
12235    pub fn delegate(
12236        mut self,
12237        new_value: &'a mut dyn common::Delegate,
12238    ) -> EditListingDeleteallCall<'a, C> {
12239        self._delegate = Some(new_value);
12240        self
12241    }
12242
12243    /// Set any additional parameter of the query string used in the request.
12244    /// It should be used to set parameters which are not yet available through their own
12245    /// setters.
12246    ///
12247    /// Please note that this method must not be used to set any of the known parameters
12248    /// which have their own setter method. If done anyway, the request will fail.
12249    ///
12250    /// # Additional Parameters
12251    ///
12252    /// * *alt* (query-string) - Data format for the response.
12253    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12254    /// * *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.
12255    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12256    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12257    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12258    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12259    pub fn param<T>(mut self, name: T, value: T) -> EditListingDeleteallCall<'a, C>
12260    where
12261        T: AsRef<str>,
12262    {
12263        self._additional_params
12264            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12265        self
12266    }
12267
12268    /// Identifies the authorization scope for the method you are building.
12269    ///
12270    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12271    /// [`Scope::Full`].
12272    ///
12273    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12274    /// tokens for more than one scope.
12275    ///
12276    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12277    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12278    /// sufficient, a read-write scope will do as well.
12279    pub fn add_scope<St>(mut self, scope: St) -> EditListingDeleteallCall<'a, C>
12280    where
12281        St: AsRef<str>,
12282    {
12283        self._scopes.insert(String::from(scope.as_ref()));
12284        self
12285    }
12286    /// Identifies the authorization scope(s) for the method you are building.
12287    ///
12288    /// See [`Self::add_scope()`] for details.
12289    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingDeleteallCall<'a, C>
12290    where
12291        I: IntoIterator<Item = St>,
12292        St: AsRef<str>,
12293    {
12294        self._scopes
12295            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12296        self
12297    }
12298
12299    /// Removes all scopes, and no default scope will be used either.
12300    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12301    /// for details).
12302    pub fn clear_scopes(mut self) -> EditListingDeleteallCall<'a, C> {
12303        self._scopes.clear();
12304        self
12305    }
12306}
12307
12308/// Fetches information about a localized store listing.
12309///
12310/// A builder for the *listings.get* method supported by a *edit* resource.
12311/// It is not used directly, but through a [`EditMethods`] instance.
12312///
12313/// # Example
12314///
12315/// Instantiate a resource method builder
12316///
12317/// ```test_harness,no_run
12318/// # extern crate hyper;
12319/// # extern crate hyper_rustls;
12320/// # extern crate google_androidpublisher2 as androidpublisher2;
12321/// # async fn dox() {
12322/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12323///
12324/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12325/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12326/// #     .with_native_roots()
12327/// #     .unwrap()
12328/// #     .https_only()
12329/// #     .enable_http2()
12330/// #     .build();
12331///
12332/// # let executor = hyper_util::rt::TokioExecutor::new();
12333/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12334/// #     secret,
12335/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12336/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12337/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12338/// #     ),
12339/// # ).build().await.unwrap();
12340///
12341/// # let client = hyper_util::client::legacy::Client::builder(
12342/// #     hyper_util::rt::TokioExecutor::new()
12343/// # )
12344/// # .build(
12345/// #     hyper_rustls::HttpsConnectorBuilder::new()
12346/// #         .with_native_roots()
12347/// #         .unwrap()
12348/// #         .https_or_http()
12349/// #         .enable_http2()
12350/// #         .build()
12351/// # );
12352/// # let mut hub = AndroidPublisher::new(client, auth);
12353/// // You can configure optional parameters by calling the respective setters at will, and
12354/// // execute the final call using `doit()`.
12355/// // Values shown here are possibly random and not representative !
12356/// let result = hub.edits().listings_get("packageName", "editId", "language")
12357///              .doit().await;
12358/// # }
12359/// ```
12360pub struct EditListingGetCall<'a, C>
12361where
12362    C: 'a,
12363{
12364    hub: &'a AndroidPublisher<C>,
12365    _package_name: String,
12366    _edit_id: String,
12367    _language: String,
12368    _delegate: Option<&'a mut dyn common::Delegate>,
12369    _additional_params: HashMap<String, String>,
12370    _scopes: BTreeSet<String>,
12371}
12372
12373impl<'a, C> common::CallBuilder for EditListingGetCall<'a, C> {}
12374
12375impl<'a, C> EditListingGetCall<'a, C>
12376where
12377    C: common::Connector,
12378{
12379    /// Perform the operation you have build so far.
12380    pub async fn doit(mut self) -> common::Result<(common::Response, Listing)> {
12381        use std::borrow::Cow;
12382        use std::io::{Read, Seek};
12383
12384        use common::{url::Params, ToParts};
12385        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12386
12387        let mut dd = common::DefaultDelegate;
12388        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12389        dlg.begin(common::MethodInfo {
12390            id: "androidpublisher.edits.listings.get",
12391            http_method: hyper::Method::GET,
12392        });
12393
12394        for &field in ["alt", "packageName", "editId", "language"].iter() {
12395            if self._additional_params.contains_key(field) {
12396                dlg.finished(false);
12397                return Err(common::Error::FieldClash(field));
12398            }
12399        }
12400
12401        let mut params = Params::with_capacity(5 + self._additional_params.len());
12402        params.push("packageName", self._package_name);
12403        params.push("editId", self._edit_id);
12404        params.push("language", self._language);
12405
12406        params.extend(self._additional_params.iter());
12407
12408        params.push("alt", "json");
12409        let mut url =
12410            self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}";
12411        if self._scopes.is_empty() {
12412            self._scopes.insert(Scope::Full.as_ref().to_string());
12413        }
12414
12415        #[allow(clippy::single_element_loop)]
12416        for &(find_this, param_name) in [
12417            ("{packageName}", "packageName"),
12418            ("{editId}", "editId"),
12419            ("{language}", "language"),
12420        ]
12421        .iter()
12422        {
12423            url = params.uri_replacement(url, param_name, find_this, false);
12424        }
12425        {
12426            let to_remove = ["language", "editId", "packageName"];
12427            params.remove_params(&to_remove);
12428        }
12429
12430        let url = params.parse_with_url(&url);
12431
12432        loop {
12433            let token = match self
12434                .hub
12435                .auth
12436                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12437                .await
12438            {
12439                Ok(token) => token,
12440                Err(e) => match dlg.token(e) {
12441                    Ok(token) => token,
12442                    Err(e) => {
12443                        dlg.finished(false);
12444                        return Err(common::Error::MissingToken(e));
12445                    }
12446                },
12447            };
12448            let mut req_result = {
12449                let client = &self.hub.client;
12450                dlg.pre_request();
12451                let mut req_builder = hyper::Request::builder()
12452                    .method(hyper::Method::GET)
12453                    .uri(url.as_str())
12454                    .header(USER_AGENT, self.hub._user_agent.clone());
12455
12456                if let Some(token) = token.as_ref() {
12457                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12458                }
12459
12460                let request = req_builder
12461                    .header(CONTENT_LENGTH, 0_u64)
12462                    .body(common::to_body::<String>(None));
12463
12464                client.request(request.unwrap()).await
12465            };
12466
12467            match req_result {
12468                Err(err) => {
12469                    if let common::Retry::After(d) = dlg.http_error(&err) {
12470                        sleep(d).await;
12471                        continue;
12472                    }
12473                    dlg.finished(false);
12474                    return Err(common::Error::HttpError(err));
12475                }
12476                Ok(res) => {
12477                    let (mut parts, body) = res.into_parts();
12478                    let mut body = common::Body::new(body);
12479                    if !parts.status.is_success() {
12480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12481                        let error = serde_json::from_str(&common::to_string(&bytes));
12482                        let response = common::to_response(parts, bytes.into());
12483
12484                        if let common::Retry::After(d) =
12485                            dlg.http_failure(&response, error.as_ref().ok())
12486                        {
12487                            sleep(d).await;
12488                            continue;
12489                        }
12490
12491                        dlg.finished(false);
12492
12493                        return Err(match error {
12494                            Ok(value) => common::Error::BadRequest(value),
12495                            _ => common::Error::Failure(response),
12496                        });
12497                    }
12498                    let response = {
12499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12500                        let encoded = common::to_string(&bytes);
12501                        match serde_json::from_str(&encoded) {
12502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12503                            Err(error) => {
12504                                dlg.response_json_decode_error(&encoded, &error);
12505                                return Err(common::Error::JsonDecodeError(
12506                                    encoded.to_string(),
12507                                    error,
12508                                ));
12509                            }
12510                        }
12511                    };
12512
12513                    dlg.finished(true);
12514                    return Ok(response);
12515                }
12516            }
12517        }
12518    }
12519
12520    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
12521    ///
12522    /// Sets the *package name* path property to the given value.
12523    ///
12524    /// Even though the property as already been set when instantiating this call,
12525    /// we provide this method for API completeness.
12526    pub fn package_name(mut self, new_value: &str) -> EditListingGetCall<'a, C> {
12527        self._package_name = new_value.to_string();
12528        self
12529    }
12530    /// Unique identifier for this edit.
12531    ///
12532    /// Sets the *edit id* path property to the given value.
12533    ///
12534    /// Even though the property as already been set when instantiating this call,
12535    /// we provide this method for API completeness.
12536    pub fn edit_id(mut self, new_value: &str) -> EditListingGetCall<'a, C> {
12537        self._edit_id = new_value.to_string();
12538        self
12539    }
12540    /// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
12541    ///
12542    /// Sets the *language* path property to the given value.
12543    ///
12544    /// Even though the property as already been set when instantiating this call,
12545    /// we provide this method for API completeness.
12546    pub fn language(mut self, new_value: &str) -> EditListingGetCall<'a, C> {
12547        self._language = new_value.to_string();
12548        self
12549    }
12550    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12551    /// while executing the actual API request.
12552    ///
12553    /// ````text
12554    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12555    /// ````
12556    ///
12557    /// Sets the *delegate* property to the given value.
12558    pub fn delegate(
12559        mut self,
12560        new_value: &'a mut dyn common::Delegate,
12561    ) -> EditListingGetCall<'a, C> {
12562        self._delegate = Some(new_value);
12563        self
12564    }
12565
12566    /// Set any additional parameter of the query string used in the request.
12567    /// It should be used to set parameters which are not yet available through their own
12568    /// setters.
12569    ///
12570    /// Please note that this method must not be used to set any of the known parameters
12571    /// which have their own setter method. If done anyway, the request will fail.
12572    ///
12573    /// # Additional Parameters
12574    ///
12575    /// * *alt* (query-string) - Data format for the response.
12576    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12577    /// * *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.
12578    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12579    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12580    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12581    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12582    pub fn param<T>(mut self, name: T, value: T) -> EditListingGetCall<'a, C>
12583    where
12584        T: AsRef<str>,
12585    {
12586        self._additional_params
12587            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12588        self
12589    }
12590
12591    /// Identifies the authorization scope for the method you are building.
12592    ///
12593    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12594    /// [`Scope::Full`].
12595    ///
12596    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12597    /// tokens for more than one scope.
12598    ///
12599    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12600    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12601    /// sufficient, a read-write scope will do as well.
12602    pub fn add_scope<St>(mut self, scope: St) -> EditListingGetCall<'a, C>
12603    where
12604        St: AsRef<str>,
12605    {
12606        self._scopes.insert(String::from(scope.as_ref()));
12607        self
12608    }
12609    /// Identifies the authorization scope(s) for the method you are building.
12610    ///
12611    /// See [`Self::add_scope()`] for details.
12612    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingGetCall<'a, C>
12613    where
12614        I: IntoIterator<Item = St>,
12615        St: AsRef<str>,
12616    {
12617        self._scopes
12618            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12619        self
12620    }
12621
12622    /// Removes all scopes, and no default scope will be used either.
12623    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12624    /// for details).
12625    pub fn clear_scopes(mut self) -> EditListingGetCall<'a, C> {
12626        self._scopes.clear();
12627        self
12628    }
12629}
12630
12631/// Returns all of the localized store listings attached to this edit.
12632///
12633/// A builder for the *listings.list* method supported by a *edit* resource.
12634/// It is not used directly, but through a [`EditMethods`] instance.
12635///
12636/// # Example
12637///
12638/// Instantiate a resource method builder
12639///
12640/// ```test_harness,no_run
12641/// # extern crate hyper;
12642/// # extern crate hyper_rustls;
12643/// # extern crate google_androidpublisher2 as androidpublisher2;
12644/// # async fn dox() {
12645/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12646///
12647/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12648/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12649/// #     .with_native_roots()
12650/// #     .unwrap()
12651/// #     .https_only()
12652/// #     .enable_http2()
12653/// #     .build();
12654///
12655/// # let executor = hyper_util::rt::TokioExecutor::new();
12656/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12657/// #     secret,
12658/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12659/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12660/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12661/// #     ),
12662/// # ).build().await.unwrap();
12663///
12664/// # let client = hyper_util::client::legacy::Client::builder(
12665/// #     hyper_util::rt::TokioExecutor::new()
12666/// # )
12667/// # .build(
12668/// #     hyper_rustls::HttpsConnectorBuilder::new()
12669/// #         .with_native_roots()
12670/// #         .unwrap()
12671/// #         .https_or_http()
12672/// #         .enable_http2()
12673/// #         .build()
12674/// # );
12675/// # let mut hub = AndroidPublisher::new(client, auth);
12676/// // You can configure optional parameters by calling the respective setters at will, and
12677/// // execute the final call using `doit()`.
12678/// // Values shown here are possibly random and not representative !
12679/// let result = hub.edits().listings_list("packageName", "editId")
12680///              .doit().await;
12681/// # }
12682/// ```
12683pub struct EditListingListCall<'a, C>
12684where
12685    C: 'a,
12686{
12687    hub: &'a AndroidPublisher<C>,
12688    _package_name: String,
12689    _edit_id: String,
12690    _delegate: Option<&'a mut dyn common::Delegate>,
12691    _additional_params: HashMap<String, String>,
12692    _scopes: BTreeSet<String>,
12693}
12694
12695impl<'a, C> common::CallBuilder for EditListingListCall<'a, C> {}
12696
12697impl<'a, C> EditListingListCall<'a, C>
12698where
12699    C: common::Connector,
12700{
12701    /// Perform the operation you have build so far.
12702    pub async fn doit(mut self) -> common::Result<(common::Response, ListingsListResponse)> {
12703        use std::borrow::Cow;
12704        use std::io::{Read, Seek};
12705
12706        use common::{url::Params, ToParts};
12707        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12708
12709        let mut dd = common::DefaultDelegate;
12710        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12711        dlg.begin(common::MethodInfo {
12712            id: "androidpublisher.edits.listings.list",
12713            http_method: hyper::Method::GET,
12714        });
12715
12716        for &field in ["alt", "packageName", "editId"].iter() {
12717            if self._additional_params.contains_key(field) {
12718                dlg.finished(false);
12719                return Err(common::Error::FieldClash(field));
12720            }
12721        }
12722
12723        let mut params = Params::with_capacity(4 + self._additional_params.len());
12724        params.push("packageName", self._package_name);
12725        params.push("editId", self._edit_id);
12726
12727        params.extend(self._additional_params.iter());
12728
12729        params.push("alt", "json");
12730        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings";
12731        if self._scopes.is_empty() {
12732            self._scopes.insert(Scope::Full.as_ref().to_string());
12733        }
12734
12735        #[allow(clippy::single_element_loop)]
12736        for &(find_this, param_name) in
12737            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
12738        {
12739            url = params.uri_replacement(url, param_name, find_this, false);
12740        }
12741        {
12742            let to_remove = ["editId", "packageName"];
12743            params.remove_params(&to_remove);
12744        }
12745
12746        let url = params.parse_with_url(&url);
12747
12748        loop {
12749            let token = match self
12750                .hub
12751                .auth
12752                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12753                .await
12754            {
12755                Ok(token) => token,
12756                Err(e) => match dlg.token(e) {
12757                    Ok(token) => token,
12758                    Err(e) => {
12759                        dlg.finished(false);
12760                        return Err(common::Error::MissingToken(e));
12761                    }
12762                },
12763            };
12764            let mut req_result = {
12765                let client = &self.hub.client;
12766                dlg.pre_request();
12767                let mut req_builder = hyper::Request::builder()
12768                    .method(hyper::Method::GET)
12769                    .uri(url.as_str())
12770                    .header(USER_AGENT, self.hub._user_agent.clone());
12771
12772                if let Some(token) = token.as_ref() {
12773                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12774                }
12775
12776                let request = req_builder
12777                    .header(CONTENT_LENGTH, 0_u64)
12778                    .body(common::to_body::<String>(None));
12779
12780                client.request(request.unwrap()).await
12781            };
12782
12783            match req_result {
12784                Err(err) => {
12785                    if let common::Retry::After(d) = dlg.http_error(&err) {
12786                        sleep(d).await;
12787                        continue;
12788                    }
12789                    dlg.finished(false);
12790                    return Err(common::Error::HttpError(err));
12791                }
12792                Ok(res) => {
12793                    let (mut parts, body) = res.into_parts();
12794                    let mut body = common::Body::new(body);
12795                    if !parts.status.is_success() {
12796                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12797                        let error = serde_json::from_str(&common::to_string(&bytes));
12798                        let response = common::to_response(parts, bytes.into());
12799
12800                        if let common::Retry::After(d) =
12801                            dlg.http_failure(&response, error.as_ref().ok())
12802                        {
12803                            sleep(d).await;
12804                            continue;
12805                        }
12806
12807                        dlg.finished(false);
12808
12809                        return Err(match error {
12810                            Ok(value) => common::Error::BadRequest(value),
12811                            _ => common::Error::Failure(response),
12812                        });
12813                    }
12814                    let response = {
12815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12816                        let encoded = common::to_string(&bytes);
12817                        match serde_json::from_str(&encoded) {
12818                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12819                            Err(error) => {
12820                                dlg.response_json_decode_error(&encoded, &error);
12821                                return Err(common::Error::JsonDecodeError(
12822                                    encoded.to_string(),
12823                                    error,
12824                                ));
12825                            }
12826                        }
12827                    };
12828
12829                    dlg.finished(true);
12830                    return Ok(response);
12831                }
12832            }
12833        }
12834    }
12835
12836    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
12837    ///
12838    /// Sets the *package name* path property to the given value.
12839    ///
12840    /// Even though the property as already been set when instantiating this call,
12841    /// we provide this method for API completeness.
12842    pub fn package_name(mut self, new_value: &str) -> EditListingListCall<'a, C> {
12843        self._package_name = new_value.to_string();
12844        self
12845    }
12846    /// Unique identifier for this edit.
12847    ///
12848    /// Sets the *edit id* path property to the given value.
12849    ///
12850    /// Even though the property as already been set when instantiating this call,
12851    /// we provide this method for API completeness.
12852    pub fn edit_id(mut self, new_value: &str) -> EditListingListCall<'a, C> {
12853        self._edit_id = new_value.to_string();
12854        self
12855    }
12856    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12857    /// while executing the actual API request.
12858    ///
12859    /// ````text
12860    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12861    /// ````
12862    ///
12863    /// Sets the *delegate* property to the given value.
12864    pub fn delegate(
12865        mut self,
12866        new_value: &'a mut dyn common::Delegate,
12867    ) -> EditListingListCall<'a, C> {
12868        self._delegate = Some(new_value);
12869        self
12870    }
12871
12872    /// Set any additional parameter of the query string used in the request.
12873    /// It should be used to set parameters which are not yet available through their own
12874    /// setters.
12875    ///
12876    /// Please note that this method must not be used to set any of the known parameters
12877    /// which have their own setter method. If done anyway, the request will fail.
12878    ///
12879    /// # Additional Parameters
12880    ///
12881    /// * *alt* (query-string) - Data format for the response.
12882    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12883    /// * *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.
12884    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12885    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12886    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12887    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12888    pub fn param<T>(mut self, name: T, value: T) -> EditListingListCall<'a, C>
12889    where
12890        T: AsRef<str>,
12891    {
12892        self._additional_params
12893            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12894        self
12895    }
12896
12897    /// Identifies the authorization scope for the method you are building.
12898    ///
12899    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12900    /// [`Scope::Full`].
12901    ///
12902    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12903    /// tokens for more than one scope.
12904    ///
12905    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12906    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12907    /// sufficient, a read-write scope will do as well.
12908    pub fn add_scope<St>(mut self, scope: St) -> EditListingListCall<'a, C>
12909    where
12910        St: AsRef<str>,
12911    {
12912        self._scopes.insert(String::from(scope.as_ref()));
12913        self
12914    }
12915    /// Identifies the authorization scope(s) for the method you are building.
12916    ///
12917    /// See [`Self::add_scope()`] for details.
12918    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingListCall<'a, C>
12919    where
12920        I: IntoIterator<Item = St>,
12921        St: AsRef<str>,
12922    {
12923        self._scopes
12924            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12925        self
12926    }
12927
12928    /// Removes all scopes, and no default scope will be used either.
12929    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12930    /// for details).
12931    pub fn clear_scopes(mut self) -> EditListingListCall<'a, C> {
12932        self._scopes.clear();
12933        self
12934    }
12935}
12936
12937/// Creates or updates a localized store listing. This method supports patch semantics.
12938///
12939/// A builder for the *listings.patch* method supported by a *edit* resource.
12940/// It is not used directly, but through a [`EditMethods`] instance.
12941///
12942/// # Example
12943///
12944/// Instantiate a resource method builder
12945///
12946/// ```test_harness,no_run
12947/// # extern crate hyper;
12948/// # extern crate hyper_rustls;
12949/// # extern crate google_androidpublisher2 as androidpublisher2;
12950/// use androidpublisher2::api::Listing;
12951/// # async fn dox() {
12952/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12953///
12954/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12955/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12956/// #     .with_native_roots()
12957/// #     .unwrap()
12958/// #     .https_only()
12959/// #     .enable_http2()
12960/// #     .build();
12961///
12962/// # let executor = hyper_util::rt::TokioExecutor::new();
12963/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12964/// #     secret,
12965/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12966/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12967/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12968/// #     ),
12969/// # ).build().await.unwrap();
12970///
12971/// # let client = hyper_util::client::legacy::Client::builder(
12972/// #     hyper_util::rt::TokioExecutor::new()
12973/// # )
12974/// # .build(
12975/// #     hyper_rustls::HttpsConnectorBuilder::new()
12976/// #         .with_native_roots()
12977/// #         .unwrap()
12978/// #         .https_or_http()
12979/// #         .enable_http2()
12980/// #         .build()
12981/// # );
12982/// # let mut hub = AndroidPublisher::new(client, auth);
12983/// // As the method needs a request, you would usually fill it with the desired information
12984/// // into the respective structure. Some of the parts shown here might not be applicable !
12985/// // Values shown here are possibly random and not representative !
12986/// let mut req = Listing::default();
12987///
12988/// // You can configure optional parameters by calling the respective setters at will, and
12989/// // execute the final call using `doit()`.
12990/// // Values shown here are possibly random and not representative !
12991/// let result = hub.edits().listings_patch(req, "packageName", "editId", "language")
12992///              .doit().await;
12993/// # }
12994/// ```
12995pub struct EditListingPatchCall<'a, C>
12996where
12997    C: 'a,
12998{
12999    hub: &'a AndroidPublisher<C>,
13000    _request: Listing,
13001    _package_name: String,
13002    _edit_id: String,
13003    _language: String,
13004    _delegate: Option<&'a mut dyn common::Delegate>,
13005    _additional_params: HashMap<String, String>,
13006    _scopes: BTreeSet<String>,
13007}
13008
13009impl<'a, C> common::CallBuilder for EditListingPatchCall<'a, C> {}
13010
13011impl<'a, C> EditListingPatchCall<'a, C>
13012where
13013    C: common::Connector,
13014{
13015    /// Perform the operation you have build so far.
13016    pub async fn doit(mut self) -> common::Result<(common::Response, Listing)> {
13017        use std::borrow::Cow;
13018        use std::io::{Read, Seek};
13019
13020        use common::{url::Params, ToParts};
13021        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13022
13023        let mut dd = common::DefaultDelegate;
13024        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13025        dlg.begin(common::MethodInfo {
13026            id: "androidpublisher.edits.listings.patch",
13027            http_method: hyper::Method::PATCH,
13028        });
13029
13030        for &field in ["alt", "packageName", "editId", "language"].iter() {
13031            if self._additional_params.contains_key(field) {
13032                dlg.finished(false);
13033                return Err(common::Error::FieldClash(field));
13034            }
13035        }
13036
13037        let mut params = Params::with_capacity(6 + self._additional_params.len());
13038        params.push("packageName", self._package_name);
13039        params.push("editId", self._edit_id);
13040        params.push("language", self._language);
13041
13042        params.extend(self._additional_params.iter());
13043
13044        params.push("alt", "json");
13045        let mut url =
13046            self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}";
13047        if self._scopes.is_empty() {
13048            self._scopes.insert(Scope::Full.as_ref().to_string());
13049        }
13050
13051        #[allow(clippy::single_element_loop)]
13052        for &(find_this, param_name) in [
13053            ("{packageName}", "packageName"),
13054            ("{editId}", "editId"),
13055            ("{language}", "language"),
13056        ]
13057        .iter()
13058        {
13059            url = params.uri_replacement(url, param_name, find_this, false);
13060        }
13061        {
13062            let to_remove = ["language", "editId", "packageName"];
13063            params.remove_params(&to_remove);
13064        }
13065
13066        let url = params.parse_with_url(&url);
13067
13068        let mut json_mime_type = mime::APPLICATION_JSON;
13069        let mut request_value_reader = {
13070            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13071            common::remove_json_null_values(&mut value);
13072            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13073            serde_json::to_writer(&mut dst, &value).unwrap();
13074            dst
13075        };
13076        let request_size = request_value_reader
13077            .seek(std::io::SeekFrom::End(0))
13078            .unwrap();
13079        request_value_reader
13080            .seek(std::io::SeekFrom::Start(0))
13081            .unwrap();
13082
13083        loop {
13084            let token = match self
13085                .hub
13086                .auth
13087                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13088                .await
13089            {
13090                Ok(token) => token,
13091                Err(e) => match dlg.token(e) {
13092                    Ok(token) => token,
13093                    Err(e) => {
13094                        dlg.finished(false);
13095                        return Err(common::Error::MissingToken(e));
13096                    }
13097                },
13098            };
13099            request_value_reader
13100                .seek(std::io::SeekFrom::Start(0))
13101                .unwrap();
13102            let mut req_result = {
13103                let client = &self.hub.client;
13104                dlg.pre_request();
13105                let mut req_builder = hyper::Request::builder()
13106                    .method(hyper::Method::PATCH)
13107                    .uri(url.as_str())
13108                    .header(USER_AGENT, self.hub._user_agent.clone());
13109
13110                if let Some(token) = token.as_ref() {
13111                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13112                }
13113
13114                let request = req_builder
13115                    .header(CONTENT_TYPE, json_mime_type.to_string())
13116                    .header(CONTENT_LENGTH, request_size as u64)
13117                    .body(common::to_body(
13118                        request_value_reader.get_ref().clone().into(),
13119                    ));
13120
13121                client.request(request.unwrap()).await
13122            };
13123
13124            match req_result {
13125                Err(err) => {
13126                    if let common::Retry::After(d) = dlg.http_error(&err) {
13127                        sleep(d).await;
13128                        continue;
13129                    }
13130                    dlg.finished(false);
13131                    return Err(common::Error::HttpError(err));
13132                }
13133                Ok(res) => {
13134                    let (mut parts, body) = res.into_parts();
13135                    let mut body = common::Body::new(body);
13136                    if !parts.status.is_success() {
13137                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13138                        let error = serde_json::from_str(&common::to_string(&bytes));
13139                        let response = common::to_response(parts, bytes.into());
13140
13141                        if let common::Retry::After(d) =
13142                            dlg.http_failure(&response, error.as_ref().ok())
13143                        {
13144                            sleep(d).await;
13145                            continue;
13146                        }
13147
13148                        dlg.finished(false);
13149
13150                        return Err(match error {
13151                            Ok(value) => common::Error::BadRequest(value),
13152                            _ => common::Error::Failure(response),
13153                        });
13154                    }
13155                    let response = {
13156                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13157                        let encoded = common::to_string(&bytes);
13158                        match serde_json::from_str(&encoded) {
13159                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13160                            Err(error) => {
13161                                dlg.response_json_decode_error(&encoded, &error);
13162                                return Err(common::Error::JsonDecodeError(
13163                                    encoded.to_string(),
13164                                    error,
13165                                ));
13166                            }
13167                        }
13168                    };
13169
13170                    dlg.finished(true);
13171                    return Ok(response);
13172                }
13173            }
13174        }
13175    }
13176
13177    ///
13178    /// Sets the *request* property to the given value.
13179    ///
13180    /// Even though the property as already been set when instantiating this call,
13181    /// we provide this method for API completeness.
13182    pub fn request(mut self, new_value: Listing) -> EditListingPatchCall<'a, C> {
13183        self._request = new_value;
13184        self
13185    }
13186    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
13187    ///
13188    /// Sets the *package name* path property to the given value.
13189    ///
13190    /// Even though the property as already been set when instantiating this call,
13191    /// we provide this method for API completeness.
13192    pub fn package_name(mut self, new_value: &str) -> EditListingPatchCall<'a, C> {
13193        self._package_name = new_value.to_string();
13194        self
13195    }
13196    /// Unique identifier for this edit.
13197    ///
13198    /// Sets the *edit id* path property to the given value.
13199    ///
13200    /// Even though the property as already been set when instantiating this call,
13201    /// we provide this method for API completeness.
13202    pub fn edit_id(mut self, new_value: &str) -> EditListingPatchCall<'a, C> {
13203        self._edit_id = new_value.to_string();
13204        self
13205    }
13206    /// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
13207    ///
13208    /// Sets the *language* path property to the given value.
13209    ///
13210    /// Even though the property as already been set when instantiating this call,
13211    /// we provide this method for API completeness.
13212    pub fn language(mut self, new_value: &str) -> EditListingPatchCall<'a, C> {
13213        self._language = new_value.to_string();
13214        self
13215    }
13216    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13217    /// while executing the actual API request.
13218    ///
13219    /// ````text
13220    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13221    /// ````
13222    ///
13223    /// Sets the *delegate* property to the given value.
13224    pub fn delegate(
13225        mut self,
13226        new_value: &'a mut dyn common::Delegate,
13227    ) -> EditListingPatchCall<'a, C> {
13228        self._delegate = Some(new_value);
13229        self
13230    }
13231
13232    /// Set any additional parameter of the query string used in the request.
13233    /// It should be used to set parameters which are not yet available through their own
13234    /// setters.
13235    ///
13236    /// Please note that this method must not be used to set any of the known parameters
13237    /// which have their own setter method. If done anyway, the request will fail.
13238    ///
13239    /// # Additional Parameters
13240    ///
13241    /// * *alt* (query-string) - Data format for the response.
13242    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13243    /// * *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.
13244    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13245    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13246    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13247    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13248    pub fn param<T>(mut self, name: T, value: T) -> EditListingPatchCall<'a, C>
13249    where
13250        T: AsRef<str>,
13251    {
13252        self._additional_params
13253            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13254        self
13255    }
13256
13257    /// Identifies the authorization scope for the method you are building.
13258    ///
13259    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13260    /// [`Scope::Full`].
13261    ///
13262    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13263    /// tokens for more than one scope.
13264    ///
13265    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13266    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13267    /// sufficient, a read-write scope will do as well.
13268    pub fn add_scope<St>(mut self, scope: St) -> EditListingPatchCall<'a, C>
13269    where
13270        St: AsRef<str>,
13271    {
13272        self._scopes.insert(String::from(scope.as_ref()));
13273        self
13274    }
13275    /// Identifies the authorization scope(s) for the method you are building.
13276    ///
13277    /// See [`Self::add_scope()`] for details.
13278    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingPatchCall<'a, C>
13279    where
13280        I: IntoIterator<Item = St>,
13281        St: AsRef<str>,
13282    {
13283        self._scopes
13284            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13285        self
13286    }
13287
13288    /// Removes all scopes, and no default scope will be used either.
13289    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13290    /// for details).
13291    pub fn clear_scopes(mut self) -> EditListingPatchCall<'a, C> {
13292        self._scopes.clear();
13293        self
13294    }
13295}
13296
13297/// Creates or updates a localized store listing.
13298///
13299/// A builder for the *listings.update* method supported by a *edit* resource.
13300/// It is not used directly, but through a [`EditMethods`] instance.
13301///
13302/// # Example
13303///
13304/// Instantiate a resource method builder
13305///
13306/// ```test_harness,no_run
13307/// # extern crate hyper;
13308/// # extern crate hyper_rustls;
13309/// # extern crate google_androidpublisher2 as androidpublisher2;
13310/// use androidpublisher2::api::Listing;
13311/// # async fn dox() {
13312/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13313///
13314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13316/// #     .with_native_roots()
13317/// #     .unwrap()
13318/// #     .https_only()
13319/// #     .enable_http2()
13320/// #     .build();
13321///
13322/// # let executor = hyper_util::rt::TokioExecutor::new();
13323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13324/// #     secret,
13325/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13326/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13327/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13328/// #     ),
13329/// # ).build().await.unwrap();
13330///
13331/// # let client = hyper_util::client::legacy::Client::builder(
13332/// #     hyper_util::rt::TokioExecutor::new()
13333/// # )
13334/// # .build(
13335/// #     hyper_rustls::HttpsConnectorBuilder::new()
13336/// #         .with_native_roots()
13337/// #         .unwrap()
13338/// #         .https_or_http()
13339/// #         .enable_http2()
13340/// #         .build()
13341/// # );
13342/// # let mut hub = AndroidPublisher::new(client, auth);
13343/// // As the method needs a request, you would usually fill it with the desired information
13344/// // into the respective structure. Some of the parts shown here might not be applicable !
13345/// // Values shown here are possibly random and not representative !
13346/// let mut req = Listing::default();
13347///
13348/// // You can configure optional parameters by calling the respective setters at will, and
13349/// // execute the final call using `doit()`.
13350/// // Values shown here are possibly random and not representative !
13351/// let result = hub.edits().listings_update(req, "packageName", "editId", "language")
13352///              .doit().await;
13353/// # }
13354/// ```
13355pub struct EditListingUpdateCall<'a, C>
13356where
13357    C: 'a,
13358{
13359    hub: &'a AndroidPublisher<C>,
13360    _request: Listing,
13361    _package_name: String,
13362    _edit_id: String,
13363    _language: String,
13364    _delegate: Option<&'a mut dyn common::Delegate>,
13365    _additional_params: HashMap<String, String>,
13366    _scopes: BTreeSet<String>,
13367}
13368
13369impl<'a, C> common::CallBuilder for EditListingUpdateCall<'a, C> {}
13370
13371impl<'a, C> EditListingUpdateCall<'a, C>
13372where
13373    C: common::Connector,
13374{
13375    /// Perform the operation you have build so far.
13376    pub async fn doit(mut self) -> common::Result<(common::Response, Listing)> {
13377        use std::borrow::Cow;
13378        use std::io::{Read, Seek};
13379
13380        use common::{url::Params, ToParts};
13381        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13382
13383        let mut dd = common::DefaultDelegate;
13384        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13385        dlg.begin(common::MethodInfo {
13386            id: "androidpublisher.edits.listings.update",
13387            http_method: hyper::Method::PUT,
13388        });
13389
13390        for &field in ["alt", "packageName", "editId", "language"].iter() {
13391            if self._additional_params.contains_key(field) {
13392                dlg.finished(false);
13393                return Err(common::Error::FieldClash(field));
13394            }
13395        }
13396
13397        let mut params = Params::with_capacity(6 + self._additional_params.len());
13398        params.push("packageName", self._package_name);
13399        params.push("editId", self._edit_id);
13400        params.push("language", self._language);
13401
13402        params.extend(self._additional_params.iter());
13403
13404        params.push("alt", "json");
13405        let mut url =
13406            self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}";
13407        if self._scopes.is_empty() {
13408            self._scopes.insert(Scope::Full.as_ref().to_string());
13409        }
13410
13411        #[allow(clippy::single_element_loop)]
13412        for &(find_this, param_name) in [
13413            ("{packageName}", "packageName"),
13414            ("{editId}", "editId"),
13415            ("{language}", "language"),
13416        ]
13417        .iter()
13418        {
13419            url = params.uri_replacement(url, param_name, find_this, false);
13420        }
13421        {
13422            let to_remove = ["language", "editId", "packageName"];
13423            params.remove_params(&to_remove);
13424        }
13425
13426        let url = params.parse_with_url(&url);
13427
13428        let mut json_mime_type = mime::APPLICATION_JSON;
13429        let mut request_value_reader = {
13430            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13431            common::remove_json_null_values(&mut value);
13432            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13433            serde_json::to_writer(&mut dst, &value).unwrap();
13434            dst
13435        };
13436        let request_size = request_value_reader
13437            .seek(std::io::SeekFrom::End(0))
13438            .unwrap();
13439        request_value_reader
13440            .seek(std::io::SeekFrom::Start(0))
13441            .unwrap();
13442
13443        loop {
13444            let token = match self
13445                .hub
13446                .auth
13447                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13448                .await
13449            {
13450                Ok(token) => token,
13451                Err(e) => match dlg.token(e) {
13452                    Ok(token) => token,
13453                    Err(e) => {
13454                        dlg.finished(false);
13455                        return Err(common::Error::MissingToken(e));
13456                    }
13457                },
13458            };
13459            request_value_reader
13460                .seek(std::io::SeekFrom::Start(0))
13461                .unwrap();
13462            let mut req_result = {
13463                let client = &self.hub.client;
13464                dlg.pre_request();
13465                let mut req_builder = hyper::Request::builder()
13466                    .method(hyper::Method::PUT)
13467                    .uri(url.as_str())
13468                    .header(USER_AGENT, self.hub._user_agent.clone());
13469
13470                if let Some(token) = token.as_ref() {
13471                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13472                }
13473
13474                let request = req_builder
13475                    .header(CONTENT_TYPE, json_mime_type.to_string())
13476                    .header(CONTENT_LENGTH, request_size as u64)
13477                    .body(common::to_body(
13478                        request_value_reader.get_ref().clone().into(),
13479                    ));
13480
13481                client.request(request.unwrap()).await
13482            };
13483
13484            match req_result {
13485                Err(err) => {
13486                    if let common::Retry::After(d) = dlg.http_error(&err) {
13487                        sleep(d).await;
13488                        continue;
13489                    }
13490                    dlg.finished(false);
13491                    return Err(common::Error::HttpError(err));
13492                }
13493                Ok(res) => {
13494                    let (mut parts, body) = res.into_parts();
13495                    let mut body = common::Body::new(body);
13496                    if !parts.status.is_success() {
13497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13498                        let error = serde_json::from_str(&common::to_string(&bytes));
13499                        let response = common::to_response(parts, bytes.into());
13500
13501                        if let common::Retry::After(d) =
13502                            dlg.http_failure(&response, error.as_ref().ok())
13503                        {
13504                            sleep(d).await;
13505                            continue;
13506                        }
13507
13508                        dlg.finished(false);
13509
13510                        return Err(match error {
13511                            Ok(value) => common::Error::BadRequest(value),
13512                            _ => common::Error::Failure(response),
13513                        });
13514                    }
13515                    let response = {
13516                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13517                        let encoded = common::to_string(&bytes);
13518                        match serde_json::from_str(&encoded) {
13519                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13520                            Err(error) => {
13521                                dlg.response_json_decode_error(&encoded, &error);
13522                                return Err(common::Error::JsonDecodeError(
13523                                    encoded.to_string(),
13524                                    error,
13525                                ));
13526                            }
13527                        }
13528                    };
13529
13530                    dlg.finished(true);
13531                    return Ok(response);
13532                }
13533            }
13534        }
13535    }
13536
13537    ///
13538    /// Sets the *request* property to the given value.
13539    ///
13540    /// Even though the property as already been set when instantiating this call,
13541    /// we provide this method for API completeness.
13542    pub fn request(mut self, new_value: Listing) -> EditListingUpdateCall<'a, C> {
13543        self._request = new_value;
13544        self
13545    }
13546    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
13547    ///
13548    /// Sets the *package name* path property to the given value.
13549    ///
13550    /// Even though the property as already been set when instantiating this call,
13551    /// we provide this method for API completeness.
13552    pub fn package_name(mut self, new_value: &str) -> EditListingUpdateCall<'a, C> {
13553        self._package_name = new_value.to_string();
13554        self
13555    }
13556    /// Unique identifier for this edit.
13557    ///
13558    /// Sets the *edit id* path property to the given value.
13559    ///
13560    /// Even though the property as already been set when instantiating this call,
13561    /// we provide this method for API completeness.
13562    pub fn edit_id(mut self, new_value: &str) -> EditListingUpdateCall<'a, C> {
13563        self._edit_id = new_value.to_string();
13564        self
13565    }
13566    /// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
13567    ///
13568    /// Sets the *language* path property to the given value.
13569    ///
13570    /// Even though the property as already been set when instantiating this call,
13571    /// we provide this method for API completeness.
13572    pub fn language(mut self, new_value: &str) -> EditListingUpdateCall<'a, C> {
13573        self._language = new_value.to_string();
13574        self
13575    }
13576    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13577    /// while executing the actual API request.
13578    ///
13579    /// ````text
13580    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13581    /// ````
13582    ///
13583    /// Sets the *delegate* property to the given value.
13584    pub fn delegate(
13585        mut self,
13586        new_value: &'a mut dyn common::Delegate,
13587    ) -> EditListingUpdateCall<'a, C> {
13588        self._delegate = Some(new_value);
13589        self
13590    }
13591
13592    /// Set any additional parameter of the query string used in the request.
13593    /// It should be used to set parameters which are not yet available through their own
13594    /// setters.
13595    ///
13596    /// Please note that this method must not be used to set any of the known parameters
13597    /// which have their own setter method. If done anyway, the request will fail.
13598    ///
13599    /// # Additional Parameters
13600    ///
13601    /// * *alt* (query-string) - Data format for the response.
13602    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13603    /// * *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.
13604    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13605    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13606    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13607    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13608    pub fn param<T>(mut self, name: T, value: T) -> EditListingUpdateCall<'a, C>
13609    where
13610        T: AsRef<str>,
13611    {
13612        self._additional_params
13613            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13614        self
13615    }
13616
13617    /// Identifies the authorization scope for the method you are building.
13618    ///
13619    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13620    /// [`Scope::Full`].
13621    ///
13622    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13623    /// tokens for more than one scope.
13624    ///
13625    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13626    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13627    /// sufficient, a read-write scope will do as well.
13628    pub fn add_scope<St>(mut self, scope: St) -> EditListingUpdateCall<'a, C>
13629    where
13630        St: AsRef<str>,
13631    {
13632        self._scopes.insert(String::from(scope.as_ref()));
13633        self
13634    }
13635    /// Identifies the authorization scope(s) for the method you are building.
13636    ///
13637    /// See [`Self::add_scope()`] for details.
13638    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingUpdateCall<'a, C>
13639    where
13640        I: IntoIterator<Item = St>,
13641        St: AsRef<str>,
13642    {
13643        self._scopes
13644            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13645        self
13646    }
13647
13648    /// Removes all scopes, and no default scope will be used either.
13649    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13650    /// for details).
13651    pub fn clear_scopes(mut self) -> EditListingUpdateCall<'a, C> {
13652        self._scopes.clear();
13653        self
13654    }
13655}
13656
13657/// A builder for the *testers.get* method supported by a *edit* resource.
13658/// It is not used directly, but through a [`EditMethods`] instance.
13659///
13660/// # Example
13661///
13662/// Instantiate a resource method builder
13663///
13664/// ```test_harness,no_run
13665/// # extern crate hyper;
13666/// # extern crate hyper_rustls;
13667/// # extern crate google_androidpublisher2 as androidpublisher2;
13668/// # async fn dox() {
13669/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13670///
13671/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13672/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13673/// #     .with_native_roots()
13674/// #     .unwrap()
13675/// #     .https_only()
13676/// #     .enable_http2()
13677/// #     .build();
13678///
13679/// # let executor = hyper_util::rt::TokioExecutor::new();
13680/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13681/// #     secret,
13682/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13683/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13684/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13685/// #     ),
13686/// # ).build().await.unwrap();
13687///
13688/// # let client = hyper_util::client::legacy::Client::builder(
13689/// #     hyper_util::rt::TokioExecutor::new()
13690/// # )
13691/// # .build(
13692/// #     hyper_rustls::HttpsConnectorBuilder::new()
13693/// #         .with_native_roots()
13694/// #         .unwrap()
13695/// #         .https_or_http()
13696/// #         .enable_http2()
13697/// #         .build()
13698/// # );
13699/// # let mut hub = AndroidPublisher::new(client, auth);
13700/// // You can configure optional parameters by calling the respective setters at will, and
13701/// // execute the final call using `doit()`.
13702/// // Values shown here are possibly random and not representative !
13703/// let result = hub.edits().testers_get("packageName", "editId", "track")
13704///              .doit().await;
13705/// # }
13706/// ```
13707pub struct EditTesterGetCall<'a, C>
13708where
13709    C: 'a,
13710{
13711    hub: &'a AndroidPublisher<C>,
13712    _package_name: String,
13713    _edit_id: String,
13714    _track: String,
13715    _delegate: Option<&'a mut dyn common::Delegate>,
13716    _additional_params: HashMap<String, String>,
13717    _scopes: BTreeSet<String>,
13718}
13719
13720impl<'a, C> common::CallBuilder for EditTesterGetCall<'a, C> {}
13721
13722impl<'a, C> EditTesterGetCall<'a, C>
13723where
13724    C: common::Connector,
13725{
13726    /// Perform the operation you have build so far.
13727    pub async fn doit(mut self) -> common::Result<(common::Response, Testers)> {
13728        use std::borrow::Cow;
13729        use std::io::{Read, Seek};
13730
13731        use common::{url::Params, ToParts};
13732        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13733
13734        let mut dd = common::DefaultDelegate;
13735        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13736        dlg.begin(common::MethodInfo {
13737            id: "androidpublisher.edits.testers.get",
13738            http_method: hyper::Method::GET,
13739        });
13740
13741        for &field in ["alt", "packageName", "editId", "track"].iter() {
13742            if self._additional_params.contains_key(field) {
13743                dlg.finished(false);
13744                return Err(common::Error::FieldClash(field));
13745            }
13746        }
13747
13748        let mut params = Params::with_capacity(5 + self._additional_params.len());
13749        params.push("packageName", self._package_name);
13750        params.push("editId", self._edit_id);
13751        params.push("track", self._track);
13752
13753        params.extend(self._additional_params.iter());
13754
13755        params.push("alt", "json");
13756        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/testers/{track}";
13757        if self._scopes.is_empty() {
13758            self._scopes.insert(Scope::Full.as_ref().to_string());
13759        }
13760
13761        #[allow(clippy::single_element_loop)]
13762        for &(find_this, param_name) in [
13763            ("{packageName}", "packageName"),
13764            ("{editId}", "editId"),
13765            ("{track}", "track"),
13766        ]
13767        .iter()
13768        {
13769            url = params.uri_replacement(url, param_name, find_this, false);
13770        }
13771        {
13772            let to_remove = ["track", "editId", "packageName"];
13773            params.remove_params(&to_remove);
13774        }
13775
13776        let url = params.parse_with_url(&url);
13777
13778        loop {
13779            let token = match self
13780                .hub
13781                .auth
13782                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13783                .await
13784            {
13785                Ok(token) => token,
13786                Err(e) => match dlg.token(e) {
13787                    Ok(token) => token,
13788                    Err(e) => {
13789                        dlg.finished(false);
13790                        return Err(common::Error::MissingToken(e));
13791                    }
13792                },
13793            };
13794            let mut req_result = {
13795                let client = &self.hub.client;
13796                dlg.pre_request();
13797                let mut req_builder = hyper::Request::builder()
13798                    .method(hyper::Method::GET)
13799                    .uri(url.as_str())
13800                    .header(USER_AGENT, self.hub._user_agent.clone());
13801
13802                if let Some(token) = token.as_ref() {
13803                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13804                }
13805
13806                let request = req_builder
13807                    .header(CONTENT_LENGTH, 0_u64)
13808                    .body(common::to_body::<String>(None));
13809
13810                client.request(request.unwrap()).await
13811            };
13812
13813            match req_result {
13814                Err(err) => {
13815                    if let common::Retry::After(d) = dlg.http_error(&err) {
13816                        sleep(d).await;
13817                        continue;
13818                    }
13819                    dlg.finished(false);
13820                    return Err(common::Error::HttpError(err));
13821                }
13822                Ok(res) => {
13823                    let (mut parts, body) = res.into_parts();
13824                    let mut body = common::Body::new(body);
13825                    if !parts.status.is_success() {
13826                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13827                        let error = serde_json::from_str(&common::to_string(&bytes));
13828                        let response = common::to_response(parts, bytes.into());
13829
13830                        if let common::Retry::After(d) =
13831                            dlg.http_failure(&response, error.as_ref().ok())
13832                        {
13833                            sleep(d).await;
13834                            continue;
13835                        }
13836
13837                        dlg.finished(false);
13838
13839                        return Err(match error {
13840                            Ok(value) => common::Error::BadRequest(value),
13841                            _ => common::Error::Failure(response),
13842                        });
13843                    }
13844                    let response = {
13845                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13846                        let encoded = common::to_string(&bytes);
13847                        match serde_json::from_str(&encoded) {
13848                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13849                            Err(error) => {
13850                                dlg.response_json_decode_error(&encoded, &error);
13851                                return Err(common::Error::JsonDecodeError(
13852                                    encoded.to_string(),
13853                                    error,
13854                                ));
13855                            }
13856                        }
13857                    };
13858
13859                    dlg.finished(true);
13860                    return Ok(response);
13861                }
13862            }
13863        }
13864    }
13865
13866    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
13867    ///
13868    /// Sets the *package name* path property to the given value.
13869    ///
13870    /// Even though the property as already been set when instantiating this call,
13871    /// we provide this method for API completeness.
13872    pub fn package_name(mut self, new_value: &str) -> EditTesterGetCall<'a, C> {
13873        self._package_name = new_value.to_string();
13874        self
13875    }
13876    /// Unique identifier for this edit.
13877    ///
13878    /// Sets the *edit id* path property to the given value.
13879    ///
13880    /// Even though the property as already been set when instantiating this call,
13881    /// we provide this method for API completeness.
13882    pub fn edit_id(mut self, new_value: &str) -> EditTesterGetCall<'a, C> {
13883        self._edit_id = new_value.to_string();
13884        self
13885    }
13886    /// The track to read or modify.
13887    ///
13888    /// Sets the *track* path property to the given value.
13889    ///
13890    /// Even though the property as already been set when instantiating this call,
13891    /// we provide this method for API completeness.
13892    pub fn track(mut self, new_value: &str) -> EditTesterGetCall<'a, C> {
13893        self._track = new_value.to_string();
13894        self
13895    }
13896    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13897    /// while executing the actual API request.
13898    ///
13899    /// ````text
13900    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13901    /// ````
13902    ///
13903    /// Sets the *delegate* property to the given value.
13904    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditTesterGetCall<'a, C> {
13905        self._delegate = Some(new_value);
13906        self
13907    }
13908
13909    /// Set any additional parameter of the query string used in the request.
13910    /// It should be used to set parameters which are not yet available through their own
13911    /// setters.
13912    ///
13913    /// Please note that this method must not be used to set any of the known parameters
13914    /// which have their own setter method. If done anyway, the request will fail.
13915    ///
13916    /// # Additional Parameters
13917    ///
13918    /// * *alt* (query-string) - Data format for the response.
13919    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13920    /// * *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.
13921    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13922    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13923    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13924    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13925    pub fn param<T>(mut self, name: T, value: T) -> EditTesterGetCall<'a, C>
13926    where
13927        T: AsRef<str>,
13928    {
13929        self._additional_params
13930            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13931        self
13932    }
13933
13934    /// Identifies the authorization scope for the method you are building.
13935    ///
13936    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13937    /// [`Scope::Full`].
13938    ///
13939    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13940    /// tokens for more than one scope.
13941    ///
13942    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13943    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13944    /// sufficient, a read-write scope will do as well.
13945    pub fn add_scope<St>(mut self, scope: St) -> EditTesterGetCall<'a, C>
13946    where
13947        St: AsRef<str>,
13948    {
13949        self._scopes.insert(String::from(scope.as_ref()));
13950        self
13951    }
13952    /// Identifies the authorization scope(s) for the method you are building.
13953    ///
13954    /// See [`Self::add_scope()`] for details.
13955    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTesterGetCall<'a, C>
13956    where
13957        I: IntoIterator<Item = St>,
13958        St: AsRef<str>,
13959    {
13960        self._scopes
13961            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13962        self
13963    }
13964
13965    /// Removes all scopes, and no default scope will be used either.
13966    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13967    /// for details).
13968    pub fn clear_scopes(mut self) -> EditTesterGetCall<'a, C> {
13969        self._scopes.clear();
13970        self
13971    }
13972}
13973
13974/// A builder for the *testers.patch* method supported by a *edit* resource.
13975/// It is not used directly, but through a [`EditMethods`] instance.
13976///
13977/// # Example
13978///
13979/// Instantiate a resource method builder
13980///
13981/// ```test_harness,no_run
13982/// # extern crate hyper;
13983/// # extern crate hyper_rustls;
13984/// # extern crate google_androidpublisher2 as androidpublisher2;
13985/// use androidpublisher2::api::Testers;
13986/// # async fn dox() {
13987/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13988///
13989/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13990/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13991/// #     .with_native_roots()
13992/// #     .unwrap()
13993/// #     .https_only()
13994/// #     .enable_http2()
13995/// #     .build();
13996///
13997/// # let executor = hyper_util::rt::TokioExecutor::new();
13998/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13999/// #     secret,
14000/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14001/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14002/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14003/// #     ),
14004/// # ).build().await.unwrap();
14005///
14006/// # let client = hyper_util::client::legacy::Client::builder(
14007/// #     hyper_util::rt::TokioExecutor::new()
14008/// # )
14009/// # .build(
14010/// #     hyper_rustls::HttpsConnectorBuilder::new()
14011/// #         .with_native_roots()
14012/// #         .unwrap()
14013/// #         .https_or_http()
14014/// #         .enable_http2()
14015/// #         .build()
14016/// # );
14017/// # let mut hub = AndroidPublisher::new(client, auth);
14018/// // As the method needs a request, you would usually fill it with the desired information
14019/// // into the respective structure. Some of the parts shown here might not be applicable !
14020/// // Values shown here are possibly random and not representative !
14021/// let mut req = Testers::default();
14022///
14023/// // You can configure optional parameters by calling the respective setters at will, and
14024/// // execute the final call using `doit()`.
14025/// // Values shown here are possibly random and not representative !
14026/// let result = hub.edits().testers_patch(req, "packageName", "editId", "track")
14027///              .doit().await;
14028/// # }
14029/// ```
14030pub struct EditTesterPatchCall<'a, C>
14031where
14032    C: 'a,
14033{
14034    hub: &'a AndroidPublisher<C>,
14035    _request: Testers,
14036    _package_name: String,
14037    _edit_id: String,
14038    _track: String,
14039    _delegate: Option<&'a mut dyn common::Delegate>,
14040    _additional_params: HashMap<String, String>,
14041    _scopes: BTreeSet<String>,
14042}
14043
14044impl<'a, C> common::CallBuilder for EditTesterPatchCall<'a, C> {}
14045
14046impl<'a, C> EditTesterPatchCall<'a, C>
14047where
14048    C: common::Connector,
14049{
14050    /// Perform the operation you have build so far.
14051    pub async fn doit(mut self) -> common::Result<(common::Response, Testers)> {
14052        use std::borrow::Cow;
14053        use std::io::{Read, Seek};
14054
14055        use common::{url::Params, ToParts};
14056        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14057
14058        let mut dd = common::DefaultDelegate;
14059        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14060        dlg.begin(common::MethodInfo {
14061            id: "androidpublisher.edits.testers.patch",
14062            http_method: hyper::Method::PATCH,
14063        });
14064
14065        for &field in ["alt", "packageName", "editId", "track"].iter() {
14066            if self._additional_params.contains_key(field) {
14067                dlg.finished(false);
14068                return Err(common::Error::FieldClash(field));
14069            }
14070        }
14071
14072        let mut params = Params::with_capacity(6 + self._additional_params.len());
14073        params.push("packageName", self._package_name);
14074        params.push("editId", self._edit_id);
14075        params.push("track", self._track);
14076
14077        params.extend(self._additional_params.iter());
14078
14079        params.push("alt", "json");
14080        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/testers/{track}";
14081        if self._scopes.is_empty() {
14082            self._scopes.insert(Scope::Full.as_ref().to_string());
14083        }
14084
14085        #[allow(clippy::single_element_loop)]
14086        for &(find_this, param_name) in [
14087            ("{packageName}", "packageName"),
14088            ("{editId}", "editId"),
14089            ("{track}", "track"),
14090        ]
14091        .iter()
14092        {
14093            url = params.uri_replacement(url, param_name, find_this, false);
14094        }
14095        {
14096            let to_remove = ["track", "editId", "packageName"];
14097            params.remove_params(&to_remove);
14098        }
14099
14100        let url = params.parse_with_url(&url);
14101
14102        let mut json_mime_type = mime::APPLICATION_JSON;
14103        let mut request_value_reader = {
14104            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14105            common::remove_json_null_values(&mut value);
14106            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14107            serde_json::to_writer(&mut dst, &value).unwrap();
14108            dst
14109        };
14110        let request_size = request_value_reader
14111            .seek(std::io::SeekFrom::End(0))
14112            .unwrap();
14113        request_value_reader
14114            .seek(std::io::SeekFrom::Start(0))
14115            .unwrap();
14116
14117        loop {
14118            let token = match self
14119                .hub
14120                .auth
14121                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14122                .await
14123            {
14124                Ok(token) => token,
14125                Err(e) => match dlg.token(e) {
14126                    Ok(token) => token,
14127                    Err(e) => {
14128                        dlg.finished(false);
14129                        return Err(common::Error::MissingToken(e));
14130                    }
14131                },
14132            };
14133            request_value_reader
14134                .seek(std::io::SeekFrom::Start(0))
14135                .unwrap();
14136            let mut req_result = {
14137                let client = &self.hub.client;
14138                dlg.pre_request();
14139                let mut req_builder = hyper::Request::builder()
14140                    .method(hyper::Method::PATCH)
14141                    .uri(url.as_str())
14142                    .header(USER_AGENT, self.hub._user_agent.clone());
14143
14144                if let Some(token) = token.as_ref() {
14145                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14146                }
14147
14148                let request = req_builder
14149                    .header(CONTENT_TYPE, json_mime_type.to_string())
14150                    .header(CONTENT_LENGTH, request_size as u64)
14151                    .body(common::to_body(
14152                        request_value_reader.get_ref().clone().into(),
14153                    ));
14154
14155                client.request(request.unwrap()).await
14156            };
14157
14158            match req_result {
14159                Err(err) => {
14160                    if let common::Retry::After(d) = dlg.http_error(&err) {
14161                        sleep(d).await;
14162                        continue;
14163                    }
14164                    dlg.finished(false);
14165                    return Err(common::Error::HttpError(err));
14166                }
14167                Ok(res) => {
14168                    let (mut parts, body) = res.into_parts();
14169                    let mut body = common::Body::new(body);
14170                    if !parts.status.is_success() {
14171                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14172                        let error = serde_json::from_str(&common::to_string(&bytes));
14173                        let response = common::to_response(parts, bytes.into());
14174
14175                        if let common::Retry::After(d) =
14176                            dlg.http_failure(&response, error.as_ref().ok())
14177                        {
14178                            sleep(d).await;
14179                            continue;
14180                        }
14181
14182                        dlg.finished(false);
14183
14184                        return Err(match error {
14185                            Ok(value) => common::Error::BadRequest(value),
14186                            _ => common::Error::Failure(response),
14187                        });
14188                    }
14189                    let response = {
14190                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14191                        let encoded = common::to_string(&bytes);
14192                        match serde_json::from_str(&encoded) {
14193                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14194                            Err(error) => {
14195                                dlg.response_json_decode_error(&encoded, &error);
14196                                return Err(common::Error::JsonDecodeError(
14197                                    encoded.to_string(),
14198                                    error,
14199                                ));
14200                            }
14201                        }
14202                    };
14203
14204                    dlg.finished(true);
14205                    return Ok(response);
14206                }
14207            }
14208        }
14209    }
14210
14211    ///
14212    /// Sets the *request* property to the given value.
14213    ///
14214    /// Even though the property as already been set when instantiating this call,
14215    /// we provide this method for API completeness.
14216    pub fn request(mut self, new_value: Testers) -> EditTesterPatchCall<'a, C> {
14217        self._request = new_value;
14218        self
14219    }
14220    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
14221    ///
14222    /// Sets the *package name* path property to the given value.
14223    ///
14224    /// Even though the property as already been set when instantiating this call,
14225    /// we provide this method for API completeness.
14226    pub fn package_name(mut self, new_value: &str) -> EditTesterPatchCall<'a, C> {
14227        self._package_name = new_value.to_string();
14228        self
14229    }
14230    /// Unique identifier for this edit.
14231    ///
14232    /// Sets the *edit id* path property to the given value.
14233    ///
14234    /// Even though the property as already been set when instantiating this call,
14235    /// we provide this method for API completeness.
14236    pub fn edit_id(mut self, new_value: &str) -> EditTesterPatchCall<'a, C> {
14237        self._edit_id = new_value.to_string();
14238        self
14239    }
14240    /// The track to read or modify.
14241    ///
14242    /// Sets the *track* path property to the given value.
14243    ///
14244    /// Even though the property as already been set when instantiating this call,
14245    /// we provide this method for API completeness.
14246    pub fn track(mut self, new_value: &str) -> EditTesterPatchCall<'a, C> {
14247        self._track = new_value.to_string();
14248        self
14249    }
14250    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14251    /// while executing the actual API request.
14252    ///
14253    /// ````text
14254    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14255    /// ````
14256    ///
14257    /// Sets the *delegate* property to the given value.
14258    pub fn delegate(
14259        mut self,
14260        new_value: &'a mut dyn common::Delegate,
14261    ) -> EditTesterPatchCall<'a, C> {
14262        self._delegate = Some(new_value);
14263        self
14264    }
14265
14266    /// Set any additional parameter of the query string used in the request.
14267    /// It should be used to set parameters which are not yet available through their own
14268    /// setters.
14269    ///
14270    /// Please note that this method must not be used to set any of the known parameters
14271    /// which have their own setter method. If done anyway, the request will fail.
14272    ///
14273    /// # Additional Parameters
14274    ///
14275    /// * *alt* (query-string) - Data format for the response.
14276    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14277    /// * *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.
14278    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14279    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14280    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14281    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14282    pub fn param<T>(mut self, name: T, value: T) -> EditTesterPatchCall<'a, C>
14283    where
14284        T: AsRef<str>,
14285    {
14286        self._additional_params
14287            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14288        self
14289    }
14290
14291    /// Identifies the authorization scope for the method you are building.
14292    ///
14293    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14294    /// [`Scope::Full`].
14295    ///
14296    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14297    /// tokens for more than one scope.
14298    ///
14299    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14300    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14301    /// sufficient, a read-write scope will do as well.
14302    pub fn add_scope<St>(mut self, scope: St) -> EditTesterPatchCall<'a, C>
14303    where
14304        St: AsRef<str>,
14305    {
14306        self._scopes.insert(String::from(scope.as_ref()));
14307        self
14308    }
14309    /// Identifies the authorization scope(s) for the method you are building.
14310    ///
14311    /// See [`Self::add_scope()`] for details.
14312    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTesterPatchCall<'a, C>
14313    where
14314        I: IntoIterator<Item = St>,
14315        St: AsRef<str>,
14316    {
14317        self._scopes
14318            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14319        self
14320    }
14321
14322    /// Removes all scopes, and no default scope will be used either.
14323    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14324    /// for details).
14325    pub fn clear_scopes(mut self) -> EditTesterPatchCall<'a, C> {
14326        self._scopes.clear();
14327        self
14328    }
14329}
14330
14331/// A builder for the *testers.update* method supported by a *edit* resource.
14332/// It is not used directly, but through a [`EditMethods`] instance.
14333///
14334/// # Example
14335///
14336/// Instantiate a resource method builder
14337///
14338/// ```test_harness,no_run
14339/// # extern crate hyper;
14340/// # extern crate hyper_rustls;
14341/// # extern crate google_androidpublisher2 as androidpublisher2;
14342/// use androidpublisher2::api::Testers;
14343/// # async fn dox() {
14344/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14345///
14346/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14347/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14348/// #     .with_native_roots()
14349/// #     .unwrap()
14350/// #     .https_only()
14351/// #     .enable_http2()
14352/// #     .build();
14353///
14354/// # let executor = hyper_util::rt::TokioExecutor::new();
14355/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14356/// #     secret,
14357/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14358/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14359/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14360/// #     ),
14361/// # ).build().await.unwrap();
14362///
14363/// # let client = hyper_util::client::legacy::Client::builder(
14364/// #     hyper_util::rt::TokioExecutor::new()
14365/// # )
14366/// # .build(
14367/// #     hyper_rustls::HttpsConnectorBuilder::new()
14368/// #         .with_native_roots()
14369/// #         .unwrap()
14370/// #         .https_or_http()
14371/// #         .enable_http2()
14372/// #         .build()
14373/// # );
14374/// # let mut hub = AndroidPublisher::new(client, auth);
14375/// // As the method needs a request, you would usually fill it with the desired information
14376/// // into the respective structure. Some of the parts shown here might not be applicable !
14377/// // Values shown here are possibly random and not representative !
14378/// let mut req = Testers::default();
14379///
14380/// // You can configure optional parameters by calling the respective setters at will, and
14381/// // execute the final call using `doit()`.
14382/// // Values shown here are possibly random and not representative !
14383/// let result = hub.edits().testers_update(req, "packageName", "editId", "track")
14384///              .doit().await;
14385/// # }
14386/// ```
14387pub struct EditTesterUpdateCall<'a, C>
14388where
14389    C: 'a,
14390{
14391    hub: &'a AndroidPublisher<C>,
14392    _request: Testers,
14393    _package_name: String,
14394    _edit_id: String,
14395    _track: String,
14396    _delegate: Option<&'a mut dyn common::Delegate>,
14397    _additional_params: HashMap<String, String>,
14398    _scopes: BTreeSet<String>,
14399}
14400
14401impl<'a, C> common::CallBuilder for EditTesterUpdateCall<'a, C> {}
14402
14403impl<'a, C> EditTesterUpdateCall<'a, C>
14404where
14405    C: common::Connector,
14406{
14407    /// Perform the operation you have build so far.
14408    pub async fn doit(mut self) -> common::Result<(common::Response, Testers)> {
14409        use std::borrow::Cow;
14410        use std::io::{Read, Seek};
14411
14412        use common::{url::Params, ToParts};
14413        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14414
14415        let mut dd = common::DefaultDelegate;
14416        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14417        dlg.begin(common::MethodInfo {
14418            id: "androidpublisher.edits.testers.update",
14419            http_method: hyper::Method::PUT,
14420        });
14421
14422        for &field in ["alt", "packageName", "editId", "track"].iter() {
14423            if self._additional_params.contains_key(field) {
14424                dlg.finished(false);
14425                return Err(common::Error::FieldClash(field));
14426            }
14427        }
14428
14429        let mut params = Params::with_capacity(6 + self._additional_params.len());
14430        params.push("packageName", self._package_name);
14431        params.push("editId", self._edit_id);
14432        params.push("track", self._track);
14433
14434        params.extend(self._additional_params.iter());
14435
14436        params.push("alt", "json");
14437        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/testers/{track}";
14438        if self._scopes.is_empty() {
14439            self._scopes.insert(Scope::Full.as_ref().to_string());
14440        }
14441
14442        #[allow(clippy::single_element_loop)]
14443        for &(find_this, param_name) in [
14444            ("{packageName}", "packageName"),
14445            ("{editId}", "editId"),
14446            ("{track}", "track"),
14447        ]
14448        .iter()
14449        {
14450            url = params.uri_replacement(url, param_name, find_this, false);
14451        }
14452        {
14453            let to_remove = ["track", "editId", "packageName"];
14454            params.remove_params(&to_remove);
14455        }
14456
14457        let url = params.parse_with_url(&url);
14458
14459        let mut json_mime_type = mime::APPLICATION_JSON;
14460        let mut request_value_reader = {
14461            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14462            common::remove_json_null_values(&mut value);
14463            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14464            serde_json::to_writer(&mut dst, &value).unwrap();
14465            dst
14466        };
14467        let request_size = request_value_reader
14468            .seek(std::io::SeekFrom::End(0))
14469            .unwrap();
14470        request_value_reader
14471            .seek(std::io::SeekFrom::Start(0))
14472            .unwrap();
14473
14474        loop {
14475            let token = match self
14476                .hub
14477                .auth
14478                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14479                .await
14480            {
14481                Ok(token) => token,
14482                Err(e) => match dlg.token(e) {
14483                    Ok(token) => token,
14484                    Err(e) => {
14485                        dlg.finished(false);
14486                        return Err(common::Error::MissingToken(e));
14487                    }
14488                },
14489            };
14490            request_value_reader
14491                .seek(std::io::SeekFrom::Start(0))
14492                .unwrap();
14493            let mut req_result = {
14494                let client = &self.hub.client;
14495                dlg.pre_request();
14496                let mut req_builder = hyper::Request::builder()
14497                    .method(hyper::Method::PUT)
14498                    .uri(url.as_str())
14499                    .header(USER_AGENT, self.hub._user_agent.clone());
14500
14501                if let Some(token) = token.as_ref() {
14502                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14503                }
14504
14505                let request = req_builder
14506                    .header(CONTENT_TYPE, json_mime_type.to_string())
14507                    .header(CONTENT_LENGTH, request_size as u64)
14508                    .body(common::to_body(
14509                        request_value_reader.get_ref().clone().into(),
14510                    ));
14511
14512                client.request(request.unwrap()).await
14513            };
14514
14515            match req_result {
14516                Err(err) => {
14517                    if let common::Retry::After(d) = dlg.http_error(&err) {
14518                        sleep(d).await;
14519                        continue;
14520                    }
14521                    dlg.finished(false);
14522                    return Err(common::Error::HttpError(err));
14523                }
14524                Ok(res) => {
14525                    let (mut parts, body) = res.into_parts();
14526                    let mut body = common::Body::new(body);
14527                    if !parts.status.is_success() {
14528                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14529                        let error = serde_json::from_str(&common::to_string(&bytes));
14530                        let response = common::to_response(parts, bytes.into());
14531
14532                        if let common::Retry::After(d) =
14533                            dlg.http_failure(&response, error.as_ref().ok())
14534                        {
14535                            sleep(d).await;
14536                            continue;
14537                        }
14538
14539                        dlg.finished(false);
14540
14541                        return Err(match error {
14542                            Ok(value) => common::Error::BadRequest(value),
14543                            _ => common::Error::Failure(response),
14544                        });
14545                    }
14546                    let response = {
14547                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14548                        let encoded = common::to_string(&bytes);
14549                        match serde_json::from_str(&encoded) {
14550                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14551                            Err(error) => {
14552                                dlg.response_json_decode_error(&encoded, &error);
14553                                return Err(common::Error::JsonDecodeError(
14554                                    encoded.to_string(),
14555                                    error,
14556                                ));
14557                            }
14558                        }
14559                    };
14560
14561                    dlg.finished(true);
14562                    return Ok(response);
14563                }
14564            }
14565        }
14566    }
14567
14568    ///
14569    /// Sets the *request* property to the given value.
14570    ///
14571    /// Even though the property as already been set when instantiating this call,
14572    /// we provide this method for API completeness.
14573    pub fn request(mut self, new_value: Testers) -> EditTesterUpdateCall<'a, C> {
14574        self._request = new_value;
14575        self
14576    }
14577    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
14578    ///
14579    /// Sets the *package name* path property to the given value.
14580    ///
14581    /// Even though the property as already been set when instantiating this call,
14582    /// we provide this method for API completeness.
14583    pub fn package_name(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C> {
14584        self._package_name = new_value.to_string();
14585        self
14586    }
14587    /// Unique identifier for this edit.
14588    ///
14589    /// Sets the *edit id* path property to the given value.
14590    ///
14591    /// Even though the property as already been set when instantiating this call,
14592    /// we provide this method for API completeness.
14593    pub fn edit_id(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C> {
14594        self._edit_id = new_value.to_string();
14595        self
14596    }
14597    /// The track to read or modify.
14598    ///
14599    /// Sets the *track* path property to the given value.
14600    ///
14601    /// Even though the property as already been set when instantiating this call,
14602    /// we provide this method for API completeness.
14603    pub fn track(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C> {
14604        self._track = new_value.to_string();
14605        self
14606    }
14607    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14608    /// while executing the actual API request.
14609    ///
14610    /// ````text
14611    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14612    /// ````
14613    ///
14614    /// Sets the *delegate* property to the given value.
14615    pub fn delegate(
14616        mut self,
14617        new_value: &'a mut dyn common::Delegate,
14618    ) -> EditTesterUpdateCall<'a, C> {
14619        self._delegate = Some(new_value);
14620        self
14621    }
14622
14623    /// Set any additional parameter of the query string used in the request.
14624    /// It should be used to set parameters which are not yet available through their own
14625    /// setters.
14626    ///
14627    /// Please note that this method must not be used to set any of the known parameters
14628    /// which have their own setter method. If done anyway, the request will fail.
14629    ///
14630    /// # Additional Parameters
14631    ///
14632    /// * *alt* (query-string) - Data format for the response.
14633    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14634    /// * *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.
14635    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14636    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14637    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14638    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14639    pub fn param<T>(mut self, name: T, value: T) -> EditTesterUpdateCall<'a, C>
14640    where
14641        T: AsRef<str>,
14642    {
14643        self._additional_params
14644            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14645        self
14646    }
14647
14648    /// Identifies the authorization scope for the method you are building.
14649    ///
14650    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14651    /// [`Scope::Full`].
14652    ///
14653    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14654    /// tokens for more than one scope.
14655    ///
14656    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14657    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14658    /// sufficient, a read-write scope will do as well.
14659    pub fn add_scope<St>(mut self, scope: St) -> EditTesterUpdateCall<'a, C>
14660    where
14661        St: AsRef<str>,
14662    {
14663        self._scopes.insert(String::from(scope.as_ref()));
14664        self
14665    }
14666    /// Identifies the authorization scope(s) for the method you are building.
14667    ///
14668    /// See [`Self::add_scope()`] for details.
14669    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTesterUpdateCall<'a, C>
14670    where
14671        I: IntoIterator<Item = St>,
14672        St: AsRef<str>,
14673    {
14674        self._scopes
14675            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14676        self
14677    }
14678
14679    /// Removes all scopes, and no default scope will be used either.
14680    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14681    /// for details).
14682    pub fn clear_scopes(mut self) -> EditTesterUpdateCall<'a, C> {
14683        self._scopes.clear();
14684        self
14685    }
14686}
14687
14688/// Fetches the track configuration for the specified track type. Includes the APK version codes that are in this track.
14689///
14690/// A builder for the *tracks.get* method supported by a *edit* resource.
14691/// It is not used directly, but through a [`EditMethods`] instance.
14692///
14693/// # Example
14694///
14695/// Instantiate a resource method builder
14696///
14697/// ```test_harness,no_run
14698/// # extern crate hyper;
14699/// # extern crate hyper_rustls;
14700/// # extern crate google_androidpublisher2 as androidpublisher2;
14701/// # async fn dox() {
14702/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14703///
14704/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14705/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14706/// #     .with_native_roots()
14707/// #     .unwrap()
14708/// #     .https_only()
14709/// #     .enable_http2()
14710/// #     .build();
14711///
14712/// # let executor = hyper_util::rt::TokioExecutor::new();
14713/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14714/// #     secret,
14715/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14716/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14717/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14718/// #     ),
14719/// # ).build().await.unwrap();
14720///
14721/// # let client = hyper_util::client::legacy::Client::builder(
14722/// #     hyper_util::rt::TokioExecutor::new()
14723/// # )
14724/// # .build(
14725/// #     hyper_rustls::HttpsConnectorBuilder::new()
14726/// #         .with_native_roots()
14727/// #         .unwrap()
14728/// #         .https_or_http()
14729/// #         .enable_http2()
14730/// #         .build()
14731/// # );
14732/// # let mut hub = AndroidPublisher::new(client, auth);
14733/// // You can configure optional parameters by calling the respective setters at will, and
14734/// // execute the final call using `doit()`.
14735/// // Values shown here are possibly random and not representative !
14736/// let result = hub.edits().tracks_get("packageName", "editId", "track")
14737///              .doit().await;
14738/// # }
14739/// ```
14740pub struct EditTrackGetCall<'a, C>
14741where
14742    C: 'a,
14743{
14744    hub: &'a AndroidPublisher<C>,
14745    _package_name: String,
14746    _edit_id: String,
14747    _track: String,
14748    _delegate: Option<&'a mut dyn common::Delegate>,
14749    _additional_params: HashMap<String, String>,
14750    _scopes: BTreeSet<String>,
14751}
14752
14753impl<'a, C> common::CallBuilder for EditTrackGetCall<'a, C> {}
14754
14755impl<'a, C> EditTrackGetCall<'a, C>
14756where
14757    C: common::Connector,
14758{
14759    /// Perform the operation you have build so far.
14760    pub async fn doit(mut self) -> common::Result<(common::Response, Track)> {
14761        use std::borrow::Cow;
14762        use std::io::{Read, Seek};
14763
14764        use common::{url::Params, ToParts};
14765        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14766
14767        let mut dd = common::DefaultDelegate;
14768        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14769        dlg.begin(common::MethodInfo {
14770            id: "androidpublisher.edits.tracks.get",
14771            http_method: hyper::Method::GET,
14772        });
14773
14774        for &field in ["alt", "packageName", "editId", "track"].iter() {
14775            if self._additional_params.contains_key(field) {
14776                dlg.finished(false);
14777                return Err(common::Error::FieldClash(field));
14778            }
14779        }
14780
14781        let mut params = Params::with_capacity(5 + self._additional_params.len());
14782        params.push("packageName", self._package_name);
14783        params.push("editId", self._edit_id);
14784        params.push("track", self._track);
14785
14786        params.extend(self._additional_params.iter());
14787
14788        params.push("alt", "json");
14789        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks/{track}";
14790        if self._scopes.is_empty() {
14791            self._scopes.insert(Scope::Full.as_ref().to_string());
14792        }
14793
14794        #[allow(clippy::single_element_loop)]
14795        for &(find_this, param_name) in [
14796            ("{packageName}", "packageName"),
14797            ("{editId}", "editId"),
14798            ("{track}", "track"),
14799        ]
14800        .iter()
14801        {
14802            url = params.uri_replacement(url, param_name, find_this, false);
14803        }
14804        {
14805            let to_remove = ["track", "editId", "packageName"];
14806            params.remove_params(&to_remove);
14807        }
14808
14809        let url = params.parse_with_url(&url);
14810
14811        loop {
14812            let token = match self
14813                .hub
14814                .auth
14815                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14816                .await
14817            {
14818                Ok(token) => token,
14819                Err(e) => match dlg.token(e) {
14820                    Ok(token) => token,
14821                    Err(e) => {
14822                        dlg.finished(false);
14823                        return Err(common::Error::MissingToken(e));
14824                    }
14825                },
14826            };
14827            let mut req_result = {
14828                let client = &self.hub.client;
14829                dlg.pre_request();
14830                let mut req_builder = hyper::Request::builder()
14831                    .method(hyper::Method::GET)
14832                    .uri(url.as_str())
14833                    .header(USER_AGENT, self.hub._user_agent.clone());
14834
14835                if let Some(token) = token.as_ref() {
14836                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14837                }
14838
14839                let request = req_builder
14840                    .header(CONTENT_LENGTH, 0_u64)
14841                    .body(common::to_body::<String>(None));
14842
14843                client.request(request.unwrap()).await
14844            };
14845
14846            match req_result {
14847                Err(err) => {
14848                    if let common::Retry::After(d) = dlg.http_error(&err) {
14849                        sleep(d).await;
14850                        continue;
14851                    }
14852                    dlg.finished(false);
14853                    return Err(common::Error::HttpError(err));
14854                }
14855                Ok(res) => {
14856                    let (mut parts, body) = res.into_parts();
14857                    let mut body = common::Body::new(body);
14858                    if !parts.status.is_success() {
14859                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14860                        let error = serde_json::from_str(&common::to_string(&bytes));
14861                        let response = common::to_response(parts, bytes.into());
14862
14863                        if let common::Retry::After(d) =
14864                            dlg.http_failure(&response, error.as_ref().ok())
14865                        {
14866                            sleep(d).await;
14867                            continue;
14868                        }
14869
14870                        dlg.finished(false);
14871
14872                        return Err(match error {
14873                            Ok(value) => common::Error::BadRequest(value),
14874                            _ => common::Error::Failure(response),
14875                        });
14876                    }
14877                    let response = {
14878                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14879                        let encoded = common::to_string(&bytes);
14880                        match serde_json::from_str(&encoded) {
14881                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14882                            Err(error) => {
14883                                dlg.response_json_decode_error(&encoded, &error);
14884                                return Err(common::Error::JsonDecodeError(
14885                                    encoded.to_string(),
14886                                    error,
14887                                ));
14888                            }
14889                        }
14890                    };
14891
14892                    dlg.finished(true);
14893                    return Ok(response);
14894                }
14895            }
14896        }
14897    }
14898
14899    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
14900    ///
14901    /// Sets the *package name* path property to the given value.
14902    ///
14903    /// Even though the property as already been set when instantiating this call,
14904    /// we provide this method for API completeness.
14905    pub fn package_name(mut self, new_value: &str) -> EditTrackGetCall<'a, C> {
14906        self._package_name = new_value.to_string();
14907        self
14908    }
14909    /// Unique identifier for this edit.
14910    ///
14911    /// Sets the *edit id* path property to the given value.
14912    ///
14913    /// Even though the property as already been set when instantiating this call,
14914    /// we provide this method for API completeness.
14915    pub fn edit_id(mut self, new_value: &str) -> EditTrackGetCall<'a, C> {
14916        self._edit_id = new_value.to_string();
14917        self
14918    }
14919    /// The track to read or modify.
14920    ///
14921    /// Sets the *track* path property to the given value.
14922    ///
14923    /// Even though the property as already been set when instantiating this call,
14924    /// we provide this method for API completeness.
14925    pub fn track(mut self, new_value: &str) -> EditTrackGetCall<'a, C> {
14926        self._track = new_value.to_string();
14927        self
14928    }
14929    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14930    /// while executing the actual API request.
14931    ///
14932    /// ````text
14933    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14934    /// ````
14935    ///
14936    /// Sets the *delegate* property to the given value.
14937    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditTrackGetCall<'a, C> {
14938        self._delegate = Some(new_value);
14939        self
14940    }
14941
14942    /// Set any additional parameter of the query string used in the request.
14943    /// It should be used to set parameters which are not yet available through their own
14944    /// setters.
14945    ///
14946    /// Please note that this method must not be used to set any of the known parameters
14947    /// which have their own setter method. If done anyway, the request will fail.
14948    ///
14949    /// # Additional Parameters
14950    ///
14951    /// * *alt* (query-string) - Data format for the response.
14952    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14953    /// * *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.
14954    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14955    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14956    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14957    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14958    pub fn param<T>(mut self, name: T, value: T) -> EditTrackGetCall<'a, C>
14959    where
14960        T: AsRef<str>,
14961    {
14962        self._additional_params
14963            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14964        self
14965    }
14966
14967    /// Identifies the authorization scope for the method you are building.
14968    ///
14969    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14970    /// [`Scope::Full`].
14971    ///
14972    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14973    /// tokens for more than one scope.
14974    ///
14975    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14976    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14977    /// sufficient, a read-write scope will do as well.
14978    pub fn add_scope<St>(mut self, scope: St) -> EditTrackGetCall<'a, C>
14979    where
14980        St: AsRef<str>,
14981    {
14982        self._scopes.insert(String::from(scope.as_ref()));
14983        self
14984    }
14985    /// Identifies the authorization scope(s) for the method you are building.
14986    ///
14987    /// See [`Self::add_scope()`] for details.
14988    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackGetCall<'a, C>
14989    where
14990        I: IntoIterator<Item = St>,
14991        St: AsRef<str>,
14992    {
14993        self._scopes
14994            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14995        self
14996    }
14997
14998    /// Removes all scopes, and no default scope will be used either.
14999    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15000    /// for details).
15001    pub fn clear_scopes(mut self) -> EditTrackGetCall<'a, C> {
15002        self._scopes.clear();
15003        self
15004    }
15005}
15006
15007/// Lists all the track configurations for this edit.
15008///
15009/// A builder for the *tracks.list* method supported by a *edit* resource.
15010/// It is not used directly, but through a [`EditMethods`] instance.
15011///
15012/// # Example
15013///
15014/// Instantiate a resource method builder
15015///
15016/// ```test_harness,no_run
15017/// # extern crate hyper;
15018/// # extern crate hyper_rustls;
15019/// # extern crate google_androidpublisher2 as androidpublisher2;
15020/// # async fn dox() {
15021/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15022///
15023/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15024/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15025/// #     .with_native_roots()
15026/// #     .unwrap()
15027/// #     .https_only()
15028/// #     .enable_http2()
15029/// #     .build();
15030///
15031/// # let executor = hyper_util::rt::TokioExecutor::new();
15032/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15033/// #     secret,
15034/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15035/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15036/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15037/// #     ),
15038/// # ).build().await.unwrap();
15039///
15040/// # let client = hyper_util::client::legacy::Client::builder(
15041/// #     hyper_util::rt::TokioExecutor::new()
15042/// # )
15043/// # .build(
15044/// #     hyper_rustls::HttpsConnectorBuilder::new()
15045/// #         .with_native_roots()
15046/// #         .unwrap()
15047/// #         .https_or_http()
15048/// #         .enable_http2()
15049/// #         .build()
15050/// # );
15051/// # let mut hub = AndroidPublisher::new(client, auth);
15052/// // You can configure optional parameters by calling the respective setters at will, and
15053/// // execute the final call using `doit()`.
15054/// // Values shown here are possibly random and not representative !
15055/// let result = hub.edits().tracks_list("packageName", "editId")
15056///              .doit().await;
15057/// # }
15058/// ```
15059pub struct EditTrackListCall<'a, C>
15060where
15061    C: 'a,
15062{
15063    hub: &'a AndroidPublisher<C>,
15064    _package_name: String,
15065    _edit_id: String,
15066    _delegate: Option<&'a mut dyn common::Delegate>,
15067    _additional_params: HashMap<String, String>,
15068    _scopes: BTreeSet<String>,
15069}
15070
15071impl<'a, C> common::CallBuilder for EditTrackListCall<'a, C> {}
15072
15073impl<'a, C> EditTrackListCall<'a, C>
15074where
15075    C: common::Connector,
15076{
15077    /// Perform the operation you have build so far.
15078    pub async fn doit(mut self) -> common::Result<(common::Response, TracksListResponse)> {
15079        use std::borrow::Cow;
15080        use std::io::{Read, Seek};
15081
15082        use common::{url::Params, ToParts};
15083        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15084
15085        let mut dd = common::DefaultDelegate;
15086        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15087        dlg.begin(common::MethodInfo {
15088            id: "androidpublisher.edits.tracks.list",
15089            http_method: hyper::Method::GET,
15090        });
15091
15092        for &field in ["alt", "packageName", "editId"].iter() {
15093            if self._additional_params.contains_key(field) {
15094                dlg.finished(false);
15095                return Err(common::Error::FieldClash(field));
15096            }
15097        }
15098
15099        let mut params = Params::with_capacity(4 + self._additional_params.len());
15100        params.push("packageName", self._package_name);
15101        params.push("editId", self._edit_id);
15102
15103        params.extend(self._additional_params.iter());
15104
15105        params.push("alt", "json");
15106        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks";
15107        if self._scopes.is_empty() {
15108            self._scopes.insert(Scope::Full.as_ref().to_string());
15109        }
15110
15111        #[allow(clippy::single_element_loop)]
15112        for &(find_this, param_name) in
15113            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
15114        {
15115            url = params.uri_replacement(url, param_name, find_this, false);
15116        }
15117        {
15118            let to_remove = ["editId", "packageName"];
15119            params.remove_params(&to_remove);
15120        }
15121
15122        let url = params.parse_with_url(&url);
15123
15124        loop {
15125            let token = match self
15126                .hub
15127                .auth
15128                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15129                .await
15130            {
15131                Ok(token) => token,
15132                Err(e) => match dlg.token(e) {
15133                    Ok(token) => token,
15134                    Err(e) => {
15135                        dlg.finished(false);
15136                        return Err(common::Error::MissingToken(e));
15137                    }
15138                },
15139            };
15140            let mut req_result = {
15141                let client = &self.hub.client;
15142                dlg.pre_request();
15143                let mut req_builder = hyper::Request::builder()
15144                    .method(hyper::Method::GET)
15145                    .uri(url.as_str())
15146                    .header(USER_AGENT, self.hub._user_agent.clone());
15147
15148                if let Some(token) = token.as_ref() {
15149                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15150                }
15151
15152                let request = req_builder
15153                    .header(CONTENT_LENGTH, 0_u64)
15154                    .body(common::to_body::<String>(None));
15155
15156                client.request(request.unwrap()).await
15157            };
15158
15159            match req_result {
15160                Err(err) => {
15161                    if let common::Retry::After(d) = dlg.http_error(&err) {
15162                        sleep(d).await;
15163                        continue;
15164                    }
15165                    dlg.finished(false);
15166                    return Err(common::Error::HttpError(err));
15167                }
15168                Ok(res) => {
15169                    let (mut parts, body) = res.into_parts();
15170                    let mut body = common::Body::new(body);
15171                    if !parts.status.is_success() {
15172                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15173                        let error = serde_json::from_str(&common::to_string(&bytes));
15174                        let response = common::to_response(parts, bytes.into());
15175
15176                        if let common::Retry::After(d) =
15177                            dlg.http_failure(&response, error.as_ref().ok())
15178                        {
15179                            sleep(d).await;
15180                            continue;
15181                        }
15182
15183                        dlg.finished(false);
15184
15185                        return Err(match error {
15186                            Ok(value) => common::Error::BadRequest(value),
15187                            _ => common::Error::Failure(response),
15188                        });
15189                    }
15190                    let response = {
15191                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15192                        let encoded = common::to_string(&bytes);
15193                        match serde_json::from_str(&encoded) {
15194                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15195                            Err(error) => {
15196                                dlg.response_json_decode_error(&encoded, &error);
15197                                return Err(common::Error::JsonDecodeError(
15198                                    encoded.to_string(),
15199                                    error,
15200                                ));
15201                            }
15202                        }
15203                    };
15204
15205                    dlg.finished(true);
15206                    return Ok(response);
15207                }
15208            }
15209        }
15210    }
15211
15212    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
15213    ///
15214    /// Sets the *package name* path property to the given value.
15215    ///
15216    /// Even though the property as already been set when instantiating this call,
15217    /// we provide this method for API completeness.
15218    pub fn package_name(mut self, new_value: &str) -> EditTrackListCall<'a, C> {
15219        self._package_name = new_value.to_string();
15220        self
15221    }
15222    /// Unique identifier for this edit.
15223    ///
15224    /// Sets the *edit id* path property to the given value.
15225    ///
15226    /// Even though the property as already been set when instantiating this call,
15227    /// we provide this method for API completeness.
15228    pub fn edit_id(mut self, new_value: &str) -> EditTrackListCall<'a, C> {
15229        self._edit_id = new_value.to_string();
15230        self
15231    }
15232    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15233    /// while executing the actual API request.
15234    ///
15235    /// ````text
15236    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15237    /// ````
15238    ///
15239    /// Sets the *delegate* property to the given value.
15240    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditTrackListCall<'a, C> {
15241        self._delegate = Some(new_value);
15242        self
15243    }
15244
15245    /// Set any additional parameter of the query string used in the request.
15246    /// It should be used to set parameters which are not yet available through their own
15247    /// setters.
15248    ///
15249    /// Please note that this method must not be used to set any of the known parameters
15250    /// which have their own setter method. If done anyway, the request will fail.
15251    ///
15252    /// # Additional Parameters
15253    ///
15254    /// * *alt* (query-string) - Data format for the response.
15255    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15256    /// * *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.
15257    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15258    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15259    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15260    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15261    pub fn param<T>(mut self, name: T, value: T) -> EditTrackListCall<'a, C>
15262    where
15263        T: AsRef<str>,
15264    {
15265        self._additional_params
15266            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15267        self
15268    }
15269
15270    /// Identifies the authorization scope for the method you are building.
15271    ///
15272    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15273    /// [`Scope::Full`].
15274    ///
15275    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15276    /// tokens for more than one scope.
15277    ///
15278    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15279    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15280    /// sufficient, a read-write scope will do as well.
15281    pub fn add_scope<St>(mut self, scope: St) -> EditTrackListCall<'a, C>
15282    where
15283        St: AsRef<str>,
15284    {
15285        self._scopes.insert(String::from(scope.as_ref()));
15286        self
15287    }
15288    /// Identifies the authorization scope(s) for the method you are building.
15289    ///
15290    /// See [`Self::add_scope()`] for details.
15291    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackListCall<'a, C>
15292    where
15293        I: IntoIterator<Item = St>,
15294        St: AsRef<str>,
15295    {
15296        self._scopes
15297            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15298        self
15299    }
15300
15301    /// Removes all scopes, and no default scope will be used either.
15302    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15303    /// for details).
15304    pub fn clear_scopes(mut self) -> EditTrackListCall<'a, C> {
15305        self._scopes.clear();
15306        self
15307    }
15308}
15309
15310/// Updates the track configuration for the specified track type. This method supports patch semantics.
15311///
15312/// A builder for the *tracks.patch* method supported by a *edit* resource.
15313/// It is not used directly, but through a [`EditMethods`] instance.
15314///
15315/// # Example
15316///
15317/// Instantiate a resource method builder
15318///
15319/// ```test_harness,no_run
15320/// # extern crate hyper;
15321/// # extern crate hyper_rustls;
15322/// # extern crate google_androidpublisher2 as androidpublisher2;
15323/// use androidpublisher2::api::Track;
15324/// # async fn dox() {
15325/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15326///
15327/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15328/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15329/// #     .with_native_roots()
15330/// #     .unwrap()
15331/// #     .https_only()
15332/// #     .enable_http2()
15333/// #     .build();
15334///
15335/// # let executor = hyper_util::rt::TokioExecutor::new();
15336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15337/// #     secret,
15338/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15339/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15340/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15341/// #     ),
15342/// # ).build().await.unwrap();
15343///
15344/// # let client = hyper_util::client::legacy::Client::builder(
15345/// #     hyper_util::rt::TokioExecutor::new()
15346/// # )
15347/// # .build(
15348/// #     hyper_rustls::HttpsConnectorBuilder::new()
15349/// #         .with_native_roots()
15350/// #         .unwrap()
15351/// #         .https_or_http()
15352/// #         .enable_http2()
15353/// #         .build()
15354/// # );
15355/// # let mut hub = AndroidPublisher::new(client, auth);
15356/// // As the method needs a request, you would usually fill it with the desired information
15357/// // into the respective structure. Some of the parts shown here might not be applicable !
15358/// // Values shown here are possibly random and not representative !
15359/// let mut req = Track::default();
15360///
15361/// // You can configure optional parameters by calling the respective setters at will, and
15362/// // execute the final call using `doit()`.
15363/// // Values shown here are possibly random and not representative !
15364/// let result = hub.edits().tracks_patch(req, "packageName", "editId", "track")
15365///              .doit().await;
15366/// # }
15367/// ```
15368pub struct EditTrackPatchCall<'a, C>
15369where
15370    C: 'a,
15371{
15372    hub: &'a AndroidPublisher<C>,
15373    _request: Track,
15374    _package_name: String,
15375    _edit_id: String,
15376    _track: String,
15377    _delegate: Option<&'a mut dyn common::Delegate>,
15378    _additional_params: HashMap<String, String>,
15379    _scopes: BTreeSet<String>,
15380}
15381
15382impl<'a, C> common::CallBuilder for EditTrackPatchCall<'a, C> {}
15383
15384impl<'a, C> EditTrackPatchCall<'a, C>
15385where
15386    C: common::Connector,
15387{
15388    /// Perform the operation you have build so far.
15389    pub async fn doit(mut self) -> common::Result<(common::Response, Track)> {
15390        use std::borrow::Cow;
15391        use std::io::{Read, Seek};
15392
15393        use common::{url::Params, ToParts};
15394        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15395
15396        let mut dd = common::DefaultDelegate;
15397        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15398        dlg.begin(common::MethodInfo {
15399            id: "androidpublisher.edits.tracks.patch",
15400            http_method: hyper::Method::PATCH,
15401        });
15402
15403        for &field in ["alt", "packageName", "editId", "track"].iter() {
15404            if self._additional_params.contains_key(field) {
15405                dlg.finished(false);
15406                return Err(common::Error::FieldClash(field));
15407            }
15408        }
15409
15410        let mut params = Params::with_capacity(6 + self._additional_params.len());
15411        params.push("packageName", self._package_name);
15412        params.push("editId", self._edit_id);
15413        params.push("track", self._track);
15414
15415        params.extend(self._additional_params.iter());
15416
15417        params.push("alt", "json");
15418        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks/{track}";
15419        if self._scopes.is_empty() {
15420            self._scopes.insert(Scope::Full.as_ref().to_string());
15421        }
15422
15423        #[allow(clippy::single_element_loop)]
15424        for &(find_this, param_name) in [
15425            ("{packageName}", "packageName"),
15426            ("{editId}", "editId"),
15427            ("{track}", "track"),
15428        ]
15429        .iter()
15430        {
15431            url = params.uri_replacement(url, param_name, find_this, false);
15432        }
15433        {
15434            let to_remove = ["track", "editId", "packageName"];
15435            params.remove_params(&to_remove);
15436        }
15437
15438        let url = params.parse_with_url(&url);
15439
15440        let mut json_mime_type = mime::APPLICATION_JSON;
15441        let mut request_value_reader = {
15442            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15443            common::remove_json_null_values(&mut value);
15444            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15445            serde_json::to_writer(&mut dst, &value).unwrap();
15446            dst
15447        };
15448        let request_size = request_value_reader
15449            .seek(std::io::SeekFrom::End(0))
15450            .unwrap();
15451        request_value_reader
15452            .seek(std::io::SeekFrom::Start(0))
15453            .unwrap();
15454
15455        loop {
15456            let token = match self
15457                .hub
15458                .auth
15459                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15460                .await
15461            {
15462                Ok(token) => token,
15463                Err(e) => match dlg.token(e) {
15464                    Ok(token) => token,
15465                    Err(e) => {
15466                        dlg.finished(false);
15467                        return Err(common::Error::MissingToken(e));
15468                    }
15469                },
15470            };
15471            request_value_reader
15472                .seek(std::io::SeekFrom::Start(0))
15473                .unwrap();
15474            let mut req_result = {
15475                let client = &self.hub.client;
15476                dlg.pre_request();
15477                let mut req_builder = hyper::Request::builder()
15478                    .method(hyper::Method::PATCH)
15479                    .uri(url.as_str())
15480                    .header(USER_AGENT, self.hub._user_agent.clone());
15481
15482                if let Some(token) = token.as_ref() {
15483                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15484                }
15485
15486                let request = req_builder
15487                    .header(CONTENT_TYPE, json_mime_type.to_string())
15488                    .header(CONTENT_LENGTH, request_size as u64)
15489                    .body(common::to_body(
15490                        request_value_reader.get_ref().clone().into(),
15491                    ));
15492
15493                client.request(request.unwrap()).await
15494            };
15495
15496            match req_result {
15497                Err(err) => {
15498                    if let common::Retry::After(d) = dlg.http_error(&err) {
15499                        sleep(d).await;
15500                        continue;
15501                    }
15502                    dlg.finished(false);
15503                    return Err(common::Error::HttpError(err));
15504                }
15505                Ok(res) => {
15506                    let (mut parts, body) = res.into_parts();
15507                    let mut body = common::Body::new(body);
15508                    if !parts.status.is_success() {
15509                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15510                        let error = serde_json::from_str(&common::to_string(&bytes));
15511                        let response = common::to_response(parts, bytes.into());
15512
15513                        if let common::Retry::After(d) =
15514                            dlg.http_failure(&response, error.as_ref().ok())
15515                        {
15516                            sleep(d).await;
15517                            continue;
15518                        }
15519
15520                        dlg.finished(false);
15521
15522                        return Err(match error {
15523                            Ok(value) => common::Error::BadRequest(value),
15524                            _ => common::Error::Failure(response),
15525                        });
15526                    }
15527                    let response = {
15528                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15529                        let encoded = common::to_string(&bytes);
15530                        match serde_json::from_str(&encoded) {
15531                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15532                            Err(error) => {
15533                                dlg.response_json_decode_error(&encoded, &error);
15534                                return Err(common::Error::JsonDecodeError(
15535                                    encoded.to_string(),
15536                                    error,
15537                                ));
15538                            }
15539                        }
15540                    };
15541
15542                    dlg.finished(true);
15543                    return Ok(response);
15544                }
15545            }
15546        }
15547    }
15548
15549    ///
15550    /// Sets the *request* property to the given value.
15551    ///
15552    /// Even though the property as already been set when instantiating this call,
15553    /// we provide this method for API completeness.
15554    pub fn request(mut self, new_value: Track) -> EditTrackPatchCall<'a, C> {
15555        self._request = new_value;
15556        self
15557    }
15558    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
15559    ///
15560    /// Sets the *package name* path property to the given value.
15561    ///
15562    /// Even though the property as already been set when instantiating this call,
15563    /// we provide this method for API completeness.
15564    pub fn package_name(mut self, new_value: &str) -> EditTrackPatchCall<'a, C> {
15565        self._package_name = new_value.to_string();
15566        self
15567    }
15568    /// Unique identifier for this edit.
15569    ///
15570    /// Sets the *edit id* path property to the given value.
15571    ///
15572    /// Even though the property as already been set when instantiating this call,
15573    /// we provide this method for API completeness.
15574    pub fn edit_id(mut self, new_value: &str) -> EditTrackPatchCall<'a, C> {
15575        self._edit_id = new_value.to_string();
15576        self
15577    }
15578    /// The track to read or modify.
15579    ///
15580    /// Sets the *track* path property to the given value.
15581    ///
15582    /// Even though the property as already been set when instantiating this call,
15583    /// we provide this method for API completeness.
15584    pub fn track(mut self, new_value: &str) -> EditTrackPatchCall<'a, C> {
15585        self._track = new_value.to_string();
15586        self
15587    }
15588    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15589    /// while executing the actual API request.
15590    ///
15591    /// ````text
15592    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15593    /// ````
15594    ///
15595    /// Sets the *delegate* property to the given value.
15596    pub fn delegate(
15597        mut self,
15598        new_value: &'a mut dyn common::Delegate,
15599    ) -> EditTrackPatchCall<'a, C> {
15600        self._delegate = Some(new_value);
15601        self
15602    }
15603
15604    /// Set any additional parameter of the query string used in the request.
15605    /// It should be used to set parameters which are not yet available through their own
15606    /// setters.
15607    ///
15608    /// Please note that this method must not be used to set any of the known parameters
15609    /// which have their own setter method. If done anyway, the request will fail.
15610    ///
15611    /// # Additional Parameters
15612    ///
15613    /// * *alt* (query-string) - Data format for the response.
15614    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15615    /// * *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.
15616    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15617    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15618    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15619    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15620    pub fn param<T>(mut self, name: T, value: T) -> EditTrackPatchCall<'a, C>
15621    where
15622        T: AsRef<str>,
15623    {
15624        self._additional_params
15625            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15626        self
15627    }
15628
15629    /// Identifies the authorization scope for the method you are building.
15630    ///
15631    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15632    /// [`Scope::Full`].
15633    ///
15634    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15635    /// tokens for more than one scope.
15636    ///
15637    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15638    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15639    /// sufficient, a read-write scope will do as well.
15640    pub fn add_scope<St>(mut self, scope: St) -> EditTrackPatchCall<'a, C>
15641    where
15642        St: AsRef<str>,
15643    {
15644        self._scopes.insert(String::from(scope.as_ref()));
15645        self
15646    }
15647    /// Identifies the authorization scope(s) for the method you are building.
15648    ///
15649    /// See [`Self::add_scope()`] for details.
15650    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackPatchCall<'a, C>
15651    where
15652        I: IntoIterator<Item = St>,
15653        St: AsRef<str>,
15654    {
15655        self._scopes
15656            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15657        self
15658    }
15659
15660    /// Removes all scopes, and no default scope will be used either.
15661    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15662    /// for details).
15663    pub fn clear_scopes(mut self) -> EditTrackPatchCall<'a, C> {
15664        self._scopes.clear();
15665        self
15666    }
15667}
15668
15669/// Updates the track configuration for the specified track type.
15670///
15671/// A builder for the *tracks.update* method supported by a *edit* resource.
15672/// It is not used directly, but through a [`EditMethods`] instance.
15673///
15674/// # Example
15675///
15676/// Instantiate a resource method builder
15677///
15678/// ```test_harness,no_run
15679/// # extern crate hyper;
15680/// # extern crate hyper_rustls;
15681/// # extern crate google_androidpublisher2 as androidpublisher2;
15682/// use androidpublisher2::api::Track;
15683/// # async fn dox() {
15684/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15685///
15686/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15687/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15688/// #     .with_native_roots()
15689/// #     .unwrap()
15690/// #     .https_only()
15691/// #     .enable_http2()
15692/// #     .build();
15693///
15694/// # let executor = hyper_util::rt::TokioExecutor::new();
15695/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15696/// #     secret,
15697/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15698/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15699/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15700/// #     ),
15701/// # ).build().await.unwrap();
15702///
15703/// # let client = hyper_util::client::legacy::Client::builder(
15704/// #     hyper_util::rt::TokioExecutor::new()
15705/// # )
15706/// # .build(
15707/// #     hyper_rustls::HttpsConnectorBuilder::new()
15708/// #         .with_native_roots()
15709/// #         .unwrap()
15710/// #         .https_or_http()
15711/// #         .enable_http2()
15712/// #         .build()
15713/// # );
15714/// # let mut hub = AndroidPublisher::new(client, auth);
15715/// // As the method needs a request, you would usually fill it with the desired information
15716/// // into the respective structure. Some of the parts shown here might not be applicable !
15717/// // Values shown here are possibly random and not representative !
15718/// let mut req = Track::default();
15719///
15720/// // You can configure optional parameters by calling the respective setters at will, and
15721/// // execute the final call using `doit()`.
15722/// // Values shown here are possibly random and not representative !
15723/// let result = hub.edits().tracks_update(req, "packageName", "editId", "track")
15724///              .doit().await;
15725/// # }
15726/// ```
15727pub struct EditTrackUpdateCall<'a, C>
15728where
15729    C: 'a,
15730{
15731    hub: &'a AndroidPublisher<C>,
15732    _request: Track,
15733    _package_name: String,
15734    _edit_id: String,
15735    _track: String,
15736    _delegate: Option<&'a mut dyn common::Delegate>,
15737    _additional_params: HashMap<String, String>,
15738    _scopes: BTreeSet<String>,
15739}
15740
15741impl<'a, C> common::CallBuilder for EditTrackUpdateCall<'a, C> {}
15742
15743impl<'a, C> EditTrackUpdateCall<'a, C>
15744where
15745    C: common::Connector,
15746{
15747    /// Perform the operation you have build so far.
15748    pub async fn doit(mut self) -> common::Result<(common::Response, Track)> {
15749        use std::borrow::Cow;
15750        use std::io::{Read, Seek};
15751
15752        use common::{url::Params, ToParts};
15753        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15754
15755        let mut dd = common::DefaultDelegate;
15756        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15757        dlg.begin(common::MethodInfo {
15758            id: "androidpublisher.edits.tracks.update",
15759            http_method: hyper::Method::PUT,
15760        });
15761
15762        for &field in ["alt", "packageName", "editId", "track"].iter() {
15763            if self._additional_params.contains_key(field) {
15764                dlg.finished(false);
15765                return Err(common::Error::FieldClash(field));
15766            }
15767        }
15768
15769        let mut params = Params::with_capacity(6 + self._additional_params.len());
15770        params.push("packageName", self._package_name);
15771        params.push("editId", self._edit_id);
15772        params.push("track", self._track);
15773
15774        params.extend(self._additional_params.iter());
15775
15776        params.push("alt", "json");
15777        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks/{track}";
15778        if self._scopes.is_empty() {
15779            self._scopes.insert(Scope::Full.as_ref().to_string());
15780        }
15781
15782        #[allow(clippy::single_element_loop)]
15783        for &(find_this, param_name) in [
15784            ("{packageName}", "packageName"),
15785            ("{editId}", "editId"),
15786            ("{track}", "track"),
15787        ]
15788        .iter()
15789        {
15790            url = params.uri_replacement(url, param_name, find_this, false);
15791        }
15792        {
15793            let to_remove = ["track", "editId", "packageName"];
15794            params.remove_params(&to_remove);
15795        }
15796
15797        let url = params.parse_with_url(&url);
15798
15799        let mut json_mime_type = mime::APPLICATION_JSON;
15800        let mut request_value_reader = {
15801            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15802            common::remove_json_null_values(&mut value);
15803            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15804            serde_json::to_writer(&mut dst, &value).unwrap();
15805            dst
15806        };
15807        let request_size = request_value_reader
15808            .seek(std::io::SeekFrom::End(0))
15809            .unwrap();
15810        request_value_reader
15811            .seek(std::io::SeekFrom::Start(0))
15812            .unwrap();
15813
15814        loop {
15815            let token = match self
15816                .hub
15817                .auth
15818                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15819                .await
15820            {
15821                Ok(token) => token,
15822                Err(e) => match dlg.token(e) {
15823                    Ok(token) => token,
15824                    Err(e) => {
15825                        dlg.finished(false);
15826                        return Err(common::Error::MissingToken(e));
15827                    }
15828                },
15829            };
15830            request_value_reader
15831                .seek(std::io::SeekFrom::Start(0))
15832                .unwrap();
15833            let mut req_result = {
15834                let client = &self.hub.client;
15835                dlg.pre_request();
15836                let mut req_builder = hyper::Request::builder()
15837                    .method(hyper::Method::PUT)
15838                    .uri(url.as_str())
15839                    .header(USER_AGENT, self.hub._user_agent.clone());
15840
15841                if let Some(token) = token.as_ref() {
15842                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15843                }
15844
15845                let request = req_builder
15846                    .header(CONTENT_TYPE, json_mime_type.to_string())
15847                    .header(CONTENT_LENGTH, request_size as u64)
15848                    .body(common::to_body(
15849                        request_value_reader.get_ref().clone().into(),
15850                    ));
15851
15852                client.request(request.unwrap()).await
15853            };
15854
15855            match req_result {
15856                Err(err) => {
15857                    if let common::Retry::After(d) = dlg.http_error(&err) {
15858                        sleep(d).await;
15859                        continue;
15860                    }
15861                    dlg.finished(false);
15862                    return Err(common::Error::HttpError(err));
15863                }
15864                Ok(res) => {
15865                    let (mut parts, body) = res.into_parts();
15866                    let mut body = common::Body::new(body);
15867                    if !parts.status.is_success() {
15868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15869                        let error = serde_json::from_str(&common::to_string(&bytes));
15870                        let response = common::to_response(parts, bytes.into());
15871
15872                        if let common::Retry::After(d) =
15873                            dlg.http_failure(&response, error.as_ref().ok())
15874                        {
15875                            sleep(d).await;
15876                            continue;
15877                        }
15878
15879                        dlg.finished(false);
15880
15881                        return Err(match error {
15882                            Ok(value) => common::Error::BadRequest(value),
15883                            _ => common::Error::Failure(response),
15884                        });
15885                    }
15886                    let response = {
15887                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15888                        let encoded = common::to_string(&bytes);
15889                        match serde_json::from_str(&encoded) {
15890                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15891                            Err(error) => {
15892                                dlg.response_json_decode_error(&encoded, &error);
15893                                return Err(common::Error::JsonDecodeError(
15894                                    encoded.to_string(),
15895                                    error,
15896                                ));
15897                            }
15898                        }
15899                    };
15900
15901                    dlg.finished(true);
15902                    return Ok(response);
15903                }
15904            }
15905        }
15906    }
15907
15908    ///
15909    /// Sets the *request* property to the given value.
15910    ///
15911    /// Even though the property as already been set when instantiating this call,
15912    /// we provide this method for API completeness.
15913    pub fn request(mut self, new_value: Track) -> EditTrackUpdateCall<'a, C> {
15914        self._request = new_value;
15915        self
15916    }
15917    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
15918    ///
15919    /// Sets the *package name* path property to the given value.
15920    ///
15921    /// Even though the property as already been set when instantiating this call,
15922    /// we provide this method for API completeness.
15923    pub fn package_name(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C> {
15924        self._package_name = new_value.to_string();
15925        self
15926    }
15927    /// Unique identifier for this edit.
15928    ///
15929    /// Sets the *edit id* path property to the given value.
15930    ///
15931    /// Even though the property as already been set when instantiating this call,
15932    /// we provide this method for API completeness.
15933    pub fn edit_id(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C> {
15934        self._edit_id = new_value.to_string();
15935        self
15936    }
15937    /// The track to read or modify.
15938    ///
15939    /// Sets the *track* path property to the given value.
15940    ///
15941    /// Even though the property as already been set when instantiating this call,
15942    /// we provide this method for API completeness.
15943    pub fn track(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C> {
15944        self._track = new_value.to_string();
15945        self
15946    }
15947    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15948    /// while executing the actual API request.
15949    ///
15950    /// ````text
15951    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15952    /// ````
15953    ///
15954    /// Sets the *delegate* property to the given value.
15955    pub fn delegate(
15956        mut self,
15957        new_value: &'a mut dyn common::Delegate,
15958    ) -> EditTrackUpdateCall<'a, C> {
15959        self._delegate = Some(new_value);
15960        self
15961    }
15962
15963    /// Set any additional parameter of the query string used in the request.
15964    /// It should be used to set parameters which are not yet available through their own
15965    /// setters.
15966    ///
15967    /// Please note that this method must not be used to set any of the known parameters
15968    /// which have their own setter method. If done anyway, the request will fail.
15969    ///
15970    /// # Additional Parameters
15971    ///
15972    /// * *alt* (query-string) - Data format for the response.
15973    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15974    /// * *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.
15975    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15976    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15977    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15978    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15979    pub fn param<T>(mut self, name: T, value: T) -> EditTrackUpdateCall<'a, C>
15980    where
15981        T: AsRef<str>,
15982    {
15983        self._additional_params
15984            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15985        self
15986    }
15987
15988    /// Identifies the authorization scope for the method you are building.
15989    ///
15990    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15991    /// [`Scope::Full`].
15992    ///
15993    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15994    /// tokens for more than one scope.
15995    ///
15996    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15997    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15998    /// sufficient, a read-write scope will do as well.
15999    pub fn add_scope<St>(mut self, scope: St) -> EditTrackUpdateCall<'a, C>
16000    where
16001        St: AsRef<str>,
16002    {
16003        self._scopes.insert(String::from(scope.as_ref()));
16004        self
16005    }
16006    /// Identifies the authorization scope(s) for the method you are building.
16007    ///
16008    /// See [`Self::add_scope()`] for details.
16009    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackUpdateCall<'a, C>
16010    where
16011        I: IntoIterator<Item = St>,
16012        St: AsRef<str>,
16013    {
16014        self._scopes
16015            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16016        self
16017    }
16018
16019    /// Removes all scopes, and no default scope will be used either.
16020    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16021    /// for details).
16022    pub fn clear_scopes(mut self) -> EditTrackUpdateCall<'a, C> {
16023        self._scopes.clear();
16024        self
16025    }
16026}
16027
16028/// Commits/applies the changes made in this edit back to the app.
16029///
16030/// A builder for the *commit* method supported by a *edit* resource.
16031/// It is not used directly, but through a [`EditMethods`] instance.
16032///
16033/// # Example
16034///
16035/// Instantiate a resource method builder
16036///
16037/// ```test_harness,no_run
16038/// # extern crate hyper;
16039/// # extern crate hyper_rustls;
16040/// # extern crate google_androidpublisher2 as androidpublisher2;
16041/// # async fn dox() {
16042/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16043///
16044/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16045/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16046/// #     .with_native_roots()
16047/// #     .unwrap()
16048/// #     .https_only()
16049/// #     .enable_http2()
16050/// #     .build();
16051///
16052/// # let executor = hyper_util::rt::TokioExecutor::new();
16053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16054/// #     secret,
16055/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16056/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16057/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16058/// #     ),
16059/// # ).build().await.unwrap();
16060///
16061/// # let client = hyper_util::client::legacy::Client::builder(
16062/// #     hyper_util::rt::TokioExecutor::new()
16063/// # )
16064/// # .build(
16065/// #     hyper_rustls::HttpsConnectorBuilder::new()
16066/// #         .with_native_roots()
16067/// #         .unwrap()
16068/// #         .https_or_http()
16069/// #         .enable_http2()
16070/// #         .build()
16071/// # );
16072/// # let mut hub = AndroidPublisher::new(client, auth);
16073/// // You can configure optional parameters by calling the respective setters at will, and
16074/// // execute the final call using `doit()`.
16075/// // Values shown here are possibly random and not representative !
16076/// let result = hub.edits().commit("packageName", "editId")
16077///              .doit().await;
16078/// # }
16079/// ```
16080pub struct EditCommitCall<'a, C>
16081where
16082    C: 'a,
16083{
16084    hub: &'a AndroidPublisher<C>,
16085    _package_name: String,
16086    _edit_id: String,
16087    _delegate: Option<&'a mut dyn common::Delegate>,
16088    _additional_params: HashMap<String, String>,
16089    _scopes: BTreeSet<String>,
16090}
16091
16092impl<'a, C> common::CallBuilder for EditCommitCall<'a, C> {}
16093
16094impl<'a, C> EditCommitCall<'a, C>
16095where
16096    C: common::Connector,
16097{
16098    /// Perform the operation you have build so far.
16099    pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
16100        use std::borrow::Cow;
16101        use std::io::{Read, Seek};
16102
16103        use common::{url::Params, ToParts};
16104        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16105
16106        let mut dd = common::DefaultDelegate;
16107        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16108        dlg.begin(common::MethodInfo {
16109            id: "androidpublisher.edits.commit",
16110            http_method: hyper::Method::POST,
16111        });
16112
16113        for &field in ["alt", "packageName", "editId"].iter() {
16114            if self._additional_params.contains_key(field) {
16115                dlg.finished(false);
16116                return Err(common::Error::FieldClash(field));
16117            }
16118        }
16119
16120        let mut params = Params::with_capacity(4 + self._additional_params.len());
16121        params.push("packageName", self._package_name);
16122        params.push("editId", self._edit_id);
16123
16124        params.extend(self._additional_params.iter());
16125
16126        params.push("alt", "json");
16127        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}:commit";
16128        if self._scopes.is_empty() {
16129            self._scopes.insert(Scope::Full.as_ref().to_string());
16130        }
16131
16132        #[allow(clippy::single_element_loop)]
16133        for &(find_this, param_name) in
16134            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
16135        {
16136            url = params.uri_replacement(url, param_name, find_this, false);
16137        }
16138        {
16139            let to_remove = ["editId", "packageName"];
16140            params.remove_params(&to_remove);
16141        }
16142
16143        let url = params.parse_with_url(&url);
16144
16145        loop {
16146            let token = match self
16147                .hub
16148                .auth
16149                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16150                .await
16151            {
16152                Ok(token) => token,
16153                Err(e) => match dlg.token(e) {
16154                    Ok(token) => token,
16155                    Err(e) => {
16156                        dlg.finished(false);
16157                        return Err(common::Error::MissingToken(e));
16158                    }
16159                },
16160            };
16161            let mut req_result = {
16162                let client = &self.hub.client;
16163                dlg.pre_request();
16164                let mut req_builder = hyper::Request::builder()
16165                    .method(hyper::Method::POST)
16166                    .uri(url.as_str())
16167                    .header(USER_AGENT, self.hub._user_agent.clone());
16168
16169                if let Some(token) = token.as_ref() {
16170                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16171                }
16172
16173                let request = req_builder
16174                    .header(CONTENT_LENGTH, 0_u64)
16175                    .body(common::to_body::<String>(None));
16176
16177                client.request(request.unwrap()).await
16178            };
16179
16180            match req_result {
16181                Err(err) => {
16182                    if let common::Retry::After(d) = dlg.http_error(&err) {
16183                        sleep(d).await;
16184                        continue;
16185                    }
16186                    dlg.finished(false);
16187                    return Err(common::Error::HttpError(err));
16188                }
16189                Ok(res) => {
16190                    let (mut parts, body) = res.into_parts();
16191                    let mut body = common::Body::new(body);
16192                    if !parts.status.is_success() {
16193                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16194                        let error = serde_json::from_str(&common::to_string(&bytes));
16195                        let response = common::to_response(parts, bytes.into());
16196
16197                        if let common::Retry::After(d) =
16198                            dlg.http_failure(&response, error.as_ref().ok())
16199                        {
16200                            sleep(d).await;
16201                            continue;
16202                        }
16203
16204                        dlg.finished(false);
16205
16206                        return Err(match error {
16207                            Ok(value) => common::Error::BadRequest(value),
16208                            _ => common::Error::Failure(response),
16209                        });
16210                    }
16211                    let response = {
16212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16213                        let encoded = common::to_string(&bytes);
16214                        match serde_json::from_str(&encoded) {
16215                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16216                            Err(error) => {
16217                                dlg.response_json_decode_error(&encoded, &error);
16218                                return Err(common::Error::JsonDecodeError(
16219                                    encoded.to_string(),
16220                                    error,
16221                                ));
16222                            }
16223                        }
16224                    };
16225
16226                    dlg.finished(true);
16227                    return Ok(response);
16228                }
16229            }
16230        }
16231    }
16232
16233    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
16234    ///
16235    /// Sets the *package name* path property to the given value.
16236    ///
16237    /// Even though the property as already been set when instantiating this call,
16238    /// we provide this method for API completeness.
16239    pub fn package_name(mut self, new_value: &str) -> EditCommitCall<'a, C> {
16240        self._package_name = new_value.to_string();
16241        self
16242    }
16243    /// Unique identifier for this edit.
16244    ///
16245    /// Sets the *edit id* path property to the given value.
16246    ///
16247    /// Even though the property as already been set when instantiating this call,
16248    /// we provide this method for API completeness.
16249    pub fn edit_id(mut self, new_value: &str) -> EditCommitCall<'a, C> {
16250        self._edit_id = new_value.to_string();
16251        self
16252    }
16253    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16254    /// while executing the actual API request.
16255    ///
16256    /// ````text
16257    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16258    /// ````
16259    ///
16260    /// Sets the *delegate* property to the given value.
16261    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditCommitCall<'a, C> {
16262        self._delegate = Some(new_value);
16263        self
16264    }
16265
16266    /// Set any additional parameter of the query string used in the request.
16267    /// It should be used to set parameters which are not yet available through their own
16268    /// setters.
16269    ///
16270    /// Please note that this method must not be used to set any of the known parameters
16271    /// which have their own setter method. If done anyway, the request will fail.
16272    ///
16273    /// # Additional Parameters
16274    ///
16275    /// * *alt* (query-string) - Data format for the response.
16276    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16277    /// * *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.
16278    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16279    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16280    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16281    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16282    pub fn param<T>(mut self, name: T, value: T) -> EditCommitCall<'a, C>
16283    where
16284        T: AsRef<str>,
16285    {
16286        self._additional_params
16287            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16288        self
16289    }
16290
16291    /// Identifies the authorization scope for the method you are building.
16292    ///
16293    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16294    /// [`Scope::Full`].
16295    ///
16296    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16297    /// tokens for more than one scope.
16298    ///
16299    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16300    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16301    /// sufficient, a read-write scope will do as well.
16302    pub fn add_scope<St>(mut self, scope: St) -> EditCommitCall<'a, C>
16303    where
16304        St: AsRef<str>,
16305    {
16306        self._scopes.insert(String::from(scope.as_ref()));
16307        self
16308    }
16309    /// Identifies the authorization scope(s) for the method you are building.
16310    ///
16311    /// See [`Self::add_scope()`] for details.
16312    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditCommitCall<'a, C>
16313    where
16314        I: IntoIterator<Item = St>,
16315        St: AsRef<str>,
16316    {
16317        self._scopes
16318            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16319        self
16320    }
16321
16322    /// Removes all scopes, and no default scope will be used either.
16323    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16324    /// for details).
16325    pub fn clear_scopes(mut self) -> EditCommitCall<'a, C> {
16326        self._scopes.clear();
16327        self
16328    }
16329}
16330
16331/// Deletes an edit for an app. Creating a new edit will automatically delete any of your previous edits so this method need only be called if you want to preemptively abandon an edit.
16332///
16333/// A builder for the *delete* method supported by a *edit* resource.
16334/// It is not used directly, but through a [`EditMethods`] instance.
16335///
16336/// # Example
16337///
16338/// Instantiate a resource method builder
16339///
16340/// ```test_harness,no_run
16341/// # extern crate hyper;
16342/// # extern crate hyper_rustls;
16343/// # extern crate google_androidpublisher2 as androidpublisher2;
16344/// # async fn dox() {
16345/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16346///
16347/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16348/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16349/// #     .with_native_roots()
16350/// #     .unwrap()
16351/// #     .https_only()
16352/// #     .enable_http2()
16353/// #     .build();
16354///
16355/// # let executor = hyper_util::rt::TokioExecutor::new();
16356/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16357/// #     secret,
16358/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16359/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16360/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16361/// #     ),
16362/// # ).build().await.unwrap();
16363///
16364/// # let client = hyper_util::client::legacy::Client::builder(
16365/// #     hyper_util::rt::TokioExecutor::new()
16366/// # )
16367/// # .build(
16368/// #     hyper_rustls::HttpsConnectorBuilder::new()
16369/// #         .with_native_roots()
16370/// #         .unwrap()
16371/// #         .https_or_http()
16372/// #         .enable_http2()
16373/// #         .build()
16374/// # );
16375/// # let mut hub = AndroidPublisher::new(client, auth);
16376/// // You can configure optional parameters by calling the respective setters at will, and
16377/// // execute the final call using `doit()`.
16378/// // Values shown here are possibly random and not representative !
16379/// let result = hub.edits().delete("packageName", "editId")
16380///              .doit().await;
16381/// # }
16382/// ```
16383pub struct EditDeleteCall<'a, C>
16384where
16385    C: 'a,
16386{
16387    hub: &'a AndroidPublisher<C>,
16388    _package_name: String,
16389    _edit_id: String,
16390    _delegate: Option<&'a mut dyn common::Delegate>,
16391    _additional_params: HashMap<String, String>,
16392    _scopes: BTreeSet<String>,
16393}
16394
16395impl<'a, C> common::CallBuilder for EditDeleteCall<'a, C> {}
16396
16397impl<'a, C> EditDeleteCall<'a, C>
16398where
16399    C: common::Connector,
16400{
16401    /// Perform the operation you have build so far.
16402    pub async fn doit(mut self) -> common::Result<common::Response> {
16403        use std::borrow::Cow;
16404        use std::io::{Read, Seek};
16405
16406        use common::{url::Params, ToParts};
16407        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16408
16409        let mut dd = common::DefaultDelegate;
16410        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16411        dlg.begin(common::MethodInfo {
16412            id: "androidpublisher.edits.delete",
16413            http_method: hyper::Method::DELETE,
16414        });
16415
16416        for &field in ["packageName", "editId"].iter() {
16417            if self._additional_params.contains_key(field) {
16418                dlg.finished(false);
16419                return Err(common::Error::FieldClash(field));
16420            }
16421        }
16422
16423        let mut params = Params::with_capacity(3 + self._additional_params.len());
16424        params.push("packageName", self._package_name);
16425        params.push("editId", self._edit_id);
16426
16427        params.extend(self._additional_params.iter());
16428
16429        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}";
16430        if self._scopes.is_empty() {
16431            self._scopes.insert(Scope::Full.as_ref().to_string());
16432        }
16433
16434        #[allow(clippy::single_element_loop)]
16435        for &(find_this, param_name) in
16436            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
16437        {
16438            url = params.uri_replacement(url, param_name, find_this, false);
16439        }
16440        {
16441            let to_remove = ["editId", "packageName"];
16442            params.remove_params(&to_remove);
16443        }
16444
16445        let url = params.parse_with_url(&url);
16446
16447        loop {
16448            let token = match self
16449                .hub
16450                .auth
16451                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16452                .await
16453            {
16454                Ok(token) => token,
16455                Err(e) => match dlg.token(e) {
16456                    Ok(token) => token,
16457                    Err(e) => {
16458                        dlg.finished(false);
16459                        return Err(common::Error::MissingToken(e));
16460                    }
16461                },
16462            };
16463            let mut req_result = {
16464                let client = &self.hub.client;
16465                dlg.pre_request();
16466                let mut req_builder = hyper::Request::builder()
16467                    .method(hyper::Method::DELETE)
16468                    .uri(url.as_str())
16469                    .header(USER_AGENT, self.hub._user_agent.clone());
16470
16471                if let Some(token) = token.as_ref() {
16472                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16473                }
16474
16475                let request = req_builder
16476                    .header(CONTENT_LENGTH, 0_u64)
16477                    .body(common::to_body::<String>(None));
16478
16479                client.request(request.unwrap()).await
16480            };
16481
16482            match req_result {
16483                Err(err) => {
16484                    if let common::Retry::After(d) = dlg.http_error(&err) {
16485                        sleep(d).await;
16486                        continue;
16487                    }
16488                    dlg.finished(false);
16489                    return Err(common::Error::HttpError(err));
16490                }
16491                Ok(res) => {
16492                    let (mut parts, body) = res.into_parts();
16493                    let mut body = common::Body::new(body);
16494                    if !parts.status.is_success() {
16495                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16496                        let error = serde_json::from_str(&common::to_string(&bytes));
16497                        let response = common::to_response(parts, bytes.into());
16498
16499                        if let common::Retry::After(d) =
16500                            dlg.http_failure(&response, error.as_ref().ok())
16501                        {
16502                            sleep(d).await;
16503                            continue;
16504                        }
16505
16506                        dlg.finished(false);
16507
16508                        return Err(match error {
16509                            Ok(value) => common::Error::BadRequest(value),
16510                            _ => common::Error::Failure(response),
16511                        });
16512                    }
16513                    let response = common::Response::from_parts(parts, body);
16514
16515                    dlg.finished(true);
16516                    return Ok(response);
16517                }
16518            }
16519        }
16520    }
16521
16522    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
16523    ///
16524    /// Sets the *package name* path property to the given value.
16525    ///
16526    /// Even though the property as already been set when instantiating this call,
16527    /// we provide this method for API completeness.
16528    pub fn package_name(mut self, new_value: &str) -> EditDeleteCall<'a, C> {
16529        self._package_name = new_value.to_string();
16530        self
16531    }
16532    /// Unique identifier for this edit.
16533    ///
16534    /// Sets the *edit id* path property to the given value.
16535    ///
16536    /// Even though the property as already been set when instantiating this call,
16537    /// we provide this method for API completeness.
16538    pub fn edit_id(mut self, new_value: &str) -> EditDeleteCall<'a, C> {
16539        self._edit_id = new_value.to_string();
16540        self
16541    }
16542    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16543    /// while executing the actual API request.
16544    ///
16545    /// ````text
16546    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16547    /// ````
16548    ///
16549    /// Sets the *delegate* property to the given value.
16550    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditDeleteCall<'a, C> {
16551        self._delegate = Some(new_value);
16552        self
16553    }
16554
16555    /// Set any additional parameter of the query string used in the request.
16556    /// It should be used to set parameters which are not yet available through their own
16557    /// setters.
16558    ///
16559    /// Please note that this method must not be used to set any of the known parameters
16560    /// which have their own setter method. If done anyway, the request will fail.
16561    ///
16562    /// # Additional Parameters
16563    ///
16564    /// * *alt* (query-string) - Data format for the response.
16565    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16566    /// * *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.
16567    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16568    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16569    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16570    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16571    pub fn param<T>(mut self, name: T, value: T) -> EditDeleteCall<'a, C>
16572    where
16573        T: AsRef<str>,
16574    {
16575        self._additional_params
16576            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16577        self
16578    }
16579
16580    /// Identifies the authorization scope for the method you are building.
16581    ///
16582    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16583    /// [`Scope::Full`].
16584    ///
16585    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16586    /// tokens for more than one scope.
16587    ///
16588    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16589    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16590    /// sufficient, a read-write scope will do as well.
16591    pub fn add_scope<St>(mut self, scope: St) -> EditDeleteCall<'a, C>
16592    where
16593        St: AsRef<str>,
16594    {
16595        self._scopes.insert(String::from(scope.as_ref()));
16596        self
16597    }
16598    /// Identifies the authorization scope(s) for the method you are building.
16599    ///
16600    /// See [`Self::add_scope()`] for details.
16601    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDeleteCall<'a, C>
16602    where
16603        I: IntoIterator<Item = St>,
16604        St: AsRef<str>,
16605    {
16606        self._scopes
16607            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16608        self
16609    }
16610
16611    /// Removes all scopes, and no default scope will be used either.
16612    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16613    /// for details).
16614    pub fn clear_scopes(mut self) -> EditDeleteCall<'a, C> {
16615        self._scopes.clear();
16616        self
16617    }
16618}
16619
16620/// Returns information about the edit specified. Calls will fail if the edit is no long active (e.g. has been deleted, superseded or expired).
16621///
16622/// A builder for the *get* method supported by a *edit* resource.
16623/// It is not used directly, but through a [`EditMethods`] instance.
16624///
16625/// # Example
16626///
16627/// Instantiate a resource method builder
16628///
16629/// ```test_harness,no_run
16630/// # extern crate hyper;
16631/// # extern crate hyper_rustls;
16632/// # extern crate google_androidpublisher2 as androidpublisher2;
16633/// # async fn dox() {
16634/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16635///
16636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16637/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16638/// #     .with_native_roots()
16639/// #     .unwrap()
16640/// #     .https_only()
16641/// #     .enable_http2()
16642/// #     .build();
16643///
16644/// # let executor = hyper_util::rt::TokioExecutor::new();
16645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16646/// #     secret,
16647/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16648/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16649/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16650/// #     ),
16651/// # ).build().await.unwrap();
16652///
16653/// # let client = hyper_util::client::legacy::Client::builder(
16654/// #     hyper_util::rt::TokioExecutor::new()
16655/// # )
16656/// # .build(
16657/// #     hyper_rustls::HttpsConnectorBuilder::new()
16658/// #         .with_native_roots()
16659/// #         .unwrap()
16660/// #         .https_or_http()
16661/// #         .enable_http2()
16662/// #         .build()
16663/// # );
16664/// # let mut hub = AndroidPublisher::new(client, auth);
16665/// // You can configure optional parameters by calling the respective setters at will, and
16666/// // execute the final call using `doit()`.
16667/// // Values shown here are possibly random and not representative !
16668/// let result = hub.edits().get("packageName", "editId")
16669///              .doit().await;
16670/// # }
16671/// ```
16672pub struct EditGetCall<'a, C>
16673where
16674    C: 'a,
16675{
16676    hub: &'a AndroidPublisher<C>,
16677    _package_name: String,
16678    _edit_id: String,
16679    _delegate: Option<&'a mut dyn common::Delegate>,
16680    _additional_params: HashMap<String, String>,
16681    _scopes: BTreeSet<String>,
16682}
16683
16684impl<'a, C> common::CallBuilder for EditGetCall<'a, C> {}
16685
16686impl<'a, C> EditGetCall<'a, C>
16687where
16688    C: common::Connector,
16689{
16690    /// Perform the operation you have build so far.
16691    pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
16692        use std::borrow::Cow;
16693        use std::io::{Read, Seek};
16694
16695        use common::{url::Params, ToParts};
16696        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16697
16698        let mut dd = common::DefaultDelegate;
16699        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16700        dlg.begin(common::MethodInfo {
16701            id: "androidpublisher.edits.get",
16702            http_method: hyper::Method::GET,
16703        });
16704
16705        for &field in ["alt", "packageName", "editId"].iter() {
16706            if self._additional_params.contains_key(field) {
16707                dlg.finished(false);
16708                return Err(common::Error::FieldClash(field));
16709            }
16710        }
16711
16712        let mut params = Params::with_capacity(4 + self._additional_params.len());
16713        params.push("packageName", self._package_name);
16714        params.push("editId", self._edit_id);
16715
16716        params.extend(self._additional_params.iter());
16717
16718        params.push("alt", "json");
16719        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}";
16720        if self._scopes.is_empty() {
16721            self._scopes.insert(Scope::Full.as_ref().to_string());
16722        }
16723
16724        #[allow(clippy::single_element_loop)]
16725        for &(find_this, param_name) in
16726            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
16727        {
16728            url = params.uri_replacement(url, param_name, find_this, false);
16729        }
16730        {
16731            let to_remove = ["editId", "packageName"];
16732            params.remove_params(&to_remove);
16733        }
16734
16735        let url = params.parse_with_url(&url);
16736
16737        loop {
16738            let token = match self
16739                .hub
16740                .auth
16741                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16742                .await
16743            {
16744                Ok(token) => token,
16745                Err(e) => match dlg.token(e) {
16746                    Ok(token) => token,
16747                    Err(e) => {
16748                        dlg.finished(false);
16749                        return Err(common::Error::MissingToken(e));
16750                    }
16751                },
16752            };
16753            let mut req_result = {
16754                let client = &self.hub.client;
16755                dlg.pre_request();
16756                let mut req_builder = hyper::Request::builder()
16757                    .method(hyper::Method::GET)
16758                    .uri(url.as_str())
16759                    .header(USER_AGENT, self.hub._user_agent.clone());
16760
16761                if let Some(token) = token.as_ref() {
16762                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16763                }
16764
16765                let request = req_builder
16766                    .header(CONTENT_LENGTH, 0_u64)
16767                    .body(common::to_body::<String>(None));
16768
16769                client.request(request.unwrap()).await
16770            };
16771
16772            match req_result {
16773                Err(err) => {
16774                    if let common::Retry::After(d) = dlg.http_error(&err) {
16775                        sleep(d).await;
16776                        continue;
16777                    }
16778                    dlg.finished(false);
16779                    return Err(common::Error::HttpError(err));
16780                }
16781                Ok(res) => {
16782                    let (mut parts, body) = res.into_parts();
16783                    let mut body = common::Body::new(body);
16784                    if !parts.status.is_success() {
16785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16786                        let error = serde_json::from_str(&common::to_string(&bytes));
16787                        let response = common::to_response(parts, bytes.into());
16788
16789                        if let common::Retry::After(d) =
16790                            dlg.http_failure(&response, error.as_ref().ok())
16791                        {
16792                            sleep(d).await;
16793                            continue;
16794                        }
16795
16796                        dlg.finished(false);
16797
16798                        return Err(match error {
16799                            Ok(value) => common::Error::BadRequest(value),
16800                            _ => common::Error::Failure(response),
16801                        });
16802                    }
16803                    let response = {
16804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16805                        let encoded = common::to_string(&bytes);
16806                        match serde_json::from_str(&encoded) {
16807                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16808                            Err(error) => {
16809                                dlg.response_json_decode_error(&encoded, &error);
16810                                return Err(common::Error::JsonDecodeError(
16811                                    encoded.to_string(),
16812                                    error,
16813                                ));
16814                            }
16815                        }
16816                    };
16817
16818                    dlg.finished(true);
16819                    return Ok(response);
16820                }
16821            }
16822        }
16823    }
16824
16825    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
16826    ///
16827    /// Sets the *package name* path property to the given value.
16828    ///
16829    /// Even though the property as already been set when instantiating this call,
16830    /// we provide this method for API completeness.
16831    pub fn package_name(mut self, new_value: &str) -> EditGetCall<'a, C> {
16832        self._package_name = new_value.to_string();
16833        self
16834    }
16835    /// Unique identifier for this edit.
16836    ///
16837    /// Sets the *edit id* path property to the given value.
16838    ///
16839    /// Even though the property as already been set when instantiating this call,
16840    /// we provide this method for API completeness.
16841    pub fn edit_id(mut self, new_value: &str) -> EditGetCall<'a, C> {
16842        self._edit_id = new_value.to_string();
16843        self
16844    }
16845    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16846    /// while executing the actual API request.
16847    ///
16848    /// ````text
16849    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16850    /// ````
16851    ///
16852    /// Sets the *delegate* property to the given value.
16853    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditGetCall<'a, C> {
16854        self._delegate = Some(new_value);
16855        self
16856    }
16857
16858    /// Set any additional parameter of the query string used in the request.
16859    /// It should be used to set parameters which are not yet available through their own
16860    /// setters.
16861    ///
16862    /// Please note that this method must not be used to set any of the known parameters
16863    /// which have their own setter method. If done anyway, the request will fail.
16864    ///
16865    /// # Additional Parameters
16866    ///
16867    /// * *alt* (query-string) - Data format for the response.
16868    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16869    /// * *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.
16870    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16871    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16872    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16873    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16874    pub fn param<T>(mut self, name: T, value: T) -> EditGetCall<'a, C>
16875    where
16876        T: AsRef<str>,
16877    {
16878        self._additional_params
16879            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16880        self
16881    }
16882
16883    /// Identifies the authorization scope for the method you are building.
16884    ///
16885    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16886    /// [`Scope::Full`].
16887    ///
16888    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16889    /// tokens for more than one scope.
16890    ///
16891    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16892    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16893    /// sufficient, a read-write scope will do as well.
16894    pub fn add_scope<St>(mut self, scope: St) -> EditGetCall<'a, C>
16895    where
16896        St: AsRef<str>,
16897    {
16898        self._scopes.insert(String::from(scope.as_ref()));
16899        self
16900    }
16901    /// Identifies the authorization scope(s) for the method you are building.
16902    ///
16903    /// See [`Self::add_scope()`] for details.
16904    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditGetCall<'a, C>
16905    where
16906        I: IntoIterator<Item = St>,
16907        St: AsRef<str>,
16908    {
16909        self._scopes
16910            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16911        self
16912    }
16913
16914    /// Removes all scopes, and no default scope will be used either.
16915    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16916    /// for details).
16917    pub fn clear_scopes(mut self) -> EditGetCall<'a, C> {
16918        self._scopes.clear();
16919        self
16920    }
16921}
16922
16923/// Creates a new edit for an app, populated with the app's current state.
16924///
16925/// A builder for the *insert* method supported by a *edit* resource.
16926/// It is not used directly, but through a [`EditMethods`] instance.
16927///
16928/// # Example
16929///
16930/// Instantiate a resource method builder
16931///
16932/// ```test_harness,no_run
16933/// # extern crate hyper;
16934/// # extern crate hyper_rustls;
16935/// # extern crate google_androidpublisher2 as androidpublisher2;
16936/// use androidpublisher2::api::AppEdit;
16937/// # async fn dox() {
16938/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16939///
16940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16941/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16942/// #     .with_native_roots()
16943/// #     .unwrap()
16944/// #     .https_only()
16945/// #     .enable_http2()
16946/// #     .build();
16947///
16948/// # let executor = hyper_util::rt::TokioExecutor::new();
16949/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16950/// #     secret,
16951/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16952/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16953/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16954/// #     ),
16955/// # ).build().await.unwrap();
16956///
16957/// # let client = hyper_util::client::legacy::Client::builder(
16958/// #     hyper_util::rt::TokioExecutor::new()
16959/// # )
16960/// # .build(
16961/// #     hyper_rustls::HttpsConnectorBuilder::new()
16962/// #         .with_native_roots()
16963/// #         .unwrap()
16964/// #         .https_or_http()
16965/// #         .enable_http2()
16966/// #         .build()
16967/// # );
16968/// # let mut hub = AndroidPublisher::new(client, auth);
16969/// // As the method needs a request, you would usually fill it with the desired information
16970/// // into the respective structure. Some of the parts shown here might not be applicable !
16971/// // Values shown here are possibly random and not representative !
16972/// let mut req = AppEdit::default();
16973///
16974/// // You can configure optional parameters by calling the respective setters at will, and
16975/// // execute the final call using `doit()`.
16976/// // Values shown here are possibly random and not representative !
16977/// let result = hub.edits().insert(req, "packageName")
16978///              .doit().await;
16979/// # }
16980/// ```
16981pub struct EditInsertCall<'a, C>
16982where
16983    C: 'a,
16984{
16985    hub: &'a AndroidPublisher<C>,
16986    _request: AppEdit,
16987    _package_name: String,
16988    _delegate: Option<&'a mut dyn common::Delegate>,
16989    _additional_params: HashMap<String, String>,
16990    _scopes: BTreeSet<String>,
16991}
16992
16993impl<'a, C> common::CallBuilder for EditInsertCall<'a, C> {}
16994
16995impl<'a, C> EditInsertCall<'a, C>
16996where
16997    C: common::Connector,
16998{
16999    /// Perform the operation you have build so far.
17000    pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
17001        use std::borrow::Cow;
17002        use std::io::{Read, Seek};
17003
17004        use common::{url::Params, ToParts};
17005        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17006
17007        let mut dd = common::DefaultDelegate;
17008        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17009        dlg.begin(common::MethodInfo {
17010            id: "androidpublisher.edits.insert",
17011            http_method: hyper::Method::POST,
17012        });
17013
17014        for &field in ["alt", "packageName"].iter() {
17015            if self._additional_params.contains_key(field) {
17016                dlg.finished(false);
17017                return Err(common::Error::FieldClash(field));
17018            }
17019        }
17020
17021        let mut params = Params::with_capacity(4 + self._additional_params.len());
17022        params.push("packageName", self._package_name);
17023
17024        params.extend(self._additional_params.iter());
17025
17026        params.push("alt", "json");
17027        let mut url = self.hub._base_url.clone() + "{packageName}/edits";
17028        if self._scopes.is_empty() {
17029            self._scopes.insert(Scope::Full.as_ref().to_string());
17030        }
17031
17032        #[allow(clippy::single_element_loop)]
17033        for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
17034            url = params.uri_replacement(url, param_name, find_this, false);
17035        }
17036        {
17037            let to_remove = ["packageName"];
17038            params.remove_params(&to_remove);
17039        }
17040
17041        let url = params.parse_with_url(&url);
17042
17043        let mut json_mime_type = mime::APPLICATION_JSON;
17044        let mut request_value_reader = {
17045            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17046            common::remove_json_null_values(&mut value);
17047            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17048            serde_json::to_writer(&mut dst, &value).unwrap();
17049            dst
17050        };
17051        let request_size = request_value_reader
17052            .seek(std::io::SeekFrom::End(0))
17053            .unwrap();
17054        request_value_reader
17055            .seek(std::io::SeekFrom::Start(0))
17056            .unwrap();
17057
17058        loop {
17059            let token = match self
17060                .hub
17061                .auth
17062                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17063                .await
17064            {
17065                Ok(token) => token,
17066                Err(e) => match dlg.token(e) {
17067                    Ok(token) => token,
17068                    Err(e) => {
17069                        dlg.finished(false);
17070                        return Err(common::Error::MissingToken(e));
17071                    }
17072                },
17073            };
17074            request_value_reader
17075                .seek(std::io::SeekFrom::Start(0))
17076                .unwrap();
17077            let mut req_result = {
17078                let client = &self.hub.client;
17079                dlg.pre_request();
17080                let mut req_builder = hyper::Request::builder()
17081                    .method(hyper::Method::POST)
17082                    .uri(url.as_str())
17083                    .header(USER_AGENT, self.hub._user_agent.clone());
17084
17085                if let Some(token) = token.as_ref() {
17086                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17087                }
17088
17089                let request = req_builder
17090                    .header(CONTENT_TYPE, json_mime_type.to_string())
17091                    .header(CONTENT_LENGTH, request_size as u64)
17092                    .body(common::to_body(
17093                        request_value_reader.get_ref().clone().into(),
17094                    ));
17095
17096                client.request(request.unwrap()).await
17097            };
17098
17099            match req_result {
17100                Err(err) => {
17101                    if let common::Retry::After(d) = dlg.http_error(&err) {
17102                        sleep(d).await;
17103                        continue;
17104                    }
17105                    dlg.finished(false);
17106                    return Err(common::Error::HttpError(err));
17107                }
17108                Ok(res) => {
17109                    let (mut parts, body) = res.into_parts();
17110                    let mut body = common::Body::new(body);
17111                    if !parts.status.is_success() {
17112                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17113                        let error = serde_json::from_str(&common::to_string(&bytes));
17114                        let response = common::to_response(parts, bytes.into());
17115
17116                        if let common::Retry::After(d) =
17117                            dlg.http_failure(&response, error.as_ref().ok())
17118                        {
17119                            sleep(d).await;
17120                            continue;
17121                        }
17122
17123                        dlg.finished(false);
17124
17125                        return Err(match error {
17126                            Ok(value) => common::Error::BadRequest(value),
17127                            _ => common::Error::Failure(response),
17128                        });
17129                    }
17130                    let response = {
17131                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17132                        let encoded = common::to_string(&bytes);
17133                        match serde_json::from_str(&encoded) {
17134                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17135                            Err(error) => {
17136                                dlg.response_json_decode_error(&encoded, &error);
17137                                return Err(common::Error::JsonDecodeError(
17138                                    encoded.to_string(),
17139                                    error,
17140                                ));
17141                            }
17142                        }
17143                    };
17144
17145                    dlg.finished(true);
17146                    return Ok(response);
17147                }
17148            }
17149        }
17150    }
17151
17152    ///
17153    /// Sets the *request* property to the given value.
17154    ///
17155    /// Even though the property as already been set when instantiating this call,
17156    /// we provide this method for API completeness.
17157    pub fn request(mut self, new_value: AppEdit) -> EditInsertCall<'a, C> {
17158        self._request = new_value;
17159        self
17160    }
17161    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
17162    ///
17163    /// Sets the *package name* path property to the given value.
17164    ///
17165    /// Even though the property as already been set when instantiating this call,
17166    /// we provide this method for API completeness.
17167    pub fn package_name(mut self, new_value: &str) -> EditInsertCall<'a, C> {
17168        self._package_name = new_value.to_string();
17169        self
17170    }
17171    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17172    /// while executing the actual API request.
17173    ///
17174    /// ````text
17175    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17176    /// ````
17177    ///
17178    /// Sets the *delegate* property to the given value.
17179    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditInsertCall<'a, C> {
17180        self._delegate = Some(new_value);
17181        self
17182    }
17183
17184    /// Set any additional parameter of the query string used in the request.
17185    /// It should be used to set parameters which are not yet available through their own
17186    /// setters.
17187    ///
17188    /// Please note that this method must not be used to set any of the known parameters
17189    /// which have their own setter method. If done anyway, the request will fail.
17190    ///
17191    /// # Additional Parameters
17192    ///
17193    /// * *alt* (query-string) - Data format for the response.
17194    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17195    /// * *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.
17196    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17197    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17198    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17199    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17200    pub fn param<T>(mut self, name: T, value: T) -> EditInsertCall<'a, C>
17201    where
17202        T: AsRef<str>,
17203    {
17204        self._additional_params
17205            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17206        self
17207    }
17208
17209    /// Identifies the authorization scope for the method you are building.
17210    ///
17211    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17212    /// [`Scope::Full`].
17213    ///
17214    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17215    /// tokens for more than one scope.
17216    ///
17217    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17218    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17219    /// sufficient, a read-write scope will do as well.
17220    pub fn add_scope<St>(mut self, scope: St) -> EditInsertCall<'a, C>
17221    where
17222        St: AsRef<str>,
17223    {
17224        self._scopes.insert(String::from(scope.as_ref()));
17225        self
17226    }
17227    /// Identifies the authorization scope(s) for the method you are building.
17228    ///
17229    /// See [`Self::add_scope()`] for details.
17230    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditInsertCall<'a, C>
17231    where
17232        I: IntoIterator<Item = St>,
17233        St: AsRef<str>,
17234    {
17235        self._scopes
17236            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17237        self
17238    }
17239
17240    /// Removes all scopes, and no default scope will be used either.
17241    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17242    /// for details).
17243    pub fn clear_scopes(mut self) -> EditInsertCall<'a, C> {
17244        self._scopes.clear();
17245        self
17246    }
17247}
17248
17249/// Checks that the edit can be successfully committed. The edit's changes are not applied to the live app.
17250///
17251/// A builder for the *validate* method supported by a *edit* resource.
17252/// It is not used directly, but through a [`EditMethods`] instance.
17253///
17254/// # Example
17255///
17256/// Instantiate a resource method builder
17257///
17258/// ```test_harness,no_run
17259/// # extern crate hyper;
17260/// # extern crate hyper_rustls;
17261/// # extern crate google_androidpublisher2 as androidpublisher2;
17262/// # async fn dox() {
17263/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17264///
17265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17266/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17267/// #     .with_native_roots()
17268/// #     .unwrap()
17269/// #     .https_only()
17270/// #     .enable_http2()
17271/// #     .build();
17272///
17273/// # let executor = hyper_util::rt::TokioExecutor::new();
17274/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17275/// #     secret,
17276/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17277/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17278/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17279/// #     ),
17280/// # ).build().await.unwrap();
17281///
17282/// # let client = hyper_util::client::legacy::Client::builder(
17283/// #     hyper_util::rt::TokioExecutor::new()
17284/// # )
17285/// # .build(
17286/// #     hyper_rustls::HttpsConnectorBuilder::new()
17287/// #         .with_native_roots()
17288/// #         .unwrap()
17289/// #         .https_or_http()
17290/// #         .enable_http2()
17291/// #         .build()
17292/// # );
17293/// # let mut hub = AndroidPublisher::new(client, auth);
17294/// // You can configure optional parameters by calling the respective setters at will, and
17295/// // execute the final call using `doit()`.
17296/// // Values shown here are possibly random and not representative !
17297/// let result = hub.edits().validate("packageName", "editId")
17298///              .doit().await;
17299/// # }
17300/// ```
17301pub struct EditValidateCall<'a, C>
17302where
17303    C: 'a,
17304{
17305    hub: &'a AndroidPublisher<C>,
17306    _package_name: String,
17307    _edit_id: String,
17308    _delegate: Option<&'a mut dyn common::Delegate>,
17309    _additional_params: HashMap<String, String>,
17310    _scopes: BTreeSet<String>,
17311}
17312
17313impl<'a, C> common::CallBuilder for EditValidateCall<'a, C> {}
17314
17315impl<'a, C> EditValidateCall<'a, C>
17316where
17317    C: common::Connector,
17318{
17319    /// Perform the operation you have build so far.
17320    pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
17321        use std::borrow::Cow;
17322        use std::io::{Read, Seek};
17323
17324        use common::{url::Params, ToParts};
17325        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17326
17327        let mut dd = common::DefaultDelegate;
17328        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17329        dlg.begin(common::MethodInfo {
17330            id: "androidpublisher.edits.validate",
17331            http_method: hyper::Method::POST,
17332        });
17333
17334        for &field in ["alt", "packageName", "editId"].iter() {
17335            if self._additional_params.contains_key(field) {
17336                dlg.finished(false);
17337                return Err(common::Error::FieldClash(field));
17338            }
17339        }
17340
17341        let mut params = Params::with_capacity(4 + self._additional_params.len());
17342        params.push("packageName", self._package_name);
17343        params.push("editId", self._edit_id);
17344
17345        params.extend(self._additional_params.iter());
17346
17347        params.push("alt", "json");
17348        let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}:validate";
17349        if self._scopes.is_empty() {
17350            self._scopes.insert(Scope::Full.as_ref().to_string());
17351        }
17352
17353        #[allow(clippy::single_element_loop)]
17354        for &(find_this, param_name) in
17355            [("{packageName}", "packageName"), ("{editId}", "editId")].iter()
17356        {
17357            url = params.uri_replacement(url, param_name, find_this, false);
17358        }
17359        {
17360            let to_remove = ["editId", "packageName"];
17361            params.remove_params(&to_remove);
17362        }
17363
17364        let url = params.parse_with_url(&url);
17365
17366        loop {
17367            let token = match self
17368                .hub
17369                .auth
17370                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17371                .await
17372            {
17373                Ok(token) => token,
17374                Err(e) => match dlg.token(e) {
17375                    Ok(token) => token,
17376                    Err(e) => {
17377                        dlg.finished(false);
17378                        return Err(common::Error::MissingToken(e));
17379                    }
17380                },
17381            };
17382            let mut req_result = {
17383                let client = &self.hub.client;
17384                dlg.pre_request();
17385                let mut req_builder = hyper::Request::builder()
17386                    .method(hyper::Method::POST)
17387                    .uri(url.as_str())
17388                    .header(USER_AGENT, self.hub._user_agent.clone());
17389
17390                if let Some(token) = token.as_ref() {
17391                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17392                }
17393
17394                let request = req_builder
17395                    .header(CONTENT_LENGTH, 0_u64)
17396                    .body(common::to_body::<String>(None));
17397
17398                client.request(request.unwrap()).await
17399            };
17400
17401            match req_result {
17402                Err(err) => {
17403                    if let common::Retry::After(d) = dlg.http_error(&err) {
17404                        sleep(d).await;
17405                        continue;
17406                    }
17407                    dlg.finished(false);
17408                    return Err(common::Error::HttpError(err));
17409                }
17410                Ok(res) => {
17411                    let (mut parts, body) = res.into_parts();
17412                    let mut body = common::Body::new(body);
17413                    if !parts.status.is_success() {
17414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17415                        let error = serde_json::from_str(&common::to_string(&bytes));
17416                        let response = common::to_response(parts, bytes.into());
17417
17418                        if let common::Retry::After(d) =
17419                            dlg.http_failure(&response, error.as_ref().ok())
17420                        {
17421                            sleep(d).await;
17422                            continue;
17423                        }
17424
17425                        dlg.finished(false);
17426
17427                        return Err(match error {
17428                            Ok(value) => common::Error::BadRequest(value),
17429                            _ => common::Error::Failure(response),
17430                        });
17431                    }
17432                    let response = {
17433                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17434                        let encoded = common::to_string(&bytes);
17435                        match serde_json::from_str(&encoded) {
17436                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17437                            Err(error) => {
17438                                dlg.response_json_decode_error(&encoded, &error);
17439                                return Err(common::Error::JsonDecodeError(
17440                                    encoded.to_string(),
17441                                    error,
17442                                ));
17443                            }
17444                        }
17445                    };
17446
17447                    dlg.finished(true);
17448                    return Ok(response);
17449                }
17450            }
17451        }
17452    }
17453
17454    /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
17455    ///
17456    /// Sets the *package name* path property to the given value.
17457    ///
17458    /// Even though the property as already been set when instantiating this call,
17459    /// we provide this method for API completeness.
17460    pub fn package_name(mut self, new_value: &str) -> EditValidateCall<'a, C> {
17461        self._package_name = new_value.to_string();
17462        self
17463    }
17464    /// Unique identifier for this edit.
17465    ///
17466    /// Sets the *edit id* path property to the given value.
17467    ///
17468    /// Even though the property as already been set when instantiating this call,
17469    /// we provide this method for API completeness.
17470    pub fn edit_id(mut self, new_value: &str) -> EditValidateCall<'a, C> {
17471        self._edit_id = new_value.to_string();
17472        self
17473    }
17474    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17475    /// while executing the actual API request.
17476    ///
17477    /// ````text
17478    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17479    /// ````
17480    ///
17481    /// Sets the *delegate* property to the given value.
17482    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditValidateCall<'a, C> {
17483        self._delegate = Some(new_value);
17484        self
17485    }
17486
17487    /// Set any additional parameter of the query string used in the request.
17488    /// It should be used to set parameters which are not yet available through their own
17489    /// setters.
17490    ///
17491    /// Please note that this method must not be used to set any of the known parameters
17492    /// which have their own setter method. If done anyway, the request will fail.
17493    ///
17494    /// # Additional Parameters
17495    ///
17496    /// * *alt* (query-string) - Data format for the response.
17497    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17498    /// * *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.
17499    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17500    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17501    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17502    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17503    pub fn param<T>(mut self, name: T, value: T) -> EditValidateCall<'a, C>
17504    where
17505        T: AsRef<str>,
17506    {
17507        self._additional_params
17508            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17509        self
17510    }
17511
17512    /// Identifies the authorization scope for the method you are building.
17513    ///
17514    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17515    /// [`Scope::Full`].
17516    ///
17517    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17518    /// tokens for more than one scope.
17519    ///
17520    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17521    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17522    /// sufficient, a read-write scope will do as well.
17523    pub fn add_scope<St>(mut self, scope: St) -> EditValidateCall<'a, C>
17524    where
17525        St: AsRef<str>,
17526    {
17527        self._scopes.insert(String::from(scope.as_ref()));
17528        self
17529    }
17530    /// Identifies the authorization scope(s) for the method you are building.
17531    ///
17532    /// See [`Self::add_scope()`] for details.
17533    pub fn add_scopes<I, St>(mut self, scopes: I) -> EditValidateCall<'a, C>
17534    where
17535        I: IntoIterator<Item = St>,
17536        St: AsRef<str>,
17537    {
17538        self._scopes
17539            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17540        self
17541    }
17542
17543    /// Removes all scopes, and no default scope will be used either.
17544    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17545    /// for details).
17546    pub fn clear_scopes(mut self) -> EditValidateCall<'a, C> {
17547        self._scopes.clear();
17548        self
17549    }
17550}
17551
17552/// Delete an in-app product for an app.
17553///
17554/// A builder for the *delete* method supported by a *inappproduct* resource.
17555/// It is not used directly, but through a [`InappproductMethods`] instance.
17556///
17557/// # Example
17558///
17559/// Instantiate a resource method builder
17560///
17561/// ```test_harness,no_run
17562/// # extern crate hyper;
17563/// # extern crate hyper_rustls;
17564/// # extern crate google_androidpublisher2 as androidpublisher2;
17565/// # async fn dox() {
17566/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17567///
17568/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17569/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17570/// #     .with_native_roots()
17571/// #     .unwrap()
17572/// #     .https_only()
17573/// #     .enable_http2()
17574/// #     .build();
17575///
17576/// # let executor = hyper_util::rt::TokioExecutor::new();
17577/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17578/// #     secret,
17579/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17580/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17581/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17582/// #     ),
17583/// # ).build().await.unwrap();
17584///
17585/// # let client = hyper_util::client::legacy::Client::builder(
17586/// #     hyper_util::rt::TokioExecutor::new()
17587/// # )
17588/// # .build(
17589/// #     hyper_rustls::HttpsConnectorBuilder::new()
17590/// #         .with_native_roots()
17591/// #         .unwrap()
17592/// #         .https_or_http()
17593/// #         .enable_http2()
17594/// #         .build()
17595/// # );
17596/// # let mut hub = AndroidPublisher::new(client, auth);
17597/// // You can configure optional parameters by calling the respective setters at will, and
17598/// // execute the final call using `doit()`.
17599/// // Values shown here are possibly random and not representative !
17600/// let result = hub.inappproducts().delete("packageName", "sku")
17601///              .doit().await;
17602/// # }
17603/// ```
17604pub struct InappproductDeleteCall<'a, C>
17605where
17606    C: 'a,
17607{
17608    hub: &'a AndroidPublisher<C>,
17609    _package_name: String,
17610    _sku: String,
17611    _delegate: Option<&'a mut dyn common::Delegate>,
17612    _additional_params: HashMap<String, String>,
17613    _scopes: BTreeSet<String>,
17614}
17615
17616impl<'a, C> common::CallBuilder for InappproductDeleteCall<'a, C> {}
17617
17618impl<'a, C> InappproductDeleteCall<'a, C>
17619where
17620    C: common::Connector,
17621{
17622    /// Perform the operation you have build so far.
17623    pub async fn doit(mut self) -> common::Result<common::Response> {
17624        use std::borrow::Cow;
17625        use std::io::{Read, Seek};
17626
17627        use common::{url::Params, ToParts};
17628        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17629
17630        let mut dd = common::DefaultDelegate;
17631        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17632        dlg.begin(common::MethodInfo {
17633            id: "androidpublisher.inappproducts.delete",
17634            http_method: hyper::Method::DELETE,
17635        });
17636
17637        for &field in ["packageName", "sku"].iter() {
17638            if self._additional_params.contains_key(field) {
17639                dlg.finished(false);
17640                return Err(common::Error::FieldClash(field));
17641            }
17642        }
17643
17644        let mut params = Params::with_capacity(3 + self._additional_params.len());
17645        params.push("packageName", self._package_name);
17646        params.push("sku", self._sku);
17647
17648        params.extend(self._additional_params.iter());
17649
17650        let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}";
17651        if self._scopes.is_empty() {
17652            self._scopes.insert(Scope::Full.as_ref().to_string());
17653        }
17654
17655        #[allow(clippy::single_element_loop)]
17656        for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
17657        {
17658            url = params.uri_replacement(url, param_name, find_this, false);
17659        }
17660        {
17661            let to_remove = ["sku", "packageName"];
17662            params.remove_params(&to_remove);
17663        }
17664
17665        let url = params.parse_with_url(&url);
17666
17667        loop {
17668            let token = match self
17669                .hub
17670                .auth
17671                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17672                .await
17673            {
17674                Ok(token) => token,
17675                Err(e) => match dlg.token(e) {
17676                    Ok(token) => token,
17677                    Err(e) => {
17678                        dlg.finished(false);
17679                        return Err(common::Error::MissingToken(e));
17680                    }
17681                },
17682            };
17683            let mut req_result = {
17684                let client = &self.hub.client;
17685                dlg.pre_request();
17686                let mut req_builder = hyper::Request::builder()
17687                    .method(hyper::Method::DELETE)
17688                    .uri(url.as_str())
17689                    .header(USER_AGENT, self.hub._user_agent.clone());
17690
17691                if let Some(token) = token.as_ref() {
17692                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17693                }
17694
17695                let request = req_builder
17696                    .header(CONTENT_LENGTH, 0_u64)
17697                    .body(common::to_body::<String>(None));
17698
17699                client.request(request.unwrap()).await
17700            };
17701
17702            match req_result {
17703                Err(err) => {
17704                    if let common::Retry::After(d) = dlg.http_error(&err) {
17705                        sleep(d).await;
17706                        continue;
17707                    }
17708                    dlg.finished(false);
17709                    return Err(common::Error::HttpError(err));
17710                }
17711                Ok(res) => {
17712                    let (mut parts, body) = res.into_parts();
17713                    let mut body = common::Body::new(body);
17714                    if !parts.status.is_success() {
17715                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17716                        let error = serde_json::from_str(&common::to_string(&bytes));
17717                        let response = common::to_response(parts, bytes.into());
17718
17719                        if let common::Retry::After(d) =
17720                            dlg.http_failure(&response, error.as_ref().ok())
17721                        {
17722                            sleep(d).await;
17723                            continue;
17724                        }
17725
17726                        dlg.finished(false);
17727
17728                        return Err(match error {
17729                            Ok(value) => common::Error::BadRequest(value),
17730                            _ => common::Error::Failure(response),
17731                        });
17732                    }
17733                    let response = common::Response::from_parts(parts, body);
17734
17735                    dlg.finished(true);
17736                    return Ok(response);
17737                }
17738            }
17739        }
17740    }
17741
17742    /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
17743    ///
17744    /// Sets the *package name* path property to the given value.
17745    ///
17746    /// Even though the property as already been set when instantiating this call,
17747    /// we provide this method for API completeness.
17748    pub fn package_name(mut self, new_value: &str) -> InappproductDeleteCall<'a, C> {
17749        self._package_name = new_value.to_string();
17750        self
17751    }
17752    /// Unique identifier for the in-app product.
17753    ///
17754    /// Sets the *sku* path property to the given value.
17755    ///
17756    /// Even though the property as already been set when instantiating this call,
17757    /// we provide this method for API completeness.
17758    pub fn sku(mut self, new_value: &str) -> InappproductDeleteCall<'a, C> {
17759        self._sku = new_value.to_string();
17760        self
17761    }
17762    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17763    /// while executing the actual API request.
17764    ///
17765    /// ````text
17766    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17767    /// ````
17768    ///
17769    /// Sets the *delegate* property to the given value.
17770    pub fn delegate(
17771        mut self,
17772        new_value: &'a mut dyn common::Delegate,
17773    ) -> InappproductDeleteCall<'a, C> {
17774        self._delegate = Some(new_value);
17775        self
17776    }
17777
17778    /// Set any additional parameter of the query string used in the request.
17779    /// It should be used to set parameters which are not yet available through their own
17780    /// setters.
17781    ///
17782    /// Please note that this method must not be used to set any of the known parameters
17783    /// which have their own setter method. If done anyway, the request will fail.
17784    ///
17785    /// # Additional Parameters
17786    ///
17787    /// * *alt* (query-string) - Data format for the response.
17788    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17789    /// * *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.
17790    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17791    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17792    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17793    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17794    pub fn param<T>(mut self, name: T, value: T) -> InappproductDeleteCall<'a, C>
17795    where
17796        T: AsRef<str>,
17797    {
17798        self._additional_params
17799            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17800        self
17801    }
17802
17803    /// Identifies the authorization scope for the method you are building.
17804    ///
17805    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17806    /// [`Scope::Full`].
17807    ///
17808    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17809    /// tokens for more than one scope.
17810    ///
17811    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17812    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17813    /// sufficient, a read-write scope will do as well.
17814    pub fn add_scope<St>(mut self, scope: St) -> InappproductDeleteCall<'a, C>
17815    where
17816        St: AsRef<str>,
17817    {
17818        self._scopes.insert(String::from(scope.as_ref()));
17819        self
17820    }
17821    /// Identifies the authorization scope(s) for the method you are building.
17822    ///
17823    /// See [`Self::add_scope()`] for details.
17824    pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductDeleteCall<'a, C>
17825    where
17826        I: IntoIterator<Item = St>,
17827        St: AsRef<str>,
17828    {
17829        self._scopes
17830            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17831        self
17832    }
17833
17834    /// Removes all scopes, and no default scope will be used either.
17835    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17836    /// for details).
17837    pub fn clear_scopes(mut self) -> InappproductDeleteCall<'a, C> {
17838        self._scopes.clear();
17839        self
17840    }
17841}
17842
17843/// Returns information about the in-app product specified.
17844///
17845/// A builder for the *get* method supported by a *inappproduct* resource.
17846/// It is not used directly, but through a [`InappproductMethods`] instance.
17847///
17848/// # Example
17849///
17850/// Instantiate a resource method builder
17851///
17852/// ```test_harness,no_run
17853/// # extern crate hyper;
17854/// # extern crate hyper_rustls;
17855/// # extern crate google_androidpublisher2 as androidpublisher2;
17856/// # async fn dox() {
17857/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17858///
17859/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17860/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17861/// #     .with_native_roots()
17862/// #     .unwrap()
17863/// #     .https_only()
17864/// #     .enable_http2()
17865/// #     .build();
17866///
17867/// # let executor = hyper_util::rt::TokioExecutor::new();
17868/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17869/// #     secret,
17870/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17871/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17872/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17873/// #     ),
17874/// # ).build().await.unwrap();
17875///
17876/// # let client = hyper_util::client::legacy::Client::builder(
17877/// #     hyper_util::rt::TokioExecutor::new()
17878/// # )
17879/// # .build(
17880/// #     hyper_rustls::HttpsConnectorBuilder::new()
17881/// #         .with_native_roots()
17882/// #         .unwrap()
17883/// #         .https_or_http()
17884/// #         .enable_http2()
17885/// #         .build()
17886/// # );
17887/// # let mut hub = AndroidPublisher::new(client, auth);
17888/// // You can configure optional parameters by calling the respective setters at will, and
17889/// // execute the final call using `doit()`.
17890/// // Values shown here are possibly random and not representative !
17891/// let result = hub.inappproducts().get("packageName", "sku")
17892///              .doit().await;
17893/// # }
17894/// ```
17895pub struct InappproductGetCall<'a, C>
17896where
17897    C: 'a,
17898{
17899    hub: &'a AndroidPublisher<C>,
17900    _package_name: String,
17901    _sku: String,
17902    _delegate: Option<&'a mut dyn common::Delegate>,
17903    _additional_params: HashMap<String, String>,
17904    _scopes: BTreeSet<String>,
17905}
17906
17907impl<'a, C> common::CallBuilder for InappproductGetCall<'a, C> {}
17908
17909impl<'a, C> InappproductGetCall<'a, C>
17910where
17911    C: common::Connector,
17912{
17913    /// Perform the operation you have build so far.
17914    pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
17915        use std::borrow::Cow;
17916        use std::io::{Read, Seek};
17917
17918        use common::{url::Params, ToParts};
17919        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17920
17921        let mut dd = common::DefaultDelegate;
17922        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17923        dlg.begin(common::MethodInfo {
17924            id: "androidpublisher.inappproducts.get",
17925            http_method: hyper::Method::GET,
17926        });
17927
17928        for &field in ["alt", "packageName", "sku"].iter() {
17929            if self._additional_params.contains_key(field) {
17930                dlg.finished(false);
17931                return Err(common::Error::FieldClash(field));
17932            }
17933        }
17934
17935        let mut params = Params::with_capacity(4 + self._additional_params.len());
17936        params.push("packageName", self._package_name);
17937        params.push("sku", self._sku);
17938
17939        params.extend(self._additional_params.iter());
17940
17941        params.push("alt", "json");
17942        let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}";
17943        if self._scopes.is_empty() {
17944            self._scopes.insert(Scope::Full.as_ref().to_string());
17945        }
17946
17947        #[allow(clippy::single_element_loop)]
17948        for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
17949        {
17950            url = params.uri_replacement(url, param_name, find_this, false);
17951        }
17952        {
17953            let to_remove = ["sku", "packageName"];
17954            params.remove_params(&to_remove);
17955        }
17956
17957        let url = params.parse_with_url(&url);
17958
17959        loop {
17960            let token = match self
17961                .hub
17962                .auth
17963                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17964                .await
17965            {
17966                Ok(token) => token,
17967                Err(e) => match dlg.token(e) {
17968                    Ok(token) => token,
17969                    Err(e) => {
17970                        dlg.finished(false);
17971                        return Err(common::Error::MissingToken(e));
17972                    }
17973                },
17974            };
17975            let mut req_result = {
17976                let client = &self.hub.client;
17977                dlg.pre_request();
17978                let mut req_builder = hyper::Request::builder()
17979                    .method(hyper::Method::GET)
17980                    .uri(url.as_str())
17981                    .header(USER_AGENT, self.hub._user_agent.clone());
17982
17983                if let Some(token) = token.as_ref() {
17984                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17985                }
17986
17987                let request = req_builder
17988                    .header(CONTENT_LENGTH, 0_u64)
17989                    .body(common::to_body::<String>(None));
17990
17991                client.request(request.unwrap()).await
17992            };
17993
17994            match req_result {
17995                Err(err) => {
17996                    if let common::Retry::After(d) = dlg.http_error(&err) {
17997                        sleep(d).await;
17998                        continue;
17999                    }
18000                    dlg.finished(false);
18001                    return Err(common::Error::HttpError(err));
18002                }
18003                Ok(res) => {
18004                    let (mut parts, body) = res.into_parts();
18005                    let mut body = common::Body::new(body);
18006                    if !parts.status.is_success() {
18007                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18008                        let error = serde_json::from_str(&common::to_string(&bytes));
18009                        let response = common::to_response(parts, bytes.into());
18010
18011                        if let common::Retry::After(d) =
18012                            dlg.http_failure(&response, error.as_ref().ok())
18013                        {
18014                            sleep(d).await;
18015                            continue;
18016                        }
18017
18018                        dlg.finished(false);
18019
18020                        return Err(match error {
18021                            Ok(value) => common::Error::BadRequest(value),
18022                            _ => common::Error::Failure(response),
18023                        });
18024                    }
18025                    let response = {
18026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18027                        let encoded = common::to_string(&bytes);
18028                        match serde_json::from_str(&encoded) {
18029                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18030                            Err(error) => {
18031                                dlg.response_json_decode_error(&encoded, &error);
18032                                return Err(common::Error::JsonDecodeError(
18033                                    encoded.to_string(),
18034                                    error,
18035                                ));
18036                            }
18037                        }
18038                    };
18039
18040                    dlg.finished(true);
18041                    return Ok(response);
18042                }
18043            }
18044        }
18045    }
18046
18047    ///
18048    /// Sets the *package name* path property to the given value.
18049    ///
18050    /// Even though the property as already been set when instantiating this call,
18051    /// we provide this method for API completeness.
18052    pub fn package_name(mut self, new_value: &str) -> InappproductGetCall<'a, C> {
18053        self._package_name = new_value.to_string();
18054        self
18055    }
18056    /// Unique identifier for the in-app product.
18057    ///
18058    /// Sets the *sku* path property to the given value.
18059    ///
18060    /// Even though the property as already been set when instantiating this call,
18061    /// we provide this method for API completeness.
18062    pub fn sku(mut self, new_value: &str) -> InappproductGetCall<'a, C> {
18063        self._sku = new_value.to_string();
18064        self
18065    }
18066    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18067    /// while executing the actual API request.
18068    ///
18069    /// ````text
18070    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18071    /// ````
18072    ///
18073    /// Sets the *delegate* property to the given value.
18074    pub fn delegate(
18075        mut self,
18076        new_value: &'a mut dyn common::Delegate,
18077    ) -> InappproductGetCall<'a, C> {
18078        self._delegate = Some(new_value);
18079        self
18080    }
18081
18082    /// Set any additional parameter of the query string used in the request.
18083    /// It should be used to set parameters which are not yet available through their own
18084    /// setters.
18085    ///
18086    /// Please note that this method must not be used to set any of the known parameters
18087    /// which have their own setter method. If done anyway, the request will fail.
18088    ///
18089    /// # Additional Parameters
18090    ///
18091    /// * *alt* (query-string) - Data format for the response.
18092    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18093    /// * *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.
18094    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18095    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18096    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18097    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18098    pub fn param<T>(mut self, name: T, value: T) -> InappproductGetCall<'a, C>
18099    where
18100        T: AsRef<str>,
18101    {
18102        self._additional_params
18103            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18104        self
18105    }
18106
18107    /// Identifies the authorization scope for the method you are building.
18108    ///
18109    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18110    /// [`Scope::Full`].
18111    ///
18112    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18113    /// tokens for more than one scope.
18114    ///
18115    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18116    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18117    /// sufficient, a read-write scope will do as well.
18118    pub fn add_scope<St>(mut self, scope: St) -> InappproductGetCall<'a, C>
18119    where
18120        St: AsRef<str>,
18121    {
18122        self._scopes.insert(String::from(scope.as_ref()));
18123        self
18124    }
18125    /// Identifies the authorization scope(s) for the method you are building.
18126    ///
18127    /// See [`Self::add_scope()`] for details.
18128    pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductGetCall<'a, C>
18129    where
18130        I: IntoIterator<Item = St>,
18131        St: AsRef<str>,
18132    {
18133        self._scopes
18134            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18135        self
18136    }
18137
18138    /// Removes all scopes, and no default scope will be used either.
18139    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18140    /// for details).
18141    pub fn clear_scopes(mut self) -> InappproductGetCall<'a, C> {
18142        self._scopes.clear();
18143        self
18144    }
18145}
18146
18147/// Creates a new in-app product for an app.
18148///
18149/// A builder for the *insert* method supported by a *inappproduct* resource.
18150/// It is not used directly, but through a [`InappproductMethods`] instance.
18151///
18152/// # Example
18153///
18154/// Instantiate a resource method builder
18155///
18156/// ```test_harness,no_run
18157/// # extern crate hyper;
18158/// # extern crate hyper_rustls;
18159/// # extern crate google_androidpublisher2 as androidpublisher2;
18160/// use androidpublisher2::api::InAppProduct;
18161/// # async fn dox() {
18162/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18163///
18164/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18165/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18166/// #     .with_native_roots()
18167/// #     .unwrap()
18168/// #     .https_only()
18169/// #     .enable_http2()
18170/// #     .build();
18171///
18172/// # let executor = hyper_util::rt::TokioExecutor::new();
18173/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18174/// #     secret,
18175/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18176/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18177/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18178/// #     ),
18179/// # ).build().await.unwrap();
18180///
18181/// # let client = hyper_util::client::legacy::Client::builder(
18182/// #     hyper_util::rt::TokioExecutor::new()
18183/// # )
18184/// # .build(
18185/// #     hyper_rustls::HttpsConnectorBuilder::new()
18186/// #         .with_native_roots()
18187/// #         .unwrap()
18188/// #         .https_or_http()
18189/// #         .enable_http2()
18190/// #         .build()
18191/// # );
18192/// # let mut hub = AndroidPublisher::new(client, auth);
18193/// // As the method needs a request, you would usually fill it with the desired information
18194/// // into the respective structure. Some of the parts shown here might not be applicable !
18195/// // Values shown here are possibly random and not representative !
18196/// let mut req = InAppProduct::default();
18197///
18198/// // You can configure optional parameters by calling the respective setters at will, and
18199/// // execute the final call using `doit()`.
18200/// // Values shown here are possibly random and not representative !
18201/// let result = hub.inappproducts().insert(req, "packageName")
18202///              .auto_convert_missing_prices(false)
18203///              .doit().await;
18204/// # }
18205/// ```
18206pub struct InappproductInsertCall<'a, C>
18207where
18208    C: 'a,
18209{
18210    hub: &'a AndroidPublisher<C>,
18211    _request: InAppProduct,
18212    _package_name: String,
18213    _auto_convert_missing_prices: Option<bool>,
18214    _delegate: Option<&'a mut dyn common::Delegate>,
18215    _additional_params: HashMap<String, String>,
18216    _scopes: BTreeSet<String>,
18217}
18218
18219impl<'a, C> common::CallBuilder for InappproductInsertCall<'a, C> {}
18220
18221impl<'a, C> InappproductInsertCall<'a, C>
18222where
18223    C: common::Connector,
18224{
18225    /// Perform the operation you have build so far.
18226    pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
18227        use std::borrow::Cow;
18228        use std::io::{Read, Seek};
18229
18230        use common::{url::Params, ToParts};
18231        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18232
18233        let mut dd = common::DefaultDelegate;
18234        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18235        dlg.begin(common::MethodInfo {
18236            id: "androidpublisher.inappproducts.insert",
18237            http_method: hyper::Method::POST,
18238        });
18239
18240        for &field in ["alt", "packageName", "autoConvertMissingPrices"].iter() {
18241            if self._additional_params.contains_key(field) {
18242                dlg.finished(false);
18243                return Err(common::Error::FieldClash(field));
18244            }
18245        }
18246
18247        let mut params = Params::with_capacity(5 + self._additional_params.len());
18248        params.push("packageName", self._package_name);
18249        if let Some(value) = self._auto_convert_missing_prices.as_ref() {
18250            params.push("autoConvertMissingPrices", value.to_string());
18251        }
18252
18253        params.extend(self._additional_params.iter());
18254
18255        params.push("alt", "json");
18256        let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts";
18257        if self._scopes.is_empty() {
18258            self._scopes.insert(Scope::Full.as_ref().to_string());
18259        }
18260
18261        #[allow(clippy::single_element_loop)]
18262        for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
18263            url = params.uri_replacement(url, param_name, find_this, false);
18264        }
18265        {
18266            let to_remove = ["packageName"];
18267            params.remove_params(&to_remove);
18268        }
18269
18270        let url = params.parse_with_url(&url);
18271
18272        let mut json_mime_type = mime::APPLICATION_JSON;
18273        let mut request_value_reader = {
18274            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18275            common::remove_json_null_values(&mut value);
18276            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18277            serde_json::to_writer(&mut dst, &value).unwrap();
18278            dst
18279        };
18280        let request_size = request_value_reader
18281            .seek(std::io::SeekFrom::End(0))
18282            .unwrap();
18283        request_value_reader
18284            .seek(std::io::SeekFrom::Start(0))
18285            .unwrap();
18286
18287        loop {
18288            let token = match self
18289                .hub
18290                .auth
18291                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18292                .await
18293            {
18294                Ok(token) => token,
18295                Err(e) => match dlg.token(e) {
18296                    Ok(token) => token,
18297                    Err(e) => {
18298                        dlg.finished(false);
18299                        return Err(common::Error::MissingToken(e));
18300                    }
18301                },
18302            };
18303            request_value_reader
18304                .seek(std::io::SeekFrom::Start(0))
18305                .unwrap();
18306            let mut req_result = {
18307                let client = &self.hub.client;
18308                dlg.pre_request();
18309                let mut req_builder = hyper::Request::builder()
18310                    .method(hyper::Method::POST)
18311                    .uri(url.as_str())
18312                    .header(USER_AGENT, self.hub._user_agent.clone());
18313
18314                if let Some(token) = token.as_ref() {
18315                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18316                }
18317
18318                let request = req_builder
18319                    .header(CONTENT_TYPE, json_mime_type.to_string())
18320                    .header(CONTENT_LENGTH, request_size as u64)
18321                    .body(common::to_body(
18322                        request_value_reader.get_ref().clone().into(),
18323                    ));
18324
18325                client.request(request.unwrap()).await
18326            };
18327
18328            match req_result {
18329                Err(err) => {
18330                    if let common::Retry::After(d) = dlg.http_error(&err) {
18331                        sleep(d).await;
18332                        continue;
18333                    }
18334                    dlg.finished(false);
18335                    return Err(common::Error::HttpError(err));
18336                }
18337                Ok(res) => {
18338                    let (mut parts, body) = res.into_parts();
18339                    let mut body = common::Body::new(body);
18340                    if !parts.status.is_success() {
18341                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18342                        let error = serde_json::from_str(&common::to_string(&bytes));
18343                        let response = common::to_response(parts, bytes.into());
18344
18345                        if let common::Retry::After(d) =
18346                            dlg.http_failure(&response, error.as_ref().ok())
18347                        {
18348                            sleep(d).await;
18349                            continue;
18350                        }
18351
18352                        dlg.finished(false);
18353
18354                        return Err(match error {
18355                            Ok(value) => common::Error::BadRequest(value),
18356                            _ => common::Error::Failure(response),
18357                        });
18358                    }
18359                    let response = {
18360                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18361                        let encoded = common::to_string(&bytes);
18362                        match serde_json::from_str(&encoded) {
18363                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18364                            Err(error) => {
18365                                dlg.response_json_decode_error(&encoded, &error);
18366                                return Err(common::Error::JsonDecodeError(
18367                                    encoded.to_string(),
18368                                    error,
18369                                ));
18370                            }
18371                        }
18372                    };
18373
18374                    dlg.finished(true);
18375                    return Ok(response);
18376                }
18377            }
18378        }
18379    }
18380
18381    ///
18382    /// Sets the *request* property to the given value.
18383    ///
18384    /// Even though the property as already been set when instantiating this call,
18385    /// we provide this method for API completeness.
18386    pub fn request(mut self, new_value: InAppProduct) -> InappproductInsertCall<'a, C> {
18387        self._request = new_value;
18388        self
18389    }
18390    /// Unique identifier for the Android app; for example, "com.spiffygame".
18391    ///
18392    /// Sets the *package name* path property to the given value.
18393    ///
18394    /// Even though the property as already been set when instantiating this call,
18395    /// we provide this method for API completeness.
18396    pub fn package_name(mut self, new_value: &str) -> InappproductInsertCall<'a, C> {
18397        self._package_name = new_value.to_string();
18398        self
18399    }
18400    /// If true the prices for all regions targeted by the parent app that don't have a price specified for this in-app product will be auto converted to the target currency based on the default price. Defaults to false.
18401    ///
18402    /// Sets the *auto convert missing prices* query property to the given value.
18403    pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductInsertCall<'a, C> {
18404        self._auto_convert_missing_prices = Some(new_value);
18405        self
18406    }
18407    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18408    /// while executing the actual API request.
18409    ///
18410    /// ````text
18411    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18412    /// ````
18413    ///
18414    /// Sets the *delegate* property to the given value.
18415    pub fn delegate(
18416        mut self,
18417        new_value: &'a mut dyn common::Delegate,
18418    ) -> InappproductInsertCall<'a, C> {
18419        self._delegate = Some(new_value);
18420        self
18421    }
18422
18423    /// Set any additional parameter of the query string used in the request.
18424    /// It should be used to set parameters which are not yet available through their own
18425    /// setters.
18426    ///
18427    /// Please note that this method must not be used to set any of the known parameters
18428    /// which have their own setter method. If done anyway, the request will fail.
18429    ///
18430    /// # Additional Parameters
18431    ///
18432    /// * *alt* (query-string) - Data format for the response.
18433    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18434    /// * *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.
18435    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18436    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18437    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18438    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18439    pub fn param<T>(mut self, name: T, value: T) -> InappproductInsertCall<'a, C>
18440    where
18441        T: AsRef<str>,
18442    {
18443        self._additional_params
18444            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18445        self
18446    }
18447
18448    /// Identifies the authorization scope for the method you are building.
18449    ///
18450    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18451    /// [`Scope::Full`].
18452    ///
18453    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18454    /// tokens for more than one scope.
18455    ///
18456    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18457    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18458    /// sufficient, a read-write scope will do as well.
18459    pub fn add_scope<St>(mut self, scope: St) -> InappproductInsertCall<'a, C>
18460    where
18461        St: AsRef<str>,
18462    {
18463        self._scopes.insert(String::from(scope.as_ref()));
18464        self
18465    }
18466    /// Identifies the authorization scope(s) for the method you are building.
18467    ///
18468    /// See [`Self::add_scope()`] for details.
18469    pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductInsertCall<'a, C>
18470    where
18471        I: IntoIterator<Item = St>,
18472        St: AsRef<str>,
18473    {
18474        self._scopes
18475            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18476        self
18477    }
18478
18479    /// Removes all scopes, and no default scope will be used either.
18480    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18481    /// for details).
18482    pub fn clear_scopes(mut self) -> InappproductInsertCall<'a, C> {
18483        self._scopes.clear();
18484        self
18485    }
18486}
18487
18488/// List all the in-app products for an Android app, both subscriptions and managed in-app products..
18489///
18490/// A builder for the *list* method supported by a *inappproduct* resource.
18491/// It is not used directly, but through a [`InappproductMethods`] instance.
18492///
18493/// # Example
18494///
18495/// Instantiate a resource method builder
18496///
18497/// ```test_harness,no_run
18498/// # extern crate hyper;
18499/// # extern crate hyper_rustls;
18500/// # extern crate google_androidpublisher2 as androidpublisher2;
18501/// # async fn dox() {
18502/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18503///
18504/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18505/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18506/// #     .with_native_roots()
18507/// #     .unwrap()
18508/// #     .https_only()
18509/// #     .enable_http2()
18510/// #     .build();
18511///
18512/// # let executor = hyper_util::rt::TokioExecutor::new();
18513/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18514/// #     secret,
18515/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18516/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18517/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18518/// #     ),
18519/// # ).build().await.unwrap();
18520///
18521/// # let client = hyper_util::client::legacy::Client::builder(
18522/// #     hyper_util::rt::TokioExecutor::new()
18523/// # )
18524/// # .build(
18525/// #     hyper_rustls::HttpsConnectorBuilder::new()
18526/// #         .with_native_roots()
18527/// #         .unwrap()
18528/// #         .https_or_http()
18529/// #         .enable_http2()
18530/// #         .build()
18531/// # );
18532/// # let mut hub = AndroidPublisher::new(client, auth);
18533/// // You can configure optional parameters by calling the respective setters at will, and
18534/// // execute the final call using `doit()`.
18535/// // Values shown here are possibly random and not representative !
18536/// let result = hub.inappproducts().list("packageName")
18537///              .token("duo")
18538///              .start_index(59)
18539///              .max_results(44)
18540///              .doit().await;
18541/// # }
18542/// ```
18543pub struct InappproductListCall<'a, C>
18544where
18545    C: 'a,
18546{
18547    hub: &'a AndroidPublisher<C>,
18548    _package_name: String,
18549    _token: Option<String>,
18550    _start_index: Option<u32>,
18551    _max_results: Option<u32>,
18552    _delegate: Option<&'a mut dyn common::Delegate>,
18553    _additional_params: HashMap<String, String>,
18554    _scopes: BTreeSet<String>,
18555}
18556
18557impl<'a, C> common::CallBuilder for InappproductListCall<'a, C> {}
18558
18559impl<'a, C> InappproductListCall<'a, C>
18560where
18561    C: common::Connector,
18562{
18563    /// Perform the operation you have build so far.
18564    pub async fn doit(mut self) -> common::Result<(common::Response, InappproductsListResponse)> {
18565        use std::borrow::Cow;
18566        use std::io::{Read, Seek};
18567
18568        use common::{url::Params, ToParts};
18569        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18570
18571        let mut dd = common::DefaultDelegate;
18572        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18573        dlg.begin(common::MethodInfo {
18574            id: "androidpublisher.inappproducts.list",
18575            http_method: hyper::Method::GET,
18576        });
18577
18578        for &field in ["alt", "packageName", "token", "startIndex", "maxResults"].iter() {
18579            if self._additional_params.contains_key(field) {
18580                dlg.finished(false);
18581                return Err(common::Error::FieldClash(field));
18582            }
18583        }
18584
18585        let mut params = Params::with_capacity(6 + self._additional_params.len());
18586        params.push("packageName", self._package_name);
18587        if let Some(value) = self._token.as_ref() {
18588            params.push("token", value);
18589        }
18590        if let Some(value) = self._start_index.as_ref() {
18591            params.push("startIndex", value.to_string());
18592        }
18593        if let Some(value) = self._max_results.as_ref() {
18594            params.push("maxResults", value.to_string());
18595        }
18596
18597        params.extend(self._additional_params.iter());
18598
18599        params.push("alt", "json");
18600        let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts";
18601        if self._scopes.is_empty() {
18602            self._scopes.insert(Scope::Full.as_ref().to_string());
18603        }
18604
18605        #[allow(clippy::single_element_loop)]
18606        for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
18607            url = params.uri_replacement(url, param_name, find_this, false);
18608        }
18609        {
18610            let to_remove = ["packageName"];
18611            params.remove_params(&to_remove);
18612        }
18613
18614        let url = params.parse_with_url(&url);
18615
18616        loop {
18617            let token = match self
18618                .hub
18619                .auth
18620                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18621                .await
18622            {
18623                Ok(token) => token,
18624                Err(e) => match dlg.token(e) {
18625                    Ok(token) => token,
18626                    Err(e) => {
18627                        dlg.finished(false);
18628                        return Err(common::Error::MissingToken(e));
18629                    }
18630                },
18631            };
18632            let mut req_result = {
18633                let client = &self.hub.client;
18634                dlg.pre_request();
18635                let mut req_builder = hyper::Request::builder()
18636                    .method(hyper::Method::GET)
18637                    .uri(url.as_str())
18638                    .header(USER_AGENT, self.hub._user_agent.clone());
18639
18640                if let Some(token) = token.as_ref() {
18641                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18642                }
18643
18644                let request = req_builder
18645                    .header(CONTENT_LENGTH, 0_u64)
18646                    .body(common::to_body::<String>(None));
18647
18648                client.request(request.unwrap()).await
18649            };
18650
18651            match req_result {
18652                Err(err) => {
18653                    if let common::Retry::After(d) = dlg.http_error(&err) {
18654                        sleep(d).await;
18655                        continue;
18656                    }
18657                    dlg.finished(false);
18658                    return Err(common::Error::HttpError(err));
18659                }
18660                Ok(res) => {
18661                    let (mut parts, body) = res.into_parts();
18662                    let mut body = common::Body::new(body);
18663                    if !parts.status.is_success() {
18664                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18665                        let error = serde_json::from_str(&common::to_string(&bytes));
18666                        let response = common::to_response(parts, bytes.into());
18667
18668                        if let common::Retry::After(d) =
18669                            dlg.http_failure(&response, error.as_ref().ok())
18670                        {
18671                            sleep(d).await;
18672                            continue;
18673                        }
18674
18675                        dlg.finished(false);
18676
18677                        return Err(match error {
18678                            Ok(value) => common::Error::BadRequest(value),
18679                            _ => common::Error::Failure(response),
18680                        });
18681                    }
18682                    let response = {
18683                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18684                        let encoded = common::to_string(&bytes);
18685                        match serde_json::from_str(&encoded) {
18686                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18687                            Err(error) => {
18688                                dlg.response_json_decode_error(&encoded, &error);
18689                                return Err(common::Error::JsonDecodeError(
18690                                    encoded.to_string(),
18691                                    error,
18692                                ));
18693                            }
18694                        }
18695                    };
18696
18697                    dlg.finished(true);
18698                    return Ok(response);
18699                }
18700            }
18701        }
18702    }
18703
18704    /// Unique identifier for the Android app with in-app products; for example, "com.spiffygame".
18705    ///
18706    /// Sets the *package name* path property to the given value.
18707    ///
18708    /// Even though the property as already been set when instantiating this call,
18709    /// we provide this method for API completeness.
18710    pub fn package_name(mut self, new_value: &str) -> InappproductListCall<'a, C> {
18711        self._package_name = new_value.to_string();
18712        self
18713    }
18714    ///
18715    /// Sets the *token* query property to the given value.
18716    pub fn token(mut self, new_value: &str) -> InappproductListCall<'a, C> {
18717        self._token = Some(new_value.to_string());
18718        self
18719    }
18720    ///
18721    /// Sets the *start index* query property to the given value.
18722    pub fn start_index(mut self, new_value: u32) -> InappproductListCall<'a, C> {
18723        self._start_index = Some(new_value);
18724        self
18725    }
18726    ///
18727    /// Sets the *max results* query property to the given value.
18728    pub fn max_results(mut self, new_value: u32) -> InappproductListCall<'a, C> {
18729        self._max_results = Some(new_value);
18730        self
18731    }
18732    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18733    /// while executing the actual API request.
18734    ///
18735    /// ````text
18736    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18737    /// ````
18738    ///
18739    /// Sets the *delegate* property to the given value.
18740    pub fn delegate(
18741        mut self,
18742        new_value: &'a mut dyn common::Delegate,
18743    ) -> InappproductListCall<'a, C> {
18744        self._delegate = Some(new_value);
18745        self
18746    }
18747
18748    /// Set any additional parameter of the query string used in the request.
18749    /// It should be used to set parameters which are not yet available through their own
18750    /// setters.
18751    ///
18752    /// Please note that this method must not be used to set any of the known parameters
18753    /// which have their own setter method. If done anyway, the request will fail.
18754    ///
18755    /// # Additional Parameters
18756    ///
18757    /// * *alt* (query-string) - Data format for the response.
18758    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18759    /// * *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.
18760    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18761    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18762    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18763    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18764    pub fn param<T>(mut self, name: T, value: T) -> InappproductListCall<'a, C>
18765    where
18766        T: AsRef<str>,
18767    {
18768        self._additional_params
18769            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18770        self
18771    }
18772
18773    /// Identifies the authorization scope for the method you are building.
18774    ///
18775    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18776    /// [`Scope::Full`].
18777    ///
18778    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18779    /// tokens for more than one scope.
18780    ///
18781    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18782    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18783    /// sufficient, a read-write scope will do as well.
18784    pub fn add_scope<St>(mut self, scope: St) -> InappproductListCall<'a, C>
18785    where
18786        St: AsRef<str>,
18787    {
18788        self._scopes.insert(String::from(scope.as_ref()));
18789        self
18790    }
18791    /// Identifies the authorization scope(s) for the method you are building.
18792    ///
18793    /// See [`Self::add_scope()`] for details.
18794    pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductListCall<'a, C>
18795    where
18796        I: IntoIterator<Item = St>,
18797        St: AsRef<str>,
18798    {
18799        self._scopes
18800            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18801        self
18802    }
18803
18804    /// Removes all scopes, and no default scope will be used either.
18805    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18806    /// for details).
18807    pub fn clear_scopes(mut self) -> InappproductListCall<'a, C> {
18808        self._scopes.clear();
18809        self
18810    }
18811}
18812
18813/// Updates the details of an in-app product. This method supports patch semantics.
18814///
18815/// A builder for the *patch* method supported by a *inappproduct* resource.
18816/// It is not used directly, but through a [`InappproductMethods`] instance.
18817///
18818/// # Example
18819///
18820/// Instantiate a resource method builder
18821///
18822/// ```test_harness,no_run
18823/// # extern crate hyper;
18824/// # extern crate hyper_rustls;
18825/// # extern crate google_androidpublisher2 as androidpublisher2;
18826/// use androidpublisher2::api::InAppProduct;
18827/// # async fn dox() {
18828/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18829///
18830/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18831/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18832/// #     .with_native_roots()
18833/// #     .unwrap()
18834/// #     .https_only()
18835/// #     .enable_http2()
18836/// #     .build();
18837///
18838/// # let executor = hyper_util::rt::TokioExecutor::new();
18839/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18840/// #     secret,
18841/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18842/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18843/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18844/// #     ),
18845/// # ).build().await.unwrap();
18846///
18847/// # let client = hyper_util::client::legacy::Client::builder(
18848/// #     hyper_util::rt::TokioExecutor::new()
18849/// # )
18850/// # .build(
18851/// #     hyper_rustls::HttpsConnectorBuilder::new()
18852/// #         .with_native_roots()
18853/// #         .unwrap()
18854/// #         .https_or_http()
18855/// #         .enable_http2()
18856/// #         .build()
18857/// # );
18858/// # let mut hub = AndroidPublisher::new(client, auth);
18859/// // As the method needs a request, you would usually fill it with the desired information
18860/// // into the respective structure. Some of the parts shown here might not be applicable !
18861/// // Values shown here are possibly random and not representative !
18862/// let mut req = InAppProduct::default();
18863///
18864/// // You can configure optional parameters by calling the respective setters at will, and
18865/// // execute the final call using `doit()`.
18866/// // Values shown here are possibly random and not representative !
18867/// let result = hub.inappproducts().patch(req, "packageName", "sku")
18868///              .auto_convert_missing_prices(false)
18869///              .doit().await;
18870/// # }
18871/// ```
18872pub struct InappproductPatchCall<'a, C>
18873where
18874    C: 'a,
18875{
18876    hub: &'a AndroidPublisher<C>,
18877    _request: InAppProduct,
18878    _package_name: String,
18879    _sku: String,
18880    _auto_convert_missing_prices: Option<bool>,
18881    _delegate: Option<&'a mut dyn common::Delegate>,
18882    _additional_params: HashMap<String, String>,
18883    _scopes: BTreeSet<String>,
18884}
18885
18886impl<'a, C> common::CallBuilder for InappproductPatchCall<'a, C> {}
18887
18888impl<'a, C> InappproductPatchCall<'a, C>
18889where
18890    C: common::Connector,
18891{
18892    /// Perform the operation you have build so far.
18893    pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
18894        use std::borrow::Cow;
18895        use std::io::{Read, Seek};
18896
18897        use common::{url::Params, ToParts};
18898        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18899
18900        let mut dd = common::DefaultDelegate;
18901        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18902        dlg.begin(common::MethodInfo {
18903            id: "androidpublisher.inappproducts.patch",
18904            http_method: hyper::Method::PATCH,
18905        });
18906
18907        for &field in ["alt", "packageName", "sku", "autoConvertMissingPrices"].iter() {
18908            if self._additional_params.contains_key(field) {
18909                dlg.finished(false);
18910                return Err(common::Error::FieldClash(field));
18911            }
18912        }
18913
18914        let mut params = Params::with_capacity(6 + self._additional_params.len());
18915        params.push("packageName", self._package_name);
18916        params.push("sku", self._sku);
18917        if let Some(value) = self._auto_convert_missing_prices.as_ref() {
18918            params.push("autoConvertMissingPrices", value.to_string());
18919        }
18920
18921        params.extend(self._additional_params.iter());
18922
18923        params.push("alt", "json");
18924        let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}";
18925        if self._scopes.is_empty() {
18926            self._scopes.insert(Scope::Full.as_ref().to_string());
18927        }
18928
18929        #[allow(clippy::single_element_loop)]
18930        for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
18931        {
18932            url = params.uri_replacement(url, param_name, find_this, false);
18933        }
18934        {
18935            let to_remove = ["sku", "packageName"];
18936            params.remove_params(&to_remove);
18937        }
18938
18939        let url = params.parse_with_url(&url);
18940
18941        let mut json_mime_type = mime::APPLICATION_JSON;
18942        let mut request_value_reader = {
18943            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18944            common::remove_json_null_values(&mut value);
18945            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18946            serde_json::to_writer(&mut dst, &value).unwrap();
18947            dst
18948        };
18949        let request_size = request_value_reader
18950            .seek(std::io::SeekFrom::End(0))
18951            .unwrap();
18952        request_value_reader
18953            .seek(std::io::SeekFrom::Start(0))
18954            .unwrap();
18955
18956        loop {
18957            let token = match self
18958                .hub
18959                .auth
18960                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18961                .await
18962            {
18963                Ok(token) => token,
18964                Err(e) => match dlg.token(e) {
18965                    Ok(token) => token,
18966                    Err(e) => {
18967                        dlg.finished(false);
18968                        return Err(common::Error::MissingToken(e));
18969                    }
18970                },
18971            };
18972            request_value_reader
18973                .seek(std::io::SeekFrom::Start(0))
18974                .unwrap();
18975            let mut req_result = {
18976                let client = &self.hub.client;
18977                dlg.pre_request();
18978                let mut req_builder = hyper::Request::builder()
18979                    .method(hyper::Method::PATCH)
18980                    .uri(url.as_str())
18981                    .header(USER_AGENT, self.hub._user_agent.clone());
18982
18983                if let Some(token) = token.as_ref() {
18984                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18985                }
18986
18987                let request = req_builder
18988                    .header(CONTENT_TYPE, json_mime_type.to_string())
18989                    .header(CONTENT_LENGTH, request_size as u64)
18990                    .body(common::to_body(
18991                        request_value_reader.get_ref().clone().into(),
18992                    ));
18993
18994                client.request(request.unwrap()).await
18995            };
18996
18997            match req_result {
18998                Err(err) => {
18999                    if let common::Retry::After(d) = dlg.http_error(&err) {
19000                        sleep(d).await;
19001                        continue;
19002                    }
19003                    dlg.finished(false);
19004                    return Err(common::Error::HttpError(err));
19005                }
19006                Ok(res) => {
19007                    let (mut parts, body) = res.into_parts();
19008                    let mut body = common::Body::new(body);
19009                    if !parts.status.is_success() {
19010                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19011                        let error = serde_json::from_str(&common::to_string(&bytes));
19012                        let response = common::to_response(parts, bytes.into());
19013
19014                        if let common::Retry::After(d) =
19015                            dlg.http_failure(&response, error.as_ref().ok())
19016                        {
19017                            sleep(d).await;
19018                            continue;
19019                        }
19020
19021                        dlg.finished(false);
19022
19023                        return Err(match error {
19024                            Ok(value) => common::Error::BadRequest(value),
19025                            _ => common::Error::Failure(response),
19026                        });
19027                    }
19028                    let response = {
19029                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19030                        let encoded = common::to_string(&bytes);
19031                        match serde_json::from_str(&encoded) {
19032                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19033                            Err(error) => {
19034                                dlg.response_json_decode_error(&encoded, &error);
19035                                return Err(common::Error::JsonDecodeError(
19036                                    encoded.to_string(),
19037                                    error,
19038                                ));
19039                            }
19040                        }
19041                    };
19042
19043                    dlg.finished(true);
19044                    return Ok(response);
19045                }
19046            }
19047        }
19048    }
19049
19050    ///
19051    /// Sets the *request* property to the given value.
19052    ///
19053    /// Even though the property as already been set when instantiating this call,
19054    /// we provide this method for API completeness.
19055    pub fn request(mut self, new_value: InAppProduct) -> InappproductPatchCall<'a, C> {
19056        self._request = new_value;
19057        self
19058    }
19059    /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
19060    ///
19061    /// Sets the *package name* path property to the given value.
19062    ///
19063    /// Even though the property as already been set when instantiating this call,
19064    /// we provide this method for API completeness.
19065    pub fn package_name(mut self, new_value: &str) -> InappproductPatchCall<'a, C> {
19066        self._package_name = new_value.to_string();
19067        self
19068    }
19069    /// Unique identifier for the in-app product.
19070    ///
19071    /// Sets the *sku* path property to the given value.
19072    ///
19073    /// Even though the property as already been set when instantiating this call,
19074    /// we provide this method for API completeness.
19075    pub fn sku(mut self, new_value: &str) -> InappproductPatchCall<'a, C> {
19076        self._sku = new_value.to_string();
19077        self
19078    }
19079    /// If true the prices for all regions targeted by the parent app that don't have a price specified for this in-app product will be auto converted to the target currency based on the default price. Defaults to false.
19080    ///
19081    /// Sets the *auto convert missing prices* query property to the given value.
19082    pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductPatchCall<'a, C> {
19083        self._auto_convert_missing_prices = Some(new_value);
19084        self
19085    }
19086    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19087    /// while executing the actual API request.
19088    ///
19089    /// ````text
19090    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19091    /// ````
19092    ///
19093    /// Sets the *delegate* property to the given value.
19094    pub fn delegate(
19095        mut self,
19096        new_value: &'a mut dyn common::Delegate,
19097    ) -> InappproductPatchCall<'a, C> {
19098        self._delegate = Some(new_value);
19099        self
19100    }
19101
19102    /// Set any additional parameter of the query string used in the request.
19103    /// It should be used to set parameters which are not yet available through their own
19104    /// setters.
19105    ///
19106    /// Please note that this method must not be used to set any of the known parameters
19107    /// which have their own setter method. If done anyway, the request will fail.
19108    ///
19109    /// # Additional Parameters
19110    ///
19111    /// * *alt* (query-string) - Data format for the response.
19112    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19113    /// * *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.
19114    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19115    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19116    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19117    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19118    pub fn param<T>(mut self, name: T, value: T) -> InappproductPatchCall<'a, C>
19119    where
19120        T: AsRef<str>,
19121    {
19122        self._additional_params
19123            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19124        self
19125    }
19126
19127    /// Identifies the authorization scope for the method you are building.
19128    ///
19129    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19130    /// [`Scope::Full`].
19131    ///
19132    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19133    /// tokens for more than one scope.
19134    ///
19135    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19136    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19137    /// sufficient, a read-write scope will do as well.
19138    pub fn add_scope<St>(mut self, scope: St) -> InappproductPatchCall<'a, C>
19139    where
19140        St: AsRef<str>,
19141    {
19142        self._scopes.insert(String::from(scope.as_ref()));
19143        self
19144    }
19145    /// Identifies the authorization scope(s) for the method you are building.
19146    ///
19147    /// See [`Self::add_scope()`] for details.
19148    pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductPatchCall<'a, C>
19149    where
19150        I: IntoIterator<Item = St>,
19151        St: AsRef<str>,
19152    {
19153        self._scopes
19154            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19155        self
19156    }
19157
19158    /// Removes all scopes, and no default scope will be used either.
19159    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19160    /// for details).
19161    pub fn clear_scopes(mut self) -> InappproductPatchCall<'a, C> {
19162        self._scopes.clear();
19163        self
19164    }
19165}
19166
19167/// Updates the details of an in-app product.
19168///
19169/// A builder for the *update* method supported by a *inappproduct* resource.
19170/// It is not used directly, but through a [`InappproductMethods`] instance.
19171///
19172/// # Example
19173///
19174/// Instantiate a resource method builder
19175///
19176/// ```test_harness,no_run
19177/// # extern crate hyper;
19178/// # extern crate hyper_rustls;
19179/// # extern crate google_androidpublisher2 as androidpublisher2;
19180/// use androidpublisher2::api::InAppProduct;
19181/// # async fn dox() {
19182/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19183///
19184/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19185/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19186/// #     .with_native_roots()
19187/// #     .unwrap()
19188/// #     .https_only()
19189/// #     .enable_http2()
19190/// #     .build();
19191///
19192/// # let executor = hyper_util::rt::TokioExecutor::new();
19193/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19194/// #     secret,
19195/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19196/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19197/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19198/// #     ),
19199/// # ).build().await.unwrap();
19200///
19201/// # let client = hyper_util::client::legacy::Client::builder(
19202/// #     hyper_util::rt::TokioExecutor::new()
19203/// # )
19204/// # .build(
19205/// #     hyper_rustls::HttpsConnectorBuilder::new()
19206/// #         .with_native_roots()
19207/// #         .unwrap()
19208/// #         .https_or_http()
19209/// #         .enable_http2()
19210/// #         .build()
19211/// # );
19212/// # let mut hub = AndroidPublisher::new(client, auth);
19213/// // As the method needs a request, you would usually fill it with the desired information
19214/// // into the respective structure. Some of the parts shown here might not be applicable !
19215/// // Values shown here are possibly random and not representative !
19216/// let mut req = InAppProduct::default();
19217///
19218/// // You can configure optional parameters by calling the respective setters at will, and
19219/// // execute the final call using `doit()`.
19220/// // Values shown here are possibly random and not representative !
19221/// let result = hub.inappproducts().update(req, "packageName", "sku")
19222///              .auto_convert_missing_prices(true)
19223///              .doit().await;
19224/// # }
19225/// ```
19226pub struct InappproductUpdateCall<'a, C>
19227where
19228    C: 'a,
19229{
19230    hub: &'a AndroidPublisher<C>,
19231    _request: InAppProduct,
19232    _package_name: String,
19233    _sku: String,
19234    _auto_convert_missing_prices: Option<bool>,
19235    _delegate: Option<&'a mut dyn common::Delegate>,
19236    _additional_params: HashMap<String, String>,
19237    _scopes: BTreeSet<String>,
19238}
19239
19240impl<'a, C> common::CallBuilder for InappproductUpdateCall<'a, C> {}
19241
19242impl<'a, C> InappproductUpdateCall<'a, C>
19243where
19244    C: common::Connector,
19245{
19246    /// Perform the operation you have build so far.
19247    pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
19248        use std::borrow::Cow;
19249        use std::io::{Read, Seek};
19250
19251        use common::{url::Params, ToParts};
19252        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19253
19254        let mut dd = common::DefaultDelegate;
19255        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19256        dlg.begin(common::MethodInfo {
19257            id: "androidpublisher.inappproducts.update",
19258            http_method: hyper::Method::PUT,
19259        });
19260
19261        for &field in ["alt", "packageName", "sku", "autoConvertMissingPrices"].iter() {
19262            if self._additional_params.contains_key(field) {
19263                dlg.finished(false);
19264                return Err(common::Error::FieldClash(field));
19265            }
19266        }
19267
19268        let mut params = Params::with_capacity(6 + self._additional_params.len());
19269        params.push("packageName", self._package_name);
19270        params.push("sku", self._sku);
19271        if let Some(value) = self._auto_convert_missing_prices.as_ref() {
19272            params.push("autoConvertMissingPrices", value.to_string());
19273        }
19274
19275        params.extend(self._additional_params.iter());
19276
19277        params.push("alt", "json");
19278        let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}";
19279        if self._scopes.is_empty() {
19280            self._scopes.insert(Scope::Full.as_ref().to_string());
19281        }
19282
19283        #[allow(clippy::single_element_loop)]
19284        for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
19285        {
19286            url = params.uri_replacement(url, param_name, find_this, false);
19287        }
19288        {
19289            let to_remove = ["sku", "packageName"];
19290            params.remove_params(&to_remove);
19291        }
19292
19293        let url = params.parse_with_url(&url);
19294
19295        let mut json_mime_type = mime::APPLICATION_JSON;
19296        let mut request_value_reader = {
19297            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19298            common::remove_json_null_values(&mut value);
19299            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19300            serde_json::to_writer(&mut dst, &value).unwrap();
19301            dst
19302        };
19303        let request_size = request_value_reader
19304            .seek(std::io::SeekFrom::End(0))
19305            .unwrap();
19306        request_value_reader
19307            .seek(std::io::SeekFrom::Start(0))
19308            .unwrap();
19309
19310        loop {
19311            let token = match self
19312                .hub
19313                .auth
19314                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19315                .await
19316            {
19317                Ok(token) => token,
19318                Err(e) => match dlg.token(e) {
19319                    Ok(token) => token,
19320                    Err(e) => {
19321                        dlg.finished(false);
19322                        return Err(common::Error::MissingToken(e));
19323                    }
19324                },
19325            };
19326            request_value_reader
19327                .seek(std::io::SeekFrom::Start(0))
19328                .unwrap();
19329            let mut req_result = {
19330                let client = &self.hub.client;
19331                dlg.pre_request();
19332                let mut req_builder = hyper::Request::builder()
19333                    .method(hyper::Method::PUT)
19334                    .uri(url.as_str())
19335                    .header(USER_AGENT, self.hub._user_agent.clone());
19336
19337                if let Some(token) = token.as_ref() {
19338                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19339                }
19340
19341                let request = req_builder
19342                    .header(CONTENT_TYPE, json_mime_type.to_string())
19343                    .header(CONTENT_LENGTH, request_size as u64)
19344                    .body(common::to_body(
19345                        request_value_reader.get_ref().clone().into(),
19346                    ));
19347
19348                client.request(request.unwrap()).await
19349            };
19350
19351            match req_result {
19352                Err(err) => {
19353                    if let common::Retry::After(d) = dlg.http_error(&err) {
19354                        sleep(d).await;
19355                        continue;
19356                    }
19357                    dlg.finished(false);
19358                    return Err(common::Error::HttpError(err));
19359                }
19360                Ok(res) => {
19361                    let (mut parts, body) = res.into_parts();
19362                    let mut body = common::Body::new(body);
19363                    if !parts.status.is_success() {
19364                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19365                        let error = serde_json::from_str(&common::to_string(&bytes));
19366                        let response = common::to_response(parts, bytes.into());
19367
19368                        if let common::Retry::After(d) =
19369                            dlg.http_failure(&response, error.as_ref().ok())
19370                        {
19371                            sleep(d).await;
19372                            continue;
19373                        }
19374
19375                        dlg.finished(false);
19376
19377                        return Err(match error {
19378                            Ok(value) => common::Error::BadRequest(value),
19379                            _ => common::Error::Failure(response),
19380                        });
19381                    }
19382                    let response = {
19383                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19384                        let encoded = common::to_string(&bytes);
19385                        match serde_json::from_str(&encoded) {
19386                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19387                            Err(error) => {
19388                                dlg.response_json_decode_error(&encoded, &error);
19389                                return Err(common::Error::JsonDecodeError(
19390                                    encoded.to_string(),
19391                                    error,
19392                                ));
19393                            }
19394                        }
19395                    };
19396
19397                    dlg.finished(true);
19398                    return Ok(response);
19399                }
19400            }
19401        }
19402    }
19403
19404    ///
19405    /// Sets the *request* property to the given value.
19406    ///
19407    /// Even though the property as already been set when instantiating this call,
19408    /// we provide this method for API completeness.
19409    pub fn request(mut self, new_value: InAppProduct) -> InappproductUpdateCall<'a, C> {
19410        self._request = new_value;
19411        self
19412    }
19413    /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
19414    ///
19415    /// Sets the *package name* path property to the given value.
19416    ///
19417    /// Even though the property as already been set when instantiating this call,
19418    /// we provide this method for API completeness.
19419    pub fn package_name(mut self, new_value: &str) -> InappproductUpdateCall<'a, C> {
19420        self._package_name = new_value.to_string();
19421        self
19422    }
19423    /// Unique identifier for the in-app product.
19424    ///
19425    /// Sets the *sku* path property to the given value.
19426    ///
19427    /// Even though the property as already been set when instantiating this call,
19428    /// we provide this method for API completeness.
19429    pub fn sku(mut self, new_value: &str) -> InappproductUpdateCall<'a, C> {
19430        self._sku = new_value.to_string();
19431        self
19432    }
19433    /// If true the prices for all regions targeted by the parent app that don't have a price specified for this in-app product will be auto converted to the target currency based on the default price. Defaults to false.
19434    ///
19435    /// Sets the *auto convert missing prices* query property to the given value.
19436    pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductUpdateCall<'a, C> {
19437        self._auto_convert_missing_prices = Some(new_value);
19438        self
19439    }
19440    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19441    /// while executing the actual API request.
19442    ///
19443    /// ````text
19444    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19445    /// ````
19446    ///
19447    /// Sets the *delegate* property to the given value.
19448    pub fn delegate(
19449        mut self,
19450        new_value: &'a mut dyn common::Delegate,
19451    ) -> InappproductUpdateCall<'a, C> {
19452        self._delegate = Some(new_value);
19453        self
19454    }
19455
19456    /// Set any additional parameter of the query string used in the request.
19457    /// It should be used to set parameters which are not yet available through their own
19458    /// setters.
19459    ///
19460    /// Please note that this method must not be used to set any of the known parameters
19461    /// which have their own setter method. If done anyway, the request will fail.
19462    ///
19463    /// # Additional Parameters
19464    ///
19465    /// * *alt* (query-string) - Data format for the response.
19466    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19467    /// * *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.
19468    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19469    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19470    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19471    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19472    pub fn param<T>(mut self, name: T, value: T) -> InappproductUpdateCall<'a, C>
19473    where
19474        T: AsRef<str>,
19475    {
19476        self._additional_params
19477            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19478        self
19479    }
19480
19481    /// Identifies the authorization scope for the method you are building.
19482    ///
19483    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19484    /// [`Scope::Full`].
19485    ///
19486    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19487    /// tokens for more than one scope.
19488    ///
19489    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19490    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19491    /// sufficient, a read-write scope will do as well.
19492    pub fn add_scope<St>(mut self, scope: St) -> InappproductUpdateCall<'a, C>
19493    where
19494        St: AsRef<str>,
19495    {
19496        self._scopes.insert(String::from(scope.as_ref()));
19497        self
19498    }
19499    /// Identifies the authorization scope(s) for the method you are building.
19500    ///
19501    /// See [`Self::add_scope()`] for details.
19502    pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductUpdateCall<'a, C>
19503    where
19504        I: IntoIterator<Item = St>,
19505        St: AsRef<str>,
19506    {
19507        self._scopes
19508            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19509        self
19510    }
19511
19512    /// Removes all scopes, and no default scope will be used either.
19513    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19514    /// for details).
19515    pub fn clear_scopes(mut self) -> InappproductUpdateCall<'a, C> {
19516        self._scopes.clear();
19517        self
19518    }
19519}
19520
19521/// Refund a user's subscription or in-app purchase order.
19522///
19523/// A builder for the *refund* method supported by a *order* resource.
19524/// It is not used directly, but through a [`OrderMethods`] instance.
19525///
19526/// # Example
19527///
19528/// Instantiate a resource method builder
19529///
19530/// ```test_harness,no_run
19531/// # extern crate hyper;
19532/// # extern crate hyper_rustls;
19533/// # extern crate google_androidpublisher2 as androidpublisher2;
19534/// # async fn dox() {
19535/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19536///
19537/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19538/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19539/// #     .with_native_roots()
19540/// #     .unwrap()
19541/// #     .https_only()
19542/// #     .enable_http2()
19543/// #     .build();
19544///
19545/// # let executor = hyper_util::rt::TokioExecutor::new();
19546/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19547/// #     secret,
19548/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19549/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19550/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19551/// #     ),
19552/// # ).build().await.unwrap();
19553///
19554/// # let client = hyper_util::client::legacy::Client::builder(
19555/// #     hyper_util::rt::TokioExecutor::new()
19556/// # )
19557/// # .build(
19558/// #     hyper_rustls::HttpsConnectorBuilder::new()
19559/// #         .with_native_roots()
19560/// #         .unwrap()
19561/// #         .https_or_http()
19562/// #         .enable_http2()
19563/// #         .build()
19564/// # );
19565/// # let mut hub = AndroidPublisher::new(client, auth);
19566/// // You can configure optional parameters by calling the respective setters at will, and
19567/// // execute the final call using `doit()`.
19568/// // Values shown here are possibly random and not representative !
19569/// let result = hub.orders().refund("packageName", "orderId")
19570///              .revoke(false)
19571///              .doit().await;
19572/// # }
19573/// ```
19574pub struct OrderRefundCall<'a, C>
19575where
19576    C: 'a,
19577{
19578    hub: &'a AndroidPublisher<C>,
19579    _package_name: String,
19580    _order_id: String,
19581    _revoke: Option<bool>,
19582    _delegate: Option<&'a mut dyn common::Delegate>,
19583    _additional_params: HashMap<String, String>,
19584    _scopes: BTreeSet<String>,
19585}
19586
19587impl<'a, C> common::CallBuilder for OrderRefundCall<'a, C> {}
19588
19589impl<'a, C> OrderRefundCall<'a, C>
19590where
19591    C: common::Connector,
19592{
19593    /// Perform the operation you have build so far.
19594    pub async fn doit(mut self) -> common::Result<common::Response> {
19595        use std::borrow::Cow;
19596        use std::io::{Read, Seek};
19597
19598        use common::{url::Params, ToParts};
19599        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19600
19601        let mut dd = common::DefaultDelegate;
19602        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19603        dlg.begin(common::MethodInfo {
19604            id: "androidpublisher.orders.refund",
19605            http_method: hyper::Method::POST,
19606        });
19607
19608        for &field in ["packageName", "orderId", "revoke"].iter() {
19609            if self._additional_params.contains_key(field) {
19610                dlg.finished(false);
19611                return Err(common::Error::FieldClash(field));
19612            }
19613        }
19614
19615        let mut params = Params::with_capacity(4 + self._additional_params.len());
19616        params.push("packageName", self._package_name);
19617        params.push("orderId", self._order_id);
19618        if let Some(value) = self._revoke.as_ref() {
19619            params.push("revoke", value.to_string());
19620        }
19621
19622        params.extend(self._additional_params.iter());
19623
19624        let mut url = self.hub._base_url.clone() + "{packageName}/orders/{orderId}:refund";
19625        if self._scopes.is_empty() {
19626            self._scopes.insert(Scope::Full.as_ref().to_string());
19627        }
19628
19629        #[allow(clippy::single_element_loop)]
19630        for &(find_this, param_name) in
19631            [("{packageName}", "packageName"), ("{orderId}", "orderId")].iter()
19632        {
19633            url = params.uri_replacement(url, param_name, find_this, false);
19634        }
19635        {
19636            let to_remove = ["orderId", "packageName"];
19637            params.remove_params(&to_remove);
19638        }
19639
19640        let url = params.parse_with_url(&url);
19641
19642        loop {
19643            let token = match self
19644                .hub
19645                .auth
19646                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19647                .await
19648            {
19649                Ok(token) => token,
19650                Err(e) => match dlg.token(e) {
19651                    Ok(token) => token,
19652                    Err(e) => {
19653                        dlg.finished(false);
19654                        return Err(common::Error::MissingToken(e));
19655                    }
19656                },
19657            };
19658            let mut req_result = {
19659                let client = &self.hub.client;
19660                dlg.pre_request();
19661                let mut req_builder = hyper::Request::builder()
19662                    .method(hyper::Method::POST)
19663                    .uri(url.as_str())
19664                    .header(USER_AGENT, self.hub._user_agent.clone());
19665
19666                if let Some(token) = token.as_ref() {
19667                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19668                }
19669
19670                let request = req_builder
19671                    .header(CONTENT_LENGTH, 0_u64)
19672                    .body(common::to_body::<String>(None));
19673
19674                client.request(request.unwrap()).await
19675            };
19676
19677            match req_result {
19678                Err(err) => {
19679                    if let common::Retry::After(d) = dlg.http_error(&err) {
19680                        sleep(d).await;
19681                        continue;
19682                    }
19683                    dlg.finished(false);
19684                    return Err(common::Error::HttpError(err));
19685                }
19686                Ok(res) => {
19687                    let (mut parts, body) = res.into_parts();
19688                    let mut body = common::Body::new(body);
19689                    if !parts.status.is_success() {
19690                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19691                        let error = serde_json::from_str(&common::to_string(&bytes));
19692                        let response = common::to_response(parts, bytes.into());
19693
19694                        if let common::Retry::After(d) =
19695                            dlg.http_failure(&response, error.as_ref().ok())
19696                        {
19697                            sleep(d).await;
19698                            continue;
19699                        }
19700
19701                        dlg.finished(false);
19702
19703                        return Err(match error {
19704                            Ok(value) => common::Error::BadRequest(value),
19705                            _ => common::Error::Failure(response),
19706                        });
19707                    }
19708                    let response = common::Response::from_parts(parts, body);
19709
19710                    dlg.finished(true);
19711                    return Ok(response);
19712                }
19713            }
19714        }
19715    }
19716
19717    /// The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
19718    ///
19719    /// Sets the *package name* path property to the given value.
19720    ///
19721    /// Even though the property as already been set when instantiating this call,
19722    /// we provide this method for API completeness.
19723    pub fn package_name(mut self, new_value: &str) -> OrderRefundCall<'a, C> {
19724        self._package_name = new_value.to_string();
19725        self
19726    }
19727    /// The order ID provided to the user when the subscription or in-app order was purchased.
19728    ///
19729    /// Sets the *order id* path property to the given value.
19730    ///
19731    /// Even though the property as already been set when instantiating this call,
19732    /// we provide this method for API completeness.
19733    pub fn order_id(mut self, new_value: &str) -> OrderRefundCall<'a, C> {
19734        self._order_id = new_value.to_string();
19735        self
19736    }
19737    /// Whether to revoke the purchased item. If set to true, access to the subscription or in-app item will be terminated immediately. If the item is a recurring subscription, all future payments will also be terminated. Consumed in-app items need to be handled by developer's app. (optional)
19738    ///
19739    /// Sets the *revoke* query property to the given value.
19740    pub fn revoke(mut self, new_value: bool) -> OrderRefundCall<'a, C> {
19741        self._revoke = Some(new_value);
19742        self
19743    }
19744    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19745    /// while executing the actual API request.
19746    ///
19747    /// ````text
19748    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19749    /// ````
19750    ///
19751    /// Sets the *delegate* property to the given value.
19752    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderRefundCall<'a, C> {
19753        self._delegate = Some(new_value);
19754        self
19755    }
19756
19757    /// Set any additional parameter of the query string used in the request.
19758    /// It should be used to set parameters which are not yet available through their own
19759    /// setters.
19760    ///
19761    /// Please note that this method must not be used to set any of the known parameters
19762    /// which have their own setter method. If done anyway, the request will fail.
19763    ///
19764    /// # Additional Parameters
19765    ///
19766    /// * *alt* (query-string) - Data format for the response.
19767    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19768    /// * *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.
19769    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19770    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19771    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19772    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19773    pub fn param<T>(mut self, name: T, value: T) -> OrderRefundCall<'a, C>
19774    where
19775        T: AsRef<str>,
19776    {
19777        self._additional_params
19778            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19779        self
19780    }
19781
19782    /// Identifies the authorization scope for the method you are building.
19783    ///
19784    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19785    /// [`Scope::Full`].
19786    ///
19787    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19788    /// tokens for more than one scope.
19789    ///
19790    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19791    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19792    /// sufficient, a read-write scope will do as well.
19793    pub fn add_scope<St>(mut self, scope: St) -> OrderRefundCall<'a, C>
19794    where
19795        St: AsRef<str>,
19796    {
19797        self._scopes.insert(String::from(scope.as_ref()));
19798        self
19799    }
19800    /// Identifies the authorization scope(s) for the method you are building.
19801    ///
19802    /// See [`Self::add_scope()`] for details.
19803    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderRefundCall<'a, C>
19804    where
19805        I: IntoIterator<Item = St>,
19806        St: AsRef<str>,
19807    {
19808        self._scopes
19809            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19810        self
19811    }
19812
19813    /// Removes all scopes, and no default scope will be used either.
19814    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19815    /// for details).
19816    pub fn clear_scopes(mut self) -> OrderRefundCall<'a, C> {
19817        self._scopes.clear();
19818        self
19819    }
19820}
19821
19822/// Checks the purchase and consumption status of an inapp item.
19823///
19824/// A builder for the *products.get* method supported by a *purchase* resource.
19825/// It is not used directly, but through a [`PurchaseMethods`] instance.
19826///
19827/// # Example
19828///
19829/// Instantiate a resource method builder
19830///
19831/// ```test_harness,no_run
19832/// # extern crate hyper;
19833/// # extern crate hyper_rustls;
19834/// # extern crate google_androidpublisher2 as androidpublisher2;
19835/// # async fn dox() {
19836/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19837///
19838/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19839/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19840/// #     .with_native_roots()
19841/// #     .unwrap()
19842/// #     .https_only()
19843/// #     .enable_http2()
19844/// #     .build();
19845///
19846/// # let executor = hyper_util::rt::TokioExecutor::new();
19847/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19848/// #     secret,
19849/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19850/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19851/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19852/// #     ),
19853/// # ).build().await.unwrap();
19854///
19855/// # let client = hyper_util::client::legacy::Client::builder(
19856/// #     hyper_util::rt::TokioExecutor::new()
19857/// # )
19858/// # .build(
19859/// #     hyper_rustls::HttpsConnectorBuilder::new()
19860/// #         .with_native_roots()
19861/// #         .unwrap()
19862/// #         .https_or_http()
19863/// #         .enable_http2()
19864/// #         .build()
19865/// # );
19866/// # let mut hub = AndroidPublisher::new(client, auth);
19867/// // You can configure optional parameters by calling the respective setters at will, and
19868/// // execute the final call using `doit()`.
19869/// // Values shown here are possibly random and not representative !
19870/// let result = hub.purchases().products_get("packageName", "productId", "token")
19871///              .doit().await;
19872/// # }
19873/// ```
19874pub struct PurchaseProductGetCall<'a, C>
19875where
19876    C: 'a,
19877{
19878    hub: &'a AndroidPublisher<C>,
19879    _package_name: String,
19880    _product_id: String,
19881    _token: String,
19882    _delegate: Option<&'a mut dyn common::Delegate>,
19883    _additional_params: HashMap<String, String>,
19884    _scopes: BTreeSet<String>,
19885}
19886
19887impl<'a, C> common::CallBuilder for PurchaseProductGetCall<'a, C> {}
19888
19889impl<'a, C> PurchaseProductGetCall<'a, C>
19890where
19891    C: common::Connector,
19892{
19893    /// Perform the operation you have build so far.
19894    pub async fn doit(mut self) -> common::Result<(common::Response, ProductPurchase)> {
19895        use std::borrow::Cow;
19896        use std::io::{Read, Seek};
19897
19898        use common::{url::Params, ToParts};
19899        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19900
19901        let mut dd = common::DefaultDelegate;
19902        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19903        dlg.begin(common::MethodInfo {
19904            id: "androidpublisher.purchases.products.get",
19905            http_method: hyper::Method::GET,
19906        });
19907
19908        for &field in ["alt", "packageName", "productId", "token"].iter() {
19909            if self._additional_params.contains_key(field) {
19910                dlg.finished(false);
19911                return Err(common::Error::FieldClash(field));
19912            }
19913        }
19914
19915        let mut params = Params::with_capacity(5 + self._additional_params.len());
19916        params.push("packageName", self._package_name);
19917        params.push("productId", self._product_id);
19918        params.push("token", self._token);
19919
19920        params.extend(self._additional_params.iter());
19921
19922        params.push("alt", "json");
19923        let mut url = self.hub._base_url.clone()
19924            + "{packageName}/purchases/products/{productId}/tokens/{token}";
19925        if self._scopes.is_empty() {
19926            self._scopes.insert(Scope::Full.as_ref().to_string());
19927        }
19928
19929        #[allow(clippy::single_element_loop)]
19930        for &(find_this, param_name) in [
19931            ("{packageName}", "packageName"),
19932            ("{productId}", "productId"),
19933            ("{token}", "token"),
19934        ]
19935        .iter()
19936        {
19937            url = params.uri_replacement(url, param_name, find_this, false);
19938        }
19939        {
19940            let to_remove = ["token", "productId", "packageName"];
19941            params.remove_params(&to_remove);
19942        }
19943
19944        let url = params.parse_with_url(&url);
19945
19946        loop {
19947            let token = match self
19948                .hub
19949                .auth
19950                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19951                .await
19952            {
19953                Ok(token) => token,
19954                Err(e) => match dlg.token(e) {
19955                    Ok(token) => token,
19956                    Err(e) => {
19957                        dlg.finished(false);
19958                        return Err(common::Error::MissingToken(e));
19959                    }
19960                },
19961            };
19962            let mut req_result = {
19963                let client = &self.hub.client;
19964                dlg.pre_request();
19965                let mut req_builder = hyper::Request::builder()
19966                    .method(hyper::Method::GET)
19967                    .uri(url.as_str())
19968                    .header(USER_AGENT, self.hub._user_agent.clone());
19969
19970                if let Some(token) = token.as_ref() {
19971                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19972                }
19973
19974                let request = req_builder
19975                    .header(CONTENT_LENGTH, 0_u64)
19976                    .body(common::to_body::<String>(None));
19977
19978                client.request(request.unwrap()).await
19979            };
19980
19981            match req_result {
19982                Err(err) => {
19983                    if let common::Retry::After(d) = dlg.http_error(&err) {
19984                        sleep(d).await;
19985                        continue;
19986                    }
19987                    dlg.finished(false);
19988                    return Err(common::Error::HttpError(err));
19989                }
19990                Ok(res) => {
19991                    let (mut parts, body) = res.into_parts();
19992                    let mut body = common::Body::new(body);
19993                    if !parts.status.is_success() {
19994                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19995                        let error = serde_json::from_str(&common::to_string(&bytes));
19996                        let response = common::to_response(parts, bytes.into());
19997
19998                        if let common::Retry::After(d) =
19999                            dlg.http_failure(&response, error.as_ref().ok())
20000                        {
20001                            sleep(d).await;
20002                            continue;
20003                        }
20004
20005                        dlg.finished(false);
20006
20007                        return Err(match error {
20008                            Ok(value) => common::Error::BadRequest(value),
20009                            _ => common::Error::Failure(response),
20010                        });
20011                    }
20012                    let response = {
20013                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20014                        let encoded = common::to_string(&bytes);
20015                        match serde_json::from_str(&encoded) {
20016                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20017                            Err(error) => {
20018                                dlg.response_json_decode_error(&encoded, &error);
20019                                return Err(common::Error::JsonDecodeError(
20020                                    encoded.to_string(),
20021                                    error,
20022                                ));
20023                            }
20024                        }
20025                    };
20026
20027                    dlg.finished(true);
20028                    return Ok(response);
20029                }
20030            }
20031        }
20032    }
20033
20034    /// The package name of the application the inapp product was sold in (for example, 'com.some.thing').
20035    ///
20036    /// Sets the *package name* path property to the given value.
20037    ///
20038    /// Even though the property as already been set when instantiating this call,
20039    /// we provide this method for API completeness.
20040    pub fn package_name(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C> {
20041        self._package_name = new_value.to_string();
20042        self
20043    }
20044    /// The inapp product SKU (for example, 'com.some.thing.inapp1').
20045    ///
20046    /// Sets the *product id* path property to the given value.
20047    ///
20048    /// Even though the property as already been set when instantiating this call,
20049    /// we provide this method for API completeness.
20050    pub fn product_id(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C> {
20051        self._product_id = new_value.to_string();
20052        self
20053    }
20054    /// The token provided to the user's device when the inapp product was purchased.
20055    ///
20056    /// Sets the *token* path property to the given value.
20057    ///
20058    /// Even though the property as already been set when instantiating this call,
20059    /// we provide this method for API completeness.
20060    pub fn token(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C> {
20061        self._token = new_value.to_string();
20062        self
20063    }
20064    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20065    /// while executing the actual API request.
20066    ///
20067    /// ````text
20068    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20069    /// ````
20070    ///
20071    /// Sets the *delegate* property to the given value.
20072    pub fn delegate(
20073        mut self,
20074        new_value: &'a mut dyn common::Delegate,
20075    ) -> PurchaseProductGetCall<'a, C> {
20076        self._delegate = Some(new_value);
20077        self
20078    }
20079
20080    /// Set any additional parameter of the query string used in the request.
20081    /// It should be used to set parameters which are not yet available through their own
20082    /// setters.
20083    ///
20084    /// Please note that this method must not be used to set any of the known parameters
20085    /// which have their own setter method. If done anyway, the request will fail.
20086    ///
20087    /// # Additional Parameters
20088    ///
20089    /// * *alt* (query-string) - Data format for the response.
20090    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20091    /// * *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.
20092    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20093    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20094    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20095    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20096    pub fn param<T>(mut self, name: T, value: T) -> PurchaseProductGetCall<'a, C>
20097    where
20098        T: AsRef<str>,
20099    {
20100        self._additional_params
20101            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20102        self
20103    }
20104
20105    /// Identifies the authorization scope for the method you are building.
20106    ///
20107    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20108    /// [`Scope::Full`].
20109    ///
20110    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20111    /// tokens for more than one scope.
20112    ///
20113    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20114    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20115    /// sufficient, a read-write scope will do as well.
20116    pub fn add_scope<St>(mut self, scope: St) -> PurchaseProductGetCall<'a, C>
20117    where
20118        St: AsRef<str>,
20119    {
20120        self._scopes.insert(String::from(scope.as_ref()));
20121        self
20122    }
20123    /// Identifies the authorization scope(s) for the method you are building.
20124    ///
20125    /// See [`Self::add_scope()`] for details.
20126    pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseProductGetCall<'a, C>
20127    where
20128        I: IntoIterator<Item = St>,
20129        St: AsRef<str>,
20130    {
20131        self._scopes
20132            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20133        self
20134    }
20135
20136    /// Removes all scopes, and no default scope will be used either.
20137    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20138    /// for details).
20139    pub fn clear_scopes(mut self) -> PurchaseProductGetCall<'a, C> {
20140        self._scopes.clear();
20141        self
20142    }
20143}
20144
20145/// Cancels a user's subscription purchase. The subscription remains valid until its expiration time.
20146///
20147/// A builder for the *subscriptions.cancel* method supported by a *purchase* resource.
20148/// It is not used directly, but through a [`PurchaseMethods`] instance.
20149///
20150/// # Example
20151///
20152/// Instantiate a resource method builder
20153///
20154/// ```test_harness,no_run
20155/// # extern crate hyper;
20156/// # extern crate hyper_rustls;
20157/// # extern crate google_androidpublisher2 as androidpublisher2;
20158/// # async fn dox() {
20159/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20160///
20161/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20162/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20163/// #     .with_native_roots()
20164/// #     .unwrap()
20165/// #     .https_only()
20166/// #     .enable_http2()
20167/// #     .build();
20168///
20169/// # let executor = hyper_util::rt::TokioExecutor::new();
20170/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20171/// #     secret,
20172/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20173/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20174/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20175/// #     ),
20176/// # ).build().await.unwrap();
20177///
20178/// # let client = hyper_util::client::legacy::Client::builder(
20179/// #     hyper_util::rt::TokioExecutor::new()
20180/// # )
20181/// # .build(
20182/// #     hyper_rustls::HttpsConnectorBuilder::new()
20183/// #         .with_native_roots()
20184/// #         .unwrap()
20185/// #         .https_or_http()
20186/// #         .enable_http2()
20187/// #         .build()
20188/// # );
20189/// # let mut hub = AndroidPublisher::new(client, auth);
20190/// // You can configure optional parameters by calling the respective setters at will, and
20191/// // execute the final call using `doit()`.
20192/// // Values shown here are possibly random and not representative !
20193/// let result = hub.purchases().subscriptions_cancel("packageName", "subscriptionId", "token")
20194///              .doit().await;
20195/// # }
20196/// ```
20197pub struct PurchaseSubscriptionCancelCall<'a, C>
20198where
20199    C: 'a,
20200{
20201    hub: &'a AndroidPublisher<C>,
20202    _package_name: String,
20203    _subscription_id: String,
20204    _token: String,
20205    _delegate: Option<&'a mut dyn common::Delegate>,
20206    _additional_params: HashMap<String, String>,
20207    _scopes: BTreeSet<String>,
20208}
20209
20210impl<'a, C> common::CallBuilder for PurchaseSubscriptionCancelCall<'a, C> {}
20211
20212impl<'a, C> PurchaseSubscriptionCancelCall<'a, C>
20213where
20214    C: common::Connector,
20215{
20216    /// Perform the operation you have build so far.
20217    pub async fn doit(mut self) -> common::Result<common::Response> {
20218        use std::borrow::Cow;
20219        use std::io::{Read, Seek};
20220
20221        use common::{url::Params, ToParts};
20222        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20223
20224        let mut dd = common::DefaultDelegate;
20225        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20226        dlg.begin(common::MethodInfo {
20227            id: "androidpublisher.purchases.subscriptions.cancel",
20228            http_method: hyper::Method::POST,
20229        });
20230
20231        for &field in ["packageName", "subscriptionId", "token"].iter() {
20232            if self._additional_params.contains_key(field) {
20233                dlg.finished(false);
20234                return Err(common::Error::FieldClash(field));
20235            }
20236        }
20237
20238        let mut params = Params::with_capacity(4 + self._additional_params.len());
20239        params.push("packageName", self._package_name);
20240        params.push("subscriptionId", self._subscription_id);
20241        params.push("token", self._token);
20242
20243        params.extend(self._additional_params.iter());
20244
20245        let mut url = self.hub._base_url.clone()
20246            + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:cancel";
20247        if self._scopes.is_empty() {
20248            self._scopes.insert(Scope::Full.as_ref().to_string());
20249        }
20250
20251        #[allow(clippy::single_element_loop)]
20252        for &(find_this, param_name) in [
20253            ("{packageName}", "packageName"),
20254            ("{subscriptionId}", "subscriptionId"),
20255            ("{token}", "token"),
20256        ]
20257        .iter()
20258        {
20259            url = params.uri_replacement(url, param_name, find_this, false);
20260        }
20261        {
20262            let to_remove = ["token", "subscriptionId", "packageName"];
20263            params.remove_params(&to_remove);
20264        }
20265
20266        let url = params.parse_with_url(&url);
20267
20268        loop {
20269            let token = match self
20270                .hub
20271                .auth
20272                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20273                .await
20274            {
20275                Ok(token) => token,
20276                Err(e) => match dlg.token(e) {
20277                    Ok(token) => token,
20278                    Err(e) => {
20279                        dlg.finished(false);
20280                        return Err(common::Error::MissingToken(e));
20281                    }
20282                },
20283            };
20284            let mut req_result = {
20285                let client = &self.hub.client;
20286                dlg.pre_request();
20287                let mut req_builder = hyper::Request::builder()
20288                    .method(hyper::Method::POST)
20289                    .uri(url.as_str())
20290                    .header(USER_AGENT, self.hub._user_agent.clone());
20291
20292                if let Some(token) = token.as_ref() {
20293                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20294                }
20295
20296                let request = req_builder
20297                    .header(CONTENT_LENGTH, 0_u64)
20298                    .body(common::to_body::<String>(None));
20299
20300                client.request(request.unwrap()).await
20301            };
20302
20303            match req_result {
20304                Err(err) => {
20305                    if let common::Retry::After(d) = dlg.http_error(&err) {
20306                        sleep(d).await;
20307                        continue;
20308                    }
20309                    dlg.finished(false);
20310                    return Err(common::Error::HttpError(err));
20311                }
20312                Ok(res) => {
20313                    let (mut parts, body) = res.into_parts();
20314                    let mut body = common::Body::new(body);
20315                    if !parts.status.is_success() {
20316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20317                        let error = serde_json::from_str(&common::to_string(&bytes));
20318                        let response = common::to_response(parts, bytes.into());
20319
20320                        if let common::Retry::After(d) =
20321                            dlg.http_failure(&response, error.as_ref().ok())
20322                        {
20323                            sleep(d).await;
20324                            continue;
20325                        }
20326
20327                        dlg.finished(false);
20328
20329                        return Err(match error {
20330                            Ok(value) => common::Error::BadRequest(value),
20331                            _ => common::Error::Failure(response),
20332                        });
20333                    }
20334                    let response = common::Response::from_parts(parts, body);
20335
20336                    dlg.finished(true);
20337                    return Ok(response);
20338                }
20339            }
20340        }
20341    }
20342
20343    /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
20344    ///
20345    /// Sets the *package name* path property to the given value.
20346    ///
20347    /// Even though the property as already been set when instantiating this call,
20348    /// we provide this method for API completeness.
20349    pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C> {
20350        self._package_name = new_value.to_string();
20351        self
20352    }
20353    /// The purchased subscription ID (for example, 'monthly001').
20354    ///
20355    /// Sets the *subscription id* path property to the given value.
20356    ///
20357    /// Even though the property as already been set when instantiating this call,
20358    /// we provide this method for API completeness.
20359    pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C> {
20360        self._subscription_id = new_value.to_string();
20361        self
20362    }
20363    /// The token provided to the user's device when the subscription was purchased.
20364    ///
20365    /// Sets the *token* path property to the given value.
20366    ///
20367    /// Even though the property as already been set when instantiating this call,
20368    /// we provide this method for API completeness.
20369    pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C> {
20370        self._token = new_value.to_string();
20371        self
20372    }
20373    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20374    /// while executing the actual API request.
20375    ///
20376    /// ````text
20377    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20378    /// ````
20379    ///
20380    /// Sets the *delegate* property to the given value.
20381    pub fn delegate(
20382        mut self,
20383        new_value: &'a mut dyn common::Delegate,
20384    ) -> PurchaseSubscriptionCancelCall<'a, C> {
20385        self._delegate = Some(new_value);
20386        self
20387    }
20388
20389    /// Set any additional parameter of the query string used in the request.
20390    /// It should be used to set parameters which are not yet available through their own
20391    /// setters.
20392    ///
20393    /// Please note that this method must not be used to set any of the known parameters
20394    /// which have their own setter method. If done anyway, the request will fail.
20395    ///
20396    /// # Additional Parameters
20397    ///
20398    /// * *alt* (query-string) - Data format for the response.
20399    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20400    /// * *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.
20401    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20402    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20403    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20404    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20405    pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionCancelCall<'a, C>
20406    where
20407        T: AsRef<str>,
20408    {
20409        self._additional_params
20410            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20411        self
20412    }
20413
20414    /// Identifies the authorization scope for the method you are building.
20415    ///
20416    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20417    /// [`Scope::Full`].
20418    ///
20419    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20420    /// tokens for more than one scope.
20421    ///
20422    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20423    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20424    /// sufficient, a read-write scope will do as well.
20425    pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionCancelCall<'a, C>
20426    where
20427        St: AsRef<str>,
20428    {
20429        self._scopes.insert(String::from(scope.as_ref()));
20430        self
20431    }
20432    /// Identifies the authorization scope(s) for the method you are building.
20433    ///
20434    /// See [`Self::add_scope()`] for details.
20435    pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionCancelCall<'a, C>
20436    where
20437        I: IntoIterator<Item = St>,
20438        St: AsRef<str>,
20439    {
20440        self._scopes
20441            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20442        self
20443    }
20444
20445    /// Removes all scopes, and no default scope will be used either.
20446    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20447    /// for details).
20448    pub fn clear_scopes(mut self) -> PurchaseSubscriptionCancelCall<'a, C> {
20449        self._scopes.clear();
20450        self
20451    }
20452}
20453
20454/// Defers a user's subscription purchase until a specified future expiration time.
20455///
20456/// A builder for the *subscriptions.defer* method supported by a *purchase* resource.
20457/// It is not used directly, but through a [`PurchaseMethods`] instance.
20458///
20459/// # Example
20460///
20461/// Instantiate a resource method builder
20462///
20463/// ```test_harness,no_run
20464/// # extern crate hyper;
20465/// # extern crate hyper_rustls;
20466/// # extern crate google_androidpublisher2 as androidpublisher2;
20467/// use androidpublisher2::api::SubscriptionPurchasesDeferRequest;
20468/// # async fn dox() {
20469/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20470///
20471/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20472/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20473/// #     .with_native_roots()
20474/// #     .unwrap()
20475/// #     .https_only()
20476/// #     .enable_http2()
20477/// #     .build();
20478///
20479/// # let executor = hyper_util::rt::TokioExecutor::new();
20480/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20481/// #     secret,
20482/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20483/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20484/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20485/// #     ),
20486/// # ).build().await.unwrap();
20487///
20488/// # let client = hyper_util::client::legacy::Client::builder(
20489/// #     hyper_util::rt::TokioExecutor::new()
20490/// # )
20491/// # .build(
20492/// #     hyper_rustls::HttpsConnectorBuilder::new()
20493/// #         .with_native_roots()
20494/// #         .unwrap()
20495/// #         .https_or_http()
20496/// #         .enable_http2()
20497/// #         .build()
20498/// # );
20499/// # let mut hub = AndroidPublisher::new(client, auth);
20500/// // As the method needs a request, you would usually fill it with the desired information
20501/// // into the respective structure. Some of the parts shown here might not be applicable !
20502/// // Values shown here are possibly random and not representative !
20503/// let mut req = SubscriptionPurchasesDeferRequest::default();
20504///
20505/// // You can configure optional parameters by calling the respective setters at will, and
20506/// // execute the final call using `doit()`.
20507/// // Values shown here are possibly random and not representative !
20508/// let result = hub.purchases().subscriptions_defer(req, "packageName", "subscriptionId", "token")
20509///              .doit().await;
20510/// # }
20511/// ```
20512pub struct PurchaseSubscriptionDeferCall<'a, C>
20513where
20514    C: 'a,
20515{
20516    hub: &'a AndroidPublisher<C>,
20517    _request: SubscriptionPurchasesDeferRequest,
20518    _package_name: String,
20519    _subscription_id: String,
20520    _token: String,
20521    _delegate: Option<&'a mut dyn common::Delegate>,
20522    _additional_params: HashMap<String, String>,
20523    _scopes: BTreeSet<String>,
20524}
20525
20526impl<'a, C> common::CallBuilder for PurchaseSubscriptionDeferCall<'a, C> {}
20527
20528impl<'a, C> PurchaseSubscriptionDeferCall<'a, C>
20529where
20530    C: common::Connector,
20531{
20532    /// Perform the operation you have build so far.
20533    pub async fn doit(
20534        mut self,
20535    ) -> common::Result<(common::Response, SubscriptionPurchasesDeferResponse)> {
20536        use std::borrow::Cow;
20537        use std::io::{Read, Seek};
20538
20539        use common::{url::Params, ToParts};
20540        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20541
20542        let mut dd = common::DefaultDelegate;
20543        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20544        dlg.begin(common::MethodInfo {
20545            id: "androidpublisher.purchases.subscriptions.defer",
20546            http_method: hyper::Method::POST,
20547        });
20548
20549        for &field in ["alt", "packageName", "subscriptionId", "token"].iter() {
20550            if self._additional_params.contains_key(field) {
20551                dlg.finished(false);
20552                return Err(common::Error::FieldClash(field));
20553            }
20554        }
20555
20556        let mut params = Params::with_capacity(6 + self._additional_params.len());
20557        params.push("packageName", self._package_name);
20558        params.push("subscriptionId", self._subscription_id);
20559        params.push("token", self._token);
20560
20561        params.extend(self._additional_params.iter());
20562
20563        params.push("alt", "json");
20564        let mut url = self.hub._base_url.clone()
20565            + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:defer";
20566        if self._scopes.is_empty() {
20567            self._scopes.insert(Scope::Full.as_ref().to_string());
20568        }
20569
20570        #[allow(clippy::single_element_loop)]
20571        for &(find_this, param_name) in [
20572            ("{packageName}", "packageName"),
20573            ("{subscriptionId}", "subscriptionId"),
20574            ("{token}", "token"),
20575        ]
20576        .iter()
20577        {
20578            url = params.uri_replacement(url, param_name, find_this, false);
20579        }
20580        {
20581            let to_remove = ["token", "subscriptionId", "packageName"];
20582            params.remove_params(&to_remove);
20583        }
20584
20585        let url = params.parse_with_url(&url);
20586
20587        let mut json_mime_type = mime::APPLICATION_JSON;
20588        let mut request_value_reader = {
20589            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20590            common::remove_json_null_values(&mut value);
20591            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20592            serde_json::to_writer(&mut dst, &value).unwrap();
20593            dst
20594        };
20595        let request_size = request_value_reader
20596            .seek(std::io::SeekFrom::End(0))
20597            .unwrap();
20598        request_value_reader
20599            .seek(std::io::SeekFrom::Start(0))
20600            .unwrap();
20601
20602        loop {
20603            let token = match self
20604                .hub
20605                .auth
20606                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20607                .await
20608            {
20609                Ok(token) => token,
20610                Err(e) => match dlg.token(e) {
20611                    Ok(token) => token,
20612                    Err(e) => {
20613                        dlg.finished(false);
20614                        return Err(common::Error::MissingToken(e));
20615                    }
20616                },
20617            };
20618            request_value_reader
20619                .seek(std::io::SeekFrom::Start(0))
20620                .unwrap();
20621            let mut req_result = {
20622                let client = &self.hub.client;
20623                dlg.pre_request();
20624                let mut req_builder = hyper::Request::builder()
20625                    .method(hyper::Method::POST)
20626                    .uri(url.as_str())
20627                    .header(USER_AGENT, self.hub._user_agent.clone());
20628
20629                if let Some(token) = token.as_ref() {
20630                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20631                }
20632
20633                let request = req_builder
20634                    .header(CONTENT_TYPE, json_mime_type.to_string())
20635                    .header(CONTENT_LENGTH, request_size as u64)
20636                    .body(common::to_body(
20637                        request_value_reader.get_ref().clone().into(),
20638                    ));
20639
20640                client.request(request.unwrap()).await
20641            };
20642
20643            match req_result {
20644                Err(err) => {
20645                    if let common::Retry::After(d) = dlg.http_error(&err) {
20646                        sleep(d).await;
20647                        continue;
20648                    }
20649                    dlg.finished(false);
20650                    return Err(common::Error::HttpError(err));
20651                }
20652                Ok(res) => {
20653                    let (mut parts, body) = res.into_parts();
20654                    let mut body = common::Body::new(body);
20655                    if !parts.status.is_success() {
20656                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20657                        let error = serde_json::from_str(&common::to_string(&bytes));
20658                        let response = common::to_response(parts, bytes.into());
20659
20660                        if let common::Retry::After(d) =
20661                            dlg.http_failure(&response, error.as_ref().ok())
20662                        {
20663                            sleep(d).await;
20664                            continue;
20665                        }
20666
20667                        dlg.finished(false);
20668
20669                        return Err(match error {
20670                            Ok(value) => common::Error::BadRequest(value),
20671                            _ => common::Error::Failure(response),
20672                        });
20673                    }
20674                    let response = {
20675                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20676                        let encoded = common::to_string(&bytes);
20677                        match serde_json::from_str(&encoded) {
20678                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20679                            Err(error) => {
20680                                dlg.response_json_decode_error(&encoded, &error);
20681                                return Err(common::Error::JsonDecodeError(
20682                                    encoded.to_string(),
20683                                    error,
20684                                ));
20685                            }
20686                        }
20687                    };
20688
20689                    dlg.finished(true);
20690                    return Ok(response);
20691                }
20692            }
20693        }
20694    }
20695
20696    ///
20697    /// Sets the *request* property to the given value.
20698    ///
20699    /// Even though the property as already been set when instantiating this call,
20700    /// we provide this method for API completeness.
20701    pub fn request(
20702        mut self,
20703        new_value: SubscriptionPurchasesDeferRequest,
20704    ) -> PurchaseSubscriptionDeferCall<'a, C> {
20705        self._request = new_value;
20706        self
20707    }
20708    /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
20709    ///
20710    /// Sets the *package name* path property to the given value.
20711    ///
20712    /// Even though the property as already been set when instantiating this call,
20713    /// we provide this method for API completeness.
20714    pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C> {
20715        self._package_name = new_value.to_string();
20716        self
20717    }
20718    /// The purchased subscription ID (for example, 'monthly001').
20719    ///
20720    /// Sets the *subscription id* path property to the given value.
20721    ///
20722    /// Even though the property as already been set when instantiating this call,
20723    /// we provide this method for API completeness.
20724    pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C> {
20725        self._subscription_id = new_value.to_string();
20726        self
20727    }
20728    /// The token provided to the user's device when the subscription was purchased.
20729    ///
20730    /// Sets the *token* path property to the given value.
20731    ///
20732    /// Even though the property as already been set when instantiating this call,
20733    /// we provide this method for API completeness.
20734    pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C> {
20735        self._token = new_value.to_string();
20736        self
20737    }
20738    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20739    /// while executing the actual API request.
20740    ///
20741    /// ````text
20742    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20743    /// ````
20744    ///
20745    /// Sets the *delegate* property to the given value.
20746    pub fn delegate(
20747        mut self,
20748        new_value: &'a mut dyn common::Delegate,
20749    ) -> PurchaseSubscriptionDeferCall<'a, C> {
20750        self._delegate = Some(new_value);
20751        self
20752    }
20753
20754    /// Set any additional parameter of the query string used in the request.
20755    /// It should be used to set parameters which are not yet available through their own
20756    /// setters.
20757    ///
20758    /// Please note that this method must not be used to set any of the known parameters
20759    /// which have their own setter method. If done anyway, the request will fail.
20760    ///
20761    /// # Additional Parameters
20762    ///
20763    /// * *alt* (query-string) - Data format for the response.
20764    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20765    /// * *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.
20766    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20767    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20768    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20769    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20770    pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionDeferCall<'a, C>
20771    where
20772        T: AsRef<str>,
20773    {
20774        self._additional_params
20775            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20776        self
20777    }
20778
20779    /// Identifies the authorization scope for the method you are building.
20780    ///
20781    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20782    /// [`Scope::Full`].
20783    ///
20784    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20785    /// tokens for more than one scope.
20786    ///
20787    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20788    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20789    /// sufficient, a read-write scope will do as well.
20790    pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionDeferCall<'a, C>
20791    where
20792        St: AsRef<str>,
20793    {
20794        self._scopes.insert(String::from(scope.as_ref()));
20795        self
20796    }
20797    /// Identifies the authorization scope(s) for the method you are building.
20798    ///
20799    /// See [`Self::add_scope()`] for details.
20800    pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionDeferCall<'a, C>
20801    where
20802        I: IntoIterator<Item = St>,
20803        St: AsRef<str>,
20804    {
20805        self._scopes
20806            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20807        self
20808    }
20809
20810    /// Removes all scopes, and no default scope will be used either.
20811    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20812    /// for details).
20813    pub fn clear_scopes(mut self) -> PurchaseSubscriptionDeferCall<'a, C> {
20814        self._scopes.clear();
20815        self
20816    }
20817}
20818
20819/// Checks whether a user's subscription purchase is valid and returns its expiry time.
20820///
20821/// A builder for the *subscriptions.get* method supported by a *purchase* resource.
20822/// It is not used directly, but through a [`PurchaseMethods`] instance.
20823///
20824/// # Example
20825///
20826/// Instantiate a resource method builder
20827///
20828/// ```test_harness,no_run
20829/// # extern crate hyper;
20830/// # extern crate hyper_rustls;
20831/// # extern crate google_androidpublisher2 as androidpublisher2;
20832/// # async fn dox() {
20833/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20834///
20835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20836/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20837/// #     .with_native_roots()
20838/// #     .unwrap()
20839/// #     .https_only()
20840/// #     .enable_http2()
20841/// #     .build();
20842///
20843/// # let executor = hyper_util::rt::TokioExecutor::new();
20844/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20845/// #     secret,
20846/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20847/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20848/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20849/// #     ),
20850/// # ).build().await.unwrap();
20851///
20852/// # let client = hyper_util::client::legacy::Client::builder(
20853/// #     hyper_util::rt::TokioExecutor::new()
20854/// # )
20855/// # .build(
20856/// #     hyper_rustls::HttpsConnectorBuilder::new()
20857/// #         .with_native_roots()
20858/// #         .unwrap()
20859/// #         .https_or_http()
20860/// #         .enable_http2()
20861/// #         .build()
20862/// # );
20863/// # let mut hub = AndroidPublisher::new(client, auth);
20864/// // You can configure optional parameters by calling the respective setters at will, and
20865/// // execute the final call using `doit()`.
20866/// // Values shown here are possibly random and not representative !
20867/// let result = hub.purchases().subscriptions_get("packageName", "subscriptionId", "token")
20868///              .doit().await;
20869/// # }
20870/// ```
20871pub struct PurchaseSubscriptionGetCall<'a, C>
20872where
20873    C: 'a,
20874{
20875    hub: &'a AndroidPublisher<C>,
20876    _package_name: String,
20877    _subscription_id: String,
20878    _token: String,
20879    _delegate: Option<&'a mut dyn common::Delegate>,
20880    _additional_params: HashMap<String, String>,
20881    _scopes: BTreeSet<String>,
20882}
20883
20884impl<'a, C> common::CallBuilder for PurchaseSubscriptionGetCall<'a, C> {}
20885
20886impl<'a, C> PurchaseSubscriptionGetCall<'a, C>
20887where
20888    C: common::Connector,
20889{
20890    /// Perform the operation you have build so far.
20891    pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionPurchase)> {
20892        use std::borrow::Cow;
20893        use std::io::{Read, Seek};
20894
20895        use common::{url::Params, ToParts};
20896        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20897
20898        let mut dd = common::DefaultDelegate;
20899        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20900        dlg.begin(common::MethodInfo {
20901            id: "androidpublisher.purchases.subscriptions.get",
20902            http_method: hyper::Method::GET,
20903        });
20904
20905        for &field in ["alt", "packageName", "subscriptionId", "token"].iter() {
20906            if self._additional_params.contains_key(field) {
20907                dlg.finished(false);
20908                return Err(common::Error::FieldClash(field));
20909            }
20910        }
20911
20912        let mut params = Params::with_capacity(5 + self._additional_params.len());
20913        params.push("packageName", self._package_name);
20914        params.push("subscriptionId", self._subscription_id);
20915        params.push("token", self._token);
20916
20917        params.extend(self._additional_params.iter());
20918
20919        params.push("alt", "json");
20920        let mut url = self.hub._base_url.clone()
20921            + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}";
20922        if self._scopes.is_empty() {
20923            self._scopes.insert(Scope::Full.as_ref().to_string());
20924        }
20925
20926        #[allow(clippy::single_element_loop)]
20927        for &(find_this, param_name) in [
20928            ("{packageName}", "packageName"),
20929            ("{subscriptionId}", "subscriptionId"),
20930            ("{token}", "token"),
20931        ]
20932        .iter()
20933        {
20934            url = params.uri_replacement(url, param_name, find_this, false);
20935        }
20936        {
20937            let to_remove = ["token", "subscriptionId", "packageName"];
20938            params.remove_params(&to_remove);
20939        }
20940
20941        let url = params.parse_with_url(&url);
20942
20943        loop {
20944            let token = match self
20945                .hub
20946                .auth
20947                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20948                .await
20949            {
20950                Ok(token) => token,
20951                Err(e) => match dlg.token(e) {
20952                    Ok(token) => token,
20953                    Err(e) => {
20954                        dlg.finished(false);
20955                        return Err(common::Error::MissingToken(e));
20956                    }
20957                },
20958            };
20959            let mut req_result = {
20960                let client = &self.hub.client;
20961                dlg.pre_request();
20962                let mut req_builder = hyper::Request::builder()
20963                    .method(hyper::Method::GET)
20964                    .uri(url.as_str())
20965                    .header(USER_AGENT, self.hub._user_agent.clone());
20966
20967                if let Some(token) = token.as_ref() {
20968                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20969                }
20970
20971                let request = req_builder
20972                    .header(CONTENT_LENGTH, 0_u64)
20973                    .body(common::to_body::<String>(None));
20974
20975                client.request(request.unwrap()).await
20976            };
20977
20978            match req_result {
20979                Err(err) => {
20980                    if let common::Retry::After(d) = dlg.http_error(&err) {
20981                        sleep(d).await;
20982                        continue;
20983                    }
20984                    dlg.finished(false);
20985                    return Err(common::Error::HttpError(err));
20986                }
20987                Ok(res) => {
20988                    let (mut parts, body) = res.into_parts();
20989                    let mut body = common::Body::new(body);
20990                    if !parts.status.is_success() {
20991                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20992                        let error = serde_json::from_str(&common::to_string(&bytes));
20993                        let response = common::to_response(parts, bytes.into());
20994
20995                        if let common::Retry::After(d) =
20996                            dlg.http_failure(&response, error.as_ref().ok())
20997                        {
20998                            sleep(d).await;
20999                            continue;
21000                        }
21001
21002                        dlg.finished(false);
21003
21004                        return Err(match error {
21005                            Ok(value) => common::Error::BadRequest(value),
21006                            _ => common::Error::Failure(response),
21007                        });
21008                    }
21009                    let response = {
21010                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21011                        let encoded = common::to_string(&bytes);
21012                        match serde_json::from_str(&encoded) {
21013                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21014                            Err(error) => {
21015                                dlg.response_json_decode_error(&encoded, &error);
21016                                return Err(common::Error::JsonDecodeError(
21017                                    encoded.to_string(),
21018                                    error,
21019                                ));
21020                            }
21021                        }
21022                    };
21023
21024                    dlg.finished(true);
21025                    return Ok(response);
21026                }
21027            }
21028        }
21029    }
21030
21031    /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
21032    ///
21033    /// Sets the *package name* path property to the given value.
21034    ///
21035    /// Even though the property as already been set when instantiating this call,
21036    /// we provide this method for API completeness.
21037    pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C> {
21038        self._package_name = new_value.to_string();
21039        self
21040    }
21041    /// The purchased subscription ID (for example, 'monthly001').
21042    ///
21043    /// Sets the *subscription id* path property to the given value.
21044    ///
21045    /// Even though the property as already been set when instantiating this call,
21046    /// we provide this method for API completeness.
21047    pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C> {
21048        self._subscription_id = new_value.to_string();
21049        self
21050    }
21051    /// The token provided to the user's device when the subscription was purchased.
21052    ///
21053    /// Sets the *token* path property to the given value.
21054    ///
21055    /// Even though the property as already been set when instantiating this call,
21056    /// we provide this method for API completeness.
21057    pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C> {
21058        self._token = new_value.to_string();
21059        self
21060    }
21061    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21062    /// while executing the actual API request.
21063    ///
21064    /// ````text
21065    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21066    /// ````
21067    ///
21068    /// Sets the *delegate* property to the given value.
21069    pub fn delegate(
21070        mut self,
21071        new_value: &'a mut dyn common::Delegate,
21072    ) -> PurchaseSubscriptionGetCall<'a, C> {
21073        self._delegate = Some(new_value);
21074        self
21075    }
21076
21077    /// Set any additional parameter of the query string used in the request.
21078    /// It should be used to set parameters which are not yet available through their own
21079    /// setters.
21080    ///
21081    /// Please note that this method must not be used to set any of the known parameters
21082    /// which have their own setter method. If done anyway, the request will fail.
21083    ///
21084    /// # Additional Parameters
21085    ///
21086    /// * *alt* (query-string) - Data format for the response.
21087    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21088    /// * *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.
21089    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21090    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21091    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21092    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21093    pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionGetCall<'a, C>
21094    where
21095        T: AsRef<str>,
21096    {
21097        self._additional_params
21098            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21099        self
21100    }
21101
21102    /// Identifies the authorization scope for the method you are building.
21103    ///
21104    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21105    /// [`Scope::Full`].
21106    ///
21107    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21108    /// tokens for more than one scope.
21109    ///
21110    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21111    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21112    /// sufficient, a read-write scope will do as well.
21113    pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionGetCall<'a, C>
21114    where
21115        St: AsRef<str>,
21116    {
21117        self._scopes.insert(String::from(scope.as_ref()));
21118        self
21119    }
21120    /// Identifies the authorization scope(s) for the method you are building.
21121    ///
21122    /// See [`Self::add_scope()`] for details.
21123    pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionGetCall<'a, C>
21124    where
21125        I: IntoIterator<Item = St>,
21126        St: AsRef<str>,
21127    {
21128        self._scopes
21129            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21130        self
21131    }
21132
21133    /// Removes all scopes, and no default scope will be used either.
21134    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21135    /// for details).
21136    pub fn clear_scopes(mut self) -> PurchaseSubscriptionGetCall<'a, C> {
21137        self._scopes.clear();
21138        self
21139    }
21140}
21141
21142/// Refunds a user's subscription purchase, but the subscription remains valid until its expiration time and it will continue to recur.
21143///
21144/// A builder for the *subscriptions.refund* method supported by a *purchase* resource.
21145/// It is not used directly, but through a [`PurchaseMethods`] instance.
21146///
21147/// # Example
21148///
21149/// Instantiate a resource method builder
21150///
21151/// ```test_harness,no_run
21152/// # extern crate hyper;
21153/// # extern crate hyper_rustls;
21154/// # extern crate google_androidpublisher2 as androidpublisher2;
21155/// # async fn dox() {
21156/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21157///
21158/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21159/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21160/// #     .with_native_roots()
21161/// #     .unwrap()
21162/// #     .https_only()
21163/// #     .enable_http2()
21164/// #     .build();
21165///
21166/// # let executor = hyper_util::rt::TokioExecutor::new();
21167/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21168/// #     secret,
21169/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21170/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21171/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21172/// #     ),
21173/// # ).build().await.unwrap();
21174///
21175/// # let client = hyper_util::client::legacy::Client::builder(
21176/// #     hyper_util::rt::TokioExecutor::new()
21177/// # )
21178/// # .build(
21179/// #     hyper_rustls::HttpsConnectorBuilder::new()
21180/// #         .with_native_roots()
21181/// #         .unwrap()
21182/// #         .https_or_http()
21183/// #         .enable_http2()
21184/// #         .build()
21185/// # );
21186/// # let mut hub = AndroidPublisher::new(client, auth);
21187/// // You can configure optional parameters by calling the respective setters at will, and
21188/// // execute the final call using `doit()`.
21189/// // Values shown here are possibly random and not representative !
21190/// let result = hub.purchases().subscriptions_refund("packageName", "subscriptionId", "token")
21191///              .doit().await;
21192/// # }
21193/// ```
21194pub struct PurchaseSubscriptionRefundCall<'a, C>
21195where
21196    C: 'a,
21197{
21198    hub: &'a AndroidPublisher<C>,
21199    _package_name: String,
21200    _subscription_id: String,
21201    _token: String,
21202    _delegate: Option<&'a mut dyn common::Delegate>,
21203    _additional_params: HashMap<String, String>,
21204    _scopes: BTreeSet<String>,
21205}
21206
21207impl<'a, C> common::CallBuilder for PurchaseSubscriptionRefundCall<'a, C> {}
21208
21209impl<'a, C> PurchaseSubscriptionRefundCall<'a, C>
21210where
21211    C: common::Connector,
21212{
21213    /// Perform the operation you have build so far.
21214    pub async fn doit(mut self) -> common::Result<common::Response> {
21215        use std::borrow::Cow;
21216        use std::io::{Read, Seek};
21217
21218        use common::{url::Params, ToParts};
21219        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21220
21221        let mut dd = common::DefaultDelegate;
21222        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21223        dlg.begin(common::MethodInfo {
21224            id: "androidpublisher.purchases.subscriptions.refund",
21225            http_method: hyper::Method::POST,
21226        });
21227
21228        for &field in ["packageName", "subscriptionId", "token"].iter() {
21229            if self._additional_params.contains_key(field) {
21230                dlg.finished(false);
21231                return Err(common::Error::FieldClash(field));
21232            }
21233        }
21234
21235        let mut params = Params::with_capacity(4 + self._additional_params.len());
21236        params.push("packageName", self._package_name);
21237        params.push("subscriptionId", self._subscription_id);
21238        params.push("token", self._token);
21239
21240        params.extend(self._additional_params.iter());
21241
21242        let mut url = self.hub._base_url.clone()
21243            + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:refund";
21244        if self._scopes.is_empty() {
21245            self._scopes.insert(Scope::Full.as_ref().to_string());
21246        }
21247
21248        #[allow(clippy::single_element_loop)]
21249        for &(find_this, param_name) in [
21250            ("{packageName}", "packageName"),
21251            ("{subscriptionId}", "subscriptionId"),
21252            ("{token}", "token"),
21253        ]
21254        .iter()
21255        {
21256            url = params.uri_replacement(url, param_name, find_this, false);
21257        }
21258        {
21259            let to_remove = ["token", "subscriptionId", "packageName"];
21260            params.remove_params(&to_remove);
21261        }
21262
21263        let url = params.parse_with_url(&url);
21264
21265        loop {
21266            let token = match self
21267                .hub
21268                .auth
21269                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21270                .await
21271            {
21272                Ok(token) => token,
21273                Err(e) => match dlg.token(e) {
21274                    Ok(token) => token,
21275                    Err(e) => {
21276                        dlg.finished(false);
21277                        return Err(common::Error::MissingToken(e));
21278                    }
21279                },
21280            };
21281            let mut req_result = {
21282                let client = &self.hub.client;
21283                dlg.pre_request();
21284                let mut req_builder = hyper::Request::builder()
21285                    .method(hyper::Method::POST)
21286                    .uri(url.as_str())
21287                    .header(USER_AGENT, self.hub._user_agent.clone());
21288
21289                if let Some(token) = token.as_ref() {
21290                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21291                }
21292
21293                let request = req_builder
21294                    .header(CONTENT_LENGTH, 0_u64)
21295                    .body(common::to_body::<String>(None));
21296
21297                client.request(request.unwrap()).await
21298            };
21299
21300            match req_result {
21301                Err(err) => {
21302                    if let common::Retry::After(d) = dlg.http_error(&err) {
21303                        sleep(d).await;
21304                        continue;
21305                    }
21306                    dlg.finished(false);
21307                    return Err(common::Error::HttpError(err));
21308                }
21309                Ok(res) => {
21310                    let (mut parts, body) = res.into_parts();
21311                    let mut body = common::Body::new(body);
21312                    if !parts.status.is_success() {
21313                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21314                        let error = serde_json::from_str(&common::to_string(&bytes));
21315                        let response = common::to_response(parts, bytes.into());
21316
21317                        if let common::Retry::After(d) =
21318                            dlg.http_failure(&response, error.as_ref().ok())
21319                        {
21320                            sleep(d).await;
21321                            continue;
21322                        }
21323
21324                        dlg.finished(false);
21325
21326                        return Err(match error {
21327                            Ok(value) => common::Error::BadRequest(value),
21328                            _ => common::Error::Failure(response),
21329                        });
21330                    }
21331                    let response = common::Response::from_parts(parts, body);
21332
21333                    dlg.finished(true);
21334                    return Ok(response);
21335                }
21336            }
21337        }
21338    }
21339
21340    /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
21341    ///
21342    /// Sets the *package name* path property to the given value.
21343    ///
21344    /// Even though the property as already been set when instantiating this call,
21345    /// we provide this method for API completeness.
21346    pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C> {
21347        self._package_name = new_value.to_string();
21348        self
21349    }
21350    /// The purchased subscription ID (for example, 'monthly001').
21351    ///
21352    /// Sets the *subscription id* path property to the given value.
21353    ///
21354    /// Even though the property as already been set when instantiating this call,
21355    /// we provide this method for API completeness.
21356    pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C> {
21357        self._subscription_id = new_value.to_string();
21358        self
21359    }
21360    /// The token provided to the user's device when the subscription was purchased.
21361    ///
21362    /// Sets the *token* path property to the given value.
21363    ///
21364    /// Even though the property as already been set when instantiating this call,
21365    /// we provide this method for API completeness.
21366    pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C> {
21367        self._token = new_value.to_string();
21368        self
21369    }
21370    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21371    /// while executing the actual API request.
21372    ///
21373    /// ````text
21374    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21375    /// ````
21376    ///
21377    /// Sets the *delegate* property to the given value.
21378    pub fn delegate(
21379        mut self,
21380        new_value: &'a mut dyn common::Delegate,
21381    ) -> PurchaseSubscriptionRefundCall<'a, C> {
21382        self._delegate = Some(new_value);
21383        self
21384    }
21385
21386    /// Set any additional parameter of the query string used in the request.
21387    /// It should be used to set parameters which are not yet available through their own
21388    /// setters.
21389    ///
21390    /// Please note that this method must not be used to set any of the known parameters
21391    /// which have their own setter method. If done anyway, the request will fail.
21392    ///
21393    /// # Additional Parameters
21394    ///
21395    /// * *alt* (query-string) - Data format for the response.
21396    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21397    /// * *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.
21398    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21399    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21400    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21401    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21402    pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionRefundCall<'a, C>
21403    where
21404        T: AsRef<str>,
21405    {
21406        self._additional_params
21407            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21408        self
21409    }
21410
21411    /// Identifies the authorization scope for the method you are building.
21412    ///
21413    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21414    /// [`Scope::Full`].
21415    ///
21416    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21417    /// tokens for more than one scope.
21418    ///
21419    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21420    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21421    /// sufficient, a read-write scope will do as well.
21422    pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionRefundCall<'a, C>
21423    where
21424        St: AsRef<str>,
21425    {
21426        self._scopes.insert(String::from(scope.as_ref()));
21427        self
21428    }
21429    /// Identifies the authorization scope(s) for the method you are building.
21430    ///
21431    /// See [`Self::add_scope()`] for details.
21432    pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionRefundCall<'a, C>
21433    where
21434        I: IntoIterator<Item = St>,
21435        St: AsRef<str>,
21436    {
21437        self._scopes
21438            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21439        self
21440    }
21441
21442    /// Removes all scopes, and no default scope will be used either.
21443    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21444    /// for details).
21445    pub fn clear_scopes(mut self) -> PurchaseSubscriptionRefundCall<'a, C> {
21446        self._scopes.clear();
21447        self
21448    }
21449}
21450
21451/// Refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.
21452///
21453/// A builder for the *subscriptions.revoke* method supported by a *purchase* resource.
21454/// It is not used directly, but through a [`PurchaseMethods`] instance.
21455///
21456/// # Example
21457///
21458/// Instantiate a resource method builder
21459///
21460/// ```test_harness,no_run
21461/// # extern crate hyper;
21462/// # extern crate hyper_rustls;
21463/// # extern crate google_androidpublisher2 as androidpublisher2;
21464/// # async fn dox() {
21465/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21466///
21467/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21468/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21469/// #     .with_native_roots()
21470/// #     .unwrap()
21471/// #     .https_only()
21472/// #     .enable_http2()
21473/// #     .build();
21474///
21475/// # let executor = hyper_util::rt::TokioExecutor::new();
21476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21477/// #     secret,
21478/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21479/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21480/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21481/// #     ),
21482/// # ).build().await.unwrap();
21483///
21484/// # let client = hyper_util::client::legacy::Client::builder(
21485/// #     hyper_util::rt::TokioExecutor::new()
21486/// # )
21487/// # .build(
21488/// #     hyper_rustls::HttpsConnectorBuilder::new()
21489/// #         .with_native_roots()
21490/// #         .unwrap()
21491/// #         .https_or_http()
21492/// #         .enable_http2()
21493/// #         .build()
21494/// # );
21495/// # let mut hub = AndroidPublisher::new(client, auth);
21496/// // You can configure optional parameters by calling the respective setters at will, and
21497/// // execute the final call using `doit()`.
21498/// // Values shown here are possibly random and not representative !
21499/// let result = hub.purchases().subscriptions_revoke("packageName", "subscriptionId", "token")
21500///              .doit().await;
21501/// # }
21502/// ```
21503pub struct PurchaseSubscriptionRevokeCall<'a, C>
21504where
21505    C: 'a,
21506{
21507    hub: &'a AndroidPublisher<C>,
21508    _package_name: String,
21509    _subscription_id: String,
21510    _token: String,
21511    _delegate: Option<&'a mut dyn common::Delegate>,
21512    _additional_params: HashMap<String, String>,
21513    _scopes: BTreeSet<String>,
21514}
21515
21516impl<'a, C> common::CallBuilder for PurchaseSubscriptionRevokeCall<'a, C> {}
21517
21518impl<'a, C> PurchaseSubscriptionRevokeCall<'a, C>
21519where
21520    C: common::Connector,
21521{
21522    /// Perform the operation you have build so far.
21523    pub async fn doit(mut self) -> common::Result<common::Response> {
21524        use std::borrow::Cow;
21525        use std::io::{Read, Seek};
21526
21527        use common::{url::Params, ToParts};
21528        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21529
21530        let mut dd = common::DefaultDelegate;
21531        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21532        dlg.begin(common::MethodInfo {
21533            id: "androidpublisher.purchases.subscriptions.revoke",
21534            http_method: hyper::Method::POST,
21535        });
21536
21537        for &field in ["packageName", "subscriptionId", "token"].iter() {
21538            if self._additional_params.contains_key(field) {
21539                dlg.finished(false);
21540                return Err(common::Error::FieldClash(field));
21541            }
21542        }
21543
21544        let mut params = Params::with_capacity(4 + self._additional_params.len());
21545        params.push("packageName", self._package_name);
21546        params.push("subscriptionId", self._subscription_id);
21547        params.push("token", self._token);
21548
21549        params.extend(self._additional_params.iter());
21550
21551        let mut url = self.hub._base_url.clone()
21552            + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:revoke";
21553        if self._scopes.is_empty() {
21554            self._scopes.insert(Scope::Full.as_ref().to_string());
21555        }
21556
21557        #[allow(clippy::single_element_loop)]
21558        for &(find_this, param_name) in [
21559            ("{packageName}", "packageName"),
21560            ("{subscriptionId}", "subscriptionId"),
21561            ("{token}", "token"),
21562        ]
21563        .iter()
21564        {
21565            url = params.uri_replacement(url, param_name, find_this, false);
21566        }
21567        {
21568            let to_remove = ["token", "subscriptionId", "packageName"];
21569            params.remove_params(&to_remove);
21570        }
21571
21572        let url = params.parse_with_url(&url);
21573
21574        loop {
21575            let token = match self
21576                .hub
21577                .auth
21578                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21579                .await
21580            {
21581                Ok(token) => token,
21582                Err(e) => match dlg.token(e) {
21583                    Ok(token) => token,
21584                    Err(e) => {
21585                        dlg.finished(false);
21586                        return Err(common::Error::MissingToken(e));
21587                    }
21588                },
21589            };
21590            let mut req_result = {
21591                let client = &self.hub.client;
21592                dlg.pre_request();
21593                let mut req_builder = hyper::Request::builder()
21594                    .method(hyper::Method::POST)
21595                    .uri(url.as_str())
21596                    .header(USER_AGENT, self.hub._user_agent.clone());
21597
21598                if let Some(token) = token.as_ref() {
21599                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21600                }
21601
21602                let request = req_builder
21603                    .header(CONTENT_LENGTH, 0_u64)
21604                    .body(common::to_body::<String>(None));
21605
21606                client.request(request.unwrap()).await
21607            };
21608
21609            match req_result {
21610                Err(err) => {
21611                    if let common::Retry::After(d) = dlg.http_error(&err) {
21612                        sleep(d).await;
21613                        continue;
21614                    }
21615                    dlg.finished(false);
21616                    return Err(common::Error::HttpError(err));
21617                }
21618                Ok(res) => {
21619                    let (mut parts, body) = res.into_parts();
21620                    let mut body = common::Body::new(body);
21621                    if !parts.status.is_success() {
21622                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21623                        let error = serde_json::from_str(&common::to_string(&bytes));
21624                        let response = common::to_response(parts, bytes.into());
21625
21626                        if let common::Retry::After(d) =
21627                            dlg.http_failure(&response, error.as_ref().ok())
21628                        {
21629                            sleep(d).await;
21630                            continue;
21631                        }
21632
21633                        dlg.finished(false);
21634
21635                        return Err(match error {
21636                            Ok(value) => common::Error::BadRequest(value),
21637                            _ => common::Error::Failure(response),
21638                        });
21639                    }
21640                    let response = common::Response::from_parts(parts, body);
21641
21642                    dlg.finished(true);
21643                    return Ok(response);
21644                }
21645            }
21646        }
21647    }
21648
21649    /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
21650    ///
21651    /// Sets the *package name* path property to the given value.
21652    ///
21653    /// Even though the property as already been set when instantiating this call,
21654    /// we provide this method for API completeness.
21655    pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C> {
21656        self._package_name = new_value.to_string();
21657        self
21658    }
21659    /// The purchased subscription ID (for example, 'monthly001').
21660    ///
21661    /// Sets the *subscription id* path property to the given value.
21662    ///
21663    /// Even though the property as already been set when instantiating this call,
21664    /// we provide this method for API completeness.
21665    pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C> {
21666        self._subscription_id = new_value.to_string();
21667        self
21668    }
21669    /// The token provided to the user's device when the subscription was purchased.
21670    ///
21671    /// Sets the *token* path property to the given value.
21672    ///
21673    /// Even though the property as already been set when instantiating this call,
21674    /// we provide this method for API completeness.
21675    pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C> {
21676        self._token = new_value.to_string();
21677        self
21678    }
21679    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21680    /// while executing the actual API request.
21681    ///
21682    /// ````text
21683    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21684    /// ````
21685    ///
21686    /// Sets the *delegate* property to the given value.
21687    pub fn delegate(
21688        mut self,
21689        new_value: &'a mut dyn common::Delegate,
21690    ) -> PurchaseSubscriptionRevokeCall<'a, C> {
21691        self._delegate = Some(new_value);
21692        self
21693    }
21694
21695    /// Set any additional parameter of the query string used in the request.
21696    /// It should be used to set parameters which are not yet available through their own
21697    /// setters.
21698    ///
21699    /// Please note that this method must not be used to set any of the known parameters
21700    /// which have their own setter method. If done anyway, the request will fail.
21701    ///
21702    /// # Additional Parameters
21703    ///
21704    /// * *alt* (query-string) - Data format for the response.
21705    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21706    /// * *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.
21707    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21708    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21709    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21710    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21711    pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionRevokeCall<'a, C>
21712    where
21713        T: AsRef<str>,
21714    {
21715        self._additional_params
21716            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21717        self
21718    }
21719
21720    /// Identifies the authorization scope for the method you are building.
21721    ///
21722    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21723    /// [`Scope::Full`].
21724    ///
21725    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21726    /// tokens for more than one scope.
21727    ///
21728    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21729    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21730    /// sufficient, a read-write scope will do as well.
21731    pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionRevokeCall<'a, C>
21732    where
21733        St: AsRef<str>,
21734    {
21735        self._scopes.insert(String::from(scope.as_ref()));
21736        self
21737    }
21738    /// Identifies the authorization scope(s) for the method you are building.
21739    ///
21740    /// See [`Self::add_scope()`] for details.
21741    pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionRevokeCall<'a, C>
21742    where
21743        I: IntoIterator<Item = St>,
21744        St: AsRef<str>,
21745    {
21746        self._scopes
21747            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21748        self
21749    }
21750
21751    /// Removes all scopes, and no default scope will be used either.
21752    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21753    /// for details).
21754    pub fn clear_scopes(mut self) -> PurchaseSubscriptionRevokeCall<'a, C> {
21755        self._scopes.clear();
21756        self
21757    }
21758}
21759
21760/// Lists the purchases that were canceled, refunded or charged-back.
21761///
21762/// A builder for the *voidedpurchases.list* method supported by a *purchase* resource.
21763/// It is not used directly, but through a [`PurchaseMethods`] instance.
21764///
21765/// # Example
21766///
21767/// Instantiate a resource method builder
21768///
21769/// ```test_harness,no_run
21770/// # extern crate hyper;
21771/// # extern crate hyper_rustls;
21772/// # extern crate google_androidpublisher2 as androidpublisher2;
21773/// # async fn dox() {
21774/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21775///
21776/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21777/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21778/// #     .with_native_roots()
21779/// #     .unwrap()
21780/// #     .https_only()
21781/// #     .enable_http2()
21782/// #     .build();
21783///
21784/// # let executor = hyper_util::rt::TokioExecutor::new();
21785/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21786/// #     secret,
21787/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21788/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21789/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21790/// #     ),
21791/// # ).build().await.unwrap();
21792///
21793/// # let client = hyper_util::client::legacy::Client::builder(
21794/// #     hyper_util::rt::TokioExecutor::new()
21795/// # )
21796/// # .build(
21797/// #     hyper_rustls::HttpsConnectorBuilder::new()
21798/// #         .with_native_roots()
21799/// #         .unwrap()
21800/// #         .https_or_http()
21801/// #         .enable_http2()
21802/// #         .build()
21803/// # );
21804/// # let mut hub = AndroidPublisher::new(client, auth);
21805/// // You can configure optional parameters by calling the respective setters at will, and
21806/// // execute the final call using `doit()`.
21807/// // Values shown here are possibly random and not representative !
21808/// let result = hub.purchases().voidedpurchases_list("packageName")
21809///              .token("nonumy")
21810///              .start_time(-22)
21811///              .start_index(89)
21812///              .max_results(80)
21813///              .end_time(-60)
21814///              .doit().await;
21815/// # }
21816/// ```
21817pub struct PurchaseVoidedpurchaseListCall<'a, C>
21818where
21819    C: 'a,
21820{
21821    hub: &'a AndroidPublisher<C>,
21822    _package_name: String,
21823    _token: Option<String>,
21824    _start_time: Option<i64>,
21825    _start_index: Option<u32>,
21826    _max_results: Option<u32>,
21827    _end_time: Option<i64>,
21828    _delegate: Option<&'a mut dyn common::Delegate>,
21829    _additional_params: HashMap<String, String>,
21830    _scopes: BTreeSet<String>,
21831}
21832
21833impl<'a, C> common::CallBuilder for PurchaseVoidedpurchaseListCall<'a, C> {}
21834
21835impl<'a, C> PurchaseVoidedpurchaseListCall<'a, C>
21836where
21837    C: common::Connector,
21838{
21839    /// Perform the operation you have build so far.
21840    pub async fn doit(mut self) -> common::Result<(common::Response, VoidedPurchasesListResponse)> {
21841        use std::borrow::Cow;
21842        use std::io::{Read, Seek};
21843
21844        use common::{url::Params, ToParts};
21845        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21846
21847        let mut dd = common::DefaultDelegate;
21848        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21849        dlg.begin(common::MethodInfo {
21850            id: "androidpublisher.purchases.voidedpurchases.list",
21851            http_method: hyper::Method::GET,
21852        });
21853
21854        for &field in [
21855            "alt",
21856            "packageName",
21857            "token",
21858            "startTime",
21859            "startIndex",
21860            "maxResults",
21861            "endTime",
21862        ]
21863        .iter()
21864        {
21865            if self._additional_params.contains_key(field) {
21866                dlg.finished(false);
21867                return Err(common::Error::FieldClash(field));
21868            }
21869        }
21870
21871        let mut params = Params::with_capacity(8 + self._additional_params.len());
21872        params.push("packageName", self._package_name);
21873        if let Some(value) = self._token.as_ref() {
21874            params.push("token", value);
21875        }
21876        if let Some(value) = self._start_time.as_ref() {
21877            params.push("startTime", value.to_string());
21878        }
21879        if let Some(value) = self._start_index.as_ref() {
21880            params.push("startIndex", value.to_string());
21881        }
21882        if let Some(value) = self._max_results.as_ref() {
21883            params.push("maxResults", value.to_string());
21884        }
21885        if let Some(value) = self._end_time.as_ref() {
21886            params.push("endTime", value.to_string());
21887        }
21888
21889        params.extend(self._additional_params.iter());
21890
21891        params.push("alt", "json");
21892        let mut url = self.hub._base_url.clone() + "{packageName}/purchases/voidedpurchases";
21893        if self._scopes.is_empty() {
21894            self._scopes.insert(Scope::Full.as_ref().to_string());
21895        }
21896
21897        #[allow(clippy::single_element_loop)]
21898        for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
21899            url = params.uri_replacement(url, param_name, find_this, false);
21900        }
21901        {
21902            let to_remove = ["packageName"];
21903            params.remove_params(&to_remove);
21904        }
21905
21906        let url = params.parse_with_url(&url);
21907
21908        loop {
21909            let token = match self
21910                .hub
21911                .auth
21912                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21913                .await
21914            {
21915                Ok(token) => token,
21916                Err(e) => match dlg.token(e) {
21917                    Ok(token) => token,
21918                    Err(e) => {
21919                        dlg.finished(false);
21920                        return Err(common::Error::MissingToken(e));
21921                    }
21922                },
21923            };
21924            let mut req_result = {
21925                let client = &self.hub.client;
21926                dlg.pre_request();
21927                let mut req_builder = hyper::Request::builder()
21928                    .method(hyper::Method::GET)
21929                    .uri(url.as_str())
21930                    .header(USER_AGENT, self.hub._user_agent.clone());
21931
21932                if let Some(token) = token.as_ref() {
21933                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21934                }
21935
21936                let request = req_builder
21937                    .header(CONTENT_LENGTH, 0_u64)
21938                    .body(common::to_body::<String>(None));
21939
21940                client.request(request.unwrap()).await
21941            };
21942
21943            match req_result {
21944                Err(err) => {
21945                    if let common::Retry::After(d) = dlg.http_error(&err) {
21946                        sleep(d).await;
21947                        continue;
21948                    }
21949                    dlg.finished(false);
21950                    return Err(common::Error::HttpError(err));
21951                }
21952                Ok(res) => {
21953                    let (mut parts, body) = res.into_parts();
21954                    let mut body = common::Body::new(body);
21955                    if !parts.status.is_success() {
21956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21957                        let error = serde_json::from_str(&common::to_string(&bytes));
21958                        let response = common::to_response(parts, bytes.into());
21959
21960                        if let common::Retry::After(d) =
21961                            dlg.http_failure(&response, error.as_ref().ok())
21962                        {
21963                            sleep(d).await;
21964                            continue;
21965                        }
21966
21967                        dlg.finished(false);
21968
21969                        return Err(match error {
21970                            Ok(value) => common::Error::BadRequest(value),
21971                            _ => common::Error::Failure(response),
21972                        });
21973                    }
21974                    let response = {
21975                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21976                        let encoded = common::to_string(&bytes);
21977                        match serde_json::from_str(&encoded) {
21978                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21979                            Err(error) => {
21980                                dlg.response_json_decode_error(&encoded, &error);
21981                                return Err(common::Error::JsonDecodeError(
21982                                    encoded.to_string(),
21983                                    error,
21984                                ));
21985                            }
21986                        }
21987                    };
21988
21989                    dlg.finished(true);
21990                    return Ok(response);
21991                }
21992            }
21993        }
21994    }
21995
21996    /// The package name of the application for which voided purchases need to be returned (for example, 'com.some.thing').
21997    ///
21998    /// Sets the *package name* path property to the given value.
21999    ///
22000    /// Even though the property as already been set when instantiating this call,
22001    /// we provide this method for API completeness.
22002    pub fn package_name(mut self, new_value: &str) -> PurchaseVoidedpurchaseListCall<'a, C> {
22003        self._package_name = new_value.to_string();
22004        self
22005    }
22006    ///
22007    /// Sets the *token* query property to the given value.
22008    pub fn token(mut self, new_value: &str) -> PurchaseVoidedpurchaseListCall<'a, C> {
22009        self._token = Some(new_value.to_string());
22010        self
22011    }
22012    /// The time, in milliseconds since the Epoch, of the oldest voided purchase that you want to see in the response. The value of this parameter cannot be older than 30 days and is ignored if a pagination token is set. Default value is current time minus 30 days. Note: This filter is applied on the time at which the record is seen as voided by our systems and not the actual voided time returned in the response.
22013    ///
22014    /// Sets the *start time* query property to the given value.
22015    pub fn start_time(mut self, new_value: i64) -> PurchaseVoidedpurchaseListCall<'a, C> {
22016        self._start_time = Some(new_value);
22017        self
22018    }
22019    ///
22020    /// Sets the *start index* query property to the given value.
22021    pub fn start_index(mut self, new_value: u32) -> PurchaseVoidedpurchaseListCall<'a, C> {
22022        self._start_index = Some(new_value);
22023        self
22024    }
22025    ///
22026    /// Sets the *max results* query property to the given value.
22027    pub fn max_results(mut self, new_value: u32) -> PurchaseVoidedpurchaseListCall<'a, C> {
22028        self._max_results = Some(new_value);
22029        self
22030    }
22031    /// The time, in milliseconds since the Epoch, of the newest voided purchase that you want to see in the response. The value of this parameter cannot be greater than the current time and is ignored if a pagination token is set. Default value is current time. Note: This filter is applied on the time at which the record is seen as voided by our systems and not the actual voided time returned in the response.
22032    ///
22033    /// Sets the *end time* query property to the given value.
22034    pub fn end_time(mut self, new_value: i64) -> PurchaseVoidedpurchaseListCall<'a, C> {
22035        self._end_time = Some(new_value);
22036        self
22037    }
22038    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22039    /// while executing the actual API request.
22040    ///
22041    /// ````text
22042    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22043    /// ````
22044    ///
22045    /// Sets the *delegate* property to the given value.
22046    pub fn delegate(
22047        mut self,
22048        new_value: &'a mut dyn common::Delegate,
22049    ) -> PurchaseVoidedpurchaseListCall<'a, C> {
22050        self._delegate = Some(new_value);
22051        self
22052    }
22053
22054    /// Set any additional parameter of the query string used in the request.
22055    /// It should be used to set parameters which are not yet available through their own
22056    /// setters.
22057    ///
22058    /// Please note that this method must not be used to set any of the known parameters
22059    /// which have their own setter method. If done anyway, the request will fail.
22060    ///
22061    /// # Additional Parameters
22062    ///
22063    /// * *alt* (query-string) - Data format for the response.
22064    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22065    /// * *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.
22066    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22067    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22068    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22069    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22070    pub fn param<T>(mut self, name: T, value: T) -> PurchaseVoidedpurchaseListCall<'a, C>
22071    where
22072        T: AsRef<str>,
22073    {
22074        self._additional_params
22075            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22076        self
22077    }
22078
22079    /// Identifies the authorization scope for the method you are building.
22080    ///
22081    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22082    /// [`Scope::Full`].
22083    ///
22084    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22085    /// tokens for more than one scope.
22086    ///
22087    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22088    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22089    /// sufficient, a read-write scope will do as well.
22090    pub fn add_scope<St>(mut self, scope: St) -> PurchaseVoidedpurchaseListCall<'a, C>
22091    where
22092        St: AsRef<str>,
22093    {
22094        self._scopes.insert(String::from(scope.as_ref()));
22095        self
22096    }
22097    /// Identifies the authorization scope(s) for the method you are building.
22098    ///
22099    /// See [`Self::add_scope()`] for details.
22100    pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseVoidedpurchaseListCall<'a, C>
22101    where
22102        I: IntoIterator<Item = St>,
22103        St: AsRef<str>,
22104    {
22105        self._scopes
22106            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22107        self
22108    }
22109
22110    /// Removes all scopes, and no default scope will be used either.
22111    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22112    /// for details).
22113    pub fn clear_scopes(mut self) -> PurchaseVoidedpurchaseListCall<'a, C> {
22114        self._scopes.clear();
22115        self
22116    }
22117}
22118
22119/// Returns a single review.
22120///
22121/// A builder for the *get* method supported by a *review* resource.
22122/// It is not used directly, but through a [`ReviewMethods`] instance.
22123///
22124/// # Example
22125///
22126/// Instantiate a resource method builder
22127///
22128/// ```test_harness,no_run
22129/// # extern crate hyper;
22130/// # extern crate hyper_rustls;
22131/// # extern crate google_androidpublisher2 as androidpublisher2;
22132/// # async fn dox() {
22133/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22134///
22135/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22136/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22137/// #     .with_native_roots()
22138/// #     .unwrap()
22139/// #     .https_only()
22140/// #     .enable_http2()
22141/// #     .build();
22142///
22143/// # let executor = hyper_util::rt::TokioExecutor::new();
22144/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22145/// #     secret,
22146/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22147/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22148/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22149/// #     ),
22150/// # ).build().await.unwrap();
22151///
22152/// # let client = hyper_util::client::legacy::Client::builder(
22153/// #     hyper_util::rt::TokioExecutor::new()
22154/// # )
22155/// # .build(
22156/// #     hyper_rustls::HttpsConnectorBuilder::new()
22157/// #         .with_native_roots()
22158/// #         .unwrap()
22159/// #         .https_or_http()
22160/// #         .enable_http2()
22161/// #         .build()
22162/// # );
22163/// # let mut hub = AndroidPublisher::new(client, auth);
22164/// // You can configure optional parameters by calling the respective setters at will, and
22165/// // execute the final call using `doit()`.
22166/// // Values shown here are possibly random and not representative !
22167/// let result = hub.reviews().get("packageName", "reviewId")
22168///              .translation_language("aliquyam")
22169///              .doit().await;
22170/// # }
22171/// ```
22172pub struct ReviewGetCall<'a, C>
22173where
22174    C: 'a,
22175{
22176    hub: &'a AndroidPublisher<C>,
22177    _package_name: String,
22178    _review_id: String,
22179    _translation_language: Option<String>,
22180    _delegate: Option<&'a mut dyn common::Delegate>,
22181    _additional_params: HashMap<String, String>,
22182    _scopes: BTreeSet<String>,
22183}
22184
22185impl<'a, C> common::CallBuilder for ReviewGetCall<'a, C> {}
22186
22187impl<'a, C> ReviewGetCall<'a, C>
22188where
22189    C: common::Connector,
22190{
22191    /// Perform the operation you have build so far.
22192    pub async fn doit(mut self) -> common::Result<(common::Response, Review)> {
22193        use std::borrow::Cow;
22194        use std::io::{Read, Seek};
22195
22196        use common::{url::Params, ToParts};
22197        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22198
22199        let mut dd = common::DefaultDelegate;
22200        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22201        dlg.begin(common::MethodInfo {
22202            id: "androidpublisher.reviews.get",
22203            http_method: hyper::Method::GET,
22204        });
22205
22206        for &field in ["alt", "packageName", "reviewId", "translationLanguage"].iter() {
22207            if self._additional_params.contains_key(field) {
22208                dlg.finished(false);
22209                return Err(common::Error::FieldClash(field));
22210            }
22211        }
22212
22213        let mut params = Params::with_capacity(5 + self._additional_params.len());
22214        params.push("packageName", self._package_name);
22215        params.push("reviewId", self._review_id);
22216        if let Some(value) = self._translation_language.as_ref() {
22217            params.push("translationLanguage", value);
22218        }
22219
22220        params.extend(self._additional_params.iter());
22221
22222        params.push("alt", "json");
22223        let mut url = self.hub._base_url.clone() + "{packageName}/reviews/{reviewId}";
22224        if self._scopes.is_empty() {
22225            self._scopes.insert(Scope::Full.as_ref().to_string());
22226        }
22227
22228        #[allow(clippy::single_element_loop)]
22229        for &(find_this, param_name) in
22230            [("{packageName}", "packageName"), ("{reviewId}", "reviewId")].iter()
22231        {
22232            url = params.uri_replacement(url, param_name, find_this, false);
22233        }
22234        {
22235            let to_remove = ["reviewId", "packageName"];
22236            params.remove_params(&to_remove);
22237        }
22238
22239        let url = params.parse_with_url(&url);
22240
22241        loop {
22242            let token = match self
22243                .hub
22244                .auth
22245                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22246                .await
22247            {
22248                Ok(token) => token,
22249                Err(e) => match dlg.token(e) {
22250                    Ok(token) => token,
22251                    Err(e) => {
22252                        dlg.finished(false);
22253                        return Err(common::Error::MissingToken(e));
22254                    }
22255                },
22256            };
22257            let mut req_result = {
22258                let client = &self.hub.client;
22259                dlg.pre_request();
22260                let mut req_builder = hyper::Request::builder()
22261                    .method(hyper::Method::GET)
22262                    .uri(url.as_str())
22263                    .header(USER_AGENT, self.hub._user_agent.clone());
22264
22265                if let Some(token) = token.as_ref() {
22266                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22267                }
22268
22269                let request = req_builder
22270                    .header(CONTENT_LENGTH, 0_u64)
22271                    .body(common::to_body::<String>(None));
22272
22273                client.request(request.unwrap()).await
22274            };
22275
22276            match req_result {
22277                Err(err) => {
22278                    if let common::Retry::After(d) = dlg.http_error(&err) {
22279                        sleep(d).await;
22280                        continue;
22281                    }
22282                    dlg.finished(false);
22283                    return Err(common::Error::HttpError(err));
22284                }
22285                Ok(res) => {
22286                    let (mut parts, body) = res.into_parts();
22287                    let mut body = common::Body::new(body);
22288                    if !parts.status.is_success() {
22289                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22290                        let error = serde_json::from_str(&common::to_string(&bytes));
22291                        let response = common::to_response(parts, bytes.into());
22292
22293                        if let common::Retry::After(d) =
22294                            dlg.http_failure(&response, error.as_ref().ok())
22295                        {
22296                            sleep(d).await;
22297                            continue;
22298                        }
22299
22300                        dlg.finished(false);
22301
22302                        return Err(match error {
22303                            Ok(value) => common::Error::BadRequest(value),
22304                            _ => common::Error::Failure(response),
22305                        });
22306                    }
22307                    let response = {
22308                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22309                        let encoded = common::to_string(&bytes);
22310                        match serde_json::from_str(&encoded) {
22311                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22312                            Err(error) => {
22313                                dlg.response_json_decode_error(&encoded, &error);
22314                                return Err(common::Error::JsonDecodeError(
22315                                    encoded.to_string(),
22316                                    error,
22317                                ));
22318                            }
22319                        }
22320                    };
22321
22322                    dlg.finished(true);
22323                    return Ok(response);
22324                }
22325            }
22326        }
22327    }
22328
22329    /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".
22330    ///
22331    /// Sets the *package name* path property to the given value.
22332    ///
22333    /// Even though the property as already been set when instantiating this call,
22334    /// we provide this method for API completeness.
22335    pub fn package_name(mut self, new_value: &str) -> ReviewGetCall<'a, C> {
22336        self._package_name = new_value.to_string();
22337        self
22338    }
22339    ///
22340    /// Sets the *review id* path property to the given value.
22341    ///
22342    /// Even though the property as already been set when instantiating this call,
22343    /// we provide this method for API completeness.
22344    pub fn review_id(mut self, new_value: &str) -> ReviewGetCall<'a, C> {
22345        self._review_id = new_value.to_string();
22346        self
22347    }
22348    ///
22349    /// Sets the *translation language* query property to the given value.
22350    pub fn translation_language(mut self, new_value: &str) -> ReviewGetCall<'a, C> {
22351        self._translation_language = Some(new_value.to_string());
22352        self
22353    }
22354    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22355    /// while executing the actual API request.
22356    ///
22357    /// ````text
22358    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22359    /// ````
22360    ///
22361    /// Sets the *delegate* property to the given value.
22362    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReviewGetCall<'a, C> {
22363        self._delegate = Some(new_value);
22364        self
22365    }
22366
22367    /// Set any additional parameter of the query string used in the request.
22368    /// It should be used to set parameters which are not yet available through their own
22369    /// setters.
22370    ///
22371    /// Please note that this method must not be used to set any of the known parameters
22372    /// which have their own setter method. If done anyway, the request will fail.
22373    ///
22374    /// # Additional Parameters
22375    ///
22376    /// * *alt* (query-string) - Data format for the response.
22377    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22378    /// * *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.
22379    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22380    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22381    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22382    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22383    pub fn param<T>(mut self, name: T, value: T) -> ReviewGetCall<'a, C>
22384    where
22385        T: AsRef<str>,
22386    {
22387        self._additional_params
22388            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22389        self
22390    }
22391
22392    /// Identifies the authorization scope for the method you are building.
22393    ///
22394    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22395    /// [`Scope::Full`].
22396    ///
22397    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22398    /// tokens for more than one scope.
22399    ///
22400    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22401    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22402    /// sufficient, a read-write scope will do as well.
22403    pub fn add_scope<St>(mut self, scope: St) -> ReviewGetCall<'a, C>
22404    where
22405        St: AsRef<str>,
22406    {
22407        self._scopes.insert(String::from(scope.as_ref()));
22408        self
22409    }
22410    /// Identifies the authorization scope(s) for the method you are building.
22411    ///
22412    /// See [`Self::add_scope()`] for details.
22413    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReviewGetCall<'a, C>
22414    where
22415        I: IntoIterator<Item = St>,
22416        St: AsRef<str>,
22417    {
22418        self._scopes
22419            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22420        self
22421    }
22422
22423    /// Removes all scopes, and no default scope will be used either.
22424    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22425    /// for details).
22426    pub fn clear_scopes(mut self) -> ReviewGetCall<'a, C> {
22427        self._scopes.clear();
22428        self
22429    }
22430}
22431
22432/// Returns a list of reviews. Only reviews from last week will be returned.
22433///
22434/// A builder for the *list* method supported by a *review* resource.
22435/// It is not used directly, but through a [`ReviewMethods`] instance.
22436///
22437/// # Example
22438///
22439/// Instantiate a resource method builder
22440///
22441/// ```test_harness,no_run
22442/// # extern crate hyper;
22443/// # extern crate hyper_rustls;
22444/// # extern crate google_androidpublisher2 as androidpublisher2;
22445/// # async fn dox() {
22446/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22447///
22448/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22449/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22450/// #     .with_native_roots()
22451/// #     .unwrap()
22452/// #     .https_only()
22453/// #     .enable_http2()
22454/// #     .build();
22455///
22456/// # let executor = hyper_util::rt::TokioExecutor::new();
22457/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22458/// #     secret,
22459/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22460/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22461/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22462/// #     ),
22463/// # ).build().await.unwrap();
22464///
22465/// # let client = hyper_util::client::legacy::Client::builder(
22466/// #     hyper_util::rt::TokioExecutor::new()
22467/// # )
22468/// # .build(
22469/// #     hyper_rustls::HttpsConnectorBuilder::new()
22470/// #         .with_native_roots()
22471/// #         .unwrap()
22472/// #         .https_or_http()
22473/// #         .enable_http2()
22474/// #         .build()
22475/// # );
22476/// # let mut hub = AndroidPublisher::new(client, auth);
22477/// // You can configure optional parameters by calling the respective setters at will, and
22478/// // execute the final call using `doit()`.
22479/// // Values shown here are possibly random and not representative !
22480/// let result = hub.reviews().list("packageName")
22481///              .translation_language("At")
22482///              .token("dolores")
22483///              .start_index(55)
22484///              .max_results(39)
22485///              .doit().await;
22486/// # }
22487/// ```
22488pub struct ReviewListCall<'a, C>
22489where
22490    C: 'a,
22491{
22492    hub: &'a AndroidPublisher<C>,
22493    _package_name: String,
22494    _translation_language: Option<String>,
22495    _token: Option<String>,
22496    _start_index: Option<u32>,
22497    _max_results: Option<u32>,
22498    _delegate: Option<&'a mut dyn common::Delegate>,
22499    _additional_params: HashMap<String, String>,
22500    _scopes: BTreeSet<String>,
22501}
22502
22503impl<'a, C> common::CallBuilder for ReviewListCall<'a, C> {}
22504
22505impl<'a, C> ReviewListCall<'a, C>
22506where
22507    C: common::Connector,
22508{
22509    /// Perform the operation you have build so far.
22510    pub async fn doit(mut self) -> common::Result<(common::Response, ReviewsListResponse)> {
22511        use std::borrow::Cow;
22512        use std::io::{Read, Seek};
22513
22514        use common::{url::Params, ToParts};
22515        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22516
22517        let mut dd = common::DefaultDelegate;
22518        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22519        dlg.begin(common::MethodInfo {
22520            id: "androidpublisher.reviews.list",
22521            http_method: hyper::Method::GET,
22522        });
22523
22524        for &field in [
22525            "alt",
22526            "packageName",
22527            "translationLanguage",
22528            "token",
22529            "startIndex",
22530            "maxResults",
22531        ]
22532        .iter()
22533        {
22534            if self._additional_params.contains_key(field) {
22535                dlg.finished(false);
22536                return Err(common::Error::FieldClash(field));
22537            }
22538        }
22539
22540        let mut params = Params::with_capacity(7 + self._additional_params.len());
22541        params.push("packageName", self._package_name);
22542        if let Some(value) = self._translation_language.as_ref() {
22543            params.push("translationLanguage", value);
22544        }
22545        if let Some(value) = self._token.as_ref() {
22546            params.push("token", value);
22547        }
22548        if let Some(value) = self._start_index.as_ref() {
22549            params.push("startIndex", value.to_string());
22550        }
22551        if let Some(value) = self._max_results.as_ref() {
22552            params.push("maxResults", value.to_string());
22553        }
22554
22555        params.extend(self._additional_params.iter());
22556
22557        params.push("alt", "json");
22558        let mut url = self.hub._base_url.clone() + "{packageName}/reviews";
22559        if self._scopes.is_empty() {
22560            self._scopes.insert(Scope::Full.as_ref().to_string());
22561        }
22562
22563        #[allow(clippy::single_element_loop)]
22564        for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
22565            url = params.uri_replacement(url, param_name, find_this, false);
22566        }
22567        {
22568            let to_remove = ["packageName"];
22569            params.remove_params(&to_remove);
22570        }
22571
22572        let url = params.parse_with_url(&url);
22573
22574        loop {
22575            let token = match self
22576                .hub
22577                .auth
22578                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22579                .await
22580            {
22581                Ok(token) => token,
22582                Err(e) => match dlg.token(e) {
22583                    Ok(token) => token,
22584                    Err(e) => {
22585                        dlg.finished(false);
22586                        return Err(common::Error::MissingToken(e));
22587                    }
22588                },
22589            };
22590            let mut req_result = {
22591                let client = &self.hub.client;
22592                dlg.pre_request();
22593                let mut req_builder = hyper::Request::builder()
22594                    .method(hyper::Method::GET)
22595                    .uri(url.as_str())
22596                    .header(USER_AGENT, self.hub._user_agent.clone());
22597
22598                if let Some(token) = token.as_ref() {
22599                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22600                }
22601
22602                let request = req_builder
22603                    .header(CONTENT_LENGTH, 0_u64)
22604                    .body(common::to_body::<String>(None));
22605
22606                client.request(request.unwrap()).await
22607            };
22608
22609            match req_result {
22610                Err(err) => {
22611                    if let common::Retry::After(d) = dlg.http_error(&err) {
22612                        sleep(d).await;
22613                        continue;
22614                    }
22615                    dlg.finished(false);
22616                    return Err(common::Error::HttpError(err));
22617                }
22618                Ok(res) => {
22619                    let (mut parts, body) = res.into_parts();
22620                    let mut body = common::Body::new(body);
22621                    if !parts.status.is_success() {
22622                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22623                        let error = serde_json::from_str(&common::to_string(&bytes));
22624                        let response = common::to_response(parts, bytes.into());
22625
22626                        if let common::Retry::After(d) =
22627                            dlg.http_failure(&response, error.as_ref().ok())
22628                        {
22629                            sleep(d).await;
22630                            continue;
22631                        }
22632
22633                        dlg.finished(false);
22634
22635                        return Err(match error {
22636                            Ok(value) => common::Error::BadRequest(value),
22637                            _ => common::Error::Failure(response),
22638                        });
22639                    }
22640                    let response = {
22641                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22642                        let encoded = common::to_string(&bytes);
22643                        match serde_json::from_str(&encoded) {
22644                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22645                            Err(error) => {
22646                                dlg.response_json_decode_error(&encoded, &error);
22647                                return Err(common::Error::JsonDecodeError(
22648                                    encoded.to_string(),
22649                                    error,
22650                                ));
22651                            }
22652                        }
22653                    };
22654
22655                    dlg.finished(true);
22656                    return Ok(response);
22657                }
22658            }
22659        }
22660    }
22661
22662    /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".
22663    ///
22664    /// Sets the *package name* path property to the given value.
22665    ///
22666    /// Even though the property as already been set when instantiating this call,
22667    /// we provide this method for API completeness.
22668    pub fn package_name(mut self, new_value: &str) -> ReviewListCall<'a, C> {
22669        self._package_name = new_value.to_string();
22670        self
22671    }
22672    ///
22673    /// Sets the *translation language* query property to the given value.
22674    pub fn translation_language(mut self, new_value: &str) -> ReviewListCall<'a, C> {
22675        self._translation_language = Some(new_value.to_string());
22676        self
22677    }
22678    ///
22679    /// Sets the *token* query property to the given value.
22680    pub fn token(mut self, new_value: &str) -> ReviewListCall<'a, C> {
22681        self._token = Some(new_value.to_string());
22682        self
22683    }
22684    ///
22685    /// Sets the *start index* query property to the given value.
22686    pub fn start_index(mut self, new_value: u32) -> ReviewListCall<'a, C> {
22687        self._start_index = Some(new_value);
22688        self
22689    }
22690    ///
22691    /// Sets the *max results* query property to the given value.
22692    pub fn max_results(mut self, new_value: u32) -> ReviewListCall<'a, C> {
22693        self._max_results = Some(new_value);
22694        self
22695    }
22696    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22697    /// while executing the actual API request.
22698    ///
22699    /// ````text
22700    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22701    /// ````
22702    ///
22703    /// Sets the *delegate* property to the given value.
22704    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReviewListCall<'a, C> {
22705        self._delegate = Some(new_value);
22706        self
22707    }
22708
22709    /// Set any additional parameter of the query string used in the request.
22710    /// It should be used to set parameters which are not yet available through their own
22711    /// setters.
22712    ///
22713    /// Please note that this method must not be used to set any of the known parameters
22714    /// which have their own setter method. If done anyway, the request will fail.
22715    ///
22716    /// # Additional Parameters
22717    ///
22718    /// * *alt* (query-string) - Data format for the response.
22719    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22720    /// * *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.
22721    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22722    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22723    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22724    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22725    pub fn param<T>(mut self, name: T, value: T) -> ReviewListCall<'a, C>
22726    where
22727        T: AsRef<str>,
22728    {
22729        self._additional_params
22730            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22731        self
22732    }
22733
22734    /// Identifies the authorization scope for the method you are building.
22735    ///
22736    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22737    /// [`Scope::Full`].
22738    ///
22739    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22740    /// tokens for more than one scope.
22741    ///
22742    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22743    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22744    /// sufficient, a read-write scope will do as well.
22745    pub fn add_scope<St>(mut self, scope: St) -> ReviewListCall<'a, C>
22746    where
22747        St: AsRef<str>,
22748    {
22749        self._scopes.insert(String::from(scope.as_ref()));
22750        self
22751    }
22752    /// Identifies the authorization scope(s) for the method you are building.
22753    ///
22754    /// See [`Self::add_scope()`] for details.
22755    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReviewListCall<'a, C>
22756    where
22757        I: IntoIterator<Item = St>,
22758        St: AsRef<str>,
22759    {
22760        self._scopes
22761            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22762        self
22763    }
22764
22765    /// Removes all scopes, and no default scope will be used either.
22766    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22767    /// for details).
22768    pub fn clear_scopes(mut self) -> ReviewListCall<'a, C> {
22769        self._scopes.clear();
22770        self
22771    }
22772}
22773
22774/// Reply to a single review, or update an existing reply.
22775///
22776/// A builder for the *reply* method supported by a *review* resource.
22777/// It is not used directly, but through a [`ReviewMethods`] instance.
22778///
22779/// # Example
22780///
22781/// Instantiate a resource method builder
22782///
22783/// ```test_harness,no_run
22784/// # extern crate hyper;
22785/// # extern crate hyper_rustls;
22786/// # extern crate google_androidpublisher2 as androidpublisher2;
22787/// use androidpublisher2::api::ReviewsReplyRequest;
22788/// # async fn dox() {
22789/// # use androidpublisher2::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22790///
22791/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22792/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22793/// #     .with_native_roots()
22794/// #     .unwrap()
22795/// #     .https_only()
22796/// #     .enable_http2()
22797/// #     .build();
22798///
22799/// # let executor = hyper_util::rt::TokioExecutor::new();
22800/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22801/// #     secret,
22802/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22803/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22804/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22805/// #     ),
22806/// # ).build().await.unwrap();
22807///
22808/// # let client = hyper_util::client::legacy::Client::builder(
22809/// #     hyper_util::rt::TokioExecutor::new()
22810/// # )
22811/// # .build(
22812/// #     hyper_rustls::HttpsConnectorBuilder::new()
22813/// #         .with_native_roots()
22814/// #         .unwrap()
22815/// #         .https_or_http()
22816/// #         .enable_http2()
22817/// #         .build()
22818/// # );
22819/// # let mut hub = AndroidPublisher::new(client, auth);
22820/// // As the method needs a request, you would usually fill it with the desired information
22821/// // into the respective structure. Some of the parts shown here might not be applicable !
22822/// // Values shown here are possibly random and not representative !
22823/// let mut req = ReviewsReplyRequest::default();
22824///
22825/// // You can configure optional parameters by calling the respective setters at will, and
22826/// // execute the final call using `doit()`.
22827/// // Values shown here are possibly random and not representative !
22828/// let result = hub.reviews().reply(req, "packageName", "reviewId")
22829///              .doit().await;
22830/// # }
22831/// ```
22832pub struct ReviewReplyCall<'a, C>
22833where
22834    C: 'a,
22835{
22836    hub: &'a AndroidPublisher<C>,
22837    _request: ReviewsReplyRequest,
22838    _package_name: String,
22839    _review_id: String,
22840    _delegate: Option<&'a mut dyn common::Delegate>,
22841    _additional_params: HashMap<String, String>,
22842    _scopes: BTreeSet<String>,
22843}
22844
22845impl<'a, C> common::CallBuilder for ReviewReplyCall<'a, C> {}
22846
22847impl<'a, C> ReviewReplyCall<'a, C>
22848where
22849    C: common::Connector,
22850{
22851    /// Perform the operation you have build so far.
22852    pub async fn doit(mut self) -> common::Result<(common::Response, ReviewsReplyResponse)> {
22853        use std::borrow::Cow;
22854        use std::io::{Read, Seek};
22855
22856        use common::{url::Params, ToParts};
22857        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22858
22859        let mut dd = common::DefaultDelegate;
22860        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22861        dlg.begin(common::MethodInfo {
22862            id: "androidpublisher.reviews.reply",
22863            http_method: hyper::Method::POST,
22864        });
22865
22866        for &field in ["alt", "packageName", "reviewId"].iter() {
22867            if self._additional_params.contains_key(field) {
22868                dlg.finished(false);
22869                return Err(common::Error::FieldClash(field));
22870            }
22871        }
22872
22873        let mut params = Params::with_capacity(5 + self._additional_params.len());
22874        params.push("packageName", self._package_name);
22875        params.push("reviewId", self._review_id);
22876
22877        params.extend(self._additional_params.iter());
22878
22879        params.push("alt", "json");
22880        let mut url = self.hub._base_url.clone() + "{packageName}/reviews/{reviewId}:reply";
22881        if self._scopes.is_empty() {
22882            self._scopes.insert(Scope::Full.as_ref().to_string());
22883        }
22884
22885        #[allow(clippy::single_element_loop)]
22886        for &(find_this, param_name) in
22887            [("{packageName}", "packageName"), ("{reviewId}", "reviewId")].iter()
22888        {
22889            url = params.uri_replacement(url, param_name, find_this, false);
22890        }
22891        {
22892            let to_remove = ["reviewId", "packageName"];
22893            params.remove_params(&to_remove);
22894        }
22895
22896        let url = params.parse_with_url(&url);
22897
22898        let mut json_mime_type = mime::APPLICATION_JSON;
22899        let mut request_value_reader = {
22900            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22901            common::remove_json_null_values(&mut value);
22902            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22903            serde_json::to_writer(&mut dst, &value).unwrap();
22904            dst
22905        };
22906        let request_size = request_value_reader
22907            .seek(std::io::SeekFrom::End(0))
22908            .unwrap();
22909        request_value_reader
22910            .seek(std::io::SeekFrom::Start(0))
22911            .unwrap();
22912
22913        loop {
22914            let token = match self
22915                .hub
22916                .auth
22917                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22918                .await
22919            {
22920                Ok(token) => token,
22921                Err(e) => match dlg.token(e) {
22922                    Ok(token) => token,
22923                    Err(e) => {
22924                        dlg.finished(false);
22925                        return Err(common::Error::MissingToken(e));
22926                    }
22927                },
22928            };
22929            request_value_reader
22930                .seek(std::io::SeekFrom::Start(0))
22931                .unwrap();
22932            let mut req_result = {
22933                let client = &self.hub.client;
22934                dlg.pre_request();
22935                let mut req_builder = hyper::Request::builder()
22936                    .method(hyper::Method::POST)
22937                    .uri(url.as_str())
22938                    .header(USER_AGENT, self.hub._user_agent.clone());
22939
22940                if let Some(token) = token.as_ref() {
22941                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22942                }
22943
22944                let request = req_builder
22945                    .header(CONTENT_TYPE, json_mime_type.to_string())
22946                    .header(CONTENT_LENGTH, request_size as u64)
22947                    .body(common::to_body(
22948                        request_value_reader.get_ref().clone().into(),
22949                    ));
22950
22951                client.request(request.unwrap()).await
22952            };
22953
22954            match req_result {
22955                Err(err) => {
22956                    if let common::Retry::After(d) = dlg.http_error(&err) {
22957                        sleep(d).await;
22958                        continue;
22959                    }
22960                    dlg.finished(false);
22961                    return Err(common::Error::HttpError(err));
22962                }
22963                Ok(res) => {
22964                    let (mut parts, body) = res.into_parts();
22965                    let mut body = common::Body::new(body);
22966                    if !parts.status.is_success() {
22967                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22968                        let error = serde_json::from_str(&common::to_string(&bytes));
22969                        let response = common::to_response(parts, bytes.into());
22970
22971                        if let common::Retry::After(d) =
22972                            dlg.http_failure(&response, error.as_ref().ok())
22973                        {
22974                            sleep(d).await;
22975                            continue;
22976                        }
22977
22978                        dlg.finished(false);
22979
22980                        return Err(match error {
22981                            Ok(value) => common::Error::BadRequest(value),
22982                            _ => common::Error::Failure(response),
22983                        });
22984                    }
22985                    let response = {
22986                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22987                        let encoded = common::to_string(&bytes);
22988                        match serde_json::from_str(&encoded) {
22989                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22990                            Err(error) => {
22991                                dlg.response_json_decode_error(&encoded, &error);
22992                                return Err(common::Error::JsonDecodeError(
22993                                    encoded.to_string(),
22994                                    error,
22995                                ));
22996                            }
22997                        }
22998                    };
22999
23000                    dlg.finished(true);
23001                    return Ok(response);
23002                }
23003            }
23004        }
23005    }
23006
23007    ///
23008    /// Sets the *request* property to the given value.
23009    ///
23010    /// Even though the property as already been set when instantiating this call,
23011    /// we provide this method for API completeness.
23012    pub fn request(mut self, new_value: ReviewsReplyRequest) -> ReviewReplyCall<'a, C> {
23013        self._request = new_value;
23014        self
23015    }
23016    /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".
23017    ///
23018    /// Sets the *package name* path property to the given value.
23019    ///
23020    /// Even though the property as already been set when instantiating this call,
23021    /// we provide this method for API completeness.
23022    pub fn package_name(mut self, new_value: &str) -> ReviewReplyCall<'a, C> {
23023        self._package_name = new_value.to_string();
23024        self
23025    }
23026    ///
23027    /// Sets the *review id* path property to the given value.
23028    ///
23029    /// Even though the property as already been set when instantiating this call,
23030    /// we provide this method for API completeness.
23031    pub fn review_id(mut self, new_value: &str) -> ReviewReplyCall<'a, C> {
23032        self._review_id = new_value.to_string();
23033        self
23034    }
23035    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23036    /// while executing the actual API request.
23037    ///
23038    /// ````text
23039    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23040    /// ````
23041    ///
23042    /// Sets the *delegate* property to the given value.
23043    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReviewReplyCall<'a, C> {
23044        self._delegate = Some(new_value);
23045        self
23046    }
23047
23048    /// Set any additional parameter of the query string used in the request.
23049    /// It should be used to set parameters which are not yet available through their own
23050    /// setters.
23051    ///
23052    /// Please note that this method must not be used to set any of the known parameters
23053    /// which have their own setter method. If done anyway, the request will fail.
23054    ///
23055    /// # Additional Parameters
23056    ///
23057    /// * *alt* (query-string) - Data format for the response.
23058    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23059    /// * *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.
23060    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23061    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23062    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23063    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23064    pub fn param<T>(mut self, name: T, value: T) -> ReviewReplyCall<'a, C>
23065    where
23066        T: AsRef<str>,
23067    {
23068        self._additional_params
23069            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23070        self
23071    }
23072
23073    /// Identifies the authorization scope for the method you are building.
23074    ///
23075    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23076    /// [`Scope::Full`].
23077    ///
23078    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23079    /// tokens for more than one scope.
23080    ///
23081    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23082    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23083    /// sufficient, a read-write scope will do as well.
23084    pub fn add_scope<St>(mut self, scope: St) -> ReviewReplyCall<'a, C>
23085    where
23086        St: AsRef<str>,
23087    {
23088        self._scopes.insert(String::from(scope.as_ref()));
23089        self
23090    }
23091    /// Identifies the authorization scope(s) for the method you are building.
23092    ///
23093    /// See [`Self::add_scope()`] for details.
23094    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReviewReplyCall<'a, C>
23095    where
23096        I: IntoIterator<Item = St>,
23097        St: AsRef<str>,
23098    {
23099        self._scopes
23100            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23101        self
23102    }
23103
23104    /// Removes all scopes, and no default scope will be used either.
23105    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23106    /// for details).
23107    pub fn clear_scopes(mut self) -> ReviewReplyCall<'a, C> {
23108        self._scopes.clear();
23109        self
23110    }
23111}