#![allow(clippy::ptr_arg)]
use std::collections::{BTreeSet, HashMap};
use tokio::time::sleep;
// ##############
// UTILITIES ###
// ############
/// Identifies the an OAuth2 authorization scope.
/// A scope is needed when requesting an
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
pub enum Scope {
/// View and manage your Google Play Developer account
Full,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::Full => "https://www.googleapis.com/auth/androidpublisher",
}
}
}
#[allow(clippy::derivable_impls)]
impl Default for Scope {
fn default() -> Scope {
Scope::Full
}
}
// ########
// HUB ###
// ######
/// Central instance to access all AndroidPublisher related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Subscription;
/// use androidpublisher3::{Result, Error};
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
/// // unless you replace `None` with the desired Flow.
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
/// // retrieve them from storage.
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Subscription::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_patch(req, "packageName", "productId")
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .regions_version_version("gubergren")
/// .latency_tolerance("eos")
/// .allow_missing(true)
/// .doit().await;
///
/// match result {
/// Err(e) => match e {
/// // The Error enum provides details about what exactly happened.
/// // You can also just use its `Debug`, `Display` or `Error` traits
/// Error::HttpError(_)
/// |Error::Io(_)
/// |Error::MissingAPIKey
/// |Error::MissingToken(_)
/// |Error::Cancelled
/// |Error::UploadSizeLimitExceeded(_, _)
/// |Error::Failure(_)
/// |Error::BadRequest(_)
/// |Error::FieldClash(_)
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
/// },
/// Ok(res) => println!("Success: {:?}", res),
/// }
/// # }
/// ```
#[derive(Clone)]
pub struct AndroidPublisher<C> {
pub client: common::Client<C>,
pub auth: Box<dyn common::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
}
impl<C> common::Hub for AndroidPublisher<C> {}
impl<'a, C> AndroidPublisher<C> {
pub fn new<A: 'static + common::GetToken>(
client: common::Client<C>,
auth: A,
) -> AndroidPublisher<C> {
AndroidPublisher {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/7.0.0".to_string(),
_base_url: "https://androidpublisher.googleapis.com/".to_string(),
_root_url: "https://androidpublisher.googleapis.com/".to_string(),
}
}
pub fn applications(&'a self) -> ApplicationMethods<'a, C> {
ApplicationMethods { hub: self }
}
pub fn apprecovery(&'a self) -> ApprecoveryMethods<'a, C> {
ApprecoveryMethods { hub: self }
}
pub fn edits(&'a self) -> EditMethods<'a, C> {
EditMethods { hub: self }
}
pub fn externaltransactions(&'a self) -> ExternaltransactionMethods<'a, C> {
ExternaltransactionMethods { hub: self }
}
pub fn generatedapks(&'a self) -> GeneratedapkMethods<'a, C> {
GeneratedapkMethods { hub: self }
}
pub fn grants(&'a self) -> GrantMethods<'a, C> {
GrantMethods { hub: self }
}
pub fn inappproducts(&'a self) -> InappproductMethods<'a, C> {
InappproductMethods { hub: self }
}
pub fn internalappsharingartifacts(&'a self) -> InternalappsharingartifactMethods<'a, C> {
InternalappsharingartifactMethods { hub: self }
}
pub fn monetization(&'a self) -> MonetizationMethods<'a, C> {
MonetizationMethods { hub: self }
}
pub fn orders(&'a self) -> OrderMethods<'a, C> {
OrderMethods { hub: self }
}
pub fn purchases(&'a self) -> PurchaseMethods<'a, C> {
PurchaseMethods { hub: self }
}
pub fn reviews(&'a self) -> ReviewMethods<'a, C> {
ReviewMethods { hub: self }
}
pub fn systemapks(&'a self) -> SystemapkMethods<'a, C> {
SystemapkMethods { hub: self }
}
pub fn users(&'a self) -> UserMethods<'a, C> {
UserMethods { hub: self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/7.0.0`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
std::mem::replace(&mut self._user_agent, agent_name)
}
/// Set the base url to use in all requests to the server.
/// It defaults to `https://androidpublisher.googleapis.com/`.
///
/// Returns the previously set base url.
pub fn base_url(&mut self, new_base_url: String) -> String {
std::mem::replace(&mut self._base_url, new_base_url)
}
/// Set the root url to use in all requests to the server.
/// It defaults to `https://androidpublisher.googleapis.com/`.
///
/// Returns the previously set root url.
pub fn root_url(&mut self, new_root_url: String) -> String {
std::mem::replace(&mut self._root_url, new_root_url)
}
}
// ############
// SCHEMAS ###
// ##########
/// Represents an Abi.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Abi {
/// Alias for an abi.
pub alias: Option<String>,
}
impl common::Part for Abi {}
/// Targeting based on Abi.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AbiTargeting {
/// Targeting of other sibling directories that were in the Bundle. For main splits this is targeting of other main splits.
pub alternatives: Option<Vec<Abi>>,
/// Value of an abi.
pub value: Option<Vec<Abi>>,
}
impl common::Part for AbiTargeting {}
/// Represents a targeting rule of the form: User never had {scope} before.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AcquisitionTargetingRule {
/// Required. The scope of subscriptions this rule considers. Only allows "this subscription" and "any subscription in app".
pub scope: Option<TargetingRuleScope>,
}
impl common::Part for AcquisitionTargetingRule {}
/// Request message for ActivateBasePlan.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans activate monetization](MonetizationSubscriptionBasePlanActivateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivateBasePlanRequest {
/// Required. The unique base plan ID of the base plan to activate.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The parent app (package name) of the base plan to activate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent subscription (ID) of the base plan to activate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::RequestValue for ActivateBasePlanRequest {}
/// Request message for ActivateOneTimeProductOffer.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers activate monetization](MonetizationOnetimeproductPurchaseOptionOfferActivateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivateOneTimeProductOfferRequest {
/// Optional. The latency tolerance for the propagation of this update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The offer ID of the offer to activate.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to activate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the offer to activate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The parent purchase option (ID) of the offer to activate.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::RequestValue for ActivateOneTimeProductOfferRequest {}
/// Request message for UpdatePurchaseOptionState.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivatePurchaseOptionRequest {
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The parent app (package name) of the purchase option to activate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the purchase option to activate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The purchase option ID of the purchase option to activate.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::Part for ActivatePurchaseOptionRequest {}
/// Request message for ActivateSubscriptionOffer.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers activate monetization](MonetizationSubscriptionBasePlanOfferActivateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivateSubscriptionOfferRequest {
/// Required. The parent base plan (ID) of the offer to activate.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The unique offer ID of the offer to activate.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to activate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent subscription (ID) of the offer to activate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::RequestValue for ActivateSubscriptionOfferRequest {}
/// Request message for AddTargeting.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [add targeting apprecovery](ApprecoveryAddTargetingCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AddTargetingRequest {
/// Specifies targeting updates such as regions, android sdk versions etc.
#[serde(rename = "targetingUpdate")]
pub targeting_update: Option<TargetingUpdate>,
}
impl common::RequestValue for AddTargetingRequest {}
/// Response message for AddTargeting.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [add targeting apprecovery](ApprecoveryAddTargetingCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AddTargetingResponse {
_never_set: Option<bool>,
}
impl common::ResponseResult for AddTargetingResponse {}
/// Object representation to describe all set of users.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AllUsers {
/// Required. Set to true if all set of users are needed.
#[serde(rename = "isAllUsersRequested")]
pub is_all_users_requested: Option<bool>,
}
impl common::Part for AllUsers {}
/// Android api level targeting data for app recovery action targeting.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AndroidSdks {
/// Android api levels of devices targeted by recovery action. See https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels for different api levels in android.
#[serde(rename = "sdkLevels")]
#[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
pub sdk_levels: Option<Vec<i64>>,
}
impl common::Part for AndroidSdks {}
/// Information about an APK. The resource for ApksService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [apks upload edits](EditApkUploadCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Apk {
/// Information about the binary payload of this APK.
pub binary: Option<ApkBinary>,
/// The version code of the APK, as specified in the manifest file.
#[serde(rename = "versionCode")]
pub version_code: Option<i32>,
}
impl common::ResponseResult for Apk {}
/// Represents the binary payload of an APK.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ApkBinary {
/// A sha1 hash of the APK payload, encoded as a hex string and matching the output of the sha1sum command.
pub sha1: Option<String>,
/// A sha256 hash of the APK payload, encoded as a hex string and matching the output of the sha256sum command.
pub sha256: Option<String>,
}
impl common::Part for ApkBinary {}
/// Description of the created apks.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ApkDescription {
/// Set only for asset slices.
#[serde(rename = "assetSliceMetadata")]
pub asset_slice_metadata: Option<SplitApkMetadata>,
/// Set only for Instant split APKs.
#[serde(rename = "instantApkMetadata")]
pub instant_apk_metadata: Option<SplitApkMetadata>,
/// Path of the Apk, will be in the following format: .apk where DownloadId is the ID used to download the apk using GeneratedApks.Download API.
pub path: Option<String>,
/// Set only for Split APKs.
#[serde(rename = "splitApkMetadata")]
pub split_apk_metadata: Option<SplitApkMetadata>,
/// Set only for standalone APKs.
#[serde(rename = "standaloneApkMetadata")]
pub standalone_apk_metadata: Option<StandaloneApkMetadata>,
/// Apk-level targeting.
pub targeting: Option<ApkTargeting>,
}
impl common::Part for ApkDescription {}
/// A set of apks representing a module.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ApkSet {
/// Description of the generated apks.
#[serde(rename = "apkDescription")]
pub apk_description: Option<Vec<ApkDescription>>,
/// Metadata about the module represented by this ApkSet
#[serde(rename = "moduleMetadata")]
pub module_metadata: Option<ModuleMetadata>,
}
impl common::Part for ApkSet {}
/// Represents a set of apk-level targetings.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ApkTargeting {
/// The abi that the apk targets
#[serde(rename = "abiTargeting")]
pub abi_targeting: Option<AbiTargeting>,
/// The language that the apk targets
#[serde(rename = "languageTargeting")]
pub language_targeting: Option<LanguageTargeting>,
/// Multi-api-level targeting.
#[serde(rename = "multiAbiTargeting")]
pub multi_abi_targeting: Option<MultiAbiTargeting>,
/// The screen density that this apk supports.
#[serde(rename = "screenDensityTargeting")]
pub screen_density_targeting: Option<ScreenDensityTargeting>,
/// The sdk version that the apk targets
#[serde(rename = "sdkVersionTargeting")]
pub sdk_version_targeting: Option<SdkVersionTargeting>,
/// Texture-compression-format-level targeting
#[serde(rename = "textureCompressionFormatTargeting")]
pub texture_compression_format_targeting: Option<TextureCompressionFormatTargeting>,
}
impl common::Part for ApkTargeting {}
/// Request to create a new externally hosted APK.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [apks addexternallyhosted edits](EditApkAddexternallyhostedCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ApksAddExternallyHostedRequest {
/// The definition of the externally-hosted APK and where it is located.
#[serde(rename = "externallyHostedApk")]
pub externally_hosted_apk: Option<ExternallyHostedApk>,
}
impl common::RequestValue for ApksAddExternallyHostedRequest {}
/// Response for creating a new externally hosted APK.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [apks addexternallyhosted edits](EditApkAddexternallyhostedCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ApksAddExternallyHostedResponse {
/// The definition of the externally-hosted APK and where it is located.
#[serde(rename = "externallyHostedApk")]
pub externally_hosted_apk: Option<ExternallyHostedApk>,
}
impl common::ResponseResult for ApksAddExternallyHostedResponse {}
/// Response listing all APKs.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [apks list edits](EditApkListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ApksListResponse {
/// All APKs.
pub apks: Option<Vec<Apk>>,
/// The kind of this response ("androidpublisher#apksListResponse").
pub kind: Option<String>,
}
impl common::ResponseResult for ApksListResponse {}
/// The app details. The resource for DetailsService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [details get edits](EditDetailGetCall) (response)
/// * [details patch edits](EditDetailPatchCall) (request|response)
/// * [details update edits](EditDetailUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AppDetails {
/// The user-visible support email for this app.
#[serde(rename = "contactEmail")]
pub contact_email: Option<String>,
/// The user-visible support telephone number for this app.
#[serde(rename = "contactPhone")]
pub contact_phone: Option<String>,
/// The user-visible website for this app.
#[serde(rename = "contactWebsite")]
pub contact_website: Option<String>,
/// Default language code, in BCP 47 format (eg "en-US").
#[serde(rename = "defaultLanguage")]
pub default_language: Option<String>,
}
impl common::RequestValue for AppDetails {}
impl common::ResponseResult for AppDetails {}
/// An app edit. The resource for EditsService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [commit edits](EditCommitCall) (response)
/// * [get edits](EditGetCall) (response)
/// * [insert edits](EditInsertCall) (request|response)
/// * [validate edits](EditValidateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AppEdit {
/// Output only. The time (as seconds since Epoch) at which the edit will expire and will be no longer valid for use.
#[serde(rename = "expiryTimeSeconds")]
pub expiry_time_seconds: Option<String>,
/// Output only. Identifier of the edit. Can be used in subsequent API calls.
pub id: Option<String>,
}
impl common::RequestValue for AppEdit {}
impl common::ResponseResult for AppEdit {}
/// Information about an app recovery action.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [create apprecovery](ApprecoveryCreateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AppRecoveryAction {
/// ID corresponding to the app recovery action.
#[serde(rename = "appRecoveryId")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub app_recovery_id: Option<i64>,
/// Timestamp of when the app recovery action is canceled by the developer. Only set if the recovery action has been canceled.
#[serde(rename = "cancelTime")]
pub cancel_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Timestamp of when the app recovery action is created by the developer. It is always set after creation of the recovery action.
#[serde(rename = "createTime")]
pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Timestamp of when the app recovery action is deployed to the users. Only set if the recovery action has been deployed.
#[serde(rename = "deployTime")]
pub deploy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Timestamp of when the developer last updated recovery action. In case the action is cancelled, it corresponds to cancellation time. It is always set after creation of the recovery action.
#[serde(rename = "lastUpdateTime")]
pub last_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Data about the remote in-app update action such as such as recovered user base, recoverable user base etc. Set only if the recovery action type is Remote In-App Update.
#[serde(rename = "remoteInAppUpdateData")]
pub remote_in_app_update_data: Option<RemoteInAppUpdateData>,
/// The status of the recovery action.
pub status: Option<String>,
/// Specifies targeting criteria for the recovery action such as regions, android sdk versions, app versions etc.
pub targeting: Option<Targeting>,
}
impl common::ResponseResult for AppRecoveryAction {}
/// Data format for a list of app versions.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AppVersionList {
/// List of app version codes.
#[serde(rename = "versionCodes")]
#[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
pub version_codes: Option<Vec<i64>>,
}
impl common::Part for AppVersionList {}
/// Data format for a continuous range of app versions.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AppVersionRange {
/// Highest app version in the range, inclusive.
#[serde(rename = "versionCodeEnd")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub version_code_end: Option<i64>,
/// Lowest app version in the range, inclusive.
#[serde(rename = "versionCodeStart")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub version_code_start: Option<i64>,
}
impl common::Part for AppVersionRange {}
/// Deprecated: subscription archiving is not supported.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions archive monetization](MonetizationSubscriptionArchiveCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ArchiveSubscriptionRequest {
_never_set: Option<bool>,
}
impl common::RequestValue for ArchiveSubscriptionRequest {}
/// Metadata of an asset module.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AssetModuleMetadata {
/// Indicates the delivery type for persistent install.
#[serde(rename = "deliveryType")]
pub delivery_type: Option<String>,
/// Module name.
pub name: Option<String>,
}
impl common::Part for AssetModuleMetadata {}
/// Set of asset slices belonging to a single asset module.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AssetSliceSet {
/// Asset slices.
#[serde(rename = "apkDescription")]
pub apk_description: Option<Vec<ApkDescription>>,
/// Module level metadata.
#[serde(rename = "assetModuleMetadata")]
pub asset_module_metadata: Option<AssetModuleMetadata>,
}
impl common::Part for AssetSliceSet {}
/// Represents a base plan that automatically renews at the end of its subscription period.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AutoRenewingBasePlanType {
/// Optional. Custom account hold period of the subscription, specified in ISO 8601 format. Acceptable values must be in days and between P0D and P60D. An empty field represents a recommended account hold, calculated as 60 days minus grace period. The sum of gracePeriodDuration and accountHoldDuration must be between P30D and P60D days, inclusive.
#[serde(rename = "accountHoldDuration")]
pub account_hold_duration: Option<String>,
/// Required. Immutable. Subscription period, specified in ISO 8601 format. For a list of acceptable billing periods, refer to the help center. The duration is immutable after the base plan is created.
#[serde(rename = "billingPeriodDuration")]
pub billing_period_duration: Option<String>,
/// Grace period of the subscription, specified in ISO 8601 format. Acceptable values must be in days and between P0D and the lesser of 30D and base plan billing period. If not specified, a default value will be used based on the billing period. The sum of gracePeriodDuration and accountHoldDuration must be between P30D and P60D days, inclusive.
#[serde(rename = "gracePeriodDuration")]
pub grace_period_duration: Option<String>,
/// Whether the renewing base plan is backward compatible. The backward compatible base plan is returned by the Google Play Billing Library deprecated method querySkuDetailsAsync(). Only one renewing base plan can be marked as legacy compatible for a given subscription.
#[serde(rename = "legacyCompatible")]
pub legacy_compatible: Option<bool>,
/// Subscription offer id which is legacy compatible. The backward compatible subscription offer is returned by the Google Play Billing Library deprecated method querySkuDetailsAsync(). Only one subscription offer can be marked as legacy compatible for a given renewing base plan. To have no Subscription offer as legacy compatible set this field as empty string.
#[serde(rename = "legacyCompatibleSubscriptionOfferId")]
pub legacy_compatible_subscription_offer_id: Option<String>,
/// The proration mode for the base plan determines what happens when a user switches to this plan from another base plan. If unspecified, defaults to CHARGE_ON_NEXT_BILLING_DATE.
#[serde(rename = "prorationMode")]
pub proration_mode: Option<String>,
/// Whether users should be able to resubscribe to this base plan in Google Play surfaces. Defaults to RESUBSCRIBE_STATE_ACTIVE if not specified.
#[serde(rename = "resubscribeState")]
pub resubscribe_state: Option<String>,
}
impl common::Part for AutoRenewingBasePlanType {}
/// Information related to an auto renewing plan.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AutoRenewingPlan {
/// If the subscription is currently set to auto-renew, e.g. the user has not canceled the subscription
#[serde(rename = "autoRenewEnabled")]
pub auto_renew_enabled: Option<bool>,
/// The installment plan commitment and state related info for the auto renewing plan.
#[serde(rename = "installmentDetails")]
pub installment_details: Option<InstallmentPlan>,
/// The information of the last price change for the item since subscription signup.
#[serde(rename = "priceChangeDetails")]
pub price_change_details: Option<SubscriptionItemPriceChangeDetails>,
/// The information of the latest price step-up consent.
#[serde(rename = "priceStepUpConsentDetails")]
pub price_step_up_consent_details: Option<PriceStepUpConsentDetails>,
/// The current recurring price of the auto renewing plan. Note that the price does not take into account discounts and does not include taxes for tax-exclusive pricing, please call orders.get API instead if transaction details are needed.
#[serde(rename = "recurringPrice")]
pub recurring_price: Option<Money>,
}
impl common::Part for AutoRenewingPlan {}
/// Details of a base price pricing phase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BaseDetails {
_never_set: Option<bool>,
}
impl common::Part for BaseDetails {}
/// A single base plan for a subscription.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BasePlan {
/// Set when the base plan automatically renews at a regular interval.
#[serde(rename = "autoRenewingBasePlanType")]
pub auto_renewing_base_plan_type: Option<AutoRenewingBasePlanType>,
/// Required. Immutable. The unique identifier of this base plan. Must be unique within the subscription, and conform with RFC-1034. That is, this ID can only contain lower-case letters (a-z), numbers (0-9), and hyphens (-), and be at most 63 characters.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Set for installments base plans where a user is committed to a specified number of payments.
#[serde(rename = "installmentsBasePlanType")]
pub installments_base_plan_type: Option<InstallmentsBasePlanType>,
/// List of up to 20 custom tags specified for this base plan, and returned to the app through the billing library. Subscription offers for this base plan will also receive these offer tags in the billing library.
#[serde(rename = "offerTags")]
pub offer_tags: Option<Vec<OfferTag>>,
/// Pricing information for any new locations Play may launch in the future. If omitted, the BasePlan will not be automatically available any new locations Play may launch in the future.
#[serde(rename = "otherRegionsConfig")]
pub other_regions_config: Option<OtherRegionsBasePlanConfig>,
/// Set when the base plan does not automatically renew at the end of the billing period.
#[serde(rename = "prepaidBasePlanType")]
pub prepaid_base_plan_type: Option<PrepaidBasePlanType>,
/// Region-specific information for this base plan.
#[serde(rename = "regionalConfigs")]
pub regional_configs: Option<Vec<RegionalBasePlanConfig>>,
/// Output only. The state of the base plan, i.e. whether it's active. Draft and inactive base plans can be activated or deleted. Active base plans can be made inactive. Inactive base plans can be canceled. This field cannot be changed by updating the resource. Use the dedicated endpoints instead.
pub state: Option<String>,
}
impl common::Part for BasePlan {}
/// Request message for BatchDeleteOneTimeProductOffers.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers batch delete monetization](MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchDeleteOneTimeProductOffersRequest {
/// Required. A list of update requests of up to 100 elements. All requests must correspond to different offers.
pub requests: Option<Vec<DeleteOneTimeProductOfferRequest>>,
}
impl common::RequestValue for BatchDeleteOneTimeProductOffersRequest {}
/// Request message for BatchDeleteOneTimeProduct.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts batch delete monetization](MonetizationOnetimeproductBatchDeleteCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchDeleteOneTimeProductsRequest {
/// Required. A list of delete requests of up to 100 elements. All requests must delete different one-time products.
pub requests: Option<Vec<DeleteOneTimeProductRequest>>,
}
impl common::RequestValue for BatchDeleteOneTimeProductsRequest {}
/// Request message for BatchDeletePurchaseOption.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options batch delete monetization](MonetizationOnetimeproductPurchaseOptionBatchDeleteCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchDeletePurchaseOptionsRequest {
/// Required. A list of delete requests of up to 100 elements. All requests must delete purchase options from different one-time products.
pub requests: Option<Vec<DeletePurchaseOptionRequest>>,
}
impl common::RequestValue for BatchDeletePurchaseOptionsRequest {}
/// Request message for the BatchGetOneTimeProductOffers endpoint.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers batch get monetization](MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetOneTimeProductOffersRequest {
/// Required. A list of get requests of up to 100 elements. All requests must retrieve different offers.
pub requests: Option<Vec<GetOneTimeProductOfferRequest>>,
}
impl common::RequestValue for BatchGetOneTimeProductOffersRequest {}
/// Response message for the BatchGetOneTimeProductOffers endpoint.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers batch get monetization](MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetOneTimeProductOffersResponse {
/// The list of updated one-time product offers, in the same order as the request.
#[serde(rename = "oneTimeProductOffers")]
pub one_time_product_offers: Option<Vec<OneTimeProductOffer>>,
}
impl common::ResponseResult for BatchGetOneTimeProductOffersResponse {}
/// Response message for the BatchGetOneTimeProducts endpoint.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts batch get monetization](MonetizationOnetimeproductBatchGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetOneTimeProductsResponse {
/// The list of requested one-time products, in the same order as the request.
#[serde(rename = "oneTimeProducts")]
pub one_time_products: Option<Vec<OneTimeProduct>>,
}
impl common::ResponseResult for BatchGetOneTimeProductsResponse {}
/// Response for the orders.batchGet API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [batchget orders](OrderBatchgetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetOrdersResponse {
/// Details for the requested order IDs.
pub orders: Option<Vec<Order>>,
}
impl common::ResponseResult for BatchGetOrdersResponse {}
/// Request message for BatchGetSubscriptionOffers endpoint.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers batch get monetization](MonetizationSubscriptionBasePlanOfferBatchGetCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetSubscriptionOffersRequest {
/// Required. A list of update requests of up to 100 elements. All requests must update different subscriptions.
pub requests: Option<Vec<GetSubscriptionOfferRequest>>,
}
impl common::RequestValue for BatchGetSubscriptionOffersRequest {}
/// Response message for BatchGetSubscriptionOffers endpoint.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers batch get monetization](MonetizationSubscriptionBasePlanOfferBatchGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetSubscriptionOffersResponse {
/// no description provided
#[serde(rename = "subscriptionOffers")]
pub subscription_offers: Option<Vec<SubscriptionOffer>>,
}
impl common::ResponseResult for BatchGetSubscriptionOffersResponse {}
/// Response message for BatchGetSubscriptions endpoint.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions batch get monetization](MonetizationSubscriptionBatchGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetSubscriptionsResponse {
/// The list of requested subscriptions, in the same order as the request.
pub subscriptions: Option<Vec<Subscription>>,
}
impl common::ResponseResult for BatchGetSubscriptionsResponse {}
/// Request message for BatchMigrateBasePlanPrices.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans batch migrate prices monetization](MonetizationSubscriptionBasePlanBatchMigratePriceCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchMigrateBasePlanPricesRequest {
/// Required. Up to 100 price migration requests. All requests must update different base plans.
pub requests: Option<Vec<MigrateBasePlanPricesRequest>>,
}
impl common::RequestValue for BatchMigrateBasePlanPricesRequest {}
/// Response message for BatchMigrateBasePlanPrices.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans batch migrate prices monetization](MonetizationSubscriptionBasePlanBatchMigratePriceCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchMigrateBasePlanPricesResponse {
/// Contains one response per requested price migration, in the same order as the request.
pub responses: Option<Vec<MigrateBasePlanPricesResponse>>,
}
impl common::ResponseResult for BatchMigrateBasePlanPricesResponse {}
/// Request message for BatchUpdateBasePlanStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans batch update states monetization](MonetizationSubscriptionBasePlanBatchUpdateStateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateBasePlanStatesRequest {
/// Required. The update request list of up to 100 elements. All requests must update different base plans.
pub requests: Option<Vec<UpdateBasePlanStateRequest>>,
}
impl common::RequestValue for BatchUpdateBasePlanStatesRequest {}
/// Response message for BatchUpdateBasePlanStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans batch update states monetization](MonetizationSubscriptionBasePlanBatchUpdateStateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateBasePlanStatesResponse {
/// The list of updated subscriptions. This list will match the requests one to one, in the same order.
pub subscriptions: Option<Vec<Subscription>>,
}
impl common::ResponseResult for BatchUpdateBasePlanStatesResponse {}
/// Request message for BatchUpdateOneTimeProductOfferStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers batch update states monetization](MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateOneTimeProductOfferStatesRequest {
/// Required. The update request list of up to 100 elements. All requests must update different offers.
pub requests: Option<Vec<UpdateOneTimeProductOfferStateRequest>>,
}
impl common::RequestValue for BatchUpdateOneTimeProductOfferStatesRequest {}
/// Response message for BatchUpdateOneTimeProductOfferStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers batch update states monetization](MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateOneTimeProductOfferStatesResponse {
/// The updated one-time product offers list, in the same order as the request.
#[serde(rename = "oneTimeProductOffers")]
pub one_time_product_offers: Option<Vec<OneTimeProductOffer>>,
}
impl common::ResponseResult for BatchUpdateOneTimeProductOfferStatesResponse {}
/// Request message for BatchUpdateOneTimeProductOffers.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers batch update monetization](MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateOneTimeProductOffersRequest {
/// Required. A list of update requests of up to 100 elements. All requests must update different offers.
pub requests: Option<Vec<UpdateOneTimeProductOfferRequest>>,
}
impl common::RequestValue for BatchUpdateOneTimeProductOffersRequest {}
/// Response message for BatchUpdateOneTimeProductOffers.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers batch update monetization](MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateOneTimeProductOffersResponse {
/// The list of updated one-time product offers, in the same order as the request.
#[serde(rename = "oneTimeProductOffers")]
pub one_time_product_offers: Option<Vec<OneTimeProductOffer>>,
}
impl common::ResponseResult for BatchUpdateOneTimeProductOffersResponse {}
/// Request message for BatchUpdateOneTimeProduct.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts batch update monetization](MonetizationOnetimeproductBatchUpdateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateOneTimeProductsRequest {
/// Required. A list of update requests of up to 100 elements. All requests must update different one-time products.
pub requests: Option<Vec<UpdateOneTimeProductRequest>>,
}
impl common::RequestValue for BatchUpdateOneTimeProductsRequest {}
/// Response message for BatchUpdateOneTimeProduct.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts batch update monetization](MonetizationOnetimeproductBatchUpdateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateOneTimeProductsResponse {
/// The list of updated one-time products list, in the same order as the request.
#[serde(rename = "oneTimeProducts")]
pub one_time_products: Option<Vec<OneTimeProduct>>,
}
impl common::ResponseResult for BatchUpdateOneTimeProductsResponse {}
/// Request message for BatchUpdatePurchaseOptionStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options batch update states monetization](MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdatePurchaseOptionStatesRequest {
/// Required. The update request list of up to 100 elements. All requests must update different purchase options.
pub requests: Option<Vec<UpdatePurchaseOptionStateRequest>>,
}
impl common::RequestValue for BatchUpdatePurchaseOptionStatesRequest {}
/// Response message for BatchUpdatePurchaseOptionStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options batch update states monetization](MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdatePurchaseOptionStatesResponse {
/// The list of updated one-time products. This list will match the requests one to one, in the same order.
#[serde(rename = "oneTimeProducts")]
pub one_time_products: Option<Vec<OneTimeProduct>>,
}
impl common::ResponseResult for BatchUpdatePurchaseOptionStatesResponse {}
/// Request message for BatchUpdateSubscriptionOfferStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers batch update states monetization](MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateSubscriptionOfferStatesRequest {
/// Required. The update request list of up to 100 elements. All requests must update different offers.
pub requests: Option<Vec<UpdateSubscriptionOfferStateRequest>>,
}
impl common::RequestValue for BatchUpdateSubscriptionOfferStatesRequest {}
/// Response message for BatchUpdateSubscriptionOfferStates.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers batch update states monetization](MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateSubscriptionOfferStatesResponse {
/// The updated subscription offers list.
#[serde(rename = "subscriptionOffers")]
pub subscription_offers: Option<Vec<SubscriptionOffer>>,
}
impl common::ResponseResult for BatchUpdateSubscriptionOfferStatesResponse {}
/// Request message for BatchUpdateSubscriptionOffers.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers batch update monetization](MonetizationSubscriptionBasePlanOfferBatchUpdateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateSubscriptionOffersRequest {
/// Required. A list of update requests of up to 100 elements. All requests must update different subscription offers.
pub requests: Option<Vec<UpdateSubscriptionOfferRequest>>,
}
impl common::RequestValue for BatchUpdateSubscriptionOffersRequest {}
/// Response message for BatchUpdateSubscriptionOffers.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers batch update monetization](MonetizationSubscriptionBasePlanOfferBatchUpdateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateSubscriptionOffersResponse {
/// The updated subscription offers list.
#[serde(rename = "subscriptionOffers")]
pub subscription_offers: Option<Vec<SubscriptionOffer>>,
}
impl common::ResponseResult for BatchUpdateSubscriptionOffersResponse {}
/// Request message for BatchUpdateSubscription.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions batch update monetization](MonetizationSubscriptionBatchUpdateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateSubscriptionsRequest {
/// Required. A list of update requests of up to 100 elements. All requests must update different subscriptions.
pub requests: Option<Vec<UpdateSubscriptionRequest>>,
}
impl common::RequestValue for BatchUpdateSubscriptionsRequest {}
/// Response message for BatchUpdateSubscription.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions batch update monetization](MonetizationSubscriptionBatchUpdateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchUpdateSubscriptionsResponse {
/// The updated subscriptions list.
pub subscriptions: Option<Vec<Subscription>>,
}
impl common::ResponseResult for BatchUpdateSubscriptionsResponse {}
/// Information about an app bundle. The resource for BundlesService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [bundles upload edits](EditBundleUploadCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Bundle {
/// A sha1 hash of the upload payload, encoded as a hex string and matching the output of the sha1sum command.
pub sha1: Option<String>,
/// A sha256 hash of the upload payload, encoded as a hex string and matching the output of the sha256sum command.
pub sha256: Option<String>,
/// The version code of the Android App Bundle, as specified in the Android App Bundle's base module APK manifest file.
#[serde(rename = "versionCode")]
pub version_code: Option<i32>,
}
impl common::ResponseResult for Bundle {}
/// Response listing all app bundles.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [bundles list edits](EditBundleListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BundlesListResponse {
/// All app bundles.
pub bundles: Option<Vec<Bundle>>,
/// The kind of this response ("androidpublisher#bundlesListResponse").
pub kind: Option<String>,
}
impl common::ResponseResult for BundlesListResponse {}
/// Address information for the customer, for use in tax computation.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BuyerAddress {
/// Two letter country code based on ISO-3166-1 Alpha-2 (UN country codes).
#[serde(rename = "buyerCountry")]
pub buyer_country: Option<String>,
/// Postal code of an address. When Google is the Merchant of Record for the order, this information is not included.
#[serde(rename = "buyerPostcode")]
pub buyer_postcode: Option<String>,
/// Top-level administrative subdivision of the buyer address country. When Google is the Merchant of Record for the order, this information is not included.
#[serde(rename = "buyerState")]
pub buyer_state: Option<String>,
}
impl common::Part for BuyerAddress {}
/// Request message for CancelAppRecovery.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [cancel apprecovery](ApprecoveryCancelCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancelAppRecoveryRequest {
_never_set: Option<bool>,
}
impl common::RequestValue for CancelAppRecoveryRequest {}
/// Response message for CancelAppRecovery.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [cancel apprecovery](ApprecoveryCancelCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancelAppRecoveryResponse {
_never_set: Option<bool>,
}
impl common::ResponseResult for CancelAppRecoveryResponse {}
/// Request message for CancelOneTimeProductOffer.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers cancel monetization](MonetizationOnetimeproductPurchaseOptionOfferCancelCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancelOneTimeProductOfferRequest {
/// Optional. The latency tolerance for the propagation of this update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The offer ID of the offer to cancel.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to cancel.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the offer to cancel.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The parent purchase option (ID) of the offer to cancel.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::RequestValue for CancelOneTimeProductOfferRequest {}
/// Request for the purchases.subscriptionsv2.cancel API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptionsv2 cancel purchases](PurchaseSubscriptionsv2CancelCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancelSubscriptionPurchaseRequest {
/// Required. Additional details around the subscription revocation.
#[serde(rename = "cancellationContext")]
pub cancellation_context: Option<CancellationContext>,
}
impl common::RequestValue for CancelSubscriptionPurchaseRequest {}
/// Response for the purchases.subscriptionsv2.cancel API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptionsv2 cancel purchases](PurchaseSubscriptionsv2CancelCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancelSubscriptionPurchaseResponse {
_never_set: Option<bool>,
}
impl common::ResponseResult for CancelSubscriptionPurchaseResponse {}
/// Result of the cancel survey when the subscription was canceled by the user.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancelSurveyResult {
/// The reason the user selected in the cancel survey.
pub reason: Option<String>,
/// Only set for CANCEL_SURVEY_REASON_OTHERS. This is the user's freeform response to the survey.
#[serde(rename = "reasonUserInput")]
pub reason_user_input: Option<String>,
}
impl common::Part for CancelSurveyResult {}
/// Information specific to a subscription in the SUBSCRIPTION_STATE_CANCELED or SUBSCRIPTION_STATE_EXPIRED state.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CanceledStateContext {
/// Subscription was canceled by the developer.
#[serde(rename = "developerInitiatedCancellation")]
pub developer_initiated_cancellation: Option<DeveloperInitiatedCancellation>,
/// Subscription was replaced by a new subscription.
#[serde(rename = "replacementCancellation")]
pub replacement_cancellation: Option<ReplacementCancellation>,
/// Subscription was canceled by the system, for example because of a billing problem.
#[serde(rename = "systemInitiatedCancellation")]
pub system_initiated_cancellation: Option<SystemInitiatedCancellation>,
/// Subscription was canceled by user.
#[serde(rename = "userInitiatedCancellation")]
pub user_initiated_cancellation: Option<UserInitiatedCancellation>,
}
impl common::Part for CanceledStateContext {}
/// Cancellation context of the purchases.subscriptionsv2.cancel API.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancellationContext {
/// Required. The type of cancellation for the purchased subscription.
#[serde(rename = "cancellationType")]
pub cancellation_type: Option<String>,
}
impl common::Part for CancellationContext {}
/// Details of when the order was canceled.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CancellationEvent {
/// The time when the order was canceled.
#[serde(rename = "eventTime")]
pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for CancellationEvent {}
/// An entry of conversation between user and developer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Comment {
/// A comment from a developer.
#[serde(rename = "developerComment")]
pub developer_comment: Option<DeveloperComment>,
/// A comment from a user.
#[serde(rename = "userComment")]
pub user_comment: Option<UserComment>,
}
impl common::Part for Comment {}
/// Request message for ConvertRegionPrices.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [convert region prices monetization](MonetizationConvertRegionPriceCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ConvertRegionPricesRequest {
/// The intital price to convert other regions from. Tax exclusive.
pub price: Option<Money>,
}
impl common::RequestValue for ConvertRegionPricesRequest {}
/// Response message for ConvertRegionPrices.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [convert region prices monetization](MonetizationConvertRegionPriceCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ConvertRegionPricesResponse {
/// Converted other regions prices in USD and EUR, to use for countries where Play doesn't support a country's local currency.
#[serde(rename = "convertedOtherRegionsPrice")]
pub converted_other_regions_price: Option<ConvertedOtherRegionsPrice>,
/// Map from region code to converted region price.
#[serde(rename = "convertedRegionPrices")]
pub converted_region_prices: Option<HashMap<String, ConvertedRegionPrice>>,
/// The region version at which the prices were generated.
#[serde(rename = "regionVersion")]
pub region_version: Option<RegionsVersion>,
}
impl common::ResponseResult for ConvertRegionPricesResponse {}
/// Converted other regions prices.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ConvertedOtherRegionsPrice {
/// Price in EUR to use for the "Other regions" location exclusive of taxes.
#[serde(rename = "eurPrice")]
pub eur_price: Option<Money>,
/// Price in USD to use for the "Other regions" location exclusive of taxes.
#[serde(rename = "usdPrice")]
pub usd_price: Option<Money>,
}
impl common::Part for ConvertedOtherRegionsPrice {}
/// A converted region price.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ConvertedRegionPrice {
/// The converted price tax inclusive.
pub price: Option<Money>,
/// The region code of the region.
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
/// The tax amount of the converted price.
#[serde(rename = "taxAmount")]
pub tax_amount: Option<Money>,
}
impl common::Part for ConvertedRegionPrice {}
/// Country targeting specification.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CountryTargeting {
/// Countries to target, specified as two letter [CLDR codes](https://unicode.org/cldr/charts/latest/supplemental/territory_containment_un_m_49.html).
pub countries: Option<Vec<String>>,
/// Include "rest of world" as well as explicitly targeted countries.
#[serde(rename = "includeRestOfWorld")]
pub include_rest_of_world: Option<bool>,
}
impl common::Part for CountryTargeting {}
/// Request message for CreateDraftAppRecovery.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [create apprecovery](ApprecoveryCreateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CreateDraftAppRecoveryRequest {
/// Action type is remote in-app update. As a consequence of this action, a downloadable recovery module is also created for testing purposes.
#[serde(rename = "remoteInAppUpdate")]
pub remote_in_app_update: Option<RemoteInAppUpdate>,
/// Specifies targeting criteria for the recovery action such as regions, android sdk versions, app versions etc.
pub targeting: Option<Targeting>,
}
impl common::RequestValue for CreateDraftAppRecoveryRequest {}
/// Request message for DeactivateBasePlan.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans deactivate monetization](MonetizationSubscriptionBasePlanDeactivateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeactivateBasePlanRequest {
/// Required. The unique base plan ID of the base plan to deactivate.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The parent app (package name) of the base plan to deactivate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent subscription (ID) of the base plan to deactivate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::RequestValue for DeactivateBasePlanRequest {}
/// Request message for DeactivateOneTimeProductOffer.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers deactivate monetization](MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeactivateOneTimeProductOfferRequest {
/// Optional. The latency tolerance for the propagation of this update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The offer ID of the offer to deactivate.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to deactivate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the offer to deactivate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The parent purchase option (ID) of the offer to deactivate.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::RequestValue for DeactivateOneTimeProductOfferRequest {}
/// Request message for UpdatePurchaseOptionState.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeactivatePurchaseOptionRequest {
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The parent app (package name) of the purchase option to deactivate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the purchase option to deactivate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The purchase option ID of the purchase option to deactivate.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::Part for DeactivatePurchaseOptionRequest {}
/// Request message for DeactivateSubscriptionOffer.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers deactivate monetization](MonetizationSubscriptionBasePlanOfferDeactivateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeactivateSubscriptionOfferRequest {
/// Required. The parent base plan (ID) of the offer to deactivate.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The unique offer ID of the offer to deactivate.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to deactivate.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent subscription (ID) of the offer to deactivate.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::RequestValue for DeactivateSubscriptionOfferRequest {}
/// Information related to deferred item replacement.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeferredItemRemoval {
_never_set: Option<bool>,
}
impl common::Part for DeferredItemRemoval {}
/// Information related to deferred item replacement.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeferredItemReplacement {
/// The product_id going to replace the existing product_id.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::Part for DeferredItemReplacement {}
/// Request message for deleting an one-time product offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeleteOneTimeProductOfferRequest {
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The unique offer ID of the offer to delete.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to delete.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the offer to delete.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The parent purchase option (ID) of the offer to delete.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::Part for DeleteOneTimeProductOfferRequest {}
/// Request message for deleting a one-time product.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeleteOneTimeProductRequest {
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The parent app (package name) of the one-time product to delete.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The one-time product ID of the one-time product to delete.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::Part for DeleteOneTimeProductRequest {}
/// Request message for deleting a purchase option.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeletePurchaseOptionRequest {
/// Optional. This field has no effect for purchase options with no offers under them. For purchase options with associated offers: * If `force` is set to false (default), an error will be returned. * If `force` is set to true, any associated offers under the purchase option will be deleted.
pub force: Option<bool>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The parent app (package name) of the purchase option to delete.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the purchase option to delete.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The purchase option ID of the purchase option to delete.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::Part for DeletePurchaseOptionRequest {}
/// Represents a deobfuscation file.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeobfuscationFile {
/// The type of the deobfuscation file.
#[serde(rename = "symbolType")]
pub symbol_type: Option<String>,
}
impl common::Part for DeobfuscationFile {}
/// Responses for the upload.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [deobfuscationfiles upload edits](EditDeobfuscationfileUploadCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeobfuscationFilesUploadResponse {
/// The uploaded Deobfuscation File configuration.
#[serde(rename = "deobfuscationFile")]
pub deobfuscation_file: Option<DeobfuscationFile>,
}
impl common::ResponseResult for DeobfuscationFilesUploadResponse {}
/// Request message for DeployAppRecovery.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [deploy apprecovery](ApprecoveryDeployCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeployAppRecoveryRequest {
_never_set: Option<bool>,
}
impl common::RequestValue for DeployAppRecoveryRequest {}
/// Response message for DeployAppRecovery.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [deploy apprecovery](ApprecoveryDeployCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeployAppRecoveryResponse {
_never_set: Option<bool>,
}
impl common::ResponseResult for DeployAppRecoveryResponse {}
/// Developer entry from conversation between user and developer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeveloperComment {
/// The last time at which this comment was updated.
#[serde(rename = "lastModified")]
pub last_modified: Option<Timestamp>,
/// The content of the comment, i.e. reply body.
pub text: Option<String>,
}
impl common::Part for DeveloperComment {}
/// Information specific to cancellations initiated by developers.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeveloperInitiatedCancellation {
_never_set: Option<bool>,
}
impl common::Part for DeveloperInitiatedCancellation {}
/// Represents a device feature.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceFeature {
/// Name of the feature.
#[serde(rename = "featureName")]
pub feature_name: Option<String>,
/// The feature version specified by android:glEsVersion or android:version in in the AndroidManifest.
#[serde(rename = "featureVersion")]
pub feature_version: Option<i32>,
}
impl common::Part for DeviceFeature {}
/// Targeting for a device feature.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceFeatureTargeting {
/// Feature of the device.
#[serde(rename = "requiredFeature")]
pub required_feature: Option<DeviceFeature>,
}
impl common::Part for DeviceFeatureTargeting {}
/// A group of devices. A group is defined by a set of device selectors. A device belongs to the group if it matches any selector (logical OR).
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceGroup {
/// Device selectors for this group. A device matching any of the selectors is included in this group.
#[serde(rename = "deviceSelectors")]
pub device_selectors: Option<Vec<DeviceSelector>>,
/// The name of the group.
pub name: Option<String>,
}
impl common::Part for DeviceGroup {}
/// Identifier of a device.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceId {
/// Value of Build.BRAND.
#[serde(rename = "buildBrand")]
pub build_brand: Option<String>,
/// Value of Build.DEVICE.
#[serde(rename = "buildDevice")]
pub build_device: Option<String>,
}
impl common::Part for DeviceId {}
/// Characteristics of the user's device.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceMetadata {
/// Device CPU make, e.g. "Qualcomm"
#[serde(rename = "cpuMake")]
pub cpu_make: Option<String>,
/// Device CPU model, e.g. "MSM8974"
#[serde(rename = "cpuModel")]
pub cpu_model: Option<String>,
/// Device class (e.g. tablet)
#[serde(rename = "deviceClass")]
pub device_class: Option<String>,
/// OpenGL version
#[serde(rename = "glEsVersion")]
pub gl_es_version: Option<i32>,
/// Device manufacturer (e.g. Motorola)
pub manufacturer: Option<String>,
/// Comma separated list of native platforms (e.g. "arm", "arm7")
#[serde(rename = "nativePlatform")]
pub native_platform: Option<String>,
/// Device model name (e.g. Droid)
#[serde(rename = "productName")]
pub product_name: Option<String>,
/// Device RAM in Megabytes, e.g. "2048"
#[serde(rename = "ramMb")]
pub ram_mb: Option<i32>,
/// Screen density in DPI
#[serde(rename = "screenDensityDpi")]
pub screen_density_dpi: Option<i32>,
/// Screen height in pixels
#[serde(rename = "screenHeightPx")]
pub screen_height_px: Option<i32>,
/// Screen width in pixels
#[serde(rename = "screenWidthPx")]
pub screen_width_px: Option<i32>,
}
impl common::Part for DeviceMetadata {}
/// Conditions about a device's RAM capabilities.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceRam {
/// Maximum RAM in bytes (bound excluded).
#[serde(rename = "maxBytes")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub max_bytes: Option<i64>,
/// Minimum RAM in bytes (bound included).
#[serde(rename = "minBytes")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub min_bytes: Option<i64>,
}
impl common::Part for DeviceRam {}
/// Selector for a device group. A selector consists of a set of conditions on the device that should all match (logical AND) to determine a device group eligibility. For instance, if a selector specifies RAM conditions, device model inclusion and device model exclusion, a device is considered to match if: device matches RAM conditions AND device matches one of the included device models AND device doesn't match excluded device models
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceSelector {
/// Conditions on the device's RAM.
#[serde(rename = "deviceRam")]
pub device_ram: Option<DeviceRam>,
/// Device models excluded by this selector, even if they match all other conditions.
#[serde(rename = "excludedDeviceIds")]
pub excluded_device_ids: Option<Vec<DeviceId>>,
/// A device that has any of these system features is excluded by this selector, even if it matches all other conditions.
#[serde(rename = "forbiddenSystemFeatures")]
pub forbidden_system_features: Option<Vec<SystemFeature>>,
/// Device models included by this selector.
#[serde(rename = "includedDeviceIds")]
pub included_device_ids: Option<Vec<DeviceId>>,
/// A device needs to have all these system features to be included by the selector.
#[serde(rename = "requiredSystemFeatures")]
pub required_system_features: Option<Vec<SystemFeature>>,
/// Optional. The SoCs included by this selector. Only works for Android S+ devices.
#[serde(rename = "systemOnChips")]
pub system_on_chips: Option<Vec<SystemOnChip>>,
}
impl common::Part for DeviceSelector {}
/// The device spec used to generate a system APK.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceSpec {
/// Screen dpi.
#[serde(rename = "screenDensity")]
pub screen_density: Option<u32>,
/// Supported ABI architectures in the order of preference. The values should be the string as reported by the platform, e.g. "armeabi-v7a", "x86_64".
#[serde(rename = "supportedAbis")]
pub supported_abis: Option<Vec<String>>,
/// All installed locales represented as BCP-47 strings, e.g. "en-US".
#[serde(rename = "supportedLocales")]
pub supported_locales: Option<Vec<String>>,
}
impl common::Part for DeviceSpec {}
/// A single device tier. Devices matching any of the device groups in device_group_names are considered to match the tier.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceTier {
/// Groups of devices included in this tier. These groups must be defined explicitly under device_groups in this configuration.
#[serde(rename = "deviceGroupNames")]
pub device_group_names: Option<Vec<String>>,
/// The priority level of the tier. Tiers are evaluated in descending order of level: the highest level tier has the highest priority. The highest tier matching a given device is selected for that device. You should use a contiguous range of levels for your tiers in a tier set; tier levels in a tier set must be unique. For instance, if your tier set has 4 tiers (including the global fallback), you should define tiers 1, 2 and 3 in this configuration. Note: tier 0 is implicitly defined as a global fallback and selected for devices that don't match any of the tiers explicitly defined here. You mustn't define level 0 explicitly in this configuration.
pub level: Option<i32>,
}
impl common::Part for DeviceTier {}
/// Configuration describing device targeting criteria for the content of an app.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [device tier configs create applications](ApplicationDeviceTierConfigCreateCall) (request|response)
/// * [device tier configs get applications](ApplicationDeviceTierConfigGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceTierConfig {
/// Definition of device groups for the app.
#[serde(rename = "deviceGroups")]
pub device_groups: Option<Vec<DeviceGroup>>,
/// Output only. The device tier config ID.
#[serde(rename = "deviceTierConfigId")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub device_tier_config_id: Option<i64>,
/// Definition of the set of device tiers for the app.
#[serde(rename = "deviceTierSet")]
pub device_tier_set: Option<DeviceTierSet>,
/// Definition of user country sets for the app.
#[serde(rename = "userCountrySets")]
pub user_country_sets: Option<Vec<UserCountrySet>>,
}
impl common::RequestValue for DeviceTierConfig {}
impl common::ResponseResult for DeviceTierConfig {}
/// A set of device tiers. A tier set determines what variation of app content gets served to a specific device, for device-targeted content. You should assign a priority level to each tier, which determines the ordering by which they are evaluated by Play. See the documentation of DeviceTier.level for more details.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DeviceTierSet {
/// Device tiers belonging to the set.
#[serde(rename = "deviceTiers")]
pub device_tiers: Option<Vec<DeviceTier>>,
}
impl common::Part for DeviceTierSet {}
/// An expansion file. The resource for ExpansionFilesService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [expansionfiles get edits](EditExpansionfileGetCall) (response)
/// * [expansionfiles patch edits](EditExpansionfilePatchCall) (request|response)
/// * [expansionfiles update edits](EditExpansionfileUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExpansionFile {
/// 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.
#[serde(rename = "fileSize")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub file_size: Option<i64>,
/// If set, this APK's expansion file references another APK's expansion file. The file_size field will not be set.
#[serde(rename = "referencesVersion")]
pub references_version: Option<i32>,
}
impl common::RequestValue for ExpansionFile {}
impl common::ResponseResult for ExpansionFile {}
/// Response for uploading an expansion file.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [expansionfiles upload edits](EditExpansionfileUploadCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExpansionFilesUploadResponse {
/// The uploaded expansion file configuration.
#[serde(rename = "expansionFile")]
pub expansion_file: Option<ExpansionFile>,
}
impl common::ResponseResult for ExpansionFilesUploadResponse {}
/// User account identifier in the third-party service.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternalAccountIdentifiers {
/// User account identifier in the third-party service. Only present if account linking happened as part of the subscription purchase flow.
#[serde(rename = "externalAccountId")]
pub external_account_id: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's account in your app. Present for the following purchases: * If account linking happened as part of the subscription purchase flow. * It was specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedaccountid when the purchase was made.
#[serde(rename = "obfuscatedExternalAccountId")]
pub obfuscated_external_account_id: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's profile in your app. Only present if specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid when the purchase was made.
#[serde(rename = "obfuscatedExternalProfileId")]
pub obfuscated_external_profile_id: Option<String>,
}
impl common::Part for ExternalAccountIdentifiers {}
/// User account identifier in your app.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternalAccountIds {
/// Optional. Specifies an optional obfuscated string that is uniquely associated with the purchaser's user account in your app. If you pass this value, Google Play can use it to detect irregular activity. Do not use this field to store any Personally Identifiable Information (PII) such as emails in cleartext. Attempting to store PII in this field will result in purchases being blocked. Google Play recommends that you use either encryption or a one-way hash to generate an obfuscated identifier to send to Google Play. This identifier is limited to 64 characters. This field can only be set for resubscription purchases. See https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedaccountid to set this field for purchases made using the standard in-app billing flow.
#[serde(rename = "obfuscatedAccountId")]
pub obfuscated_account_id: Option<String>,
/// Optional. Specifies an optional obfuscated string that is uniquely associated with the purchaser's user profile in your app. If you pass this value, Google Play can use it to detect irregular activity. Do not use this field to store any Personally Identifiable Information (PII) such as emails in cleartext. Attempting to store PII in this field will result in purchases being blocked. Google Play recommends that you use either encryption or a one-way hash to generate an obfuscated identifier to send to Google Play. This identifier is limited to 64 characters. This field can only be set for resubscription purchases. See https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid to set this field for purchases made using the standard in-app billing flow.
#[serde(rename = "obfuscatedProfileId")]
pub obfuscated_profile_id: Option<String>,
}
impl common::Part for ExternalAccountIds {}
/// Reporting details unique to the external offers program.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternalOfferDetails {
/// Optional. The external transaction id associated with the app download event through an external link. Required when reporting transactions made in externally installed apps.
#[serde(rename = "appDownloadEventExternalTransactionId")]
pub app_download_event_external_transaction_id: Option<String>,
/// Optional. The category of the downloaded app though this transaction. This must match the category provided in Play Console during the external app verification process. Only required for app downloads.
#[serde(rename = "installedAppCategory")]
pub installed_app_category: Option<String>,
/// Optional. The package name of the app downloaded through this transaction. Required when link_type is LINK_TO_APP_DOWNLOAD.
#[serde(rename = "installedAppPackage")]
pub installed_app_package: Option<String>,
/// Optional. The type of content being reported by this transaction. Required when reporting app downloads or purchased digital content offers made in app installed through Google Play.
#[serde(rename = "linkType")]
pub link_type: Option<String>,
}
impl common::Part for ExternalOfferDetails {}
/// Details of an external subscription.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternalSubscription {
/// Required. The type of the external subscription.
#[serde(rename = "subscriptionType")]
pub subscription_type: Option<String>,
}
impl common::Part for ExternalSubscription {}
/// The details of an external transaction.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [createexternaltransaction externaltransactions](ExternaltransactionCreateexternaltransactionCall) (request|response)
/// * [getexternaltransaction externaltransactions](ExternaltransactionGetexternaltransactionCall) (response)
/// * [refundexternaltransaction externaltransactions](ExternaltransactionRefundexternaltransactionCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternalTransaction {
/// Output only. The time when this transaction was created. This is the time when Google was notified of the transaction.
#[serde(rename = "createTime")]
pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Output only. The current transaction amount before tax. This represents the current pre-tax amount including any refunds that may have been applied to this transaction.
#[serde(rename = "currentPreTaxAmount")]
pub current_pre_tax_amount: Option<Price>,
/// Output only. The current tax amount. This represents the current tax amount including any refunds that may have been applied to this transaction.
#[serde(rename = "currentTaxAmount")]
pub current_tax_amount: Option<Price>,
/// Optional. Details necessary to accurately report external offers transactions.
#[serde(rename = "externalOfferDetails")]
pub external_offer_details: Option<ExternalOfferDetails>,
/// Output only. The id of this transaction. All transaction ids under the same package name must be unique. Set when creating the external transaction.
#[serde(rename = "externalTransactionId")]
pub external_transaction_id: Option<String>,
/// This is a one-time transaction and not part of a subscription.
#[serde(rename = "oneTimeTransaction")]
pub one_time_transaction: Option<OneTimeExternalTransaction>,
/// Required. The original transaction amount before taxes. This represents the pre-tax amount originally notified to Google before any refunds were applied.
#[serde(rename = "originalPreTaxAmount")]
pub original_pre_tax_amount: Option<Price>,
/// Required. The original tax amount. This represents the tax amount originally notified to Google before any refunds were applied.
#[serde(rename = "originalTaxAmount")]
pub original_tax_amount: Option<Price>,
/// Output only. The resource name of the external transaction. The package name of the application the inapp products were sold (for example, 'com.some.app').
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// This transaction is part of a recurring series of transactions.
#[serde(rename = "recurringTransaction")]
pub recurring_transaction: Option<RecurringExternalTransaction>,
/// Output only. If set, this transaction was a test purchase. Google will not charge for a test transaction.
#[serde(rename = "testPurchase")]
pub test_purchase: Option<ExternalTransactionTestPurchase>,
/// Optional. The transaction program code, used to help determine service fee for eligible apps participating in partner programs. Developers participating in the Play Media Experience Program (https://play.google.com/console/about/programs/mediaprogram/) must provide the program code when reporting alternative billing transactions. If you are an eligible developer, please contact your BDM for more information on how to set this field. Note: this field can not be used for external offers transactions.
#[serde(rename = "transactionProgramCode")]
pub transaction_program_code: Option<i32>,
/// Output only. The current state of the transaction.
#[serde(rename = "transactionState")]
pub transaction_state: Option<String>,
/// Required. The time when the transaction was completed.
#[serde(rename = "transactionTime")]
pub transaction_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Required. User address for tax computation.
#[serde(rename = "userTaxAddress")]
pub user_tax_address: Option<ExternalTransactionAddress>,
}
impl common::RequestValue for ExternalTransaction {}
impl common::Resource for ExternalTransaction {}
impl common::ResponseResult for ExternalTransaction {}
/// User's address for the external transaction.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternalTransactionAddress {
/// Optional. Top-level administrative subdivision of the country/region. Only required for transactions in India. Valid values are "ANDAMAN AND NICOBAR ISLANDS", "ANDHRA PRADESH", "ARUNACHAL PRADESH", "ASSAM", "BIHAR", "CHANDIGARH", "CHHATTISGARH", "DADRA AND NAGAR HAVELI", "DADRA AND NAGAR HAVELI AND DAMAN AND DIU", "DAMAN AND DIU", "DELHI", "GOA", "GUJARAT", "HARYANA", "HIMACHAL PRADESH", "JAMMU AND KASHMIR", "JHARKHAND", "KARNATAKA", "KERALA", "LADAKH", "LAKSHADWEEP", "MADHYA PRADESH", "MAHARASHTRA", "MANIPUR", "MEGHALAYA", "MIZORAM", "NAGALAND", "ODISHA", "PUDUCHERRY", "PUNJAB", "RAJASTHAN", "SIKKIM", "TAMIL NADU", "TELANGANA", "TRIPURA", "UTTAR PRADESH", "UTTARAKHAND", and "WEST BENGAL".
#[serde(rename = "administrativeArea")]
pub administrative_area: Option<String>,
/// Required. Two letter region code based on ISO-3166-1 Alpha-2 (UN region codes).
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
}
impl common::Part for ExternalTransactionAddress {}
/// Represents a transaction performed using a test account. These transactions will not be charged by Google.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternalTransactionTestPurchase {
_never_set: Option<bool>,
}
impl common::Part for ExternalTransactionTestPurchase {}
/// Defines an APK available for this application that is hosted externally and not uploaded to Google Play. This function is only available to organizations using Managed Play whose application is configured to restrict distribution to the organizations.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ExternallyHostedApk {
/// The application label.
#[serde(rename = "applicationLabel")]
pub application_label: Option<String>,
/// A certificate (or array of certificates if a certificate-chain is used) used to sign this APK, represented as a base64 encoded byte array.
#[serde(rename = "certificateBase64s")]
pub certificate_base64s: Option<Vec<String>>,
/// The URL at which the APK is hosted. This must be an https URL.
#[serde(rename = "externallyHostedUrl")]
pub externally_hosted_url: Option<String>,
/// The sha1 checksum of this APK, represented as a base64 encoded byte array.
#[serde(rename = "fileSha1Base64")]
pub file_sha1_base64: Option<String>,
/// The sha256 checksum of this APK, represented as a base64 encoded byte array.
#[serde(rename = "fileSha256Base64")]
pub file_sha256_base64: Option<String>,
/// The file size in bytes of this APK.
#[serde(rename = "fileSize")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub file_size: Option<i64>,
/// The icon image from the APK, as a base64 encoded byte array.
#[serde(rename = "iconBase64")]
pub icon_base64: Option<String>,
/// The maximum SDK supported by this APK (optional).
#[serde(rename = "maximumSdk")]
pub maximum_sdk: Option<i32>,
/// The minimum SDK targeted by this APK.
#[serde(rename = "minimumSdk")]
pub minimum_sdk: Option<i32>,
/// The native code environments supported by this APK (optional).
#[serde(rename = "nativeCodes")]
pub native_codes: Option<Vec<String>>,
/// The package name.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// The features required by this APK (optional).
#[serde(rename = "usesFeatures")]
pub uses_features: Option<Vec<String>>,
/// The permissions requested by this APK.
#[serde(rename = "usesPermissions")]
pub uses_permissions: Option<Vec<UsesPermission>>,
/// The version code of this APK.
#[serde(rename = "versionCode")]
pub version_code: Option<i32>,
/// The version name of this APK.
#[serde(rename = "versionName")]
pub version_name: Option<String>,
}
impl common::Part for ExternallyHostedApk {}
/// Details of a free trial pricing phase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct FreeTrialDetails {
_never_set: Option<bool>,
}
impl common::Part for FreeTrialDetails {}
/// A full refund of the remaining amount of a transaction.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct FullRefund {
_never_set: Option<bool>,
}
impl common::Part for FullRefund {}
/// Response to list generated APKs.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list generatedapks](GeneratedapkListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeneratedApksListResponse {
/// All generated APKs, grouped by the APK signing key.
#[serde(rename = "generatedApks")]
pub generated_apks: Option<Vec<GeneratedApksPerSigningKey>>,
}
impl common::ResponseResult for GeneratedApksListResponse {}
/// Download metadata for split, standalone and universal APKs, as well as asset pack slices, signed with a given key.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeneratedApksPerSigningKey {
/// SHA256 hash of the APK signing public key certificate.
#[serde(rename = "certificateSha256Hash")]
pub certificate_sha256_hash: Option<String>,
/// List of asset pack slices which will be served for this app bundle, signed with a key corresponding to certificate_sha256_hash.
#[serde(rename = "generatedAssetPackSlices")]
pub generated_asset_pack_slices: Option<Vec<GeneratedAssetPackSlice>>,
/// Generated recovery apks for recovery actions signed with a key corresponding to certificate_sha256_hash. This includes all generated recovery APKs, also those in draft or cancelled state. This field is not set if no recovery actions were created for this signing key.
#[serde(rename = "generatedRecoveryModules")]
pub generated_recovery_modules: Option<Vec<GeneratedRecoveryApk>>,
/// List of generated split APKs, signed with a key corresponding to certificate_sha256_hash.
#[serde(rename = "generatedSplitApks")]
pub generated_split_apks: Option<Vec<GeneratedSplitApk>>,
/// List of generated standalone APKs, signed with a key corresponding to certificate_sha256_hash.
#[serde(rename = "generatedStandaloneApks")]
pub generated_standalone_apks: Option<Vec<GeneratedStandaloneApk>>,
/// Generated universal APK, signed with a key corresponding to certificate_sha256_hash. This field is not set if no universal APK was generated for this signing key.
#[serde(rename = "generatedUniversalApk")]
pub generated_universal_apk: Option<GeneratedUniversalApk>,
/// Contains targeting information about the generated apks.
#[serde(rename = "targetingInfo")]
pub targeting_info: Option<TargetingInfo>,
}
impl common::Part for GeneratedApksPerSigningKey {}
/// Download metadata for an asset pack slice.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeneratedAssetPackSlice {
/// Download ID, which uniquely identifies the APK to download. Should be supplied to `generatedapks.download` method.
#[serde(rename = "downloadId")]
pub download_id: Option<String>,
/// Name of the module that this asset slice belongs to.
#[serde(rename = "moduleName")]
pub module_name: Option<String>,
/// Asset slice ID.
#[serde(rename = "sliceId")]
pub slice_id: Option<String>,
/// Asset module version.
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub version: Option<i64>,
}
impl common::Part for GeneratedAssetPackSlice {}
/// Download metadata for an app recovery module.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeneratedRecoveryApk {
/// Download ID, which uniquely identifies the APK to download. Should be supplied to `generatedapks.download` method.
#[serde(rename = "downloadId")]
pub download_id: Option<String>,
/// Name of the module which recovery apk belongs to.
#[serde(rename = "moduleName")]
pub module_name: Option<String>,
/// ID of the recovery action.
#[serde(rename = "recoveryId")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub recovery_id: Option<i64>,
/// The status of the recovery action corresponding to the recovery apk.
#[serde(rename = "recoveryStatus")]
pub recovery_status: Option<String>,
}
impl common::Part for GeneratedRecoveryApk {}
/// Download metadata for a split APK.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeneratedSplitApk {
/// Download ID, which uniquely identifies the APK to download. Should be supplied to `generatedapks.download` method.
#[serde(rename = "downloadId")]
pub download_id: Option<String>,
/// Name of the module that this APK belongs to.
#[serde(rename = "moduleName")]
pub module_name: Option<String>,
/// Split ID. Empty for the main split of the base module.
#[serde(rename = "splitId")]
pub split_id: Option<String>,
/// ID of the generated variant.
#[serde(rename = "variantId")]
pub variant_id: Option<i32>,
}
impl common::Part for GeneratedSplitApk {}
/// Download metadata for a standalone APK.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeneratedStandaloneApk {
/// Download ID, which uniquely identifies the APK to download. Should be supplied to `generatedapks.download` method.
#[serde(rename = "downloadId")]
pub download_id: Option<String>,
/// ID of the generated variant.
#[serde(rename = "variantId")]
pub variant_id: Option<i32>,
}
impl common::Part for GeneratedStandaloneApk {}
/// Download metadata for a universal APK.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeneratedUniversalApk {
/// Download ID, which uniquely identifies the APK to download. Should be supplied to `generatedapks.download` method.
#[serde(rename = "downloadId")]
pub download_id: Option<String>,
}
impl common::Part for GeneratedUniversalApk {}
/// Request message for GetOneTimeProductOffers.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GetOneTimeProductOfferRequest {
/// Required. The unique offer ID of the offer to get.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to get.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent one-time product (ID) of the offer to get.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The parent purchase option (ID) of the offer to get.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
}
impl common::Part for GetOneTimeProductOfferRequest {}
/// Request message for GetSubscriptionOffer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GetSubscriptionOfferRequest {
/// Required. The parent base plan (ID) of the offer to get.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Required. The unique offer ID of the offer to get.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Required. The parent app (package name) of the offer to get.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The parent subscription (ID) of the offer to get.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::Part for GetSubscriptionOfferRequest {}
/// An access grant resource.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [create grants](GrantCreateCall) (request|response)
/// * [delete grants](GrantDeleteCall) (none)
/// * [patch grants](GrantPatchCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Grant {
/// The permissions granted to the user for this app.
#[serde(rename = "appLevelPermissions")]
pub app_level_permissions: Option<Vec<String>>,
/// Required. Resource name for this grant, following the pattern "developers/{developer}/users/{email}/grants/{package_name}". If this grant is for a draft app, the app ID will be used in this resource name instead of the package name.
pub name: Option<String>,
/// Immutable. The package name of the app. This will be empty for draft apps.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
}
impl common::RequestValue for Grant {}
impl common::Resource for Grant {}
impl common::ResponseResult for Grant {}
/// An uploaded image. The resource for ImagesService.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Image {
/// A unique id representing this image.
pub id: Option<String>,
/// A sha1 hash of the image.
pub sha1: Option<String>,
/// A sha256 hash of the image.
pub sha256: Option<String>,
/// A URL that will serve a preview of the image.
pub url: Option<String>,
}
impl common::Part for Image {}
/// Response for deleting all images.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [images deleteall edits](EditImageDeleteallCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ImagesDeleteAllResponse {
/// The deleted images.
pub deleted: Option<Vec<Image>>,
}
impl common::ResponseResult for ImagesDeleteAllResponse {}
/// Response listing all images.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [images list edits](EditImageListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ImagesListResponse {
/// All listed Images.
pub images: Option<Vec<Image>>,
}
impl common::ResponseResult for ImagesListResponse {}
/// Response for uploading an image.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [images upload edits](EditImageUploadCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ImagesUploadResponse {
/// The uploaded image.
pub image: Option<Image>,
}
impl common::ResponseResult for ImagesUploadResponse {}
/// An in-app product. The resource for InappproductsService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [get inappproducts](InappproductGetCall) (response)
/// * [insert inappproducts](InappproductInsertCall) (request|response)
/// * [patch inappproducts](InappproductPatchCall) (request|response)
/// * [update inappproducts](InappproductUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InAppProduct {
/// Default language of the localized data, as defined by BCP-47. e.g. "en-US".
#[serde(rename = "defaultLanguage")]
pub default_language: Option<String>,
/// Default price. Cannot be zero, as in-app products are never free. Always in the developer's Checkout merchant currency.
#[serde(rename = "defaultPrice")]
pub default_price: Option<Price>,
/// Grace period of the subscription, specified in ISO 8601 format. Allows developers to give their subscribers a grace period when the payment for the new recurrence period is declined. Acceptable values are P0D (zero days), P3D (three days), P7D (seven days), P14D (14 days), and P30D (30 days).
#[serde(rename = "gracePeriod")]
pub grace_period: Option<String>,
/// List of localized title and description data. Map key is the language of the localized data, as defined by BCP-47, e.g. "en-US".
pub listings: Option<HashMap<String, InAppProductListing>>,
/// Details about taxes and legal compliance. Only applicable to managed products.
#[serde(rename = "managedProductTaxesAndComplianceSettings")]
pub managed_product_taxes_and_compliance_settings:
Option<ManagedProductTaxAndComplianceSettings>,
/// Package name of the parent app.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Prices per buyer region. None of these can be zero, as in-app products are never free. Map key is region code, as defined by ISO 3166-2.
pub prices: Option<HashMap<String, Price>>,
/// The type of the product, e.g. a recurring subscription.
#[serde(rename = "purchaseType")]
pub purchase_type: Option<String>,
/// Stock-keeping-unit (SKU) of the product, unique within an app.
pub sku: Option<String>,
/// The status of the product, e.g. whether it's active.
pub status: Option<String>,
/// 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).
#[serde(rename = "subscriptionPeriod")]
pub subscription_period: Option<String>,
/// Details about taxes and legal compliance. Only applicable to subscription products.
#[serde(rename = "subscriptionTaxesAndComplianceSettings")]
pub subscription_taxes_and_compliance_settings: Option<SubscriptionTaxAndComplianceSettings>,
/// Trial period, specified in ISO 8601 format. Acceptable values are anything between P7D (seven days) and P999D (999 days).
#[serde(rename = "trialPeriod")]
pub trial_period: Option<String>,
}
impl common::RequestValue for InAppProduct {}
impl common::Resource for InAppProduct {}
impl common::ResponseResult for InAppProduct {}
/// Store listing of a single in-app product.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InAppProductListing {
/// Localized entitlement benefits for a subscription.
pub benefits: Option<Vec<String>>,
/// Description for the store listing.
pub description: Option<String>,
/// Title for the store listing.
pub title: Option<String>,
}
impl common::Part for InAppProductListing {}
/// Request to delete multiple in-app products.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [batch delete inappproducts](InappproductBatchDeleteCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InappproductsBatchDeleteRequest {
/// Individual delete requests. At least one request is required. Can contain up to 100 requests. All requests must correspond to different in-app products.
pub requests: Option<Vec<InappproductsDeleteRequest>>,
}
impl common::RequestValue for InappproductsBatchDeleteRequest {}
/// Response message for BatchGetSubscriptions endpoint.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [batch get inappproducts](InappproductBatchGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InappproductsBatchGetResponse {
/// The list of requested in-app products, in the same order as the request.
pub inappproduct: Option<Vec<InAppProduct>>,
}
impl common::ResponseResult for InappproductsBatchGetResponse {}
/// Request to update or insert one or more in-app products.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [batch update inappproducts](InappproductBatchUpdateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InappproductsBatchUpdateRequest {
/// Required. Individual update requests. At least one request is required. Can contain up to 100 requests. All requests must correspond to different in-app products.
pub requests: Option<Vec<InappproductsUpdateRequest>>,
}
impl common::RequestValue for InappproductsBatchUpdateRequest {}
/// Response for a batch in-app product update.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [batch update inappproducts](InappproductBatchUpdateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InappproductsBatchUpdateResponse {
/// The updated or inserted in-app products.
pub inappproducts: Option<Vec<InAppProduct>>,
}
impl common::ResponseResult for InappproductsBatchUpdateResponse {}
/// Request to delete an in-app product.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InappproductsDeleteRequest {
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Package name of the app.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Unique identifier for the in-app product.
pub sku: Option<String>,
}
impl common::Part for InappproductsDeleteRequest {}
/// Response listing all in-app products.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list inappproducts](InappproductListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InappproductsListResponse {
/// All in-app products.
pub inappproduct: Option<Vec<InAppProduct>>,
/// The kind of this response ("androidpublisher#inappproductsListResponse").
pub kind: Option<String>,
/// Deprecated and unset.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// Pagination token, to handle a number of products that is over one page.
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
}
impl common::ResponseResult for InappproductsListResponse {}
/// Request to update an in-app product.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InappproductsUpdateRequest {
/// If set to true, and the in-app product with the given package_name and sku doesn't exist, the in-app product will be created.
#[serde(rename = "allowMissing")]
pub allow_missing: Option<bool>,
/// 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.
#[serde(rename = "autoConvertMissingPrices")]
pub auto_convert_missing_prices: Option<bool>,
/// The new in-app product.
pub inappproduct: Option<InAppProduct>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Package name of the app.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Unique identifier for the in-app product.
pub sku: Option<String>,
}
impl common::Part for InappproductsUpdateRequest {}
/// Information to a installment plan.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InstallmentPlan {
/// Total number of payments the user is initially committed for.
#[serde(rename = "initialCommittedPaymentsCount")]
pub initial_committed_payments_count: Option<i32>,
/// If present, this installment plan is pending to be canceled. The cancellation will happen only after the user finished all committed payments.
#[serde(rename = "pendingCancellation")]
pub pending_cancellation: Option<PendingCancellation>,
/// Total number of committed payments remaining to be paid for in this renewal cycle.
#[serde(rename = "remainingCommittedPaymentsCount")]
pub remaining_committed_payments_count: Option<i32>,
/// Total number of payments the user will be committed for after each commitment period. Empty means the installment plan will fall back to a normal auto-renew subscription after initial commitment.
#[serde(rename = "subsequentCommittedPaymentsCount")]
pub subsequent_committed_payments_count: Option<i32>,
}
impl common::Part for InstallmentPlan {}
/// Represents an installments base plan where a user commits to a specified number of payments.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InstallmentsBasePlanType {
/// Optional. Custom account hold period of the subscription, specified in ISO 8601 format. Acceptable values must be in days and between P0D and P60D. An empty field represents a recommended account hold, calculated as 60 days minus grace period. The sum of gracePeriodDuration and accountHoldDuration must be between P30D and P60D days, inclusive.
#[serde(rename = "accountHoldDuration")]
pub account_hold_duration: Option<String>,
/// Required. Immutable. Subscription period, specified in ISO 8601 format. For a list of acceptable billing periods, refer to the help center. The duration is immutable after the base plan is created.
#[serde(rename = "billingPeriodDuration")]
pub billing_period_duration: Option<String>,
/// Required. Immutable. The number of payments the user is committed to. It is immutable after the base plan is created.
#[serde(rename = "committedPaymentsCount")]
pub committed_payments_count: Option<i32>,
/// Grace period of the subscription, specified in ISO 8601 format. Acceptable values must be in days and between P0D and the lesser of 30D and base plan billing period. If not specified, a default value will be used based on the billing period. The sum of gracePeriodDuration and accountHoldDuration must be between P30D and P60D days, inclusive.
#[serde(rename = "gracePeriodDuration")]
pub grace_period_duration: Option<String>,
/// The proration mode for the base plan determines what happens when a user switches to this plan from another base plan. If unspecified, defaults to CHARGE_ON_NEXT_BILLING_DATE.
#[serde(rename = "prorationMode")]
pub proration_mode: Option<String>,
/// Required. Immutable. Installments base plan renewal type. Determines the behavior at the end of the initial commitment. The renewal type is immutable after the base plan is created.
#[serde(rename = "renewalType")]
pub renewal_type: Option<String>,
/// Whether users should be able to resubscribe to this base plan in Google Play surfaces. Defaults to RESUBSCRIBE_STATE_ACTIVE if not specified.
#[serde(rename = "resubscribeState")]
pub resubscribe_state: Option<String>,
}
impl common::Part for InstallmentsBasePlanType {}
/// An artifact resource which gets created when uploading an APK or Android App Bundle through internal app sharing.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [uploadapk internalappsharingartifacts](InternalappsharingartifactUploadapkCall) (response)
/// * [uploadbundle internalappsharingartifacts](InternalappsharingartifactUploadbundleCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InternalAppSharingArtifact {
/// The sha256 fingerprint of the certificate used to sign the generated artifact.
#[serde(rename = "certificateFingerprint")]
pub certificate_fingerprint: Option<String>,
/// The download URL generated for the uploaded artifact. Users that are authorized to download can follow the link to the Play Store app to install it.
#[serde(rename = "downloadUrl")]
pub download_url: Option<String>,
/// The sha256 hash of the artifact represented as a lowercase hexadecimal number, matching the output of the sha256sum command.
pub sha256: Option<String>,
}
impl common::Resource for InternalAppSharingArtifact {}
impl common::ResponseResult for InternalAppSharingArtifact {}
/// Details of an introductory price pricing phase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct IntroductoryPriceDetails {
_never_set: Option<bool>,
}
impl common::Part for IntroductoryPriceDetails {}
/// Contains the introductory price information for a subscription.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct IntroductoryPriceInfo {
/// Introductory price of the subscription, not including tax. The currency is the same as price_currency_code. 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.
#[serde(rename = "introductoryPriceAmountMicros")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub introductory_price_amount_micros: Option<i64>,
/// ISO 4217 currency code for the introductory subscription price. For example, if the price is specified in British pounds sterling, price_currency_code is "GBP".
#[serde(rename = "introductoryPriceCurrencyCode")]
pub introductory_price_currency_code: Option<String>,
/// The number of billing period to offer introductory pricing.
#[serde(rename = "introductoryPriceCycles")]
pub introductory_price_cycles: Option<i32>,
/// Introductory price period, specified in ISO 8601 format. Common values are (but not limited to) "P1W" (one week), "P1M" (one month), "P3M" (three months), "P6M" (six months), and "P1Y" (one year).
#[serde(rename = "introductoryPricePeriod")]
pub introductory_price_period: Option<String>,
}
impl common::Part for IntroductoryPriceInfo {}
/// Details about a subscription line item that is being replaced.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ItemReplacement {
/// The base plan ID of the subscription line item being replaced.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// The offer ID of the subscription line item being replaced, if applicable.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// The product ID of the subscription line item being replaced.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// The replacement mode applied during the purchase.
#[serde(rename = "replacementMode")]
pub replacement_mode: Option<String>,
}
impl common::Part for ItemReplacement {}
/// Targeting based on language.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LanguageTargeting {
/// Alternative languages.
pub alternatives: Option<Vec<String>>,
/// ISO-639: 2 or 3 letter language code.
pub value: Option<Vec<String>>,
}
impl common::Part for LanguageTargeting {}
/// Details of a line item.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LineItem {
/// Item's listed price on Play Store, this may or may not include tax. Excludes any discounts or promotions.
#[serde(rename = "listingPrice")]
pub listing_price: Option<Money>,
/// Details of a one-time purchase.
#[serde(rename = "oneTimePurchaseDetails")]
pub one_time_purchase_details: Option<OneTimePurchaseDetails>,
/// Details of a paid app purchase.
#[serde(rename = "paidAppDetails")]
pub paid_app_details: Option<PaidAppDetails>,
/// The purchased product ID or in-app SKU (for example, 'monthly001' or 'com.some.thing.inapp1').
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Developer-specified name of the product. Displayed in buyer's locale. Example: coins, monthly subscription, etc.
#[serde(rename = "productTitle")]
pub product_title: Option<String>,
/// Details of a subscription purchase.
#[serde(rename = "subscriptionDetails")]
pub subscription_details: Option<SubscriptionDetails>,
/// The tax paid for this line item.
pub tax: Option<Money>,
/// The total amount paid by the user for this line item, taking into account discounts and tax.
pub total: Option<Money>,
}
impl common::Part for LineItem {}
/// Response message for ListAppRecoveries. – api-linter: core::0158::response-next-page-token-field=disabled
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list apprecovery](ApprecoveryListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListAppRecoveriesResponse {
/// List of recovery actions associated with the requested package name.
#[serde(rename = "recoveryActions")]
pub recovery_actions: Option<Vec<AppRecoveryAction>>,
}
impl common::ResponseResult for ListAppRecoveriesResponse {}
/// Response listing existing device tier configs.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [device tier configs list applications](ApplicationDeviceTierConfigListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListDeviceTierConfigsResponse {
/// Device tier configs created by the developer.
#[serde(rename = "deviceTierConfigs")]
pub device_tier_configs: Option<Vec<DeviceTierConfig>>,
/// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
}
impl common::ResponseResult for ListDeviceTierConfigsResponse {}
/// Response message for ListOneTimeProductOffers.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers list monetization](MonetizationOnetimeproductPurchaseOptionOfferListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListOneTimeProductOffersResponse {
/// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
/// The one_time_product offers from the specified request.
#[serde(rename = "oneTimeProductOffers")]
pub one_time_product_offers: Option<Vec<OneTimeProductOffer>>,
}
impl common::ResponseResult for ListOneTimeProductOffersResponse {}
/// Response message for ListOneTimeProducts.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts list monetization](MonetizationOnetimeproductListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListOneTimeProductsResponse {
/// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
/// The one-time products from the specified app.
#[serde(rename = "oneTimeProducts")]
pub one_time_products: Option<Vec<OneTimeProduct>>,
}
impl common::ResponseResult for ListOneTimeProductsResponse {}
/// Response message for ListSubscriptionOffers.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers list monetization](MonetizationSubscriptionBasePlanOfferListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListSubscriptionOffersResponse {
/// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
/// The subscription offers from the specified subscription.
#[serde(rename = "subscriptionOffers")]
pub subscription_offers: Option<Vec<SubscriptionOffer>>,
}
impl common::ResponseResult for ListSubscriptionOffersResponse {}
/// Response message for ListSubscriptions.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions list monetization](MonetizationSubscriptionListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListSubscriptionsResponse {
/// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
/// The subscriptions from the specified app.
pub subscriptions: Option<Vec<Subscription>>,
}
impl common::ResponseResult for ListSubscriptionsResponse {}
/// A response containing one or more users with access to an account.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list users](UserListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListUsersResponse {
/// A token to pass to subsequent calls in order to retrieve subsequent results. This will not be set if there are no more results to return.
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
/// The resulting users.
pub users: Option<Vec<User>>,
}
impl common::ResponseResult for ListUsersResponse {}
/// A localized store listing. The resource for ListingsService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [listings get edits](EditListingGetCall) (response)
/// * [listings patch edits](EditListingPatchCall) (request|response)
/// * [listings update edits](EditListingUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Listing {
/// Full description of the app.
#[serde(rename = "fullDescription")]
pub full_description: Option<String>,
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
pub language: Option<String>,
/// Short description of the app.
#[serde(rename = "shortDescription")]
pub short_description: Option<String>,
/// Localized title of the app.
pub title: Option<String>,
/// URL of a promotional YouTube video for the app.
pub video: Option<String>,
}
impl common::RequestValue for Listing {}
impl common::ResponseResult for Listing {}
/// Response listing all localized listings.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [listings list edits](EditListingListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ListingsListResponse {
/// The kind of this response ("androidpublisher#listingsListResponse").
pub kind: Option<String>,
/// All localized listings.
pub listings: Option<Vec<Listing>>,
}
impl common::ResponseResult for ListingsListResponse {}
/// Localized text in given language.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LocalizedText {
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
pub language: Option<String>,
/// The text in the given language.
pub text: Option<String>,
}
impl common::Part for LocalizedText {}
/// Details about taxation and legal compliance for managed products.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ManagedProductTaxAndComplianceSettings {
/// Digital content or service classification for products distributed to users in the European Economic Area (EEA). The withdrawal regime under EEA consumer laws depends on this classification. Refer to the [Help Center article](https://support.google.com/googleplay/android-developer/answer/10463498) for more information.
#[serde(rename = "eeaWithdrawalRightType")]
pub eea_withdrawal_right_type: Option<String>,
/// Whether this in-app product is declared as a product representing a tokenized digital asset.
#[serde(rename = "isTokenizedDigitalAsset")]
pub is_tokenized_digital_asset: Option<bool>,
/// Product tax category code to assign to the in-app product. Product tax category determines the transaction tax rates applied to the product. Refer to the [Help Center article](https://support.google.com/googleplay/android-developer/answer/16408159) for more information.
#[serde(rename = "productTaxCategoryCode")]
pub product_tax_category_code: Option<String>,
/// A mapping from region code to tax rate details. The keys are region codes as defined by Unicode's "CLDR".
#[serde(rename = "taxRateInfoByRegionCode")]
pub tax_rate_info_by_region_code: Option<HashMap<String, RegionalTaxRateInfo>>,
}
impl common::Part for ManagedProductTaxAndComplianceSettings {}
/// Request message for MigrateBasePlanPrices.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans migrate prices monetization](MonetizationSubscriptionBasePlanMigratePriceCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MigrateBasePlanPricesRequest {
/// Required. The unique base plan ID of the base plan to update prices on.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. Package name of the parent app. Must be equal to the package_name field on the Subscription resource.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The ID of the subscription to update. Must be equal to the product_id field on the Subscription resource.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The regional prices to update.
#[serde(rename = "regionalPriceMigrations")]
pub regional_price_migrations: Option<Vec<RegionalPriceMigrationConfig>>,
/// Required. The version of the available regions being used for the regional_price_migrations.
#[serde(rename = "regionsVersion")]
pub regions_version: Option<RegionsVersion>,
}
impl common::RequestValue for MigrateBasePlanPricesRequest {}
/// Response message for MigrateBasePlanPrices.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans migrate prices monetization](MonetizationSubscriptionBasePlanMigratePriceCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MigrateBasePlanPricesResponse {
_never_set: Option<bool>,
}
impl common::ResponseResult for MigrateBasePlanPricesResponse {}
/// Metadata of a module.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ModuleMetadata {
/// Indicates the delivery type (e.g. on-demand) of the module.
#[serde(rename = "deliveryType")]
pub delivery_type: Option<String>,
/// Names of the modules that this module directly depends on. Each module implicitly depends on the base module.
pub dependencies: Option<Vec<String>>,
/// Indicates the type of this feature module.
#[serde(rename = "moduleType")]
pub module_type: Option<String>,
/// Module name.
pub name: Option<String>,
/// The targeting that makes a conditional module installed. Relevant only for Split APKs.
pub targeting: Option<ModuleTargeting>,
}
impl common::Part for ModuleMetadata {}
/// Targeting on the module level.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ModuleTargeting {
/// Targeting for device features.
#[serde(rename = "deviceFeatureTargeting")]
pub device_feature_targeting: Option<Vec<DeviceFeatureTargeting>>,
/// The sdk version that the variant targets
#[serde(rename = "sdkVersionTargeting")]
pub sdk_version_targeting: Option<SdkVersionTargeting>,
/// Countries-level targeting
#[serde(rename = "userCountriesTargeting")]
pub user_countries_targeting: Option<UserCountriesTargeting>,
}
impl common::Part for ModuleTargeting {}
/// Represents an amount of money with its currency type.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Money {
/// The three-letter currency code defined in ISO 4217.
#[serde(rename = "currencyCode")]
pub currency_code: Option<String>,
/// Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If `units` is positive, `nanos` must be positive or zero. If `units` is zero, `nanos` can be positive, zero, or negative. If `units` is negative, `nanos` must be negative or zero. For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
pub nanos: Option<i32>,
/// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub units: Option<i64>,
}
impl common::Part for Money {}
/// Represents a list of ABIs.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MultiAbi {
/// A list of targeted ABIs, as represented by the Android Platform
pub abi: Option<Vec<Abi>>,
}
impl common::Part for MultiAbi {}
/// Targeting based on multiple abis.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MultiAbiTargeting {
/// Targeting of other sibling directories that were in the Bundle. For main splits this is targeting of other main splits.
pub alternatives: Option<Vec<MultiAbi>>,
/// Value of a multi abi.
pub value: Option<Vec<MultiAbi>>,
}
impl common::Part for MultiAbiTargeting {}
/// Offer details information related to a purchase line item.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OfferDetails {
/// The base plan ID. Present for all base plan and offers.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// The offer ID. Only present for discounted offers.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// The latest offer tags associated with the offer. It includes tags inherited from the base plan.
#[serde(rename = "offerTags")]
pub offer_tags: Option<Vec<String>>,
}
impl common::Part for OfferDetails {}
/// Details of a pricing phase for the entitlement period funded by this order.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OfferPhaseDetails {
/// The order funds a base price period.
#[serde(rename = "baseDetails")]
pub base_details: Option<BaseDetails>,
/// The order funds a free trial period.
#[serde(rename = "freeTrialDetails")]
pub free_trial_details: Option<FreeTrialDetails>,
/// The order funds an introductory pricing period.
#[serde(rename = "introductoryPriceDetails")]
pub introductory_price_details: Option<IntroductoryPriceDetails>,
/// The order funds a proration period.
#[serde(rename = "prorationPeriodDetails")]
pub proration_period_details: Option<ProrationPeriodDetails>,
}
impl common::Part for OfferPhaseDetails {}
/// Represents a custom tag specified for a product offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OfferTag {
/// Must conform with RFC-1034. That is, this string can only contain lower-case letters (a-z), numbers (0-9), and hyphens (-), and be at most 20 characters.
pub tag: Option<String>,
}
impl common::Part for OfferTag {}
/// A single use promotion code.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeCode {
_never_set: Option<bool>,
}
impl common::Part for OneTimeCode {}
/// Represents a one-time transaction.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeExternalTransaction {
/// Input only. Provided during the call to Create. Retrieved from the client when the alternative billing flow is launched.
#[serde(rename = "externalTransactionToken")]
pub external_transaction_token: Option<String>,
}
impl common::Part for OneTimeExternalTransaction {}
/// A single one-time product for an app.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts get monetization](MonetizationOnetimeproductGetCall) (response)
/// * [onetimeproducts patch monetization](MonetizationOnetimeproductPatchCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProduct {
/// Required. Set of localized title and description data. Must not have duplicate entries with the same language_code.
pub listings: Option<Vec<OneTimeProductListing>>,
/// Optional. List of up to 20 custom tags specified for this one-time product, and returned to the app through the billing library. Purchase options and offers for this product will also receive these tags in the billing library.
#[serde(rename = "offerTags")]
pub offer_tags: Option<Vec<OfferTag>>,
/// Required. Immutable. Package name of the parent app.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. Immutable. Unique product ID of the product. Unique within the parent app. Product IDs must start with a number or lowercase letter, and can contain numbers (0-9), lowercase letters (a-z), underscores (_), and periods (.).
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The set of purchase options for this one-time product.
#[serde(rename = "purchaseOptions")]
pub purchase_options: Option<Vec<OneTimeProductPurchaseOption>>,
/// Output only. The version of the regions configuration that was used to generate the one-time product.
#[serde(rename = "regionsVersion")]
pub regions_version: Option<RegionsVersion>,
/// Optional. Countries where the purchase of this one-time product is restricted to payment methods registered in the same country. If empty, no payment location restrictions are imposed.
#[serde(rename = "restrictedPaymentCountries")]
pub restricted_payment_countries: Option<RestrictedPaymentCountries>,
/// Details about taxes and legal compliance.
#[serde(rename = "taxAndComplianceSettings")]
pub tax_and_compliance_settings: Option<OneTimeProductTaxAndComplianceSettings>,
}
impl common::RequestValue for OneTimeProduct {}
impl common::ResponseResult for OneTimeProduct {}
/// A purchase option that can be bought.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductBuyPurchaseOption {
/// Optional. Whether this purchase option will be available in legacy PBL flows that do not support one-time products model. Up to one "buy" purchase option can be marked as backwards compatible.
#[serde(rename = "legacyCompatible")]
pub legacy_compatible: Option<bool>,
/// Optional. Whether this purchase option allows multi-quantity. Multi-quantity allows buyer to purchase more than one item in a single checkout.
#[serde(rename = "multiQuantityEnabled")]
pub multi_quantity_enabled: Option<bool>,
}
impl common::Part for OneTimeProductBuyPurchaseOption {}
/// Configuration specific to discounted offers.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductDiscountedOffer {
/// Time when the offer will stop being available.
#[serde(rename = "endTime")]
pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Optional. The number of times this offer can be redeemed. If unset or set to 0, allows for unlimited offer redemptions. Otherwise must be a number between 1 and 50 inclusive.
#[serde(rename = "redemptionLimit")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub redemption_limit: Option<i64>,
/// Time when the offer will start being available.
#[serde(rename = "startTime")]
pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for OneTimeProductDiscountedOffer {}
/// Regional store listing for a one-time product.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductListing {
/// Required. The description of this product in the language of this listing. The maximum length is 200 characters.
pub description: Option<String>,
/// Required. The language of this listing, as defined by BCP-47, e.g., "en-US".
#[serde(rename = "languageCode")]
pub language_code: Option<String>,
/// Required. The title of this product in the language of this listing. The maximum length is 55 characters.
pub title: Option<String>,
}
impl common::Part for OneTimeProductListing {}
/// A single offer for a one-time product.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [onetimeproducts purchase options offers activate monetization](MonetizationOnetimeproductPurchaseOptionOfferActivateCall) (response)
/// * [onetimeproducts purchase options offers cancel monetization](MonetizationOnetimeproductPurchaseOptionOfferCancelCall) (response)
/// * [onetimeproducts purchase options offers deactivate monetization](MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductOffer {
/// A discounted offer.
#[serde(rename = "discountedOffer")]
pub discounted_offer: Option<OneTimeProductDiscountedOffer>,
/// Required. Immutable. The ID of this product offer. Must be unique within the purchase option. It must start with a number or lower-case letter, and can only contain lower-case letters (a-z), numbers (0-9), and hyphens (-). The maximum length is 63 characters.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// Optional. List of up to 20 custom tags specified for this offer, and returned to the app through the billing library.
#[serde(rename = "offerTags")]
pub offer_tags: Option<Vec<OfferTag>>,
/// Required. Immutable. The package name of the app the parent product belongs to.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// A pre-order offer.
#[serde(rename = "preOrderOffer")]
pub pre_order_offer: Option<OneTimeProductPreOrderOffer>,
/// Required. Immutable. The ID of the parent product this offer belongs to.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. Immutable. The ID of the purchase option to which this offer is an extension.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
/// Set of regional pricing and availability information for this offer. Must not have duplicate entries with the same region_code.
#[serde(rename = "regionalPricingAndAvailabilityConfigs")]
pub regional_pricing_and_availability_configs:
Option<Vec<OneTimeProductOfferRegionalPricingAndAvailabilityConfig>>,
/// Output only. The version of the regions configuration that was used to generate the one-time product offer.
#[serde(rename = "regionsVersion")]
pub regions_version: Option<RegionsVersion>,
/// Output only. The current state of this offer. This field cannot be changed by updating the resource. Use the dedicated endpoints instead.
pub state: Option<String>,
}
impl common::ResponseResult for OneTimeProductOffer {}
/// Options for one-time product offers without a regional price override.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductOfferNoPriceOverrideOptions {
_never_set: Option<bool>,
}
impl common::Part for OneTimeProductOfferNoPriceOverrideOptions {}
/// Regional pricing and availability configuration for a one-time product offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductOfferRegionalPricingAndAvailabilityConfig {
/// The absolute value of the discount that is subtracted from the purchase option price. It should be between 0 and the purchase option price.
#[serde(rename = "absoluteDiscount")]
pub absolute_discount: Option<Money>,
/// Required. The availability for this region.
pub availability: Option<String>,
/// The price defined in the purchase option for this region will be used.
#[serde(rename = "noOverride")]
pub no_override: Option<OneTimeProductOfferNoPriceOverrideOptions>,
/// Required. Region code this configuration applies to, as defined by ISO 3166-2, e.g., "US".
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
/// The fraction of the purchase option price that the user pays for this offer. For example, if the purchase option price for this region is $12, then a 50% discount would correspond to a price of $6. The discount must be specified as a fraction strictly larger than 0 and strictly smaller than 1. The resulting price will be rounded to the nearest billable unit (e.g. cents for USD). The relative discount is considered invalid if the discounted price ends up being smaller than the minimum price allowed in this region.
#[serde(rename = "relativeDiscount")]
pub relative_discount: Option<f64>,
}
impl common::Part for OneTimeProductOfferRegionalPricingAndAvailabilityConfig {}
/// Configuration specific to pre-order offers.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductPreOrderOffer {
/// Required. Time when the pre-order will stop being available.
#[serde(rename = "endTime")]
pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Required. Immutable. Specifies how price changes affect pre-existing pre-orders.
#[serde(rename = "priceChangeBehavior")]
pub price_change_behavior: Option<String>,
/// Required. Time on which the product associated with the pre-order will be released and the pre-order orders fulfilled.
#[serde(rename = "releaseTime")]
pub release_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Required. Time when the pre-order will start being available.
#[serde(rename = "startTime")]
pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for OneTimeProductPreOrderOffer {}
/// A single purchase option for a one-time product.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductPurchaseOption {
/// A purchase option that can be bought.
#[serde(rename = "buyOption")]
pub buy_option: Option<OneTimeProductBuyPurchaseOption>,
/// Pricing information for any new locations Play may launch in the future. If omitted, the purchase option will not be automatically available in any new locations Play may launch in the future.
#[serde(rename = "newRegionsConfig")]
pub new_regions_config: Option<OneTimeProductPurchaseOptionNewRegionsConfig>,
/// Optional. List of up to 20 custom tags specified for this purchase option, and returned to the app through the billing library. Offers for this purchase option will also receive these tags in the billing library.
#[serde(rename = "offerTags")]
pub offer_tags: Option<Vec<OfferTag>>,
/// Required. Immutable. The unique identifier of this purchase option. Must be unique within the one-time product. It must start with a number or lower-case letter, and can only contain lower-case letters (a-z), numbers (0-9), and hyphens (-). The maximum length is 63 characters.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
/// Regional pricing and availability information for this purchase option.
#[serde(rename = "regionalPricingAndAvailabilityConfigs")]
pub regional_pricing_and_availability_configs:
Option<Vec<OneTimeProductPurchaseOptionRegionalPricingAndAvailabilityConfig>>,
/// A purchase option that can be rented.
#[serde(rename = "rentOption")]
pub rent_option: Option<OneTimeProductRentPurchaseOption>,
/// Output only. The state of the purchase option, i.e., whether it's active. This field cannot be changed by updating the resource. Use the dedicated endpoints instead.
pub state: Option<String>,
/// Optional. Details about taxes and legal compliance.
#[serde(rename = "taxAndComplianceSettings")]
pub tax_and_compliance_settings: Option<PurchaseOptionTaxAndComplianceSettings>,
}
impl common::Part for OneTimeProductPurchaseOption {}
/// Pricing information for any new regions Play may launch in the future.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductPurchaseOptionNewRegionsConfig {
/// Required. The regional availability for the new regions config. When set to AVAILABLE, the pricing information will be used for any new regions Play may launch in the future.
pub availability: Option<String>,
/// Required. Price in EUR to use for any new regions Play may launch in.
#[serde(rename = "eurPrice")]
pub eur_price: Option<Money>,
/// Required. Price in USD to use for any new regions Play may launch in.
#[serde(rename = "usdPrice")]
pub usd_price: Option<Money>,
}
impl common::Part for OneTimeProductPurchaseOptionNewRegionsConfig {}
/// Regional pricing and availability configuration for a purchase option.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductPurchaseOptionRegionalPricingAndAvailabilityConfig {
/// The availability of the purchase option.
pub availability: Option<String>,
/// The price of the purchase option in the specified region. Must be set in the currency that is linked to the specified region.
pub price: Option<Money>,
/// Required. Region code this configuration applies to, as defined by ISO 3166-2, e.g., "US".
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
}
impl common::Part for OneTimeProductPurchaseOptionRegionalPricingAndAvailabilityConfig {}
/// A purchase option that can be rented.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductRentPurchaseOption {
/// Optional. The amount of time the user has after starting consuming the entitlement before it is revoked. Specified in ISO 8601 format.
#[serde(rename = "expirationPeriod")]
pub expiration_period: Option<String>,
/// Required. The amount of time a user has the entitlement for. Starts at purchase flow completion. Specified in ISO 8601 format.
#[serde(rename = "rentalPeriod")]
pub rental_period: Option<String>,
}
impl common::Part for OneTimeProductRentPurchaseOption {}
/// Details about taxation, Google Play policy and legal compliance for one-time products.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimeProductTaxAndComplianceSettings {
/// Whether this one-time product is declared as a product representing a tokenized digital asset.
#[serde(rename = "isTokenizedDigitalAsset")]
pub is_tokenized_digital_asset: Option<bool>,
/// Product tax category code to assign to the one-time product. Product tax category determines the transaction tax rates applied to the product. Refer to the [Help Center article](https://support.google.com/googleplay/android-developer/answer/16408159) for more information.
#[serde(rename = "productTaxCategoryCode")]
pub product_tax_category_code: Option<String>,
/// Regional tax configuration.
#[serde(rename = "regionalTaxConfigs")]
pub regional_tax_configs: Option<Vec<RegionalTaxConfig>>,
}
impl common::Part for OneTimeProductTaxAndComplianceSettings {}
/// Details of a one-time purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OneTimePurchaseDetails {
/// The offer ID of the one-time purchase offer.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// The details of a pre-order purchase. Only set if it is a pre-order purchase. Note that this field will be set even after pre-order is fulfilled.
#[serde(rename = "preorderDetails")]
pub preorder_details: Option<PreorderDetails>,
/// ID of the purchase option. This field is set for both purchase options and variant offers. For purchase options, this ID identifies the purchase option itself. For variant offers, this ID refers to the associated purchase option, and in conjunction with offer_id it identifies the variant offer.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
/// The number of items purchased (for multi-quantity item purchases).
pub quantity: Option<i32>,
/// The details of a rent purchase. Only set if it is a rent purchase.
#[serde(rename = "rentalDetails")]
pub rental_details: Option<RentalDetails>,
}
impl common::Part for OneTimePurchaseDetails {}
/// The Order resource encapsulates comprehensive information about a transaction made on Google Play. It includes a variety of attributes that provide details about the order itself, the products purchased, and the history of events related to the order. The Orders APIs provide real-time access to your order data within the Google Play ecosystem. You can retrieve detailed information and metadata for both one-time and recurring orders, including transaction details like charges, taxes, and refunds, as well as metadata such as pricing phases for subscriptions. The Orders APIs let you automate tasks related to order management, reducing the need for manual checks via the Play Developer Console. The following are some of the use cases for this API: + Real-time order data retrieval - Get order details and metadata immediately after a purchase using an order ID. + Order update synchronization - Periodically sync order updates to maintain an up-to-date record of order information. Note: + The Orders API calls count towards your Play Developer API quota, which defaults to 200K daily, and may be insufficient to sync extensive order histories. + A maximum of 1000 orders can be retrieved per call. Using larger page sizes is recommended to minimize quota usage. Check your quota in the Cloud Console and request more if required.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [batchget orders](OrderBatchgetCall) (none)
/// * [get orders](OrderGetCall) (response)
/// * [refund orders](OrderRefundCall) (none)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Order {
/// Address information for the customer, for use in tax computation. When Google is the Merchant of Record for the order, only country is shown.
#[serde(rename = "buyerAddress")]
pub buyer_address: Option<BuyerAddress>,
/// The time when the order was created.
#[serde(rename = "createTime")]
pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Your revenue for this order in the buyer's currency, including deductions of partial refunds, taxes and fees. Google deducts standard transaction and third party fees from each sale, including VAT in some regions.
#[serde(rename = "developerRevenueInBuyerCurrency")]
pub developer_revenue_in_buyer_currency: Option<Money>,
/// The time of the last event that occurred on the order.
#[serde(rename = "lastEventTime")]
pub last_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The individual line items making up this order.
#[serde(rename = "lineItems")]
pub line_items: Option<Vec<LineItem>>,
/// Detailed information about the order at creation time.
#[serde(rename = "orderDetails")]
pub order_details: Option<OrderDetails>,
/// Details about events which modified the order.
#[serde(rename = "orderHistory")]
pub order_history: Option<OrderHistory>,
/// The order ID.
#[serde(rename = "orderId")]
pub order_id: Option<String>,
/// Play points applied to the order, including offer information, discount rate and point values.
#[serde(rename = "pointsDetails")]
pub points_details: Option<PointsDetails>,
/// The token provided to the user's device when the subscription or item was purchased.
#[serde(rename = "purchaseToken")]
pub purchase_token: Option<String>,
/// The originating sales channel of the order.
#[serde(rename = "salesChannel")]
pub sales_channel: Option<String>,
/// The state of the order.
pub state: Option<String>,
/// The total tax paid as a part of this order.
pub tax: Option<Money>,
/// The final amount paid by the customer, taking into account discounts and taxes.
pub total: Option<Money>,
}
impl common::Resource for Order {}
impl common::ResponseResult for Order {}
/// Detailed information about the order at creation time.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OrderDetails {
/// Indicates whether the listed price was tax inclusive or not.
#[serde(rename = "taxInclusive")]
pub tax_inclusive: Option<bool>,
}
impl common::Part for OrderDetails {}
/// Details about events which modified the order.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OrderHistory {
/// Details of when the order was canceled.
#[serde(rename = "cancellationEvent")]
pub cancellation_event: Option<CancellationEvent>,
/// Details of the partial refund events for this order.
#[serde(rename = "partialRefundEvents")]
pub partial_refund_events: Option<Vec<PartialRefundEvent>>,
/// Details of when the order was processed.
#[serde(rename = "processedEvent")]
pub processed_event: Option<ProcessedEvent>,
/// Details of when the order was fully refunded.
#[serde(rename = "refundEvent")]
pub refund_event: Option<RefundEvent>,
}
impl common::Part for OrderHistory {}
/// Details of a recurring external transaction product which doesn't belong to any other more specific category.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OtherRecurringProduct {
_never_set: Option<bool>,
}
impl common::Part for OtherRecurringProduct {}
/// Pricing information for any new locations Play may launch in.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OtherRegionsBasePlanConfig {
/// Required. Price in EUR to use for any new locations Play may launch in.
#[serde(rename = "eurPrice")]
pub eur_price: Option<Money>,
/// Whether the base plan is available for new subscribers in any new locations Play may launch in. If not specified, this will default to false.
#[serde(rename = "newSubscriberAvailability")]
pub new_subscriber_availability: Option<bool>,
/// Required. Price in USD to use for any new locations Play may launch in.
#[serde(rename = "usdPrice")]
pub usd_price: Option<Money>,
}
impl common::Part for OtherRegionsBasePlanConfig {}
/// Configuration for any new locations Play may launch in specified on a subscription offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OtherRegionsSubscriptionOfferConfig {
/// Whether the subscription offer in any new locations Play may launch in the future. If not specified, this will default to false.
#[serde(rename = "otherRegionsNewSubscriberAvailability")]
pub other_regions_new_subscriber_availability: Option<bool>,
}
impl common::Part for OtherRegionsSubscriptionOfferConfig {}
/// Configuration for any new locations Play may launch in for a single offer phase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OtherRegionsSubscriptionOfferPhaseConfig {
/// The absolute amount of money subtracted from the base plan price prorated over the phase duration that the user pays for this offer phase. For example, if the base plan price for this region is $12 for a period of 1 year, then a $1 absolute discount for a phase of a duration of 3 months would correspond to a price of $2. The resulting price may not be smaller than the minimum price allowed for any new locations Play may launch in.
#[serde(rename = "absoluteDiscounts")]
pub absolute_discounts: Option<OtherRegionsSubscriptionOfferPhasePrices>,
/// Set to specify this offer is free to obtain.
pub free: Option<OtherRegionsSubscriptionOfferPhaseFreePriceOverride>,
/// The absolute price the user pays for this offer phase. The price must not be smaller than the minimum price allowed for any new locations Play may launch in.
#[serde(rename = "otherRegionsPrices")]
pub other_regions_prices: Option<OtherRegionsSubscriptionOfferPhasePrices>,
/// The fraction of the base plan price prorated over the phase duration that the user pays for this offer phase. For example, if the base plan price for this region is $12 for a period of 1 year, then a 50% discount for a phase of a duration of 3 months would correspond to a price of $1.50. The discount must be specified as a fraction strictly larger than 0 and strictly smaller than 1. The resulting price will be rounded to the nearest billable unit (e.g. cents for USD). The relative discount is considered invalid if the discounted price ends up being smaller than the minimum price allowed in any new locations Play may launch in.
#[serde(rename = "relativeDiscount")]
pub relative_discount: Option<f64>,
}
impl common::Part for OtherRegionsSubscriptionOfferPhaseConfig {}
/// Represents the free price override configuration for any new locations Play may launch for a single offer phase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OtherRegionsSubscriptionOfferPhaseFreePriceOverride {
_never_set: Option<bool>,
}
impl common::Part for OtherRegionsSubscriptionOfferPhaseFreePriceOverride {}
/// Pricing information for any new locations Play may launch in.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OtherRegionsSubscriptionOfferPhasePrices {
/// Required. Price in EUR to use for any new locations Play may launch in.
#[serde(rename = "eurPrice")]
pub eur_price: Option<Money>,
/// Required. Price in USD to use for any new locations Play may launch in.
#[serde(rename = "usdPrice")]
pub usd_price: Option<Money>,
}
impl common::Part for OtherRegionsSubscriptionOfferPhasePrices {}
/// Information specific to an out of app purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct OutOfAppPurchaseContext {
/// User account identifier from the last expired subscription for this SKU.
#[serde(rename = "expiredExternalAccountIdentifiers")]
pub expired_external_account_identifiers: Option<ExternalAccountIdentifiers>,
/// The purchase token of the last expired subscription. This purchase token must only be used to help identify the user if the link between the purchaseToken and user is stored in your database. This cannot be used to call the Google Developer API if it has been more than 60 days since expiry.
#[serde(rename = "expiredPurchaseToken")]
pub expired_purchase_token: Option<String>,
}
impl common::Part for OutOfAppPurchaseContext {}
/// Information about the current page. List operations that supports paging return only one "page" of results. This protocol buffer message describes the page that has been returned.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PageInfo {
/// Maximum number of results returned in one page. ! The number of results included in the API response.
#[serde(rename = "resultPerPage")]
pub result_per_page: Option<i32>,
/// Index of the first result returned in the current page.
#[serde(rename = "startIndex")]
pub start_index: Option<i32>,
/// Total number of results available on the backend ! The total number of results in the result set.
#[serde(rename = "totalResults")]
pub total_results: Option<i32>,
}
impl common::Part for PageInfo {}
/// Details of a paid app purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PaidAppDetails {
_never_set: Option<bool>,
}
impl common::Part for PaidAppDetails {}
/// A partial refund of a transaction.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PartialRefund {
/// Required. A unique id distinguishing this partial refund. If the refund is successful, subsequent refunds with the same id will fail. Must be unique across refunds for one individual transaction.
#[serde(rename = "refundId")]
pub refund_id: Option<String>,
/// Required. The pre-tax amount of the partial refund. Should be less than the remaining pre-tax amount of the transaction.
#[serde(rename = "refundPreTaxAmount")]
pub refund_pre_tax_amount: Option<Price>,
}
impl common::Part for PartialRefund {}
/// Details of the partial refund events for this order.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PartialRefundEvent {
/// The time when the partial refund was created.
#[serde(rename = "createTime")]
pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The time when the partial refund was processed.
#[serde(rename = "processTime")]
pub process_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Details for the partial refund.
#[serde(rename = "refundDetails")]
pub refund_details: Option<RefundDetails>,
/// The state of the partial refund.
pub state: Option<String>,
}
impl common::Part for PartialRefundEvent {}
/// Information specific to a subscription in paused state.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PausedStateContext {
/// Time at which the subscription will be automatically resumed.
#[serde(rename = "autoResumeTime")]
pub auto_resume_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for PausedStateContext {}
/// This is an indicator of whether there is a pending cancellation on the virtual installment plan. The cancellation will happen only after the user finished all committed payments.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PendingCancellation {
_never_set: Option<bool>,
}
impl common::Part for PendingCancellation {}
/// Details relating to any Play Points applied to an order.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PointsDetails {
/// The monetary value of a Play Points coupon. This is the discount the coupon provides, which may not be the total amount. Only set when Play Points coupons have been used. E.g. for a 100 points for $2 coupon, this is $2.
#[serde(rename = "pointsCouponValue")]
pub points_coupon_value: Option<Money>,
/// The percentage rate which the Play Points promotion reduces the cost by. E.g. for a 100 points for $2 coupon, this is 500,000. Since $2 has an estimate of 200 points, but the actual Points required, 100, is 50% of this, and 50% in micros is 500,000. Between 0 and 1,000,000.
#[serde(rename = "pointsDiscountRateMicros")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub points_discount_rate_micros: Option<i64>,
/// ID unique to the play points offer in use for this order.
#[serde(rename = "pointsOfferId")]
pub points_offer_id: Option<String>,
/// The number of Play Points applied in this order. E.g. for a 100 points for $2 coupon, this is 100. For coupon stacked with base offer, this is the total points spent across both.
#[serde(rename = "pointsSpent")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub points_spent: Option<i64>,
}
impl common::Part for PointsDetails {}
/// Details of a pre-order purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PreorderDetails {
_never_set: Option<bool>,
}
impl common::Part for PreorderDetails {}
/// Offer details information related to a preorder line item.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PreorderOfferDetails {
/// The time when a preordered item is released for a preorder purchase.
#[serde(rename = "preorderReleaseTime")]
pub preorder_release_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for PreorderOfferDetails {}
/// Represents a base plan that does not automatically renew at the end of the base plan, and must be manually renewed by the user.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PrepaidBasePlanType {
/// Required. Immutable. Subscription period, specified in ISO 8601 format. For a list of acceptable billing periods, refer to the help center. The duration is immutable after the base plan is created.
#[serde(rename = "billingPeriodDuration")]
pub billing_period_duration: Option<String>,
/// Whether users should be able to extend this prepaid base plan in Google Play surfaces. Defaults to TIME_EXTENSION_ACTIVE if not specified.
#[serde(rename = "timeExtension")]
pub time_extension: Option<String>,
}
impl common::Part for PrepaidBasePlanType {}
/// Information related to a prepaid plan.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PrepaidPlan {
/// If present, this is the time after which top up purchases are allowed for the prepaid plan. Will not be present for expired prepaid plans.
#[serde(rename = "allowExtendAfterTime")]
pub allow_extend_after_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for PrepaidPlan {}
/// Definition of a price, i.e. currency and units.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Price {
/// 3 letter Currency code, as defined by ISO 4217. See java/com/google/common/money/CurrencyCode.java
pub currency: Option<String>,
/// Price in 1/million of the currency base unit, represented as a string.
#[serde(rename = "priceMicros")]
pub price_micros: Option<String>,
}
impl common::Part for Price {}
/// Information related to a price step-up that requires user consent.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PriceStepUpConsentDetails {
/// The deadline by which the user must provide consent. If consent is not provided by this time, the subscription will be canceled.
#[serde(rename = "consentDeadlineTime")]
pub consent_deadline_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The new price which requires user consent.
#[serde(rename = "newPrice")]
pub new_price: Option<Money>,
/// Output only. The state of the price step-up consent.
pub state: Option<String>,
}
impl common::Part for PriceStepUpConsentDetails {}
/// Details of when the order was processed.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ProcessedEvent {
/// The time when the order was processed.
#[serde(rename = "eventTime")]
pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for ProcessedEvent {}
/// Contains item-level info for a ProductPurchaseV2.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ProductLineItem {
/// The purchased product ID (for example, 'monthly001').
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// The offer details for this item.
#[serde(rename = "productOfferDetails")]
pub product_offer_details: Option<ProductOfferDetails>,
}
impl common::Part for ProductLineItem {}
/// Offer details information related to a purchase line item.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ProductOfferDetails {
/// Output only. The consumption state of the purchase.
#[serde(rename = "consumptionState")]
pub consumption_state: Option<String>,
/// The offer ID. Only present for offers.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// The latest offer tags associated with the offer. It includes tags inherited from the purchase option.
#[serde(rename = "offerTags")]
pub offer_tags: Option<Vec<String>>,
/// The per-transaction offer token used to make this purchase line item.
#[serde(rename = "offerToken")]
pub offer_token: Option<String>,
/// Offer details for a preorder offer. This will only be set for preorders.
#[serde(rename = "preorderOfferDetails")]
pub preorder_offer_details: Option<PreorderOfferDetails>,
/// The purchase option ID.
#[serde(rename = "purchaseOptionId")]
pub purchase_option_id: Option<String>,
/// The quantity associated with the purchase of the inapp product.
pub quantity: Option<i32>,
/// The quantity eligible for refund, i.e. quantity that hasn't been refunded. The value reflects quantity-based partial refunds and full refunds.
#[serde(rename = "refundableQuantity")]
pub refundable_quantity: Option<i32>,
/// Offer details about rent offers. This will only be set for rental line items.
#[serde(rename = "rentOfferDetails")]
pub rent_offer_details: Option<RentOfferDetails>,
}
impl common::Part for ProductOfferDetails {}
/// A ProductPurchase resource indicates the status of a user’s inapp product purchase.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [products get purchases](PurchaseProductGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ProductPurchase {
/// The acknowledgement state of the inapp product. Possible values are: 0. Yet to be acknowledged 1. Acknowledged
#[serde(rename = "acknowledgementState")]
pub acknowledgement_state: Option<i32>,
/// The consumption state of the inapp product. Possible values are: 0. Yet to be consumed 1. Consumed
#[serde(rename = "consumptionState")]
pub consumption_state: Option<i32>,
/// A developer-specified string that contains supplemental information about an order.
#[serde(rename = "developerPayload")]
pub developer_payload: Option<String>,
/// This kind represents an inappPurchase object in the androidpublisher service.
pub kind: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's account in your app. Only present if specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedaccountid when the purchase was made.
#[serde(rename = "obfuscatedExternalAccountId")]
pub obfuscated_external_account_id: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's profile in your app. Only present if specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid when the purchase was made.
#[serde(rename = "obfuscatedExternalProfileId")]
pub obfuscated_external_profile_id: Option<String>,
/// The order id associated with the purchase of the inapp product.
#[serde(rename = "orderId")]
pub order_id: Option<String>,
/// The inapp product SKU. May not be present.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// The purchase state of the order. Possible values are: 0. Purchased 1. Canceled 2. Pending
#[serde(rename = "purchaseState")]
pub purchase_state: Option<i32>,
/// The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
#[serde(rename = "purchaseTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub purchase_time_millis: Option<i64>,
/// The purchase token generated to identify this purchase. May not be present.
#[serde(rename = "purchaseToken")]
pub purchase_token: Option<String>,
/// 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: 0. Test (i.e. purchased from a license testing account) 1. Promo (i.e. purchased using a promo code). Does not include Play Points purchases. 2. Rewarded (i.e. from watching a video ad instead of paying)
#[serde(rename = "purchaseType")]
pub purchase_type: Option<i32>,
/// The quantity associated with the purchase of the inapp product. If not present, the quantity is 1.
pub quantity: Option<i32>,
/// The quantity eligible for refund, i.e. quantity that hasn't been refunded. The value reflects quantity-based partial refunds and full refunds.
#[serde(rename = "refundableQuantity")]
pub refundable_quantity: Option<i32>,
/// ISO 3166-1 alpha-2 billing region code of the user at the time the product was granted.
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
}
impl common::ResponseResult for ProductPurchase {}
/// A ProductPurchaseV2 resource indicates the status of a user’s inapp product purchase.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [productsv2 getproductpurchasev2 purchases](PurchaseProductsv2Getproductpurchasev2Call) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ProductPurchaseV2 {
/// Output only. The acknowledgement state of the purchase.
#[serde(rename = "acknowledgementState")]
pub acknowledgement_state: Option<String>,
/// This kind represents a ProductPurchaseV2 object in the androidpublisher service.
pub kind: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's account in your app. Only present if specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedaccountid when the purchase was made.
#[serde(rename = "obfuscatedExternalAccountId")]
pub obfuscated_external_account_id: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's profile in your app. Only present if specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid when the purchase was made.
#[serde(rename = "obfuscatedExternalProfileId")]
pub obfuscated_external_profile_id: Option<String>,
/// The order id associated with the purchase of the inapp product. May not be set if there is no order associated with the purchase.
#[serde(rename = "orderId")]
pub order_id: Option<String>,
/// Contains item-level info for a ProductPurchaseV2.
#[serde(rename = "productLineItem")]
pub product_line_item: Option<Vec<ProductLineItem>>,
/// The time when the purchase was successful, i.e., when the PurchaseState has changed to PURCHASED. This field will not be present until the payment is complete. For example, if the user initiated a pending transaction (https://developer.android.com/google/play/billing/integrate#pending), this field will not be populated until the user successfully completes the steps required to complete the transaction.
#[serde(rename = "purchaseCompletionTime")]
pub purchase_completion_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Information about the purchase state of the purchase.
#[serde(rename = "purchaseStateContext")]
pub purchase_state_context: Option<PurchaseStateContext>,
/// ISO 3166-1 alpha-2 billing region code of the user at the time the product was granted.
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
/// Information related to test purchases. This will only be set for test purchases.
#[serde(rename = "testPurchaseContext")]
pub test_purchase_context: Option<TestPurchaseContext>,
}
impl common::ResponseResult for ProductPurchaseV2 {}
/// Request for the product.purchases.acknowledge API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [products acknowledge purchases](PurchaseProductAcknowledgeCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ProductPurchasesAcknowledgeRequest {
/// Payload to attach to the purchase.
#[serde(rename = "developerPayload")]
pub developer_payload: Option<String>,
}
impl common::RequestValue for ProductPurchasesAcknowledgeRequest {}
/// Details of a proration period. A proration period can be a period calculated during a plan change to cover existing entitlements (For more information, see [Allow users to upgrade, downgrade, or change their subscription](https://developer.android.com/google/play/billing/subscriptions#allow-users-change), or a prorated period to align add-on renewal dates with the base (For more information, see [Rules applicable for items in the purchase](https://developer.android.com/google/play/billing/subscription-with-addons#rules-base-addons)).
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ProrationPeriodDetails {
/// Represent the original offer phase from the purchased the line item if the proration period contains any of them. For example, a proration period from CHARGE_FULL_PRICE plan change may merge the 1st offer phase of the subscription offer of the new product user purchased. In this case, the original offer phase will be set here.
#[serde(rename = "originalOfferPhase")]
pub original_offer_phase: Option<String>,
}
impl common::Part for ProrationPeriodDetails {}
/// Details about taxation, Google Play policy and legal compliance for one-time product purchase options.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PurchaseOptionTaxAndComplianceSettings {
/// Optional. Digital content or service classification for products distributed to users in eligible regions. If unset, it defaults to `WITHDRAWAL_RIGHT_DIGITAL_CONTENT`. Refer to the [Help Center article](https://support.google.com/googleplay/android-developer/answer/10463498) for more information.
#[serde(rename = "withdrawalRightType")]
pub withdrawal_right_type: Option<String>,
}
impl common::Part for PurchaseOptionTaxAndComplianceSettings {}
/// Context about the purchase state.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PurchaseStateContext {
/// Output only. The purchase state of the purchase.
#[serde(rename = "purchaseState")]
pub purchase_state: Option<String>,
}
impl common::Part for PurchaseStateContext {}
/// Represents a transaction that is part of a recurring series of payments. This can be a subscription or a one-time product with multiple payments (such as preorder).
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RecurringExternalTransaction {
/// Details of an external subscription.
#[serde(rename = "externalSubscription")]
pub external_subscription: Option<ExternalSubscription>,
/// Input only. Provided during the call to Create. Retrieved from the client when the alternative billing flow is launched. Required only for the initial purchase.
#[serde(rename = "externalTransactionToken")]
pub external_transaction_token: Option<String>,
/// The external transaction id of the first transaction of this recurring series of transactions. For example, for a subscription this would be the transaction id of the first payment. Required when creating recurring external transactions.
#[serde(rename = "initialExternalTransactionId")]
pub initial_external_transaction_id: Option<String>,
/// Input only. Provided during the call to Create. Must only be used when migrating a subscription from manual monthly reporting to automated reporting.
#[serde(rename = "migratedTransactionProgram")]
pub migrated_transaction_program: Option<String>,
/// Details of a recurring external transaction product which doesn't belong to any other specific category.
#[serde(rename = "otherRecurringProduct")]
pub other_recurring_product: Option<OtherRecurringProduct>,
}
impl common::Part for RecurringExternalTransaction {}
/// Details for a partial or full refund.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RefundDetails {
/// The amount of tax refunded.
pub tax: Option<Money>,
/// The total amount refunded, including tax.
pub total: Option<Money>,
}
impl common::Part for RefundDetails {}
/// Details of when the order was fully refunded.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RefundEvent {
/// The time when the order was fully refunded.
#[serde(rename = "eventTime")]
pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Details for the full refund.
#[serde(rename = "refundDetails")]
pub refund_details: Option<RefundDetails>,
/// The reason the order was refunded.
#[serde(rename = "refundReason")]
pub refund_reason: Option<String>,
}
impl common::Part for RefundEvent {}
/// A request to refund an existing external transaction.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [refundexternaltransaction externaltransactions](ExternaltransactionRefundexternaltransactionCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RefundExternalTransactionRequest {
/// A full-amount refund.
#[serde(rename = "fullRefund")]
pub full_refund: Option<FullRefund>,
/// A partial refund.
#[serde(rename = "partialRefund")]
pub partial_refund: Option<PartialRefund>,
/// Required. The time that the transaction was refunded.
#[serde(rename = "refundTime")]
pub refund_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::RequestValue for RefundExternalTransactionRequest {}
/// Configuration for a base plan specific to a region.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionalBasePlanConfig {
/// Whether the base plan in the specified region is available for new subscribers. Existing subscribers will not have their subscription canceled if this value is set to false. If not specified, this will default to false.
#[serde(rename = "newSubscriberAvailability")]
pub new_subscriber_availability: Option<bool>,
/// The price of the base plan in the specified region. Must be set if the base plan is available to new subscribers. Must be set in the currency that is linked to the specified region.
pub price: Option<Money>,
/// Required. Region code this configuration applies to, as defined by ISO 3166-2, e.g. "US".
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
}
impl common::Part for RegionalBasePlanConfig {}
/// Configuration for migration of a legacy price cohort.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionalPriceMigrationConfig {
/// Required. Subscribers in all legacy price cohorts before this time will be migrated to the current price. Subscribers in any newer price cohorts are unaffected. Affected subscribers will receive one or more notifications from Google Play about the price change. Price decreases occur at the subscriber's next billing date. Price increases occur at the subscriber's next billing date following a notification period that varies by region and price increase type.
#[serde(rename = "oldestAllowedPriceVersionTime")]
pub oldest_allowed_price_version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Optional. The requested type of price increase
#[serde(rename = "priceIncreaseType")]
pub price_increase_type: Option<String>,
/// Required. Region code this configuration applies to, as defined by ISO 3166-2, e.g. "US".
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
}
impl common::Part for RegionalPriceMigrationConfig {}
/// Configuration for a subscription offer in a single region.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionalSubscriptionOfferConfig {
/// Whether the subscription offer in the specified region is available for new subscribers. Existing subscribers will not have their subscription cancelled if this value is set to false. If not specified, this will default to false.
#[serde(rename = "newSubscriberAvailability")]
pub new_subscriber_availability: Option<bool>,
/// Required. Immutable. Region code this configuration applies to, as defined by ISO 3166-2, e.g. "US".
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
}
impl common::Part for RegionalSubscriptionOfferConfig {}
/// Configuration for a single phase of a subscription offer in a single region.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionalSubscriptionOfferPhaseConfig {
/// The absolute amount of money subtracted from the base plan price prorated over the phase duration that the user pays for this offer phase. For example, if the base plan price for this region is $12 for a period of 1 year, then a $1 absolute discount for a phase of a duration of 3 months would correspond to a price of $2. The resulting price may not be smaller than the minimum price allowed for this region.
#[serde(rename = "absoluteDiscount")]
pub absolute_discount: Option<Money>,
/// Set to specify this offer is free to obtain.
pub free: Option<RegionalSubscriptionOfferPhaseFreePriceOverride>,
/// The absolute price the user pays for this offer phase. The price must not be smaller than the minimum price allowed for this region.
pub price: Option<Money>,
/// Required. Immutable. The region to which this config applies.
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
/// The fraction of the base plan price prorated over the phase duration that the user pays for this offer phase. For example, if the base plan price for this region is $12 for a period of 1 year, then a 50% discount for a phase of a duration of 3 months would correspond to a price of $1.50. The discount must be specified as a fraction strictly larger than 0 and strictly smaller than 1. The resulting price will be rounded to the nearest billable unit (e.g. cents for USD). The relative discount is considered invalid if the discounted price ends up being smaller than the minimum price allowed in this region.
#[serde(rename = "relativeDiscount")]
pub relative_discount: Option<f64>,
}
impl common::Part for RegionalSubscriptionOfferPhaseConfig {}
/// Represents the free price override configuration for a single phase of a subscription offer
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionalSubscriptionOfferPhaseFreePriceOverride {
_never_set: Option<bool>,
}
impl common::Part for RegionalSubscriptionOfferPhaseFreePriceOverride {}
/// Details about taxation in a given geographical region.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionalTaxConfig {
/// You must tell us if your app contains streaming products to correctly charge US state and local sales tax. Field only supported in the United States.
#[serde(rename = "eligibleForStreamingServiceTaxRate")]
pub eligible_for_streaming_service_tax_rate: Option<bool>,
/// Required. Region code this configuration applies to, as defined by ISO 3166-2, e.g. "US".
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
/// To collect communications or amusement taxes in the United States, choose the appropriate tax category. [Learn more](https://support.google.com/googleplay/android-developer/answer/10463498#streaming_tax).
#[serde(rename = "streamingTaxType")]
pub streaming_tax_type: Option<String>,
/// Tax tier to specify reduced tax rate. Developers who sell digital news, magazines, newspapers, books, or audiobooks in various regions may be eligible for reduced tax rates. [Learn more](https://support.google.com/googleplay/android-developer/answer/10463498).
#[serde(rename = "taxTier")]
pub tax_tier: Option<String>,
}
impl common::Part for RegionalTaxConfig {}
/// Specified details about taxation in a given geographical region.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionalTaxRateInfo {
/// You must tell us if your app contains streaming products to correctly charge US state and local sales tax. Field only supported in the United States.
#[serde(rename = "eligibleForStreamingServiceTaxRate")]
pub eligible_for_streaming_service_tax_rate: Option<bool>,
/// To collect communications or amusement taxes in the United States, choose the appropriate tax category. [Learn more](https://support.google.com/googleplay/android-developer/answer/10463498#streaming_tax).
#[serde(rename = "streamingTaxType")]
pub streaming_tax_type: Option<String>,
/// Tax tier to specify reduced tax rate. Developers who sell digital news, magazines, newspapers, books, or audiobooks in various regions may be eligible for reduced tax rates. [Learn more](https://support.google.com/googleplay/android-developer/answer/10463498).
#[serde(rename = "taxTier")]
pub tax_tier: Option<String>,
}
impl common::Part for RegionalTaxRateInfo {}
/// Region targeting data for app recovery action targeting.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Regions {
/// Regions targeted by the recovery action. Region codes are ISO 3166 Alpha-2 country codes. For example, US stands for United States of America. See https://www.iso.org/iso-3166-country-codes.html for the complete list of country codes.
#[serde(rename = "regionCode")]
pub region_code: Option<Vec<String>>,
}
impl common::Part for Regions {}
/// The version of the available regions being used for the specified resource.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RegionsVersion {
/// Required. A string representing the version of available regions being used for the specified resource. Regional prices and latest supported version for the resource have to be specified according to the information published in [this article](https://support.google.com/googleplay/android-developer/answer/10532353). Each time the supported locations substantially change, the version will be incremented. Using this field will ensure that creating and updating the resource with an older region's version and set of regional prices and currencies will succeed even though a new version is available.
pub version: Option<String>,
}
impl common::Part for RegionsVersion {}
/// Object representation for Remote in-app update action type.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RemoteInAppUpdate {
/// Required. Set to true if Remote In-App Update action type is needed.
#[serde(rename = "isRemoteInAppUpdateRequested")]
pub is_remote_in_app_update_requested: Option<bool>,
}
impl common::Part for RemoteInAppUpdate {}
/// Data related to Remote In-App Update action such as recovered user count, affected user count etc.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RemoteInAppUpdateData {
/// Data related to the recovery action at bundle level.
#[serde(rename = "remoteAppUpdateDataPerBundle")]
pub remote_app_update_data_per_bundle: Option<Vec<RemoteInAppUpdateDataPerBundle>>,
}
impl common::Part for RemoteInAppUpdateData {}
/// Data related to the recovery action at bundle level.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RemoteInAppUpdateDataPerBundle {
/// Total number of devices which have been rescued.
#[serde(rename = "recoveredDeviceCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub recovered_device_count: Option<i64>,
/// Total number of devices affected by this recovery action associated with bundle of the app.
#[serde(rename = "totalDeviceCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub total_device_count: Option<i64>,
/// Version Code corresponding to the target bundle.
#[serde(rename = "versionCode")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub version_code: Option<i64>,
}
impl common::Part for RemoteInAppUpdateDataPerBundle {}
/// Offer details information related to a rental line item.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RentOfferDetails {
_never_set: Option<bool>,
}
impl common::Part for RentOfferDetails {}
/// Details of a rental purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RentalDetails {
_never_set: Option<bool>,
}
impl common::Part for RentalDetails {}
/// Information specific to cancellations caused by subscription replacement.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ReplacementCancellation {
_never_set: Option<bool>,
}
impl common::Part for ReplacementCancellation {}
/// Countries where the purchase of this product is restricted to payment methods registered in the same country. If empty, no payment location restrictions are imposed.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RestrictedPaymentCountries {
/// Required. Region codes to impose payment restrictions on, as defined by ISO 3166-2, e.g. "US".
#[serde(rename = "regionCodes")]
pub region_codes: Option<Vec<String>>,
}
impl common::Part for RestrictedPaymentCountries {}
/// An Android app review.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [get reviews](ReviewGetCall) (response)
/// * [list reviews](ReviewListCall) (none)
/// * [reply reviews](ReviewReplyCall) (none)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Review {
/// The name of the user who wrote the review.
#[serde(rename = "authorName")]
pub author_name: Option<String>,
/// A repeated field containing comments for the review.
pub comments: Option<Vec<Comment>>,
/// Unique identifier for this review.
#[serde(rename = "reviewId")]
pub review_id: Option<String>,
}
impl common::Resource for Review {}
impl common::ResponseResult for Review {}
/// The result of replying/updating a reply to review.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ReviewReplyResult {
/// The time at which the reply took effect.
#[serde(rename = "lastEdited")]
pub last_edited: Option<Timestamp>,
/// The reply text that was applied.
#[serde(rename = "replyText")]
pub reply_text: Option<String>,
}
impl common::Part for ReviewReplyResult {}
/// Response listing reviews.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list reviews](ReviewListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ReviewsListResponse {
/// Information about the current page.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// List of reviews.
pub reviews: Option<Vec<Review>>,
/// Pagination token, to handle a number of products that is over one page.
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
}
impl common::ResponseResult for ReviewsListResponse {}
/// Request to reply to review or update existing reply.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [reply reviews](ReviewReplyCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ReviewsReplyRequest {
/// The text to set as the reply. Replies of more than approximately 350 characters will be rejected. HTML tags will be stripped.
#[serde(rename = "replyText")]
pub reply_text: Option<String>,
}
impl common::RequestValue for ReviewsReplyRequest {}
/// Response on status of replying to a review.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [reply reviews](ReviewReplyCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ReviewsReplyResponse {
/// The result of replying/updating a reply to review.
pub result: Option<ReviewReplyResult>,
}
impl common::ResponseResult for ReviewsReplyResponse {}
/// Revocation context of the purchases.subscriptionsv2.revoke API.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RevocationContext {
/// Optional. Used when users should be refunded the full amount of latest charge on each item in the subscription.
#[serde(rename = "fullRefund")]
pub full_refund: Option<RevocationContextFullRefund>,
/// Optional. Used when a specific item should be refunded in a subscription with add-on items.
#[serde(rename = "itemBasedRefund")]
pub item_based_refund: Option<RevocationContextItemBasedRefund>,
/// Optional. Used when users should be refunded a prorated amount they paid for their subscription based on the amount of time remaining in a subscription.
#[serde(rename = "proratedRefund")]
pub prorated_refund: Option<RevocationContextProratedRefund>,
}
impl common::Part for RevocationContext {}
/// Used to determine if the refund type in the RevocationContext is a full refund.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RevocationContextFullRefund {
_never_set: Option<bool>,
}
impl common::Part for RevocationContextFullRefund {}
/// Used to determine what specific item to revoke in a subscription with multiple items.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RevocationContextItemBasedRefund {
/// Required. If the subscription is a subscription with add-ons, the product id of the subscription item to revoke.
#[serde(rename = "productId")]
pub product_id: Option<String>,
}
impl common::Part for RevocationContextItemBasedRefund {}
/// Used to determine if the refund type in the RevocationContext is a prorated refund.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RevocationContextProratedRefund {
_never_set: Option<bool>,
}
impl common::Part for RevocationContextProratedRefund {}
/// Request for the purchases.subscriptionsv2.revoke API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptionsv2 revoke purchases](PurchaseSubscriptionsv2RevokeCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RevokeSubscriptionPurchaseRequest {
/// Required. Additional details around the subscription revocation.
#[serde(rename = "revocationContext")]
pub revocation_context: Option<RevocationContext>,
}
impl common::RequestValue for RevokeSubscriptionPurchaseRequest {}
/// Response for the purchases.subscriptionsv2.revoke API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptionsv2 revoke purchases](PurchaseSubscriptionsv2RevokeCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RevokeSubscriptionPurchaseResponse {
_never_set: Option<bool>,
}
impl common::ResponseResult for RevokeSubscriptionPurchaseResponse {}
/// Request to update Safety Labels of an app.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [data safety applications](ApplicationDataSafetyCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SafetyLabelsUpdateRequest {
/// Required. Contents of the CSV file containing Data Safety responses. For the format of this file, see the Help Center documentation at https://support.google.com/googleplay/android-developer/answer/10787469?#zippy=%2Cunderstand-the-csv-format To download an up to date template, follow the steps at https://support.google.com/googleplay/android-developer/answer/10787469?#zippy=%2Cexport-to-a-csv-file
#[serde(rename = "safetyLabels")]
pub safety_labels: Option<String>,
}
impl common::RequestValue for SafetyLabelsUpdateRequest {}
/// Response for SafetyLabelsUpdate rpc.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [data safety applications](ApplicationDataSafetyCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SafetyLabelsUpdateResponse {
_never_set: Option<bool>,
}
impl common::ResponseResult for SafetyLabelsUpdateResponse {}
/// Represents a screen density.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ScreenDensity {
/// Alias for a screen density.
#[serde(rename = "densityAlias")]
pub density_alias: Option<String>,
/// Value for density dpi.
#[serde(rename = "densityDpi")]
pub density_dpi: Option<i32>,
}
impl common::Part for ScreenDensity {}
/// Targeting based on screen density.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ScreenDensityTargeting {
/// Targeting of other sibling directories that were in the Bundle. For main splits this is targeting of other main splits.
pub alternatives: Option<Vec<ScreenDensity>>,
/// Value of a screen density.
pub value: Option<Vec<ScreenDensity>>,
}
impl common::Part for ScreenDensityTargeting {}
/// Represents an sdk version.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SdkVersion {
/// Inclusive minimum value of an sdk version.
pub min: Option<i32>,
}
impl common::Part for SdkVersion {}
/// Targeting based on sdk version.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SdkVersionTargeting {
/// Targeting of other sibling directories that were in the Bundle. For main splits this is targeting of other main splits.
pub alternatives: Option<Vec<SdkVersion>>,
/// Value of an sdk version.
pub value: Option<Vec<SdkVersion>>,
}
impl common::Part for SdkVersionTargeting {}
/// The promotion applied on this item when purchased.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SignupPromotion {
/// A one-time code was applied.
#[serde(rename = "oneTimeCode")]
pub one_time_code: Option<OneTimeCode>,
/// A vanity code was applied.
#[serde(rename = "vanityCode")]
pub vanity_code: Option<VanityCode>,
}
impl common::Part for SignupPromotion {}
/// Holds data specific to Split APKs.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SplitApkMetadata {
/// Indicates whether this APK is the main split of the module.
#[serde(rename = "isMasterSplit")]
pub is_master_split: Option<bool>,
/// Id of the split.
#[serde(rename = "splitId")]
pub split_id: Option<String>,
}
impl common::Part for SplitApkMetadata {}
/// Variant is a group of APKs that covers a part of the device configuration space. APKs from multiple variants are never combined on one device.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SplitApkVariant {
/// Set of APKs, one set per module.
#[serde(rename = "apkSet")]
pub apk_set: Option<Vec<ApkSet>>,
/// Variant-level targeting.
pub targeting: Option<VariantTargeting>,
/// Number of the variant, starting at 0 (unless overridden). A device will receive APKs from the first variant that matches the device configuration, with higher variant numbers having priority over lower variant numbers.
#[serde(rename = "variantNumber")]
pub variant_number: Option<i32>,
}
impl common::Part for SplitApkVariant {}
/// Holds data specific to Standalone APKs.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct StandaloneApkMetadata {
/// Names of the modules fused in this standalone APK.
#[serde(rename = "fusedModuleName")]
pub fused_module_name: Option<Vec<String>>,
}
impl common::Part for StandaloneApkMetadata {}
/// Information associated with purchases made with 'Subscribe with Google'.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscribeWithGoogleInfo {
/// The email address of the user when the subscription was purchased.
#[serde(rename = "emailAddress")]
pub email_address: Option<String>,
/// The family name of the user when the subscription was purchased.
#[serde(rename = "familyName")]
pub family_name: Option<String>,
/// The given name of the user when the subscription was purchased.
#[serde(rename = "givenName")]
pub given_name: Option<String>,
/// The Google profile id of the user when the subscription was purchased.
#[serde(rename = "profileId")]
pub profile_id: Option<String>,
/// The profile name of the user when the subscription was purchased.
#[serde(rename = "profileName")]
pub profile_name: Option<String>,
}
impl common::Part for SubscribeWithGoogleInfo {}
/// A single subscription for an app.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans activate monetization](MonetizationSubscriptionBasePlanActivateCall) (response)
/// * [subscriptions base plans deactivate monetization](MonetizationSubscriptionBasePlanDeactivateCall) (response)
/// * [subscriptions archive monetization](MonetizationSubscriptionArchiveCall) (response)
/// * [subscriptions create monetization](MonetizationSubscriptionCreateCall) (request|response)
/// * [subscriptions get monetization](MonetizationSubscriptionGetCall) (response)
/// * [subscriptions patch monetization](MonetizationSubscriptionPatchCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Subscription {
/// Output only. Deprecated: subscription archiving is not supported.
pub archived: Option<bool>,
/// The set of base plans for this subscription. Represents the prices and duration of the subscription if no other offers apply.
#[serde(rename = "basePlans")]
pub base_plans: Option<Vec<BasePlan>>,
/// Required. List of localized listings for this subscription. Must contain at least an entry for the default language of the parent app.
pub listings: Option<Vec<SubscriptionListing>>,
/// Immutable. Package name of the parent app.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Immutable. Unique product ID of the product. Unique within the parent app. Product IDs must be composed of lower-case letters (a-z), numbers (0-9), underscores (_) and dots (.). It must start with a lower-case letter or number, and be between 1 and 40 (inclusive) characters in length.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Optional. Countries where the purchase of this subscription is restricted to payment methods registered in the same country. If empty, no payment location restrictions are imposed.
#[serde(rename = "restrictedPaymentCountries")]
pub restricted_payment_countries: Option<RestrictedPaymentCountries>,
/// Details about taxes and legal compliance.
#[serde(rename = "taxAndComplianceSettings")]
pub tax_and_compliance_settings: Option<SubscriptionTaxAndComplianceSettings>,
}
impl common::RequestValue for Subscription {}
impl common::ResponseResult for Subscription {}
/// Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey).
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionCancelSurveyResult {
/// The cancellation reason the user chose in the survey. Possible values are: 0. Other 1. I don't use this service enough 2. Technical issues 3. Cost-related reasons 4. I found a better app
#[serde(rename = "cancelSurveyReason")]
pub cancel_survey_reason: Option<i32>,
/// The customized input cancel reason from the user. Only present when cancelReason is 0.
#[serde(rename = "userInputCancelReason")]
pub user_input_cancel_reason: Option<String>,
}
impl common::Part for SubscriptionCancelSurveyResult {}
/// A SubscriptionDeferralInfo contains the data needed to defer a subscription purchase to a future expiry time.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionDeferralInfo {
/// 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.
#[serde(rename = "desiredExpiryTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub desired_expiry_time_millis: Option<i64>,
/// 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.
#[serde(rename = "expectedExpiryTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub expected_expiry_time_millis: Option<i64>,
}
impl common::Part for SubscriptionDeferralInfo {}
/// Details of a subscription purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionDetails {
/// The base plan ID of the subscription.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// The offer ID for the current subscription offer.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// The pricing phase for the billing period funded by this order. Deprecated. Use offer_phase_details instead.
#[serde(rename = "offerPhase")]
pub offer_phase: Option<String>,
/// The pricing phase details for the entitlement period funded by this order.
#[serde(rename = "offerPhaseDetails")]
pub offer_phase_details: Option<OfferPhaseDetails>,
/// The end of the billing period funded by this order. This is a snapshot of the billing/service period end time at the moment the order was processed, and should be used only for accounting. To get the current end time of the subscription service period, use purchases.subscriptionsv2.get.
#[serde(rename = "servicePeriodEndTime")]
pub service_period_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The start of the billing period funded by this order. This is a snapshot of the billing/service period start time at the moment the order was processed, and should be used only for accounting.
#[serde(rename = "servicePeriodStartTime")]
pub service_period_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for SubscriptionDetails {}
/// Price change related information of a subscription item.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionItemPriceChangeDetails {
/// The renewal time at which the price change will become effective for the user. This is subject to change(to a future time) due to cases where the renewal time shifts like pause. This field is only populated if the price change has not taken effect.
#[serde(rename = "expectedNewPriceChargeTime")]
pub expected_new_price_charge_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// New recurring price for the subscription item.
#[serde(rename = "newPrice")]
pub new_price: Option<Money>,
/// Price change mode specifies how the subscription item price is changing.
#[serde(rename = "priceChangeMode")]
pub price_change_mode: Option<String>,
/// State the price change is currently in.
#[serde(rename = "priceChangeState")]
pub price_change_state: Option<String>,
}
impl common::Part for SubscriptionItemPriceChangeDetails {}
/// The consumer-visible metadata of a subscription.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionListing {
/// A list of benefits shown to the user on platforms such as the Play Store and in restoration flows in the language of this listing. Plain text. Ordered list of at most four benefits.
pub benefits: Option<Vec<String>>,
/// The description of this subscription in the language of this listing. Maximum length - 80 characters. Plain text.
pub description: Option<String>,
/// Required. The language of this listing, as defined by BCP-47, e.g. "en-US".
#[serde(rename = "languageCode")]
pub language_code: Option<String>,
/// Required. The title of this subscription in the language of this listing. Plain text.
pub title: Option<String>,
}
impl common::Part for SubscriptionListing {}
/// A single, temporary offer
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions base plans offers activate monetization](MonetizationSubscriptionBasePlanOfferActivateCall) (response)
/// * [subscriptions base plans offers create monetization](MonetizationSubscriptionBasePlanOfferCreateCall) (request|response)
/// * [subscriptions base plans offers deactivate monetization](MonetizationSubscriptionBasePlanOfferDeactivateCall) (response)
/// * [subscriptions base plans offers get monetization](MonetizationSubscriptionBasePlanOfferGetCall) (response)
/// * [subscriptions base plans offers patch monetization](MonetizationSubscriptionBasePlanOfferPatchCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionOffer {
/// Required. Immutable. The ID of the base plan to which this offer is an extension.
#[serde(rename = "basePlanId")]
pub base_plan_id: Option<String>,
/// Required. Immutable. Unique ID of this subscription offer. Must be unique within the base plan.
#[serde(rename = "offerId")]
pub offer_id: Option<String>,
/// List of up to 20 custom tags specified for this offer, and returned to the app through the billing library.
#[serde(rename = "offerTags")]
pub offer_tags: Option<Vec<OfferTag>>,
/// The configuration for any new locations Play may launch in the future.
#[serde(rename = "otherRegionsConfig")]
pub other_regions_config: Option<OtherRegionsSubscriptionOfferConfig>,
/// Required. Immutable. The package name of the app the parent subscription belongs to.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// Required. The phases of this subscription offer. Must contain at least one and at most two entries. Users will always receive all these phases in the specified order.
pub phases: Option<Vec<SubscriptionOfferPhase>>,
/// Required. Immutable. The ID of the parent subscription this offer belongs to.
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Required. The region-specific configuration of this offer. Must contain at least one entry.
#[serde(rename = "regionalConfigs")]
pub regional_configs: Option<Vec<RegionalSubscriptionOfferConfig>>,
/// Output only. The current state of this offer. Can be changed using Activate and Deactivate actions. NB: the base plan state supersedes this state, so an active offer may not be available if the base plan is not active.
pub state: Option<String>,
/// The requirements that users need to fulfil to be eligible for this offer. Represents the requirements that Play will evaluate to decide whether an offer should be returned. Developers may further filter these offers themselves.
pub targeting: Option<SubscriptionOfferTargeting>,
}
impl common::RequestValue for SubscriptionOffer {}
impl common::ResponseResult for SubscriptionOffer {}
/// A single phase of a subscription offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionOfferPhase {
/// Required. The duration of a single recurrence of this phase. Specified in ISO 8601 format.
pub duration: Option<String>,
/// Pricing information for any new locations Play may launch in.
#[serde(rename = "otherRegionsConfig")]
pub other_regions_config: Option<OtherRegionsSubscriptionOfferPhaseConfig>,
/// Required. The number of times this phase repeats. If this offer phase is not free, each recurrence charges the user the price of this offer phase.
#[serde(rename = "recurrenceCount")]
pub recurrence_count: Option<i32>,
/// Required. The region-specific configuration of this offer phase. This list must contain exactly one entry for each region for which the subscription offer has a regional config.
#[serde(rename = "regionalConfigs")]
pub regional_configs: Option<Vec<RegionalSubscriptionOfferPhaseConfig>>,
}
impl common::Part for SubscriptionOfferPhase {}
/// Defines the rule a user needs to satisfy to receive this offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionOfferTargeting {
/// Offer targeting rule for new user acquisition.
#[serde(rename = "acquisitionRule")]
pub acquisition_rule: Option<AcquisitionTargetingRule>,
/// Offer targeting rule for upgrading users' existing plans.
#[serde(rename = "upgradeRule")]
pub upgrade_rule: Option<UpgradeTargetingRule>,
}
impl common::Part for SubscriptionOfferTargeting {}
/// 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.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionPriceChange {
/// The new price the subscription will renew with if the price change is accepted by the user.
#[serde(rename = "newPrice")]
pub new_price: Option<Price>,
/// The current state of the price change. Possible values are: 0. 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. 1. 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.
pub state: Option<i32>,
}
impl common::Part for SubscriptionPriceChange {}
/// A SubscriptionPurchase resource indicates the status of a user’s subscription purchase.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions get purchases](PurchaseSubscriptionGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionPurchase {
/// The acknowledgement state of the subscription product. Possible values are: 0. Yet to be acknowledged 1. Acknowledged
#[serde(rename = "acknowledgementState")]
pub acknowledgement_state: Option<i32>,
/// Whether the subscription will automatically be renewed when it reaches its current expiry time.
#[serde(rename = "autoRenewing")]
pub auto_renewing: Option<bool>,
/// Time at which the subscription will be automatically resumed, in milliseconds since the Epoch. Only present if the user has requested to pause the subscription.
#[serde(rename = "autoResumeTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub auto_resume_time_millis: Option<i64>,
/// The reason why a subscription was canceled or is not auto-renewing. Possible values are: 0. User canceled the subscription 1. Subscription was canceled by the system, for example because of a billing problem 2. Subscription was replaced with a new subscription 3. Subscription was canceled by the developer
#[serde(rename = "cancelReason")]
pub cancel_reason: Option<i32>,
/// Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey).
#[serde(rename = "cancelSurveyResult")]
pub cancel_survey_result: Option<SubscriptionCancelSurveyResult>,
/// ISO 3166-1 alpha-2 billing country/region code of the user at the time the subscription was granted.
#[serde(rename = "countryCode")]
pub country_code: Option<String>,
/// A developer-specified string that contains supplemental information about an order.
#[serde(rename = "developerPayload")]
pub developer_payload: Option<String>,
/// The email address of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
#[serde(rename = "emailAddress")]
pub email_address: Option<String>,
/// Time at which the subscription will expire, in milliseconds since the Epoch.
#[serde(rename = "expiryTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub expiry_time_millis: Option<i64>,
/// User account identifier in the third-party service. Only present if account linking happened as part of the subscription purchase flow.
#[serde(rename = "externalAccountId")]
pub external_account_id: Option<String>,
/// The family name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
#[serde(rename = "familyName")]
pub family_name: Option<String>,
/// The given name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
#[serde(rename = "givenName")]
pub given_name: Option<String>,
/// Introductory price information of the subscription. This is only present when the subscription was purchased with an introductory price. This field does not indicate the subscription is currently in introductory price period.
#[serde(rename = "introductoryPriceInfo")]
pub introductory_price_info: Option<IntroductoryPriceInfo>,
/// This kind represents a subscriptionPurchase object in the androidpublisher service.
pub kind: Option<String>,
/// The purchase token of the originating purchase if this subscription is one of the following: 0. Re-signup of a canceled but non-lapsed subscription 1. 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.
#[serde(rename = "linkedPurchaseToken")]
pub linked_purchase_token: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's account in your app. Present for the following purchases: * If account linking happened as part of the subscription purchase flow. * It was specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedaccountid when the purchase was made.
#[serde(rename = "obfuscatedExternalAccountId")]
pub obfuscated_external_account_id: Option<String>,
/// An obfuscated version of the id that is uniquely associated with the user's profile in your app. Only present if specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid when the purchase was made.
#[serde(rename = "obfuscatedExternalProfileId")]
pub obfuscated_external_profile_id: Option<String>,
/// The order id of the latest recurring order associated with the purchase of the subscription. If the subscription was canceled because payment was declined, this will be the order id from the payment declined order.
#[serde(rename = "orderId")]
pub order_id: Option<String>,
/// The payment state of the subscription. Possible values are: 0. Payment pending 1. Payment received 2. Free trial 3. Pending deferred upgrade/downgrade Not present for canceled, expired subscriptions.
#[serde(rename = "paymentState")]
pub payment_state: Option<i32>,
/// Price of the subscription, For tax exclusive countries, the price doesn't include tax. For tax inclusive countries, the price includes 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.
#[serde(rename = "priceAmountMicros")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub price_amount_micros: Option<i64>,
/// The latest price change information available. This is present only when there is an upcoming price change for the subscription yet to be applied. Once the subscription renews with the new price or the subscription is canceled, no price change information will be returned.
#[serde(rename = "priceChange")]
pub price_change: Option<SubscriptionPriceChange>,
/// ISO 4217 currency code for the subscription price. For example, if the price is specified in British pounds sterling, price_currency_code is "GBP".
#[serde(rename = "priceCurrencyCode")]
pub price_currency_code: Option<String>,
/// The Google profile id of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
#[serde(rename = "profileId")]
pub profile_id: Option<String>,
/// The profile name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
#[serde(rename = "profileName")]
pub profile_name: Option<String>,
/// The promotion code applied on this purchase. This field is only set if a vanity code promotion is applied when the subscription was purchased.
#[serde(rename = "promotionCode")]
pub promotion_code: Option<String>,
/// The type of promotion applied on this purchase. This field is only set if a promotion is applied when the subscription was purchased. Possible values are: 0. One time code 1. Vanity code
#[serde(rename = "promotionType")]
pub promotion_type: Option<i32>,
/// 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: 0. Test (i.e. purchased from a license testing account) 1. Promo (i.e. purchased using a promo code)
#[serde(rename = "purchaseType")]
pub purchase_type: Option<i32>,
/// Time at which the subscription was granted, in milliseconds since the Epoch.
#[serde(rename = "startTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub start_time_millis: Option<i64>,
/// The time at which the subscription was canceled by the user, in milliseconds since the epoch. Only present if cancelReason is 0.
#[serde(rename = "userCancellationTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub user_cancellation_time_millis: Option<i64>,
}
impl common::ResponseResult for SubscriptionPurchase {}
/// Item-level info for a subscription purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionPurchaseLineItem {
/// The item is auto renewing.
#[serde(rename = "autoRenewingPlan")]
pub auto_renewing_plan: Option<AutoRenewingPlan>,
/// Information for deferred item removal.
#[serde(rename = "deferredItemRemoval")]
pub deferred_item_removal: Option<DeferredItemRemoval>,
/// Information for deferred item replacement.
#[serde(rename = "deferredItemReplacement")]
pub deferred_item_replacement: Option<DeferredItemReplacement>,
/// Time at which the subscription expired or will expire unless the access is extended (ex. renews).
#[serde(rename = "expiryTime")]
pub expiry_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Details of the item being replaced. This field is only populated if this item replaced another item in a previous subscription and is only available for 60 days after the purchase time.
#[serde(rename = "itemReplacement")]
pub item_replacement: Option<ItemReplacement>,
/// The order id of the latest successful order associated with this item. Not present if the item is not owned by the user yet (e.g. the item being deferred replaced to).
#[serde(rename = "latestSuccessfulOrderId")]
pub latest_successful_order_id: Option<String>,
/// The offer details for this item.
#[serde(rename = "offerDetails")]
pub offer_details: Option<OfferDetails>,
/// The item is prepaid.
#[serde(rename = "prepaidPlan")]
pub prepaid_plan: Option<PrepaidPlan>,
/// The purchased product ID (for example, 'monthly001').
#[serde(rename = "productId")]
pub product_id: Option<String>,
/// Promotion details about this item. Only set if a promotion was applied during signup.
#[serde(rename = "signupPromotion")]
pub signup_promotion: Option<SignupPromotion>,
}
impl common::Part for SubscriptionPurchaseLineItem {}
/// Indicates the status of a user’s subscription purchase.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptionsv2 get purchases](PurchaseSubscriptionsv2GetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionPurchaseV2 {
/// The acknowledgement state of the subscription.
#[serde(rename = "acknowledgementState")]
pub acknowledgement_state: Option<String>,
/// Additional context around canceled subscriptions. Only present if the subscription currently has subscription_state SUBSCRIPTION_STATE_CANCELED or SUBSCRIPTION_STATE_EXPIRED.
#[serde(rename = "canceledStateContext")]
pub canceled_state_context: Option<CanceledStateContext>,
/// User account identifier in the third-party service.
#[serde(rename = "externalAccountIdentifiers")]
pub external_account_identifiers: Option<ExternalAccountIdentifiers>,
/// This kind represents a SubscriptionPurchaseV2 object in the androidpublisher service.
pub kind: Option<String>,
/// Deprecated: Use line_items.latest_successful_order_id instead. The order id of the latest order associated with the purchase of the subscription. For autoRenewing subscription, this is the order id of signup order if it is not renewed yet, or the last recurring order id (success, pending, or declined order). For prepaid subscription, this is the order id associated with the queried purchase token.
#[serde(rename = "latestOrderId")]
pub latest_order_id: Option<String>,
/// Item-level info for a subscription purchase. The items in the same purchase should be either all with AutoRenewingPlan or all with PrepaidPlan.
#[serde(rename = "lineItems")]
pub line_items: Option<Vec<SubscriptionPurchaseLineItem>>,
/// The purchase token of the old subscription if this subscription is one of the following: * Re-signup of a canceled but non-lapsed subscription * Upgrade/downgrade from a previous subscription. * Convert from prepaid to auto renewing subscription. * Convert from an auto renewing subscription to prepaid. * Topup a prepaid subscription.
#[serde(rename = "linkedPurchaseToken")]
pub linked_purchase_token: Option<String>,
/// Additional context for out of app purchases. This information is only present for re-subscription purchases (subscription purchases made after the previous subscription of the same product has expired) made through the Google Play subscriptions center. This field will be removed after you acknowledge the subscription.
#[serde(rename = "outOfAppPurchaseContext")]
pub out_of_app_purchase_context: Option<OutOfAppPurchaseContext>,
/// Additional context around paused subscriptions. Only present if the subscription currently has subscription_state SUBSCRIPTION_STATE_PAUSED.
#[serde(rename = "pausedStateContext")]
pub paused_state_context: Option<PausedStateContext>,
/// ISO 3166-1 alpha-2 billing country/region code of the user at the time the subscription was granted.
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
/// Time at which the subscription was granted. Not set for pending subscriptions (subscription was created but awaiting payment during signup).
#[serde(rename = "startTime")]
pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// User profile associated with purchases made with 'Subscribe with Google'.
#[serde(rename = "subscribeWithGoogleInfo")]
pub subscribe_with_google_info: Option<SubscribeWithGoogleInfo>,
/// The current state of the subscription.
#[serde(rename = "subscriptionState")]
pub subscription_state: Option<String>,
/// Only present if this subscription purchase is a test purchase.
#[serde(rename = "testPurchase")]
pub test_purchase: Option<TestPurchase>,
}
impl common::ResponseResult for SubscriptionPurchaseV2 {}
/// Request for the purchases.subscriptions.acknowledge API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions acknowledge purchases](PurchaseSubscriptionAcknowledgeCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionPurchasesAcknowledgeRequest {
/// Payload to attach to the purchase.
#[serde(rename = "developerPayload")]
pub developer_payload: Option<String>,
/// Optional. User account identifier in your app.
#[serde(rename = "externalAccountIds")]
pub external_account_ids: Option<ExternalAccountIds>,
}
impl common::RequestValue for SubscriptionPurchasesAcknowledgeRequest {}
/// Request for the purchases.subscriptions.defer API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions defer purchases](PurchaseSubscriptionDeferCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionPurchasesDeferRequest {
/// The information about the new desired expiry time for the subscription.
#[serde(rename = "deferralInfo")]
pub deferral_info: Option<SubscriptionDeferralInfo>,
}
impl common::RequestValue for SubscriptionPurchasesDeferRequest {}
/// Response for the purchases.subscriptions.defer API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [subscriptions defer purchases](PurchaseSubscriptionDeferCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionPurchasesDeferResponse {
/// The new expiry time for the subscription in milliseconds since the Epoch.
#[serde(rename = "newExpiryTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub new_expiry_time_millis: Option<i64>,
}
impl common::ResponseResult for SubscriptionPurchasesDeferResponse {}
/// Details about taxation, Google Play policy, and legal compliance for subscription products.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionTaxAndComplianceSettings {
/// Digital content or service classification for products distributed to users in the European Economic Area (EEA). The withdrawal regime under EEA consumer laws depends on this classification. Refer to the [Help Center article](https://support.google.com/googleplay/android-developer/answer/10463498) for more information.
#[serde(rename = "eeaWithdrawalRightType")]
pub eea_withdrawal_right_type: Option<String>,
/// Whether this subscription is declared as a product representing a tokenized digital asset.
#[serde(rename = "isTokenizedDigitalAsset")]
pub is_tokenized_digital_asset: Option<bool>,
/// Product tax category code to assign to the subscription. Product tax category determines the transaction tax rates applied to the subscription. Refer to the [Help Center article](https://support.google.com/googleplay/android-developer/answer/16408159) for more information.
#[serde(rename = "productTaxCategoryCode")]
pub product_tax_category_code: Option<String>,
/// A mapping from region code to tax rate details. The keys are region codes as defined by Unicode's "CLDR".
#[serde(rename = "taxRateInfoByRegionCode")]
pub tax_rate_info_by_region_code: Option<HashMap<String, RegionalTaxRateInfo>>,
}
impl common::Part for SubscriptionTaxAndComplianceSettings {}
/// Options for system APKs.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SystemApkOptions {
/// Whether to use the rotated key for signing the system APK.
pub rotated: Option<bool>,
/// Whether system APK was generated with uncompressed dex files.
#[serde(rename = "uncompressedDexFiles")]
pub uncompressed_dex_files: Option<bool>,
/// Whether system APK was generated with uncompressed native libraries.
#[serde(rename = "uncompressedNativeLibraries")]
pub uncompressed_native_libraries: Option<bool>,
}
impl common::Part for SystemApkOptions {}
/// Response to list previously created system APK variants.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [variants list systemapks](SystemapkVariantListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SystemApksListResponse {
/// All system APK variants created.
pub variants: Option<Vec<Variant>>,
}
impl common::ResponseResult for SystemApksListResponse {}
/// Representation of a system feature.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SystemFeature {
/// The name of the feature.
pub name: Option<String>,
}
impl common::Part for SystemFeature {}
/// Information specific to cancellations initiated by Google system.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SystemInitiatedCancellation {
_never_set: Option<bool>,
}
impl common::Part for SystemInitiatedCancellation {}
/// Representation of a System-on-Chip (SoC) of an Android device. Can be used to target S+ devices.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SystemOnChip {
/// Required. The designer of the SoC, eg. "Google" Value of build property "ro.soc.manufacturer" https://developer.android.com/reference/android/os/Build#SOC_MANUFACTURER Required.
pub manufacturer: Option<String>,
/// Required. The model of the SoC, eg. "Tensor" Value of build property "ro.soc.model" https://developer.android.com/reference/android/os/Build#SOC_MODEL Required.
pub model: Option<String>,
}
impl common::Part for SystemOnChip {}
/// Targeting details for a recovery action such as regions, android sdk levels, app versions etc.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Targeting {
/// All users are targeted.
#[serde(rename = "allUsers")]
pub all_users: Option<AllUsers>,
/// Targeting is based on android api levels of devices.
#[serde(rename = "androidSdks")]
pub android_sdks: Option<AndroidSdks>,
/// Targeting is based on the user account region.
pub regions: Option<Regions>,
/// Target version codes as a list.
#[serde(rename = "versionList")]
pub version_list: Option<AppVersionList>,
/// Target version codes as a range.
#[serde(rename = "versionRange")]
pub version_range: Option<AppVersionRange>,
}
impl common::Part for Targeting {}
/// Targeting information about the generated apks.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TargetingInfo {
/// List of created asset slices.
#[serde(rename = "assetSliceSet")]
pub asset_slice_set: Option<Vec<AssetSliceSet>>,
/// The package name of this app.
#[serde(rename = "packageName")]
pub package_name: Option<String>,
/// List of the created variants.
pub variant: Option<Vec<SplitApkVariant>>,
}
impl common::Part for TargetingInfo {}
/// Defines the scope of subscriptions which a targeting rule can match to target offers to users based on past or current entitlement.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TargetingRuleScope {
/// The scope of the current targeting rule is any subscription in the parent app.
#[serde(rename = "anySubscriptionInApp")]
pub any_subscription_in_app: Option<TargetingRuleScopeAnySubscriptionInApp>,
/// The scope of the current targeting rule is the subscription with the specified subscription ID. Must be a subscription within the same parent app.
#[serde(rename = "specificSubscriptionInApp")]
pub specific_subscription_in_app: Option<String>,
/// The scope of the current targeting rule is the subscription in which this offer is defined.
#[serde(rename = "thisSubscription")]
pub this_subscription: Option<TargetingRuleScopeThisSubscription>,
}
impl common::Part for TargetingRuleScope {}
/// Represents the targeting rule scope corresponding to any subscription in the parent app.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TargetingRuleScopeAnySubscriptionInApp {
_never_set: Option<bool>,
}
impl common::Part for TargetingRuleScopeAnySubscriptionInApp {}
/// Represents the targeting rule scope corresponding to the subscriptions in which this offer is defined.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TargetingRuleScopeThisSubscription {
_never_set: Option<bool>,
}
impl common::Part for TargetingRuleScopeThisSubscription {}
/// Update type for targeting. Note it is always a subset Targeting.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TargetingUpdate {
/// All users are targeted.
#[serde(rename = "allUsers")]
pub all_users: Option<AllUsers>,
/// Additional android sdk levels are targeted by the recovery action.
#[serde(rename = "androidSdks")]
pub android_sdks: Option<AndroidSdks>,
/// Additional regions are targeted by the recovery action.
pub regions: Option<Regions>,
}
impl common::Part for TargetingUpdate {}
/// Whether this subscription purchase is a test purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TestPurchase {
_never_set: Option<bool>,
}
impl common::Part for TestPurchase {}
/// Context about a test purchase.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TestPurchaseContext {
/// The fop type of the test purchase.
#[serde(rename = "fopType")]
pub fop_type: Option<String>,
}
impl common::Part for TestPurchaseContext {}
/// The testers of an app. The resource for TestersService. Note: while it is possible in the Play Console UI to add testers via email lists, email lists are not supported by this resource.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [testers get edits](EditTesterGetCall) (response)
/// * [testers patch edits](EditTesterPatchCall) (request|response)
/// * [testers update edits](EditTesterUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Testers {
/// All testing Google Groups, as email addresses.
#[serde(rename = "googleGroups")]
pub google_groups: Option<Vec<String>>,
}
impl common::RequestValue for Testers {}
impl common::ResponseResult for Testers {}
/// Represents texture compression format.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TextureCompressionFormat {
/// Alias for texture compression format.
pub alias: Option<String>,
}
impl common::Part for TextureCompressionFormat {}
/// Targeting by a texture compression format.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TextureCompressionFormatTargeting {
/// List of alternative TCFs (TCFs targeted by the sibling splits).
pub alternatives: Option<Vec<TextureCompressionFormat>>,
/// The list of targeted TCFs. Should not be empty.
pub value: Option<Vec<TextureCompressionFormat>>,
}
impl common::Part for TextureCompressionFormatTargeting {}
/// A Timestamp represents a point in time independent of any time zone or local calendar, encoded as a count of seconds and fractions of seconds at nanosecond resolution. The count is relative to an epoch at UTC midnight on January 1, 1970.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Timestamp {
/// Non-negative fractions of a second at nanosecond resolution. Must be from 0 to 999,999,999 inclusive.
pub nanos: Option<i32>,
/// Represents seconds of UTC time since Unix epoch.
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub seconds: Option<i64>,
}
impl common::Part for Timestamp {}
/// Pagination information returned by a List operation when token pagination is enabled. List operations that supports paging return only one "page" of results. This protocol buffer message describes the page that has been returned. When using token pagination, clients should use the next/previous token to get another page of the result. The presence or absence of next/previous token indicates whether a next/previous page is available and provides a mean of accessing this page. ListRequest.page_token should be set to either next_page_token or previous_page_token to access another page.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TokenPagination {
/// Tokens to pass to the standard list field 'page_token'. Whenever available, tokens are preferred over manipulating start_index.
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
/// no description provided
#[serde(rename = "previousPageToken")]
pub previous_page_token: Option<String>,
}
impl common::Part for TokenPagination {}
/// A track configuration. The resource for TracksService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [tracks create edits](EditTrackCreateCall) (response)
/// * [tracks get edits](EditTrackGetCall) (response)
/// * [tracks patch edits](EditTrackPatchCall) (request|response)
/// * [tracks update edits](EditTrackUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Track {
/// In a read request, represents all active releases in the track. In an update request, represents desired changes.
pub releases: Option<Vec<TrackRelease>>,
/// Identifier of the track. Form factor tracks have a special prefix as an identifier, for example `wear:production`, `automotive:production`. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
pub track: Option<String>,
}
impl common::RequestValue for Track {}
impl common::ResponseResult for Track {}
/// Configurations of the new track.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [tracks create edits](EditTrackCreateCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TrackConfig {
/// Required. Form factor of the new track. Defaults to the default track.
#[serde(rename = "formFactor")]
pub form_factor: Option<String>,
/// Required. Identifier of the new track. For default tracks, this field consists of the track alias only. Form factor tracks have a special prefix as an identifier, for example `wear:production`, `automotive:production`. This prefix must match the value of the `form_factor` field, if it is not a default track. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
pub track: Option<String>,
/// Required. Type of the new track. Currently, the only supported value is closedTesting.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::RequestValue for TrackConfig {}
/// Resource for per-track country availability information.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [countryavailability get edits](EditCountryavailabilityGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TrackCountryAvailability {
/// A list of one or more countries where artifacts in this track are available. This list includes all countries that are targeted by the track, even if only specific carriers are targeted in that country.
pub countries: Option<Vec<TrackTargetedCountry>>,
/// Whether artifacts in this track are available to "rest of the world" countries.
#[serde(rename = "restOfWorld")]
pub rest_of_world: Option<bool>,
/// Whether this track's availability is synced with the default production track. See https://support.google.com/googleplay/android-developer/answer/7550024 for more information on syncing country availability with production. Note that if this is true, the returned "countries" and "rest_of_world" fields will reflect the values for the default production track.
#[serde(rename = "syncWithProduction")]
pub sync_with_production: Option<bool>,
}
impl common::ResponseResult for TrackCountryAvailability {}
/// A release within a track.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TrackRelease {
/// Restricts a release to a specific set of countries. Note this is only allowed to be set for inProgress releases in the production track.
#[serde(rename = "countryTargeting")]
pub country_targeting: Option<CountryTargeting>,
/// In-app update priority of the release. All newly added APKs in the release will be considered at this priority. Can take values in the range [0, 5], with 5 the highest priority. Defaults to 0. in_app_update_priority can not be updated once the release is rolled out. See https://developer.android.com/guide/playcore/in-app-updates.
#[serde(rename = "inAppUpdatePriority")]
pub in_app_update_priority: Option<i32>,
/// The release name. Not required to be unique. If not set, the name is generated from the APK's version_name. If the release contains multiple APKs, the name is generated from the date.
pub name: Option<String>,
/// A description of what is new in this release.
#[serde(rename = "releaseNotes")]
pub release_notes: Option<Vec<LocalizedText>>,
/// The status of the release.
pub status: Option<String>,
/// Fraction of users who are eligible for a staged release. 0 < fraction < 1. Can only be set when status is "inProgress" or "halted".
#[serde(rename = "userFraction")]
pub user_fraction: Option<f64>,
/// Version codes of all APKs in the release. Must include version codes to retain from previous releases.
#[serde(rename = "versionCodes")]
#[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
pub version_codes: Option<Vec<i64>>,
}
impl common::Part for TrackRelease {}
/// Representation of a single country where the contents of a track are available.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TrackTargetedCountry {
/// The country to target, as a two-letter CLDR code.
#[serde(rename = "countryCode")]
pub country_code: Option<String>,
}
impl common::Part for TrackTargetedCountry {}
/// Response listing all tracks.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [tracks list edits](EditTrackListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TracksListResponse {
/// The kind of this response ("androidpublisher#tracksListResponse").
pub kind: Option<String>,
/// All tracks (including tracks with no releases).
pub tracks: Option<Vec<Track>>,
}
impl common::ResponseResult for TracksListResponse {}
/// Request message to update the state of a subscription base plan.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdateBasePlanStateRequest {
/// Activates a base plan. Once activated, base plans will be available to new subscribers.
#[serde(rename = "activateBasePlanRequest")]
pub activate_base_plan_request: Option<ActivateBasePlanRequest>,
/// Deactivates a base plan. Once deactivated, the base plan will become unavailable to new subscribers, but existing subscribers will maintain their subscription
#[serde(rename = "deactivateBasePlanRequest")]
pub deactivate_base_plan_request: Option<DeactivateBasePlanRequest>,
}
impl common::Part for UpdateBasePlanStateRequest {}
/// Request message for UpdateOneTimeProductOffer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdateOneTimeProductOfferRequest {
/// Optional. If set to true, and the offer with the given package_name, product_id, purchase_option_id and offer_id doesn't exist, an offer will be created. If a new offer is created, the update_mask is ignored.
#[serde(rename = "allowMissing")]
pub allow_missing: Option<bool>,
/// Optional. The latency tolerance for the propagation of this offer update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The one-time product offer to update.
#[serde(rename = "oneTimeProductOffer")]
pub one_time_product_offer: Option<OneTimeProductOffer>,
/// Required. The version of the available regions being used for the offer.
#[serde(rename = "regionsVersion")]
pub regions_version: Option<RegionsVersion>,
/// Required. The list of fields to be updated.
#[serde(rename = "updateMask")]
pub update_mask: Option<common::FieldMask>,
}
impl common::Part for UpdateOneTimeProductOfferRequest {}
/// Request message to update the state of a one-time product offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdateOneTimeProductOfferStateRequest {
/// Activates an offer. Once activated, the offer is available to users, as long as its conditions are met.
#[serde(rename = "activateOneTimeProductOfferRequest")]
pub activate_one_time_product_offer_request: Option<ActivateOneTimeProductOfferRequest>,
/// Cancels an offer. Once cancelled, the offer is not available to users. Any pending orders related to this offer will be cancelled. This state transition is specific to pre-orders.
#[serde(rename = "cancelOneTimeProductOfferRequest")]
pub cancel_one_time_product_offer_request: Option<CancelOneTimeProductOfferRequest>,
/// Deactivates an offer. Once deactivated, the offer is no longer available to users. This state transition is specific to discounted offers.
#[serde(rename = "deactivateOneTimeProductOfferRequest")]
pub deactivate_one_time_product_offer_request: Option<DeactivateOneTimeProductOfferRequest>,
}
impl common::Part for UpdateOneTimeProductOfferStateRequest {}
/// Request message for UpdateOneTimeProduct.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdateOneTimeProductRequest {
/// Optional. If set to true, and the one-time product with the given package_name and product_id doesn't exist, the one-time product will be created. If a new one-time product is created, update_mask is ignored.
#[serde(rename = "allowMissing")]
pub allow_missing: Option<bool>,
/// Optional. The latency tolerance for the propagation of this product upsert. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The one-time product to upsert.
#[serde(rename = "oneTimeProduct")]
pub one_time_product: Option<OneTimeProduct>,
/// Required. The version of the available regions being used for the one-time product.
#[serde(rename = "regionsVersion")]
pub regions_version: Option<RegionsVersion>,
/// Required. The list of fields to be updated.
#[serde(rename = "updateMask")]
pub update_mask: Option<common::FieldMask>,
}
impl common::Part for UpdateOneTimeProductRequest {}
/// Request message to update the state of a one-time product purchase option.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdatePurchaseOptionStateRequest {
/// Activates a purchase option. Once activated, the purchase option will be available.
#[serde(rename = "activatePurchaseOptionRequest")]
pub activate_purchase_option_request: Option<ActivatePurchaseOptionRequest>,
/// Deactivates a purchase option. Once deactivated, the purchase option will become unavailable.
#[serde(rename = "deactivatePurchaseOptionRequest")]
pub deactivate_purchase_option_request: Option<DeactivatePurchaseOptionRequest>,
}
impl common::Part for UpdatePurchaseOptionStateRequest {}
/// Request message for UpdateSubscriptionOffer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdateSubscriptionOfferRequest {
/// Optional. If set to true, and the subscription offer with the given package_name, product_id, base_plan_id and offer_id doesn't exist, an offer will be created. If a new offer is created, update_mask is ignored.
#[serde(rename = "allowMissing")]
pub allow_missing: Option<bool>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The version of the available regions being used for the subscription_offer.
#[serde(rename = "regionsVersion")]
pub regions_version: Option<RegionsVersion>,
/// Required. The subscription offer to update.
#[serde(rename = "subscriptionOffer")]
pub subscription_offer: Option<SubscriptionOffer>,
/// Required. The list of fields to be updated.
#[serde(rename = "updateMask")]
pub update_mask: Option<common::FieldMask>,
}
impl common::Part for UpdateSubscriptionOfferRequest {}
/// Request message to update the state of a subscription offer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdateSubscriptionOfferStateRequest {
/// Activates an offer. Once activated, the offer will be available to new subscribers.
#[serde(rename = "activateSubscriptionOfferRequest")]
pub activate_subscription_offer_request: Option<ActivateSubscriptionOfferRequest>,
/// Deactivates an offer. Once deactivated, the offer will become unavailable to new subscribers, but existing subscribers will maintain their subscription
#[serde(rename = "deactivateSubscriptionOfferRequest")]
pub deactivate_subscription_offer_request: Option<DeactivateSubscriptionOfferRequest>,
}
impl common::Part for UpdateSubscriptionOfferStateRequest {}
/// Request message for UpdateSubscription.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpdateSubscriptionRequest {
/// Optional. If set to true, and the subscription with the given package_name and product_id doesn't exist, the subscription will be created. If a new subscription is created, update_mask is ignored.
#[serde(rename = "allowMissing")]
pub allow_missing: Option<bool>,
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
#[serde(rename = "latencyTolerance")]
pub latency_tolerance: Option<String>,
/// Required. The version of the available regions being used for the subscription.
#[serde(rename = "regionsVersion")]
pub regions_version: Option<RegionsVersion>,
/// Required. The subscription to update.
pub subscription: Option<Subscription>,
/// Required. The list of fields to be updated.
#[serde(rename = "updateMask")]
pub update_mask: Option<common::FieldMask>,
}
impl common::Part for UpdateSubscriptionRequest {}
/// Represents a targeting rule of the form: User currently has {scope} [with billing period {billing_period}].
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UpgradeTargetingRule {
/// The specific billing period duration, specified in ISO 8601 format, that a user must be currently subscribed to to be eligible for this rule. If not specified, users subscribed to any billing period are matched.
#[serde(rename = "billingPeriodDuration")]
pub billing_period_duration: Option<String>,
/// Limit this offer to only once per user. If set to true, a user can never be eligible for this offer again if they ever subscribed to this offer.
#[serde(rename = "oncePerUser")]
pub once_per_user: Option<bool>,
/// Required. The scope of subscriptions this rule considers. Only allows "this subscription" and "specific subscription in app".
pub scope: Option<TargetingRuleScope>,
}
impl common::Part for UpgradeTargetingRule {}
/// A user resource.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [create users](UserCreateCall) (request|response)
/// * [delete users](UserDeleteCall) (none)
/// * [list users](UserListCall) (none)
/// * [patch users](UserPatchCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct User {
/// Output only. The state of the user's access to the Play Console.
#[serde(rename = "accessState")]
pub access_state: Option<String>,
/// Permissions for the user which apply across the developer account.
#[serde(rename = "developerAccountPermissions")]
pub developer_account_permissions: Option<Vec<String>>,
/// Immutable. The user's email address.
pub email: Option<String>,
/// The time at which the user's access expires, if set. When setting this value, it must always be in the future.
#[serde(rename = "expirationTime")]
pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Output only. Per-app permissions for the user.
pub grants: Option<Vec<Grant>>,
/// Required. Resource name for this user, following the pattern "developers/{developer}/users/{email}".
pub name: Option<String>,
/// Output only. Whether there are more permissions for the user that are not represented here. This can happen if the caller does not have permission to manage all apps in the account. This is also `true` if this user is the account owner. If this field is `true`, it should be taken as a signal that this user cannot be fully managed via the API. That is, the API caller is not be able to manage all of the permissions this user holds, either because it doesn't know about them or because the user is the account owner.
pub partial: Option<bool>,
}
impl common::RequestValue for User {}
impl common::Resource for User {}
impl common::ResponseResult for User {}
/// User entry from conversation between user and developer.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UserComment {
/// Integer Android SDK version of the user's device at the time the review was written, e.g. 23 is Marshmallow. May be absent.
#[serde(rename = "androidOsVersion")]
pub android_os_version: Option<i32>,
/// Integer version code of the app as installed at the time the review was written. May be absent.
#[serde(rename = "appVersionCode")]
pub app_version_code: Option<i32>,
/// String version name of the app as installed at the time the review was written. May be absent.
#[serde(rename = "appVersionName")]
pub app_version_name: Option<String>,
/// Codename for the reviewer's device, e.g. klte, flounder. May be absent.
pub device: Option<String>,
/// Information about the characteristics of the user's device.
#[serde(rename = "deviceMetadata")]
pub device_metadata: Option<DeviceMetadata>,
/// The last time at which this comment was updated.
#[serde(rename = "lastModified")]
pub last_modified: Option<Timestamp>,
/// Untranslated text of the review, where the review was translated. If the review was not translated this is left blank.
#[serde(rename = "originalText")]
pub original_text: Option<String>,
/// 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.
#[serde(rename = "reviewerLanguage")]
pub reviewer_language: Option<String>,
/// The star rating associated with the review, from 1 to 5.
#[serde(rename = "starRating")]
pub star_rating: Option<i32>,
/// 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.
pub text: Option<String>,
/// Number of users who have given this review a thumbs down.
#[serde(rename = "thumbsDownCount")]
pub thumbs_down_count: Option<i32>,
/// Number of users who have given this review a thumbs up.
#[serde(rename = "thumbsUpCount")]
pub thumbs_up_count: Option<i32>,
}
impl common::Part for UserComment {}
/// Describes an inclusive/exclusive list of country codes that module targets.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UserCountriesTargeting {
/// List of country codes in the two-letter CLDR territory format.
#[serde(rename = "countryCodes")]
pub country_codes: Option<Vec<String>>,
/// Indicates if the list above is exclusive.
pub exclude: Option<bool>,
}
impl common::Part for UserCountriesTargeting {}
/// A set of user countries. A country set determines what variation of app content gets served to a specific location.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UserCountrySet {
/// List of country codes representing countries. A Country code is represented in ISO 3166 alpha-2 format. For Example:- "IT" for Italy, "GE" for Georgia.
#[serde(rename = "countryCodes")]
pub country_codes: Option<Vec<String>>,
/// Country set name.
pub name: Option<String>,
}
impl common::Part for UserCountrySet {}
/// Information specific to cancellations initiated by users.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UserInitiatedCancellation {
/// Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey).
#[serde(rename = "cancelSurveyResult")]
pub cancel_survey_result: Option<CancelSurveyResult>,
/// The time at which the subscription was canceled by the user. The user might still have access to the subscription after this time. Use line_items.expiry_time to determine if a user still has access.
#[serde(rename = "cancelTime")]
pub cancel_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for UserInitiatedCancellation {}
/// A permission used by this APK.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct UsesPermission {
/// Optionally, the maximum SDK version for which the permission is required.
#[serde(rename = "maxSdkVersion")]
pub max_sdk_version: Option<i32>,
/// The name of the permission requested.
pub name: Option<String>,
}
impl common::Part for UsesPermission {}
/// A multiple use, predefined promotion code.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VanityCode {
/// The promotion code.
#[serde(rename = "promotionCode")]
pub promotion_code: Option<String>,
}
impl common::Part for VanityCode {}
/// APK that is suitable for inclusion in a system image. The resource of SystemApksService.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [variants create systemapks](SystemapkVariantCreateCall) (request|response)
/// * [variants get systemapks](SystemapkVariantGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Variant {
/// The device spec used to generate the APK.
#[serde(rename = "deviceSpec")]
pub device_spec: Option<DeviceSpec>,
/// Optional. Options applied to the generated APK.
pub options: Option<SystemApkOptions>,
/// Output only. The ID of a previously created system APK variant.
#[serde(rename = "variantId")]
pub variant_id: Option<u32>,
}
impl common::RequestValue for Variant {}
impl common::ResponseResult for Variant {}
/// Targeting on the level of variants.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VariantTargeting {
/// The abi that the variant targets
#[serde(rename = "abiTargeting")]
pub abi_targeting: Option<AbiTargeting>,
/// Multi-api-level targeting
#[serde(rename = "multiAbiTargeting")]
pub multi_abi_targeting: Option<MultiAbiTargeting>,
/// The screen densities that this variant supports
#[serde(rename = "screenDensityTargeting")]
pub screen_density_targeting: Option<ScreenDensityTargeting>,
/// The sdk version that the variant targets
#[serde(rename = "sdkVersionTargeting")]
pub sdk_version_targeting: Option<SdkVersionTargeting>,
/// Texture-compression-format-level targeting
#[serde(rename = "textureCompressionFormatTargeting")]
pub texture_compression_format_targeting: Option<TextureCompressionFormatTargeting>,
}
impl common::Part for VariantTargeting {}
/// A VoidedPurchase resource indicates a purchase that was either canceled/refunded/charged-back.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VoidedPurchase {
/// This kind represents a voided purchase object in the androidpublisher service.
pub kind: Option<String>,
/// The order id which uniquely identifies a one-time purchase, subscription purchase, or subscription renewal.
#[serde(rename = "orderId")]
pub order_id: Option<String>,
/// The time at which the purchase was made, in milliseconds since the epoch (Jan 1, 1970).
#[serde(rename = "purchaseTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub purchase_time_millis: Option<i64>,
/// 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).
#[serde(rename = "purchaseToken")]
pub purchase_token: Option<String>,
/// The voided quantity as the result of a quantity-based partial refund. Voided purchases of quantity-based partial refunds may only be returned when includeQuantityBasedPartialRefund is set to true.
#[serde(rename = "voidedQuantity")]
pub voided_quantity: Option<i32>,
/// The reason why the purchase was voided, possible values are: 0. Other 1. Remorse 2. Not_received 3. Defective 4. Accidental_purchase 5. Fraud 6. Friendly_fraud 7. Chargeback 8. Unacknowledged_purchase
#[serde(rename = "voidedReason")]
pub voided_reason: Option<i32>,
/// The initiator of voided purchase, possible values are: 0. User 1. Developer 2. Google
#[serde(rename = "voidedSource")]
pub voided_source: Option<i32>,
/// The time at which the purchase was canceled/refunded/charged-back, in milliseconds since the epoch (Jan 1, 1970).
#[serde(rename = "voidedTimeMillis")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub voided_time_millis: Option<i64>,
}
impl common::Part for VoidedPurchase {}
/// Response for the voidedpurchases.list API.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [voidedpurchases list purchases](PurchaseVoidedpurchaseListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VoidedPurchasesListResponse {
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// Pagination information for token pagination.
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// no description provided
#[serde(rename = "voidedPurchases")]
pub voided_purchases: Option<Vec<VoidedPurchase>>,
}
impl common::ResponseResult for VoidedPurchasesListResponse {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *application* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `data_safety(...)`, `device_tier_configs_create(...)`, `device_tier_configs_get(...)` and `device_tier_configs_list(...)`
/// // to build up your call.
/// let rb = hub.applications();
/// # }
/// ```
pub struct ApplicationMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for ApplicationMethods<'a, C> {}
impl<'a, C> ApplicationMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Creates a new device tier config for an app.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
pub fn device_tier_configs_create(
&self,
request: DeviceTierConfig,
package_name: &str,
) -> ApplicationDeviceTierConfigCreateCall<'a, C> {
ApplicationDeviceTierConfigCreateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_allow_unknown_devices: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns a particular device tier config.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `deviceTierConfigId` - Required. Id of an existing device tier config.
pub fn device_tier_configs_get(
&self,
package_name: &str,
device_tier_config_id: i64,
) -> ApplicationDeviceTierConfigGetCall<'a, C> {
ApplicationDeviceTierConfigGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_device_tier_config_id: device_tier_config_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns created device tier configs, ordered by descending creation time.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
pub fn device_tier_configs_list(
&self,
package_name: &str,
) -> ApplicationDeviceTierConfigListCall<'a, C> {
ApplicationDeviceTierConfigListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Writes the Safety Labels declaration of an app.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Package name of the app.
pub fn data_safety(
&self,
request: SafetyLabelsUpdateRequest,
package_name: &str,
) -> ApplicationDataSafetyCall<'a, C> {
ApplicationDataSafetyCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *apprecovery* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `add_targeting(...)`, `cancel(...)`, `create(...)`, `deploy(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.apprecovery();
/// # }
/// ```
pub struct ApprecoveryMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for ApprecoveryMethods<'a, C> {}
impl<'a, C> ApprecoveryMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Incrementally update targeting for a recovery action. Note that only the criteria selected during the creation of recovery action can be expanded.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Package name of the app for which recovery action is to be updated.
/// * `appRecoveryId` - Required. ID corresponding to the app recovery action.
pub fn add_targeting(
&self,
request: AddTargetingRequest,
package_name: &str,
app_recovery_id: i64,
) -> ApprecoveryAddTargetingCall<'a, C> {
ApprecoveryAddTargetingCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_app_recovery_id: app_recovery_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Cancel an already executing app recovery action. Note that this action changes status of the recovery action to CANCELED.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Package name of the app for which recovery action cancellation is requested.
/// * `appRecoveryId` - Required. ID corresponding to the app recovery action.
pub fn cancel(
&self,
request: CancelAppRecoveryRequest,
package_name: &str,
app_recovery_id: i64,
) -> ApprecoveryCancelCall<'a, C> {
ApprecoveryCancelCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_app_recovery_id: app_recovery_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Create an app recovery action with recovery status as DRAFT. Note that this action does not execute the recovery action.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Package name of the app on which recovery action is performed.
pub fn create(
&self,
request: CreateDraftAppRecoveryRequest,
package_name: &str,
) -> ApprecoveryCreateCall<'a, C> {
ApprecoveryCreateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deploy an already created app recovery action with recovery status DRAFT. Note that this action activates the recovery action for all targeted users and changes its status to ACTIVE.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Package name of the app for which recovery action is deployed.
/// * `appRecoveryId` - Required. ID corresponding to the app recovery action to deploy.
pub fn deploy(
&self,
request: DeployAppRecoveryRequest,
package_name: &str,
app_recovery_id: i64,
) -> ApprecoveryDeployCall<'a, C> {
ApprecoveryDeployCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_app_recovery_id: app_recovery_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List all app recovery action resources associated with a particular package name and app version.
///
/// # Arguments
///
/// * `packageName` - Required. Package name of the app for which list of recovery actions is requested.
pub fn list(&self, package_name: &str) -> ApprecoveryListCall<'a, C> {
ApprecoveryListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_version_code: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *edit* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `apks_addexternallyhosted(...)`, `apks_list(...)`, `apks_upload(...)`, `bundles_list(...)`, `bundles_upload(...)`, `commit(...)`, `countryavailability_get(...)`, `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_create(...)`, `tracks_get(...)`, `tracks_list(...)`, `tracks_patch(...)`, `tracks_update(...)` and `validate(...)`
/// // to build up your call.
/// let rb = hub.edits();
/// # }
/// ```
pub struct EditMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for EditMethods<'a, C> {}
impl<'a, C> EditMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// 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 organizations using Managed Play whose application is configured to restrict distribution to the organizations.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn apks_addexternallyhosted(
&self,
request: ApksAddExternallyHostedRequest,
package_name: &str,
edit_id: &str,
) -> EditApkAddexternallyhostedCall<'a, C> {
EditApkAddexternallyhostedCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all current APKs of the app and edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn apks_list(&self, package_name: &str, edit_id: &str) -> EditApkListCall<'a, C> {
EditApkListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Uploads an APK and adds to the current edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn apks_upload(&self, package_name: &str, edit_id: &str) -> EditApkUploadCall<'a, C> {
EditApkUploadCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all current Android App Bundles of the app and edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn bundles_list(&self, package_name: &str, edit_id: &str) -> EditBundleListCall<'a, C> {
EditBundleListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// 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 [Timeouts and Errors](https://developers.google.com/api-client-library/java/google-api-java-client/errors) for an example in java.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn bundles_upload(&self, package_name: &str, edit_id: &str) -> EditBundleUploadCall<'a, C> {
EditBundleUploadCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_device_tier_config_id: Default::default(),
_ack_bundle_installation_warning: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets country availability.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `track` - The track to read from.
pub fn countryavailability_get(
&self,
package_name: &str,
edit_id: &str,
track: &str,
) -> EditCountryavailabilityGetCall<'a, C> {
EditCountryavailabilityGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_track: track.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Uploads a new deobfuscation file and attaches to the specified APK.
///
/// # Arguments
///
/// * `packageName` - Unique identifier for the Android app.
/// * `editId` - Unique identifier for this edit.
/// * `apkVersionCode` - The version code of the APK whose Deobfuscation File is being uploaded.
/// * `deobfuscationFileType` - The type of the deobfuscation file.
pub fn deobfuscationfiles_upload(
&self,
package_name: &str,
edit_id: &str,
apk_version_code: i32,
deobfuscation_file_type: &str,
) -> EditDeobfuscationfileUploadCall<'a, C> {
EditDeobfuscationfileUploadCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_apk_version_code: apk_version_code,
_deobfuscation_file_type: deobfuscation_file_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets details of an app.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn details_get(&self, package_name: &str, edit_id: &str) -> EditDetailGetCall<'a, C> {
EditDetailGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Patches details of an app.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn details_patch(
&self,
request: AppDetails,
package_name: &str,
edit_id: &str,
) -> EditDetailPatchCall<'a, C> {
EditDetailPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates details of an app.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn details_update(
&self,
request: AppDetails,
package_name: &str,
edit_id: &str,
) -> EditDetailUpdateCall<'a, C> {
EditDetailUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Fetches the expansion file configuration for the specified APK.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `apkVersionCode` - The version code of the APK whose expansion file configuration is being read or modified.
/// * `expansionFileType` - The file type of the file configuration which is being read or modified.
pub fn expansionfiles_get(
&self,
package_name: &str,
edit_id: &str,
apk_version_code: i32,
expansion_file_type: &str,
) -> EditExpansionfileGetCall<'a, C> {
EditExpansionfileGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_apk_version_code: apk_version_code,
_expansion_file_type: expansion_file_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Patches the APK's expansion file configuration to reference another APK's expansion file. To add a new expansion file use the Upload method.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `apkVersionCode` - The version code of the APK whose expansion file configuration is being read or modified.
/// * `expansionFileType` - The file type of the expansion file configuration which is being updated.
pub fn expansionfiles_patch(
&self,
request: ExpansionFile,
package_name: &str,
edit_id: &str,
apk_version_code: i32,
expansion_file_type: &str,
) -> EditExpansionfilePatchCall<'a, C> {
EditExpansionfilePatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_apk_version_code: apk_version_code,
_expansion_file_type: expansion_file_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates the APK's expansion file configuration to reference another APK's expansion file. To add a new expansion file use the Upload method.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `apkVersionCode` - The version code of the APK whose expansion file configuration is being read or modified.
/// * `expansionFileType` - The file type of the file configuration which is being read or modified.
pub fn expansionfiles_update(
&self,
request: ExpansionFile,
package_name: &str,
edit_id: &str,
apk_version_code: i32,
expansion_file_type: &str,
) -> EditExpansionfileUpdateCall<'a, C> {
EditExpansionfileUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_apk_version_code: apk_version_code,
_expansion_file_type: expansion_file_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Uploads a new expansion file and attaches to the specified APK.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `apkVersionCode` - The version code of the APK whose expansion file configuration is being read or modified.
/// * `expansionFileType` - The file type of the expansion file configuration which is being updated.
pub fn expansionfiles_upload(
&self,
package_name: &str,
edit_id: &str,
apk_version_code: i32,
expansion_file_type: &str,
) -> EditExpansionfileUploadCall<'a, C> {
EditExpansionfileUploadCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_apk_version_code: apk_version_code,
_expansion_file_type: expansion_file_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes the image (specified by id) from the edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
/// * `imageType` - Type of the Image.
/// * `imageId` - Unique identifier an image within the set of images attached to this edit.
pub fn images_delete(
&self,
package_name: &str,
edit_id: &str,
language: &str,
image_type: &str,
image_id: &str,
) -> EditImageDeleteCall<'a, C> {
EditImageDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_image_type: image_type.to_string(),
_image_id: image_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes all images for the specified language and image type. Returns an empty response if no images are found.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German). Providing a language that is not supported by the App is a no-op.
/// * `imageType` - Type of the Image. Providing an image type that refers to no images is a no-op.
pub fn images_deleteall(
&self,
package_name: &str,
edit_id: &str,
language: &str,
image_type: &str,
) -> EditImageDeleteallCall<'a, C> {
EditImageDeleteallCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_image_type: image_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all images. The response may be empty.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German). There must be a store listing for the specified language.
/// * `imageType` - Type of the Image. Providing an image type that refers to no images will return an empty response.
pub fn images_list(
&self,
package_name: &str,
edit_id: &str,
language: &str,
image_type: &str,
) -> EditImageListCall<'a, C> {
EditImageListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_image_type: image_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Uploads an image of the specified language and image type, and adds to the edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German). Providing a language that is not supported by the App is a no-op.
/// * `imageType` - Type of the Image.
pub fn images_upload(
&self,
package_name: &str,
edit_id: &str,
language: &str,
image_type: &str,
) -> EditImageUploadCall<'a, C> {
EditImageUploadCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_image_type: image_type.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes a localized store listing.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
pub fn listings_delete(
&self,
package_name: &str,
edit_id: &str,
language: &str,
) -> EditListingDeleteCall<'a, C> {
EditListingDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes all store listings.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn listings_deleteall(
&self,
package_name: &str,
edit_id: &str,
) -> EditListingDeleteallCall<'a, C> {
EditListingDeleteallCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets a localized store listing.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
pub fn listings_get(
&self,
package_name: &str,
edit_id: &str,
language: &str,
) -> EditListingGetCall<'a, C> {
EditListingGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all localized store listings.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn listings_list(&self, package_name: &str, edit_id: &str) -> EditListingListCall<'a, C> {
EditListingListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Patches a localized store listing.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
pub fn listings_patch(
&self,
request: Listing,
package_name: &str,
edit_id: &str,
language: &str,
) -> EditListingPatchCall<'a, C> {
EditListingPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates or updates a localized store listing.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `language` - Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
pub fn listings_update(
&self,
request: Listing,
package_name: &str,
edit_id: &str,
language: &str,
) -> EditListingUpdateCall<'a, C> {
EditListingUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_language: language.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets testers. Note: Testers resource does not support email lists.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `track` - The track to read from.
pub fn testers_get(
&self,
package_name: &str,
edit_id: &str,
track: &str,
) -> EditTesterGetCall<'a, C> {
EditTesterGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_track: track.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Patches testers. Note: Testers resource does not support email lists.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `track` - The track to update.
pub fn testers_patch(
&self,
request: Testers,
package_name: &str,
edit_id: &str,
track: &str,
) -> EditTesterPatchCall<'a, C> {
EditTesterPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_track: track.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates testers. Note: Testers resource does not support email lists.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `track` - The track to update.
pub fn testers_update(
&self,
request: Testers,
package_name: &str,
edit_id: &str,
track: &str,
) -> EditTesterUpdateCall<'a, C> {
EditTesterUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_track: track.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates a new track.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Package name of the app.
/// * `editId` - Required. Identifier of the edit.
pub fn tracks_create(
&self,
request: TrackConfig,
package_name: &str,
edit_id: &str,
) -> EditTrackCreateCall<'a, C> {
EditTrackCreateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets a track.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `track` - Identifier of the track. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
pub fn tracks_get(
&self,
package_name: &str,
edit_id: &str,
track: &str,
) -> EditTrackGetCall<'a, C> {
EditTrackGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_track: track.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all tracks.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn tracks_list(&self, package_name: &str, edit_id: &str) -> EditTrackListCall<'a, C> {
EditTrackListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Patches a track.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `track` - Identifier of the track. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
pub fn tracks_patch(
&self,
request: Track,
package_name: &str,
edit_id: &str,
track: &str,
) -> EditTrackPatchCall<'a, C> {
EditTrackPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_track: track.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a track.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
/// * `track` - Identifier of the track. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
pub fn tracks_update(
&self,
request: Track,
package_name: &str,
edit_id: &str,
track: &str,
) -> EditTrackUpdateCall<'a, C> {
EditTrackUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_track: track.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Commits an app edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn commit(&self, package_name: &str, edit_id: &str) -> EditCommitCall<'a, C> {
EditCommitCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_changes_not_sent_for_review: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes an app edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn delete(&self, package_name: &str, edit_id: &str) -> EditDeleteCall<'a, C> {
EditDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets an app edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn get(&self, package_name: &str, edit_id: &str) -> EditGetCall<'a, C> {
EditGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates a new edit for an app.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
pub fn insert(&self, request: AppEdit, package_name: &str) -> EditInsertCall<'a, C> {
EditInsertCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Validates an app edit.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `editId` - Identifier of the edit.
pub fn validate(&self, package_name: &str, edit_id: &str) -> EditValidateCall<'a, C> {
EditValidateCall {
hub: self.hub,
_package_name: package_name.to_string(),
_edit_id: edit_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *externaltransaction* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `createexternaltransaction(...)`, `getexternaltransaction(...)` and `refundexternaltransaction(...)`
/// // to build up your call.
/// let rb = hub.externaltransactions();
/// # }
/// ```
pub struct ExternaltransactionMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for ExternaltransactionMethods<'a, C> {}
impl<'a, C> ExternaltransactionMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Creates a new external transaction.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `parent` - Required. The parent resource where this external transaction will be created. Format: applications/{package_name}
pub fn createexternaltransaction(
&self,
request: ExternalTransaction,
parent: &str,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C> {
ExternaltransactionCreateexternaltransactionCall {
hub: self.hub,
_request: request,
_parent: parent.to_string(),
_external_transaction_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets an existing external transaction.
///
/// # Arguments
///
/// * `name` - Required. The name of the external transaction to retrieve. Format: applications/{package_name}/externalTransactions/{external_transaction}
pub fn getexternaltransaction(
&self,
name: &str,
) -> ExternaltransactionGetexternaltransactionCall<'a, C> {
ExternaltransactionGetexternaltransactionCall {
hub: self.hub,
_name: name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Refunds or partially refunds an existing external transaction.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `name` - Required. The name of the external transaction that will be refunded. Format: applications/{package_name}/externalTransactions/{external_transaction}
pub fn refundexternaltransaction(
&self,
request: RefundExternalTransactionRequest,
name: &str,
) -> ExternaltransactionRefundexternaltransactionCall<'a, C> {
ExternaltransactionRefundexternaltransactionCall {
hub: self.hub,
_request: request,
_name: name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *generatedapk* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `download(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.generatedapks();
/// # }
/// ```
pub struct GeneratedapkMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for GeneratedapkMethods<'a, C> {}
impl<'a, C> GeneratedapkMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Downloads a single signed APK generated from an app bundle.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `versionCode` - Version code of the app bundle.
/// * `downloadId` - Download ID, which uniquely identifies the APK to download. Can be obtained from the response of `generatedapks.list` method.
pub fn download(
&self,
package_name: &str,
version_code: i32,
download_id: &str,
) -> GeneratedapkDownloadCall<'a, C> {
GeneratedapkDownloadCall {
hub: self.hub,
_package_name: package_name.to_string(),
_version_code: version_code,
_download_id: download_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns download metadata for all APKs that were generated from a given app bundle.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `versionCode` - Version code of the app bundle.
pub fn list(&self, package_name: &str, version_code: i32) -> GeneratedapkListCall<'a, C> {
GeneratedapkListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_version_code: version_code,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *grant* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `create(...)`, `delete(...)` and `patch(...)`
/// // to build up your call.
/// let rb = hub.grants();
/// # }
/// ```
pub struct GrantMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for GrantMethods<'a, C> {}
impl<'a, C> GrantMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Grant access for a user to the given package.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `parent` - Required. The user which needs permission. Format: developers/{developer}/users/{user}
pub fn create(&self, request: Grant, parent: &str) -> GrantCreateCall<'a, C> {
GrantCreateCall {
hub: self.hub,
_request: request,
_parent: parent.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Removes all access for the user to the given package or developer account.
///
/// # Arguments
///
/// * `name` - Required. The name of the grant to delete. Format: developers/{developer}/users/{email}/grants/{package_name}
pub fn delete(&self, name: &str) -> GrantDeleteCall<'a, C> {
GrantDeleteCall {
hub: self.hub,
_name: name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates access for the user to the given package.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `name` - Required. Resource name for this grant, following the pattern "developers/{developer}/users/{email}/grants/{package_name}". If this grant is for a draft app, the app ID will be used in this resource name instead of the package name.
pub fn patch(&self, request: Grant, name: &str) -> GrantPatchCall<'a, C> {
GrantPatchCall {
hub: self.hub,
_request: request,
_name: name.to_string(),
_update_mask: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *inappproduct* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `batch_delete(...)`, `batch_get(...)`, `batch_update(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.inappproducts();
/// # }
/// ```
pub struct InappproductMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for InappproductMethods<'a, C> {}
impl<'a, C> InappproductMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Deletes in-app products (managed products or subscriptions). Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput. This method should not be used to delete subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
pub fn batch_delete(
&self,
request: InappproductsBatchDeleteRequest,
package_name: &str,
) -> InappproductBatchDeleteCall<'a, C> {
InappproductBatchDeleteCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads multiple in-app products, which can be managed products or subscriptions. This method should not be used to retrieve subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
pub fn batch_get(&self, package_name: &str) -> InappproductBatchGetCall<'a, C> {
InappproductBatchGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_sku: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates or inserts one or more in-app products (managed products or subscriptions). Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput. This method should no longer be used to update subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
pub fn batch_update(
&self,
request: InappproductsBatchUpdateRequest,
package_name: &str,
) -> InappproductBatchUpdateCall<'a, C> {
InappproductBatchUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes an in-app product (a managed product or a subscription). This method should no longer be used to delete subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `sku` - Unique identifier for the in-app product.
pub fn delete(&self, package_name: &str, sku: &str) -> InappproductDeleteCall<'a, C> {
InappproductDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_sku: sku.to_string(),
_latency_tolerance: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets an in-app product, which can be a managed product or a subscription. This method should no longer be used to retrieve subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `sku` - Unique identifier for the in-app product.
pub fn get(&self, package_name: &str, sku: &str) -> InappproductGetCall<'a, C> {
InappproductGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_sku: sku.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates an in-app product (a managed product or a subscription). This method should no longer be used to create subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
pub fn insert(
&self,
request: InAppProduct,
package_name: &str,
) -> InappproductInsertCall<'a, C> {
InappproductInsertCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_auto_convert_missing_prices: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all in-app products - both managed products and subscriptions. If an app has a large number of in-app products, the response may be paginated. In this case the response field `tokenPagination.nextPageToken` will be set and the caller should provide its value as a `token` request parameter to retrieve the next page. This method should no longer be used to retrieve subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
pub fn list(&self, package_name: &str) -> InappproductListCall<'a, C> {
InappproductListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_token: Default::default(),
_start_index: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Patches an in-app product (a managed product or a subscription). This method should no longer be used to update subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `sku` - Unique identifier for the in-app product.
pub fn patch(
&self,
request: InAppProduct,
package_name: &str,
sku: &str,
) -> InappproductPatchCall<'a, C> {
InappproductPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_sku: sku.to_string(),
_latency_tolerance: Default::default(),
_auto_convert_missing_prices: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates an in-app product (a managed product or a subscription). This method should no longer be used to update subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `sku` - Unique identifier for the in-app product.
pub fn update(
&self,
request: InAppProduct,
package_name: &str,
sku: &str,
) -> InappproductUpdateCall<'a, C> {
InappproductUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_sku: sku.to_string(),
_latency_tolerance: Default::default(),
_auto_convert_missing_prices: Default::default(),
_allow_missing: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *internalappsharingartifact* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `uploadapk(...)` and `uploadbundle(...)`
/// // to build up your call.
/// let rb = hub.internalappsharingartifacts();
/// # }
/// ```
pub struct InternalappsharingartifactMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for InternalappsharingartifactMethods<'a, C> {}
impl<'a, C> InternalappsharingartifactMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Uploads an APK to internal app sharing. 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 [Timeouts and Errors](https://developers.google.com/api-client-library/java/google-api-java-client/errors) for an example in java.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
pub fn uploadapk(&self, package_name: &str) -> InternalappsharingartifactUploadapkCall<'a, C> {
InternalappsharingartifactUploadapkCall {
hub: self.hub,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Uploads an app bundle to internal app sharing. 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 [Timeouts and Errors](https://developers.google.com/api-client-library/java/google-api-java-client/errors) for an example in java.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
pub fn uploadbundle(
&self,
package_name: &str,
) -> InternalappsharingartifactUploadbundleCall<'a, C> {
InternalappsharingartifactUploadbundleCall {
hub: self.hub,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *monetization* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `convert_region_prices(...)`, `onetimeproducts_batch_delete(...)`, `onetimeproducts_batch_get(...)`, `onetimeproducts_batch_update(...)`, `onetimeproducts_delete(...)`, `onetimeproducts_get(...)`, `onetimeproducts_list(...)`, `onetimeproducts_patch(...)`, `onetimeproducts_purchase_options_batch_delete(...)`, `onetimeproducts_purchase_options_batch_update_states(...)`, `onetimeproducts_purchase_options_offers_activate(...)`, `onetimeproducts_purchase_options_offers_batch_delete(...)`, `onetimeproducts_purchase_options_offers_batch_get(...)`, `onetimeproducts_purchase_options_offers_batch_update(...)`, `onetimeproducts_purchase_options_offers_batch_update_states(...)`, `onetimeproducts_purchase_options_offers_cancel(...)`, `onetimeproducts_purchase_options_offers_deactivate(...)`, `onetimeproducts_purchase_options_offers_list(...)`, `subscriptions_archive(...)`, `subscriptions_base_plans_activate(...)`, `subscriptions_base_plans_batch_migrate_prices(...)`, `subscriptions_base_plans_batch_update_states(...)`, `subscriptions_base_plans_deactivate(...)`, `subscriptions_base_plans_delete(...)`, `subscriptions_base_plans_migrate_prices(...)`, `subscriptions_base_plans_offers_activate(...)`, `subscriptions_base_plans_offers_batch_get(...)`, `subscriptions_base_plans_offers_batch_update(...)`, `subscriptions_base_plans_offers_batch_update_states(...)`, `subscriptions_base_plans_offers_create(...)`, `subscriptions_base_plans_offers_deactivate(...)`, `subscriptions_base_plans_offers_delete(...)`, `subscriptions_base_plans_offers_get(...)`, `subscriptions_base_plans_offers_list(...)`, `subscriptions_base_plans_offers_patch(...)`, `subscriptions_batch_get(...)`, `subscriptions_batch_update(...)`, `subscriptions_create(...)`, `subscriptions_delete(...)`, `subscriptions_get(...)`, `subscriptions_list(...)` and `subscriptions_patch(...)`
/// // to build up your call.
/// let rb = hub.monetization();
/// # }
/// ```
pub struct MonetizationMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for MonetizationMethods<'a, C> {}
impl<'a, C> MonetizationMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Activates a one-time product offer.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the offer to activate.
/// * `productId` - Required. The parent one-time product (ID) of the offer to activate.
/// * `purchaseOptionId` - Required. The parent purchase option (ID) of the offer to activate.
/// * `offerId` - Required. The offer ID of the offer to activate.
pub fn onetimeproducts_purchase_options_offers_activate(
&self,
request: ActivateOneTimeProductOfferRequest,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
offer_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferActivateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_offer_id: offer_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes one or more one-time product offers.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the offers to delete. Must be equal to the package_name field on all the OneTimeProductOffer resources.
/// * `productId` - Required. The product ID of the parent one-time product, if all offers to delete belong to the same product. If this request spans multiple one-time products, set this field to "-".
/// * `purchaseOptionId` - Required. The parent purchase option (ID) for which the offers should be deleted. May be specified as '-' to update offers from multiple purchase options.
pub fn onetimeproducts_purchase_options_offers_batch_delete(
&self,
request: BatchDeleteOneTimeProductOffersRequest,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads one or more one-time product offers.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the updated offers. Must be equal to the package_name field on all the updated OneTimeProductOffer resources.
/// * `productId` - Required. The product ID of the parent one-time product, if all updated offers belong to the same product. If this request spans multiple one-time products, set this field to "-".
/// * `purchaseOptionId` - Required. The parent purchase option (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple purchase options.
pub fn onetimeproducts_purchase_options_offers_batch_get(
&self,
request: BatchGetOneTimeProductOffersRequest,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates or updates one or more one-time product offers.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the updated offers. Must be equal to the package_name field on all the updated OneTimeProductOffer resources.
/// * `productId` - Required. The product ID of the parent one-time product, if all updated offers belong to the same product. If this request spans multiple one-time products, set this field to "-".
/// * `purchaseOptionId` - Required. The parent purchase option (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple purchase options.
pub fn onetimeproducts_purchase_options_offers_batch_update(
&self,
request: BatchUpdateOneTimeProductOffersRequest,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a batch of one-time product offer states.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the updated one-time product offers.
/// * `productId` - Required. The product ID of the parent one-time product, if all updated offers belong to the same one-time product. If this batch update spans multiple one-time products, set this field to "-".
/// * `purchaseOptionId` - Required. The purchase option ID of the parent purchase option, if all updated offers belong to the same purchase option. If this batch update spans multiple purchase options, set this field to "-".
pub fn onetimeproducts_purchase_options_offers_batch_update_states(
&self,
request: BatchUpdateOneTimeProductOfferStatesRequest,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Cancels a one-time product offer.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the offer to cancel.
/// * `productId` - Required. The parent one-time product (ID) of the offer to cancel.
/// * `purchaseOptionId` - Required. The parent purchase option (ID) of the offer to cancel.
/// * `offerId` - Required. The offer ID of the offer to cancel.
pub fn onetimeproducts_purchase_options_offers_cancel(
&self,
request: CancelOneTimeProductOfferRequest,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
offer_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferCancelCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_offer_id: offer_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deactivates a one-time product offer.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the offer to deactivate.
/// * `productId` - Required. The parent one-time product (ID) of the offer to deactivate.
/// * `purchaseOptionId` - Required. The parent purchase option (ID) of the offer to deactivate.
/// * `offerId` - Required. The offer ID of the offer to deactivate.
pub fn onetimeproducts_purchase_options_offers_deactivate(
&self,
request: DeactivateOneTimeProductOfferRequest,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
offer_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_offer_id: offer_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all offers under a given app, product, or purchase option.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) for which the offers should be read.
/// * `productId` - Required. The parent one-time product (ID) for which the offers should be read. May be specified as '-' to read all offers under an app.
/// * `purchaseOptionId` - Required. The parent purchase option (ID) for which the offers should be read. May be specified as '-' to read all offers under a one-time product or an app. Must be specified as '-' if product_id is specified as '-'.
pub fn onetimeproducts_purchase_options_offers_list(
&self,
package_name: &str,
product_id: &str,
purchase_option_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionOfferListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_purchase_option_id: purchase_option_id.to_string(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes purchase options across one or multiple one-time products. By default this operation will fail if there are any existing offers under the deleted purchase options. Use the force parameter to override the default behavior.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the purchase options to delete.
/// * `productId` - Required. The product ID of the parent one-time product, if all purchase options to delete belong to the same one-time product. If this batch delete spans multiple one-time products, set this field to "-".
pub fn onetimeproducts_purchase_options_batch_delete(
&self,
request: BatchDeletePurchaseOptionsRequest,
package_name: &str,
product_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionBatchDeleteCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Activates or deactivates purchase options across one or multiple one-time products.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the updated purchase options.
/// * `productId` - Required. The product ID of the parent one-time product, if all updated purchase options belong to the same one-time product. If this batch update spans multiple one-time products, set this field to "-".
pub fn onetimeproducts_purchase_options_batch_update_states(
&self,
request: BatchUpdatePurchaseOptionStatesRequest,
package_name: &str,
product_id: &str,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C> {
MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes one or more one-time products.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) for which the one-time products should be deleted. Must be equal to the package_name field on all the OneTimeProduct resources.
pub fn onetimeproducts_batch_delete(
&self,
request: BatchDeleteOneTimeProductsRequest,
package_name: &str,
) -> MonetizationOnetimeproductBatchDeleteCall<'a, C> {
MonetizationOnetimeproductBatchDeleteCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads one or more one-time products.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) for which the products should be retrieved. Must be equal to the package_name field on all requests.
pub fn onetimeproducts_batch_get(
&self,
package_name: &str,
) -> MonetizationOnetimeproductBatchGetCall<'a, C> {
MonetizationOnetimeproductBatchGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_ids: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates or updates one or more one-time products.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) for which the one-time products should be updated. Must be equal to the package_name field on all the OneTimeProduct resources.
pub fn onetimeproducts_batch_update(
&self,
request: BatchUpdateOneTimeProductsRequest,
package_name: &str,
) -> MonetizationOnetimeproductBatchUpdateCall<'a, C> {
MonetizationOnetimeproductBatchUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes a one-time product.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) of the one-time product to delete.
/// * `productId` - Required. The one-time product ID of the one-time product to delete.
pub fn onetimeproducts_delete(
&self,
package_name: &str,
product_id: &str,
) -> MonetizationOnetimeproductDeleteCall<'a, C> {
MonetizationOnetimeproductDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_latency_tolerance: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads a single one-time product.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) of the product to retrieve.
/// * `productId` - Required. The product ID of the product to retrieve.
pub fn onetimeproducts_get(
&self,
package_name: &str,
product_id: &str,
) -> MonetizationOnetimeproductGetCall<'a, C> {
MonetizationOnetimeproductGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all one-time products under a given app.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) for which the one-time product should be read.
pub fn onetimeproducts_list(
&self,
package_name: &str,
) -> MonetizationOnetimeproductListCall<'a, C> {
MonetizationOnetimeproductListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates or updates a one-time product.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Immutable. Package name of the parent app.
/// * `productId` - Required. Immutable. Unique product ID of the product. Unique within the parent app. Product IDs must start with a number or lowercase letter, and can contain numbers (0-9), lowercase letters (a-z), underscores (_), and periods (.).
pub fn onetimeproducts_patch(
&self,
request: OneTimeProduct,
package_name: &str,
product_id: &str,
) -> MonetizationOnetimeproductPatchCall<'a, C> {
MonetizationOnetimeproductPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_update_mask: Default::default(),
_regions_version_version: Default::default(),
_latency_tolerance: Default::default(),
_allow_missing: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Activates a subscription offer. Once activated, subscription offers will be available to new subscribers.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the offer to activate.
/// * `productId` - Required. The parent subscription (ID) of the offer to activate.
/// * `basePlanId` - Required. The parent base plan (ID) of the offer to activate.
/// * `offerId` - Required. The unique offer ID of the offer to activate.
pub fn subscriptions_base_plans_offers_activate(
&self,
request: ActivateSubscriptionOfferRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
offer_id: &str,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
MonetizationSubscriptionBasePlanOfferActivateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_offer_id: offer_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads one or more subscription offers.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) for which the subscriptions should be created or updated. Must be equal to the package_name field on all the requests.
/// * `productId` - Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this request spans multiple subscriptions, set this field to "-". Must be set.
/// * `basePlanId` - Required. The parent base plan (ID) for which the offers should be read. May be specified as '-' to read offers from multiple base plans.
pub fn subscriptions_base_plans_offers_batch_get(
&self,
request: BatchGetSubscriptionOffersRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {
MonetizationSubscriptionBasePlanOfferBatchGetCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a batch of subscription offers. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the updated subscription offers. Must be equal to the package_name field on all the updated SubscriptionOffer resources.
/// * `productId` - Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this request spans multiple subscriptions, set this field to "-". Must be set.
/// * `basePlanId` - Required. The parent base plan (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple base plans.
pub fn subscriptions_base_plans_offers_batch_update(
&self,
request: BatchUpdateSubscriptionOffersRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {
MonetizationSubscriptionBasePlanOfferBatchUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a batch of subscription offer states. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the updated subscription offers. Must be equal to the package_name field on all the updated SubscriptionOffer resources.
/// * `productId` - Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this request spans multiple subscriptions, set this field to "-". Must be set.
/// * `basePlanId` - Required. The parent base plan (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple base plans.
pub fn subscriptions_base_plans_offers_batch_update_states(
&self,
request: BatchUpdateSubscriptionOfferStatesRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C> {
MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates a new subscription offer. Only auto-renewing base plans can have subscription offers. The offer state will be DRAFT until it is activated.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) for which the offer should be created. Must be equal to the package_name field on the Subscription resource.
/// * `productId` - Required. The parent subscription (ID) for which the offer should be created. Must be equal to the product_id field on the SubscriptionOffer resource.
/// * `basePlanId` - Required. The parent base plan (ID) for which the offer should be created. Must be equal to the base_plan_id field on the SubscriptionOffer resource.
pub fn subscriptions_base_plans_offers_create(
&self,
request: SubscriptionOffer,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
MonetizationSubscriptionBasePlanOfferCreateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_regions_version_version: Default::default(),
_offer_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deactivates a subscription offer. Once deactivated, existing subscribers will maintain their subscription, but the offer will become unavailable to new subscribers.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the offer to deactivate.
/// * `productId` - Required. The parent subscription (ID) of the offer to deactivate.
/// * `basePlanId` - Required. The parent base plan (ID) of the offer to deactivate.
/// * `offerId` - Required. The unique offer ID of the offer to deactivate.
pub fn subscriptions_base_plans_offers_deactivate(
&self,
request: DeactivateSubscriptionOfferRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
offer_id: &str,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
MonetizationSubscriptionBasePlanOfferDeactivateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_offer_id: offer_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes a subscription offer. Can only be done for draft offers. This action is irreversible.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) of the offer to delete.
/// * `productId` - Required. The parent subscription (ID) of the offer to delete.
/// * `basePlanId` - Required. The parent base plan (ID) of the offer to delete.
/// * `offerId` - Required. The unique offer ID of the offer to delete.
pub fn subscriptions_base_plans_offers_delete(
&self,
package_name: &str,
product_id: &str,
base_plan_id: &str,
offer_id: &str,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {
MonetizationSubscriptionBasePlanOfferDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_offer_id: offer_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads a single offer
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) of the offer to get.
/// * `productId` - Required. The parent subscription (ID) of the offer to get.
/// * `basePlanId` - Required. The parent base plan (ID) of the offer to get.
/// * `offerId` - Required. The unique offer ID of the offer to get.
pub fn subscriptions_base_plans_offers_get(
&self,
package_name: &str,
product_id: &str,
base_plan_id: &str,
offer_id: &str,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {
MonetizationSubscriptionBasePlanOfferGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_offer_id: offer_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all offers under a given subscription.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) for which the subscriptions should be read.
/// * `productId` - Required. The parent subscription (ID) for which the offers should be read. May be specified as '-' to read all offers under an app.
/// * `basePlanId` - Required. The parent base plan (ID) for which the offers should be read. May be specified as '-' to read all offers under a subscription or an app. Must be specified as '-' if product_id is specified as '-'.
pub fn subscriptions_base_plans_offers_list(
&self,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
MonetizationSubscriptionBasePlanOfferListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates an existing subscription offer.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Immutable. The package name of the app the parent subscription belongs to.
/// * `productId` - Required. Immutable. The ID of the parent subscription this offer belongs to.
/// * `basePlanId` - Required. Immutable. The ID of the base plan to which this offer is an extension.
/// * `offerId` - Required. Immutable. Unique ID of this subscription offer. Must be unique within the base plan.
pub fn subscriptions_base_plans_offers_patch(
&self,
request: SubscriptionOffer,
package_name: &str,
product_id: &str,
base_plan_id: &str,
offer_id: &str,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
MonetizationSubscriptionBasePlanOfferPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_offer_id: offer_id.to_string(),
_update_mask: Default::default(),
_regions_version_version: Default::default(),
_latency_tolerance: Default::default(),
_allow_missing: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Activates a base plan. Once activated, base plans will be available to new subscribers.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the base plan to activate.
/// * `productId` - Required. The parent subscription (ID) of the base plan to activate.
/// * `basePlanId` - Required. The unique base plan ID of the base plan to activate.
pub fn subscriptions_base_plans_activate(
&self,
request: ActivateBasePlanRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C> {
MonetizationSubscriptionBasePlanActivateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Batch variant of the MigrateBasePlanPrices endpoint. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) for which the subscriptions should be created or updated. Must be equal to the package_name field on all the Subscription resources.
/// * `productId` - Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this batch update spans multiple subscriptions, set this field to "-". Must be set.
pub fn subscriptions_base_plans_batch_migrate_prices(
&self,
request: BatchMigrateBasePlanPricesRequest,
package_name: &str,
product_id: &str,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C> {
MonetizationSubscriptionBasePlanBatchMigratePriceCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Activates or deactivates base plans across one or multiple subscriptions. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the updated base plans.
/// * `productId` - Required. The product ID of the parent subscription, if all updated base plans belong to the same subscription. If this batch update spans multiple subscriptions, set this field to "-". Must be set.
pub fn subscriptions_base_plans_batch_update_states(
&self,
request: BatchUpdateBasePlanStatesRequest,
package_name: &str,
product_id: &str,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C> {
MonetizationSubscriptionBasePlanBatchUpdateStateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deactivates a base plan. Once deactivated, the base plan will become unavailable to new subscribers, but existing subscribers will maintain their subscription
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the base plan to deactivate.
/// * `productId` - Required. The parent subscription (ID) of the base plan to deactivate.
/// * `basePlanId` - Required. The unique base plan ID of the base plan to deactivate.
pub fn subscriptions_base_plans_deactivate(
&self,
request: DeactivateBasePlanRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {
MonetizationSubscriptionBasePlanDeactivateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes a base plan. Can only be done for draft base plans. This action is irreversible.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) of the base plan to delete.
/// * `productId` - Required. The parent subscription (ID) of the base plan to delete.
/// * `basePlanId` - Required. The unique offer ID of the base plan to delete.
pub fn subscriptions_base_plans_delete(
&self,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C> {
MonetizationSubscriptionBasePlanDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Migrates subscribers from one or more legacy price cohorts to the current price. Requests result in Google Play notifying affected subscribers. Only up to 250 simultaneous legacy price cohorts are supported.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. Package name of the parent app. Must be equal to the package_name field on the Subscription resource.
/// * `productId` - Required. The ID of the subscription to update. Must be equal to the product_id field on the Subscription resource.
/// * `basePlanId` - Required. The unique base plan ID of the base plan to update prices on.
pub fn subscriptions_base_plans_migrate_prices(
&self,
request: MigrateBasePlanPricesRequest,
package_name: &str,
product_id: &str,
base_plan_id: &str,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {
MonetizationSubscriptionBasePlanMigratePriceCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_base_plan_id: base_plan_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deprecated: subscription archiving is not supported.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) of the app of the subscription to delete.
/// * `productId` - Required. The unique product ID of the subscription to delete.
pub fn subscriptions_archive(
&self,
request: ArchiveSubscriptionRequest,
package_name: &str,
product_id: &str,
) -> MonetizationSubscriptionArchiveCall<'a, C> {
MonetizationSubscriptionArchiveCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads one or more subscriptions.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) for which the subscriptions should be retrieved. Must be equal to the package_name field on all the requests.
pub fn subscriptions_batch_get(
&self,
package_name: &str,
) -> MonetizationSubscriptionBatchGetCall<'a, C> {
MonetizationSubscriptionBatchGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_ids: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a batch of subscriptions. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) for which the subscriptions should be updated. Must be equal to the package_name field on all the Subscription resources.
pub fn subscriptions_batch_update(
&self,
request: BatchUpdateSubscriptionsRequest,
package_name: &str,
) -> MonetizationSubscriptionBatchUpdateCall<'a, C> {
MonetizationSubscriptionBatchUpdateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Creates a new subscription. Newly added base plans will remain in draft state until activated.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The parent app (package name) for which the subscription should be created. Must be equal to the package_name field on the Subscription resource.
pub fn subscriptions_create(
&self,
request: Subscription,
package_name: &str,
) -> MonetizationSubscriptionCreateCall<'a, C> {
MonetizationSubscriptionCreateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_regions_version_version: Default::default(),
_product_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes a subscription. A subscription can only be deleted if it has never had a base plan published.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) of the app of the subscription to delete.
/// * `productId` - Required. The unique product ID of the subscription to delete.
pub fn subscriptions_delete(
&self,
package_name: &str,
product_id: &str,
) -> MonetizationSubscriptionDeleteCall<'a, C> {
MonetizationSubscriptionDeleteCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Reads a single subscription.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) of the subscription to get.
/// * `productId` - Required. The unique product ID of the subscription to get.
pub fn subscriptions_get(
&self,
package_name: &str,
product_id: &str,
) -> MonetizationSubscriptionGetCall<'a, C> {
MonetizationSubscriptionGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all subscriptions under a given app.
///
/// # Arguments
///
/// * `packageName` - Required. The parent app (package name) for which the subscriptions should be read.
pub fn subscriptions_list(
&self,
package_name: &str,
) -> MonetizationSubscriptionListCall<'a, C> {
MonetizationSubscriptionListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_show_archived: Default::default(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates an existing subscription.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Immutable. Package name of the parent app.
/// * `productId` - Immutable. Unique product ID of the product. Unique within the parent app. Product IDs must be composed of lower-case letters (a-z), numbers (0-9), underscores (_) and dots (.). It must start with a lower-case letter or number, and be between 1 and 40 (inclusive) characters in length.
pub fn subscriptions_patch(
&self,
request: Subscription,
package_name: &str,
product_id: &str,
) -> MonetizationSubscriptionPatchCall<'a, C> {
MonetizationSubscriptionPatchCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_update_mask: Default::default(),
_regions_version_version: Default::default(),
_latency_tolerance: Default::default(),
_allow_missing: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Calculates the region prices, using today's exchange rate and country-specific pricing patterns, based on the price in the request for a set of regions.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The app package name.
pub fn convert_region_prices(
&self,
request: ConvertRegionPricesRequest,
package_name: &str,
) -> MonetizationConvertRegionPriceCall<'a, C> {
MonetizationConvertRegionPriceCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *order* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `batchget(...)`, `get(...)` and `refund(...)`
/// // to build up your call.
/// let rb = hub.orders();
/// # }
/// ```
pub struct OrderMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for OrderMethods<'a, C> {}
impl<'a, C> OrderMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Get order details for a list of orders.
///
/// # Arguments
///
/// * `packageName` - Required. The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
pub fn batchget(&self, package_name: &str) -> OrderBatchgetCall<'a, C> {
OrderBatchgetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_order_ids: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get order details for a single order.
///
/// # Arguments
///
/// * `packageName` - Required. The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
/// * `orderId` - Required. The order ID provided to the user when the subscription or in-app order was purchased.
pub fn get(&self, package_name: &str, order_id: &str) -> OrderGetCall<'a, C> {
OrderGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Refunds a user's subscription or in-app purchase order. Orders older than 3 years cannot be refunded.
///
/// # Arguments
///
/// * `packageName` - The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
/// * `orderId` - The order ID provided to the user when the subscription or in-app order was purchased.
pub fn refund(&self, package_name: &str, order_id: &str) -> OrderRefundCall<'a, C> {
OrderRefundCall {
hub: self.hub,
_package_name: package_name.to_string(),
_order_id: order_id.to_string(),
_revoke: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *purchase* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `products_acknowledge(...)`, `products_consume(...)`, `products_get(...)`, `productsv2_getproductpurchasev2(...)`, `subscriptions_acknowledge(...)`, `subscriptions_cancel(...)`, `subscriptions_defer(...)`, `subscriptions_get(...)`, `subscriptions_refund(...)`, `subscriptions_revoke(...)`, `subscriptionsv2_cancel(...)`, `subscriptionsv2_get(...)`, `subscriptionsv2_revoke(...)` and `voidedpurchases_list(...)`
/// // to build up your call.
/// let rb = hub.purchases();
/// # }
/// ```
pub struct PurchaseMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for PurchaseMethods<'a, C> {}
impl<'a, C> PurchaseMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Acknowledges a purchase of an inapp item.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - The package name of the application the inapp product was sold in (for example, 'com.some.thing').
/// * `productId` - The inapp product SKU (for example, 'com.some.thing.inapp1').
/// * `token` - The token provided to the user's device when the inapp product was purchased.
pub fn products_acknowledge(
&self,
request: ProductPurchasesAcknowledgeRequest,
package_name: &str,
product_id: &str,
token: &str,
) -> PurchaseProductAcknowledgeCall<'a, C> {
PurchaseProductAcknowledgeCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Consumes a purchase for an inapp item.
///
/// # Arguments
///
/// * `packageName` - The package name of the application the inapp product was sold in (for example, 'com.some.thing').
/// * `productId` - The inapp product SKU (for example, 'com.some.thing.inapp1').
/// * `token` - The token provided to the user's device when the inapp product was purchased.
pub fn products_consume(
&self,
package_name: &str,
product_id: &str,
token: &str,
) -> PurchaseProductConsumeCall<'a, C> {
PurchaseProductConsumeCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Checks the purchase and consumption status of an inapp item.
///
/// # Arguments
///
/// * `packageName` - The package name of the application the inapp product was sold in (for example, 'com.some.thing').
/// * `productId` - The inapp product SKU (for example, 'com.some.thing.inapp1').
/// * `token` - The token provided to the user's device when the inapp product was purchased.
pub fn products_get(
&self,
package_name: &str,
product_id: &str,
token: &str,
) -> PurchaseProductGetCall<'a, C> {
PurchaseProductGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_product_id: product_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Checks the purchase and consumption status of an inapp item.
///
/// # Arguments
///
/// * `packageName` - The package name of the application the inapp product was sold in (for example, 'com.some.thing').
/// * `token` - The token provided to the user's device when the inapp product was purchased.
pub fn productsv2_getproductpurchasev2(
&self,
package_name: &str,
token: &str,
) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C> {
PurchaseProductsv2Getproductpurchasev2Call {
hub: self.hub,
_package_name: package_name.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Acknowledges a subscription purchase.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `subscriptionId` - Note: Since May 21, 2025, subscription_id is not required, and not recommended for subscription with add-ons. The purchased subscription ID (for example, 'monthly001').
/// * `token` - The token provided to the user's device when the subscription was purchased.
pub fn subscriptions_acknowledge(
&self,
request: SubscriptionPurchasesAcknowledgeRequest,
package_name: &str,
subscription_id: &str,
token: &str,
) -> PurchaseSubscriptionAcknowledgeCall<'a, C> {
PurchaseSubscriptionAcknowledgeCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_subscription_id: subscription_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Cancels a user's subscription purchase. The subscription remains valid until its expiration time. Newer version is available at purchases.subscriptionsv2.cancel for better client library support.
///
/// # Arguments
///
/// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `subscriptionId` - Note: Since May 21, 2025, subscription_id is not required, and not recommended for subscription with add-ons. The purchased subscription ID (for example, 'monthly001').
/// * `token` - The token provided to the user's device when the subscription was purchased.
pub fn subscriptions_cancel(
&self,
package_name: &str,
subscription_id: &str,
token: &str,
) -> PurchaseSubscriptionCancelCall<'a, C> {
PurchaseSubscriptionCancelCall {
hub: self.hub,
_package_name: package_name.to_string(),
_subscription_id: subscription_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Defers a user's subscription purchase until a specified future expiration time.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
/// * `token` - The token provided to the user's device when the subscription was purchased.
pub fn subscriptions_defer(
&self,
request: SubscriptionPurchasesDeferRequest,
package_name: &str,
subscription_id: &str,
token: &str,
) -> PurchaseSubscriptionDeferCall<'a, C> {
PurchaseSubscriptionDeferCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_subscription_id: subscription_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deprecated: Use purchases.subscriptionsv2.get instead. Checks whether a user's subscription purchase is valid and returns its expiry time.
///
/// # Arguments
///
/// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
/// * `token` - The token provided to the user's device when the subscription was purchased.
pub fn subscriptions_get(
&self,
package_name: &str,
subscription_id: &str,
token: &str,
) -> PurchaseSubscriptionGetCall<'a, C> {
PurchaseSubscriptionGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_subscription_id: subscription_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deprecated: Use orders.refund instead. Refunds a user's subscription purchase, but the subscription remains valid until its expiration time and it will continue to recur.
///
/// # Arguments
///
/// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `subscriptionId` - "The purchased subscription ID (for example, 'monthly001').
/// * `token` - The token provided to the user's device when the subscription was purchased.
pub fn subscriptions_refund(
&self,
package_name: &str,
subscription_id: &str,
token: &str,
) -> PurchaseSubscriptionRefundCall<'a, C> {
PurchaseSubscriptionRefundCall {
hub: self.hub,
_package_name: package_name.to_string(),
_subscription_id: subscription_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deprecated: Use purchases.subscriptionsv2.revoke instead. Refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.
///
/// # Arguments
///
/// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001').
/// * `token` - The token provided to the user's device when the subscription was purchased.
pub fn subscriptions_revoke(
&self,
package_name: &str,
subscription_id: &str,
token: &str,
) -> PurchaseSubscriptionRevokeCall<'a, C> {
PurchaseSubscriptionRevokeCall {
hub: self.hub,
_package_name: package_name.to_string(),
_subscription_id: subscription_id.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Cancel a subscription purchase for the user.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The package of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `token` - Required. The token provided to the user's device when the subscription was purchased.
pub fn subscriptionsv2_cancel(
&self,
request: CancelSubscriptionPurchaseRequest,
package_name: &str,
token: &str,
) -> PurchaseSubscriptionsv2CancelCall<'a, C> {
PurchaseSubscriptionsv2CancelCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get metadata about a subscription
///
/// # Arguments
///
/// * `packageName` - The package of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `token` - Required. The token provided to the user's device when the subscription was purchased.
pub fn subscriptionsv2_get(
&self,
package_name: &str,
token: &str,
) -> PurchaseSubscriptionsv2GetCall<'a, C> {
PurchaseSubscriptionsv2GetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Revoke a subscription purchase for the user.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Required. The package of the application for which this subscription was purchased (for example, 'com.some.thing').
/// * `token` - Required. The token provided to the user's device when the subscription was purchased.
pub fn subscriptionsv2_revoke(
&self,
request: RevokeSubscriptionPurchaseRequest,
package_name: &str,
token: &str,
) -> PurchaseSubscriptionsv2RevokeCall<'a, C> {
PurchaseSubscriptionsv2RevokeCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_token: token.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists the purchases that were canceled, refunded or charged-back.
///
/// # Arguments
///
/// * `packageName` - The package name of the application for which voided purchases need to be returned (for example, 'com.some.thing').
pub fn voidedpurchases_list(
&self,
package_name: &str,
) -> PurchaseVoidedpurchaseListCall<'a, C> {
PurchaseVoidedpurchaseListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_type_: Default::default(),
_token: Default::default(),
_start_time: Default::default(),
_start_index: Default::default(),
_max_results: Default::default(),
_include_quantity_based_partial_refund: Default::default(),
_end_time: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *review* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `get(...)`, `list(...)` and `reply(...)`
/// // to build up your call.
/// let rb = hub.reviews();
/// # }
/// ```
pub struct ReviewMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for ReviewMethods<'a, C> {}
impl<'a, C> ReviewMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Gets a single review.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `reviewId` - Unique identifier for a review.
pub fn get(&self, package_name: &str, review_id: &str) -> ReviewGetCall<'a, C> {
ReviewGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_review_id: review_id.to_string(),
_translation_language: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all reviews.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
pub fn list(&self, package_name: &str) -> ReviewListCall<'a, C> {
ReviewListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_translation_language: Default::default(),
_token: Default::default(),
_start_index: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Replies to a single review, or updates an existing reply.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `reviewId` - Unique identifier for a review.
pub fn reply(
&self,
request: ReviewsReplyRequest,
package_name: &str,
review_id: &str,
) -> ReviewReplyCall<'a, C> {
ReviewReplyCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_review_id: review_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *systemapk* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `variants_create(...)`, `variants_download(...)`, `variants_get(...)` and `variants_list(...)`
/// // to build up your call.
/// let rb = hub.systemapks();
/// # }
/// ```
pub struct SystemapkMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for SystemapkMethods<'a, C> {}
impl<'a, C> SystemapkMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Creates an APK which is suitable for inclusion in a system image from an already uploaded Android App Bundle.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `packageName` - Package name of the app.
/// * `versionCode` - The version code of the App Bundle.
pub fn variants_create(
&self,
request: Variant,
package_name: &str,
version_code: i64,
) -> SystemapkVariantCreateCall<'a, C> {
SystemapkVariantCreateCall {
hub: self.hub,
_request: request,
_package_name: package_name.to_string(),
_version_code: version_code,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Downloads a previously created system APK which is suitable for inclusion in a system image.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `versionCode` - The version code of the App Bundle.
/// * `variantId` - The ID of a previously created system APK variant.
pub fn variants_download(
&self,
package_name: &str,
version_code: i64,
variant_id: u32,
) -> SystemapkVariantDownloadCall<'a, C> {
SystemapkVariantDownloadCall {
hub: self.hub,
_package_name: package_name.to_string(),
_version_code: version_code,
_variant_id: variant_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns a previously created system APK variant.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `versionCode` - The version code of the App Bundle.
/// * `variantId` - The ID of a previously created system APK variant.
pub fn variants_get(
&self,
package_name: &str,
version_code: i64,
variant_id: u32,
) -> SystemapkVariantGetCall<'a, C> {
SystemapkVariantGetCall {
hub: self.hub,
_package_name: package_name.to_string(),
_version_code: version_code,
_variant_id: variant_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns the list of previously created system APK variants.
///
/// # Arguments
///
/// * `packageName` - Package name of the app.
/// * `versionCode` - The version code of the App Bundle.
pub fn variants_list(
&self,
package_name: &str,
version_code: i64,
) -> SystemapkVariantListCall<'a, C> {
SystemapkVariantListCall {
hub: self.hub,
_package_name: package_name.to_string(),
_version_code: version_code,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *user* resources.
/// It is not used directly, but through the [`AndroidPublisher`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_androidpublisher3 as androidpublisher3;
///
/// # async fn dox() {
/// use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = AndroidPublisher::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `create(...)`, `delete(...)`, `list(...)` and `patch(...)`
/// // to build up your call.
/// let rb = hub.users();
/// # }
/// ```
pub struct UserMethods<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
}
impl<'a, C> common::MethodsBuilder for UserMethods<'a, C> {}
impl<'a, C> UserMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Grant access for a user to the given developer account.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `parent` - Required. The developer account to add the user to. Format: developers/{developer}
pub fn create(&self, request: User, parent: &str) -> UserCreateCall<'a, C> {
UserCreateCall {
hub: self.hub,
_request: request,
_parent: parent.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Removes all access for the user to the given developer account.
///
/// # Arguments
///
/// * `name` - Required. The name of the user to delete. Format: developers/{developer}/users/{email}
pub fn delete(&self, name: &str) -> UserDeleteCall<'a, C> {
UserDeleteCall {
hub: self.hub,
_name: name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists all users with access to a developer account.
///
/// # Arguments
///
/// * `parent` - Required. The developer account to fetch users from. Format: developers/{developer}
pub fn list(&self, parent: &str) -> UserListCall<'a, C> {
UserListCall {
hub: self.hub,
_parent: parent.to_string(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates access for the user to the developer account.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `name` - Required. Resource name for this user, following the pattern "developers/{developer}/users/{email}".
pub fn patch(&self, request: User, name: &str) -> UserPatchCall<'a, C> {
UserPatchCall {
hub: self.hub,
_request: request,
_name: name.to_string(),
_update_mask: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
/// Creates a new device tier config for an app.
///
/// A builder for the *deviceTierConfigs.create* method supported by a *application* resource.
/// It is not used directly, but through a [`ApplicationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::DeviceTierConfig;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = DeviceTierConfig::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.applications().device_tier_configs_create(req, "packageName")
/// .allow_unknown_devices(true)
/// .doit().await;
/// # }
/// ```
pub struct ApplicationDeviceTierConfigCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: DeviceTierConfig,
_package_name: String,
_allow_unknown_devices: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApplicationDeviceTierConfigCreateCall<'a, C> {}
impl<'a, C> ApplicationDeviceTierConfigCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, DeviceTierConfig)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.applications.deviceTierConfigs.create",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "allowUnknownDevices"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._allow_unknown_devices.as_ref() {
params.push("allowUnknownDevices", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/deviceTierConfigs";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: DeviceTierConfig,
) -> ApplicationDeviceTierConfigCreateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApplicationDeviceTierConfigCreateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Whether the service should accept device IDs that are unknown to Play's device catalog.
///
/// Sets the *allow unknown devices* query property to the given value.
pub fn allow_unknown_devices(
mut self,
new_value: bool,
) -> ApplicationDeviceTierConfigCreateCall<'a, C> {
self._allow_unknown_devices = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApplicationDeviceTierConfigCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApplicationDeviceTierConfigCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApplicationDeviceTierConfigCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApplicationDeviceTierConfigCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApplicationDeviceTierConfigCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Returns a particular device tier config.
///
/// A builder for the *deviceTierConfigs.get* method supported by a *application* resource.
/// It is not used directly, but through a [`ApplicationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.applications().device_tier_configs_get("packageName", -50)
/// .doit().await;
/// # }
/// ```
pub struct ApplicationDeviceTierConfigGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_device_tier_config_id: i64,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApplicationDeviceTierConfigGetCall<'a, C> {}
impl<'a, C> ApplicationDeviceTierConfigGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, DeviceTierConfig)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.applications.deviceTierConfigs.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "deviceTierConfigId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push(
"deviceTierConfigId",
self._device_tier_config_id.to_string(),
);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/deviceTierConfigs/{deviceTierConfigId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{deviceTierConfigId}", "deviceTierConfigId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["deviceTierConfigId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApplicationDeviceTierConfigGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. Id of an existing device tier config.
///
/// Sets the *device tier config id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn device_tier_config_id(
mut self,
new_value: i64,
) -> ApplicationDeviceTierConfigGetCall<'a, C> {
self._device_tier_config_id = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApplicationDeviceTierConfigGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApplicationDeviceTierConfigGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApplicationDeviceTierConfigGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApplicationDeviceTierConfigGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApplicationDeviceTierConfigGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Returns created device tier configs, ordered by descending creation time.
///
/// A builder for the *deviceTierConfigs.list* method supported by a *application* resource.
/// It is not used directly, but through a [`ApplicationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.applications().device_tier_configs_list("packageName")
/// .page_token("ut")
/// .page_size(-12)
/// .doit().await;
/// # }
/// ```
pub struct ApplicationDeviceTierConfigListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApplicationDeviceTierConfigListCall<'a, C> {}
impl<'a, C> ApplicationDeviceTierConfigListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, ListDeviceTierConfigsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.applications.deviceTierConfigs.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "pageToken", "pageSize"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/deviceTierConfigs";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApplicationDeviceTierConfigListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// A page token, received from a previous `ListDeviceTierConfigs` call. Provide this to retrieve the subsequent page.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(mut self, new_value: &str) -> ApplicationDeviceTierConfigListCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
/// The maximum number of device tier configs to return. The service may return fewer than this value. If unspecified, at most 10 device tier configs will be returned. The maximum value for this field is 100; values above 100 will be coerced to 100. Device tier configs will be ordered by descending creation time.
///
/// Sets the *page size* query property to the given value.
pub fn page_size(mut self, new_value: i32) -> ApplicationDeviceTierConfigListCall<'a, C> {
self._page_size = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApplicationDeviceTierConfigListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApplicationDeviceTierConfigListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApplicationDeviceTierConfigListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApplicationDeviceTierConfigListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApplicationDeviceTierConfigListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Writes the Safety Labels declaration of an app.
///
/// A builder for the *dataSafety* method supported by a *application* resource.
/// It is not used directly, but through a [`ApplicationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::SafetyLabelsUpdateRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = SafetyLabelsUpdateRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.applications().data_safety(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct ApplicationDataSafetyCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: SafetyLabelsUpdateRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApplicationDataSafetyCall<'a, C> {}
impl<'a, C> ApplicationDataSafetyCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SafetyLabelsUpdateResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.applications.dataSafety",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/dataSafety";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: SafetyLabelsUpdateRequest,
) -> ApplicationDataSafetyCall<'a, C> {
self._request = new_value;
self
}
/// Required. Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApplicationDataSafetyCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApplicationDataSafetyCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApplicationDataSafetyCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApplicationDataSafetyCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApplicationDataSafetyCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApplicationDataSafetyCall<'a, C> {
self._scopes.clear();
self
}
}
/// Incrementally update targeting for a recovery action. Note that only the criteria selected during the creation of recovery action can be expanded.
///
/// A builder for the *addTargeting* method supported by a *apprecovery* resource.
/// It is not used directly, but through a [`ApprecoveryMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::AddTargetingRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = AddTargetingRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.apprecovery().add_targeting(req, "packageName", -50)
/// .doit().await;
/// # }
/// ```
pub struct ApprecoveryAddTargetingCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: AddTargetingRequest,
_package_name: String,
_app_recovery_id: i64,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApprecoveryAddTargetingCall<'a, C> {}
impl<'a, C> ApprecoveryAddTargetingCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AddTargetingResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.apprecovery.addTargeting",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "appRecoveryId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("appRecoveryId", self._app_recovery_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/appRecoveries/{appRecoveryId}:addTargeting";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{appRecoveryId}", "appRecoveryId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["appRecoveryId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: AddTargetingRequest) -> ApprecoveryAddTargetingCall<'a, C> {
self._request = new_value;
self
}
/// Required. Package name of the app for which recovery action is to be updated.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApprecoveryAddTargetingCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. ID corresponding to the app recovery action.
///
/// Sets the *app recovery id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn app_recovery_id(mut self, new_value: i64) -> ApprecoveryAddTargetingCall<'a, C> {
self._app_recovery_id = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApprecoveryAddTargetingCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApprecoveryAddTargetingCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApprecoveryAddTargetingCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApprecoveryAddTargetingCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApprecoveryAddTargetingCall<'a, C> {
self._scopes.clear();
self
}
}
/// Cancel an already executing app recovery action. Note that this action changes status of the recovery action to CANCELED.
///
/// A builder for the *cancel* method supported by a *apprecovery* resource.
/// It is not used directly, but through a [`ApprecoveryMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::CancelAppRecoveryRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = CancelAppRecoveryRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.apprecovery().cancel(req, "packageName", -7)
/// .doit().await;
/// # }
/// ```
pub struct ApprecoveryCancelCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: CancelAppRecoveryRequest,
_package_name: String,
_app_recovery_id: i64,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApprecoveryCancelCall<'a, C> {}
impl<'a, C> ApprecoveryCancelCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, CancelAppRecoveryResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.apprecovery.cancel",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "appRecoveryId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("appRecoveryId", self._app_recovery_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/appRecoveries/{appRecoveryId}:cancel";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{appRecoveryId}", "appRecoveryId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["appRecoveryId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: CancelAppRecoveryRequest) -> ApprecoveryCancelCall<'a, C> {
self._request = new_value;
self
}
/// Required. Package name of the app for which recovery action cancellation is requested.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApprecoveryCancelCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. ID corresponding to the app recovery action.
///
/// Sets the *app recovery id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn app_recovery_id(mut self, new_value: i64) -> ApprecoveryCancelCall<'a, C> {
self._app_recovery_id = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApprecoveryCancelCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApprecoveryCancelCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApprecoveryCancelCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApprecoveryCancelCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApprecoveryCancelCall<'a, C> {
self._scopes.clear();
self
}
}
/// Create an app recovery action with recovery status as DRAFT. Note that this action does not execute the recovery action.
///
/// A builder for the *create* method supported by a *apprecovery* resource.
/// It is not used directly, but through a [`ApprecoveryMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::CreateDraftAppRecoveryRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = CreateDraftAppRecoveryRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.apprecovery().create(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct ApprecoveryCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: CreateDraftAppRecoveryRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApprecoveryCreateCall<'a, C> {}
impl<'a, C> ApprecoveryCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppRecoveryAction)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.apprecovery.create",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/appRecoveries";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: CreateDraftAppRecoveryRequest,
) -> ApprecoveryCreateCall<'a, C> {
self._request = new_value;
self
}
/// Required. Package name of the app on which recovery action is performed.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApprecoveryCreateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApprecoveryCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApprecoveryCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApprecoveryCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApprecoveryCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApprecoveryCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deploy an already created app recovery action with recovery status DRAFT. Note that this action activates the recovery action for all targeted users and changes its status to ACTIVE.
///
/// A builder for the *deploy* method supported by a *apprecovery* resource.
/// It is not used directly, but through a [`ApprecoveryMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::DeployAppRecoveryRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = DeployAppRecoveryRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.apprecovery().deploy(req, "packageName", -99)
/// .doit().await;
/// # }
/// ```
pub struct ApprecoveryDeployCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: DeployAppRecoveryRequest,
_package_name: String,
_app_recovery_id: i64,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApprecoveryDeployCall<'a, C> {}
impl<'a, C> ApprecoveryDeployCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, DeployAppRecoveryResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.apprecovery.deploy",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "appRecoveryId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("appRecoveryId", self._app_recovery_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/appRecoveries/{appRecoveryId}:deploy";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{appRecoveryId}", "appRecoveryId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["appRecoveryId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: DeployAppRecoveryRequest) -> ApprecoveryDeployCall<'a, C> {
self._request = new_value;
self
}
/// Required. Package name of the app for which recovery action is deployed.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApprecoveryDeployCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. ID corresponding to the app recovery action to deploy.
///
/// Sets the *app recovery id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn app_recovery_id(mut self, new_value: i64) -> ApprecoveryDeployCall<'a, C> {
self._app_recovery_id = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApprecoveryDeployCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApprecoveryDeployCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApprecoveryDeployCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApprecoveryDeployCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApprecoveryDeployCall<'a, C> {
self._scopes.clear();
self
}
}
/// List all app recovery action resources associated with a particular package name and app version.
///
/// A builder for the *list* method supported by a *apprecovery* resource.
/// It is not used directly, but through a [`ApprecoveryMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.apprecovery().list("packageName")
/// .version_code(-25)
/// .doit().await;
/// # }
/// ```
pub struct ApprecoveryListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_version_code: Option<i64>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ApprecoveryListCall<'a, C> {}
impl<'a, C> ApprecoveryListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ListAppRecoveriesResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.apprecovery.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "versionCode"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._version_code.as_ref() {
params.push("versionCode", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/appRecoveries";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. Package name of the app for which list of recovery actions is requested.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ApprecoveryListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. Version code targeted by the list of recovery actions.
///
/// Sets the *version code* query property to the given value.
pub fn version_code(mut self, new_value: i64) -> ApprecoveryListCall<'a, C> {
self._version_code = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ApprecoveryListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ApprecoveryListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ApprecoveryListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ApprecoveryListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ApprecoveryListCall<'a, C> {
self._scopes.clear();
self
}
}
/// 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 organizations using Managed Play whose application is configured to restrict distribution to the organizations.
///
/// A builder for the *apks.addexternallyhosted* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ApksAddExternallyHostedRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ApksAddExternallyHostedRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().apks_addexternallyhosted(req, "packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditApkAddexternallyhostedCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ApksAddExternallyHostedRequest,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditApkAddexternallyhostedCall<'a, C> {}
impl<'a, C> EditApkAddexternallyhostedCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, ApksAddExternallyHostedResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.apks.addexternallyhosted",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/externallyHosted";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ApksAddExternallyHostedRequest,
) -> EditApkAddexternallyhostedCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditApkAddexternallyhostedCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditApkAddexternallyhostedCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditApkAddexternallyhostedCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApkAddexternallyhostedCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditApkAddexternallyhostedCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all current APKs of the app and edit.
///
/// A builder for the *apks.list* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().apks_list("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditApkListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditApkListCall<'a, C> {}
impl<'a, C> EditApkListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ApksListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.apks.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/apks";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditApkListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditApkListCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditApkListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditApkListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditApkListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApkListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditApkListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Uploads an APK and adds to the current edit.
///
/// A builder for the *apks.upload* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use std::fs;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `upload(...)`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().apks_upload("packageName", "editId")
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct EditApkUploadCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditApkUploadCall<'a, C> {}
impl<'a, C> EditApkUploadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, Apk)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.apks.upload",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
(self.hub._root_url.clone() + "resumable/upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/apks", "resumable")
} else if protocol == common::UploadProtocol::Simple {
(
self.hub._root_url.clone()
+ "upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/apks",
"multipart",
)
} else {
unreachable!()
};
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 10737418240 {
return Err(common::Error::UploadSizeLimitExceeded(size, 10737418240));
}
let mut bytes = Vec::with_capacity(size as usize);
reader.read_to_end(&mut bytes)?;
req_builder
.header(CONTENT_TYPE, reader_mime_type.to_string())
.header(CONTENT_LENGTH, size)
.body(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 10737418240 {
return Err(common::Error::UploadSizeLimitExceeded(size, 10737418240));
}
let upload_result = {
let url_str = &parts
.headers
.get("Location")
.expect("LOCATION header is part of protocol")
.to_str()
.unwrap();
if upload_url_from_server {
dlg.store_upload_url(Some(url_str));
}
common::ResumableUploadHelper {
client: &self.hub.client,
delegate: dlg,
start_at: if upload_url_from_server {
Some(0)
} else {
None
},
auth: &self.hub.auth,
user_agent: &self.hub._user_agent,
// TODO: Check this assumption
auth_header: format!(
"Bearer {}",
token
.ok_or_else(|| common::Error::MissingToken(
"resumable upload requires token".into()
))?
.as_str()
),
url: url_str,
reader: &mut reader,
media_type: reader_mime_type.clone(),
content_length: size,
}
.upload()
.await
};
match upload_result {
None => {
dlg.finished(false);
return Err(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Upload media in a resumable fashion.
/// Even if the upload fails or is interrupted, it can be resumed for a
/// certain amount of time as the server maintains state temporarily.
///
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
/// `cancel_chunk_upload(...)`.
///
/// * *multipart*: yes
/// * *max size*: 10737418240
/// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
pub async fn upload_resumable<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Apk)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::UploadProtocol::Resumable,
)
.await
}
/// Upload media all at once.
/// If the upload fails for whichever reason, all progress is lost.
///
/// * *multipart*: yes
/// * *max size*: 10737418240
/// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
pub async fn upload<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Apk)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::UploadProtocol::Simple)
.await
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditApkUploadCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditApkUploadCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditApkUploadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditApkUploadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditApkUploadCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditApkUploadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditApkUploadCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all current Android App Bundles of the app and edit.
///
/// A builder for the *bundles.list* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().bundles_list("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditBundleListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditBundleListCall<'a, C> {}
impl<'a, C> EditBundleListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, BundlesListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.bundles.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/bundles";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditBundleListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditBundleListCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditBundleListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditBundleListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditBundleListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditBundleListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditBundleListCall<'a, C> {
self._scopes.clear();
self
}
}
/// 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 [Timeouts and Errors](https://developers.google.com/api-client-library/java/google-api-java-client/errors) for an example in java.
///
/// A builder for the *bundles.upload* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use std::fs;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `upload(...)`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().bundles_upload("packageName", "editId")
/// .device_tier_config_id("et")
/// .ack_bundle_installation_warning(false)
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct EditBundleUploadCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_device_tier_config_id: Option<String>,
_ack_bundle_installation_warning: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditBundleUploadCall<'a, C> {}
impl<'a, C> EditBundleUploadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, Bundle)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.bundles.upload",
http_method: hyper::Method::POST,
});
for &field in [
"alt",
"packageName",
"editId",
"deviceTierConfigId",
"ackBundleInstallationWarning",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
if let Some(value) = self._device_tier_config_id.as_ref() {
params.push("deviceTierConfigId", value);
}
if let Some(value) = self._ack_bundle_installation_warning.as_ref() {
params.push("ackBundleInstallationWarning", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
(self.hub._root_url.clone() + "resumable/upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/bundles", "resumable")
} else if protocol == common::UploadProtocol::Simple {
(self.hub._root_url.clone() + "upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/bundles", "multipart")
} else {
unreachable!()
};
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 53687091200 {
return Err(common::Error::UploadSizeLimitExceeded(size, 53687091200));
}
let mut bytes = Vec::with_capacity(size as usize);
reader.read_to_end(&mut bytes)?;
req_builder
.header(CONTENT_TYPE, reader_mime_type.to_string())
.header(CONTENT_LENGTH, size)
.body(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 53687091200 {
return Err(common::Error::UploadSizeLimitExceeded(size, 53687091200));
}
let upload_result = {
let url_str = &parts
.headers
.get("Location")
.expect("LOCATION header is part of protocol")
.to_str()
.unwrap();
if upload_url_from_server {
dlg.store_upload_url(Some(url_str));
}
common::ResumableUploadHelper {
client: &self.hub.client,
delegate: dlg,
start_at: if upload_url_from_server {
Some(0)
} else {
None
},
auth: &self.hub.auth,
user_agent: &self.hub._user_agent,
// TODO: Check this assumption
auth_header: format!(
"Bearer {}",
token
.ok_or_else(|| common::Error::MissingToken(
"resumable upload requires token".into()
))?
.as_str()
),
url: url_str,
reader: &mut reader,
media_type: reader_mime_type.clone(),
content_length: size,
}
.upload()
.await
};
match upload_result {
None => {
dlg.finished(false);
return Err(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Upload media in a resumable fashion.
/// Even if the upload fails or is interrupted, it can be resumed for a
/// certain amount of time as the server maintains state temporarily.
///
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
/// `cancel_chunk_upload(...)`.
///
/// * *multipart*: yes
/// * *max size*: 53687091200
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload_resumable<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Bundle)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::UploadProtocol::Resumable,
)
.await
}
/// Upload media all at once.
/// If the upload fails for whichever reason, all progress is lost.
///
/// * *multipart*: yes
/// * *max size*: 53687091200
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Bundle)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::UploadProtocol::Simple)
.await
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditBundleUploadCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditBundleUploadCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Device tier config (DTC) to be used for generating deliverables (APKs). Contains id of the DTC or "LATEST" for last uploaded DTC.
///
/// Sets the *device tier config id* query property to the given value.
pub fn device_tier_config_id(mut self, new_value: &str) -> EditBundleUploadCall<'a, C> {
self._device_tier_config_id = Some(new_value.to_string());
self
}
/// Deprecated. The installation warning has been removed, it's not necessary to set this field anymore.
///
/// Sets the *ack bundle installation warning* query property to the given value.
pub fn ack_bundle_installation_warning(
mut self,
new_value: bool,
) -> EditBundleUploadCall<'a, C> {
self._ack_bundle_installation_warning = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditBundleUploadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditBundleUploadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditBundleUploadCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditBundleUploadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditBundleUploadCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets country availability.
///
/// A builder for the *countryavailability.get* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().countryavailability_get("packageName", "editId", "track")
/// .doit().await;
/// # }
/// ```
pub struct EditCountryavailabilityGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_track: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditCountryavailabilityGetCall<'a, C> {}
impl<'a, C> EditCountryavailabilityGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, TrackCountryAvailability)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.countryavailability.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId", "track"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("track", self._track);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits/{editId}/countryAvailability/{track}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{track}", "track"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["track", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditCountryavailabilityGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditCountryavailabilityGetCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The track to read from.
///
/// Sets the *track* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn track(mut self, new_value: &str) -> EditCountryavailabilityGetCall<'a, C> {
self._track = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditCountryavailabilityGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditCountryavailabilityGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditCountryavailabilityGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditCountryavailabilityGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditCountryavailabilityGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Uploads a new deobfuscation file and attaches to the specified APK.
///
/// A builder for the *deobfuscationfiles.upload* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use std::fs;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `upload(...)`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().deobfuscationfiles_upload("packageName", "editId", -28, "deobfuscationFileType")
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct EditDeobfuscationfileUploadCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_apk_version_code: i32,
_deobfuscation_file_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditDeobfuscationfileUploadCall<'a, C> {}
impl<'a, C> EditDeobfuscationfileUploadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, DeobfuscationFilesUploadResponse)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.deobfuscationfiles.upload",
http_method: hyper::Method::POST,
});
for &field in [
"alt",
"packageName",
"editId",
"apkVersionCode",
"deobfuscationFileType",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("apkVersionCode", self._apk_version_code.to_string());
params.push("deobfuscationFileType", self._deobfuscation_file_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
(self.hub._root_url.clone() + "resumable/upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/deobfuscationFiles/{deobfuscationFileType}", "resumable")
} else if protocol == common::UploadProtocol::Simple {
(self.hub._root_url.clone() + "upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/deobfuscationFiles/{deobfuscationFileType}", "multipart")
} else {
unreachable!()
};
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{apkVersionCode}", "apkVersionCode"),
("{deobfuscationFileType}", "deobfuscationFileType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = [
"deobfuscationFileType",
"apkVersionCode",
"editId",
"packageName",
];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 1677721600 {
return Err(common::Error::UploadSizeLimitExceeded(size, 1677721600));
}
let mut bytes = Vec::with_capacity(size as usize);
reader.read_to_end(&mut bytes)?;
req_builder
.header(CONTENT_TYPE, reader_mime_type.to_string())
.header(CONTENT_LENGTH, size)
.body(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 1677721600 {
return Err(common::Error::UploadSizeLimitExceeded(size, 1677721600));
}
let upload_result = {
let url_str = &parts
.headers
.get("Location")
.expect("LOCATION header is part of protocol")
.to_str()
.unwrap();
if upload_url_from_server {
dlg.store_upload_url(Some(url_str));
}
common::ResumableUploadHelper {
client: &self.hub.client,
delegate: dlg,
start_at: if upload_url_from_server {
Some(0)
} else {
None
},
auth: &self.hub.auth,
user_agent: &self.hub._user_agent,
// TODO: Check this assumption
auth_header: format!(
"Bearer {}",
token
.ok_or_else(|| common::Error::MissingToken(
"resumable upload requires token".into()
))?
.as_str()
),
url: url_str,
reader: &mut reader,
media_type: reader_mime_type.clone(),
content_length: size,
}
.upload()
.await
};
match upload_result {
None => {
dlg.finished(false);
return Err(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Upload media in a resumable fashion.
/// Even if the upload fails or is interrupted, it can be resumed for a
/// certain amount of time as the server maintains state temporarily.
///
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
/// `cancel_chunk_upload(...)`.
///
/// * *multipart*: yes
/// * *max size*: 1677721600
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload_resumable<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, DeobfuscationFilesUploadResponse)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::UploadProtocol::Resumable,
)
.await
}
/// Upload media all at once.
/// If the upload fails for whichever reason, all progress is lost.
///
/// * *multipart*: yes
/// * *max size*: 1677721600
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, DeobfuscationFilesUploadResponse)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::UploadProtocol::Simple)
.await
}
/// Unique identifier for the Android app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditDeobfuscationfileUploadCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for this edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditDeobfuscationfileUploadCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The version code of the APK whose Deobfuscation File is being uploaded.
///
/// Sets the *apk version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn apk_version_code(mut self, new_value: i32) -> EditDeobfuscationfileUploadCall<'a, C> {
self._apk_version_code = new_value;
self
}
/// The type of the deobfuscation file.
///
/// Sets the *deobfuscation file type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn deobfuscation_file_type(
mut self,
new_value: &str,
) -> EditDeobfuscationfileUploadCall<'a, C> {
self._deobfuscation_file_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditDeobfuscationfileUploadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditDeobfuscationfileUploadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditDeobfuscationfileUploadCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDeobfuscationfileUploadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditDeobfuscationfileUploadCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets details of an app.
///
/// A builder for the *details.get* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().details_get("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditDetailGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditDetailGetCall<'a, C> {}
impl<'a, C> EditDetailGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppDetails)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.details.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/details";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditDetailGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditDetailGetCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditDetailGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditDetailGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditDetailGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDetailGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditDetailGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Patches details of an app.
///
/// A builder for the *details.patch* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::AppDetails;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = AppDetails::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().details_patch(req, "packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditDetailPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: AppDetails,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditDetailPatchCall<'a, C> {}
impl<'a, C> EditDetailPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppDetails)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.details.patch",
http_method: hyper::Method::PATCH,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/details";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: AppDetails) -> EditDetailPatchCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditDetailPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditDetailPatchCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditDetailPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditDetailPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditDetailPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDetailPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditDetailPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates details of an app.
///
/// A builder for the *details.update* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::AppDetails;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = AppDetails::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().details_update(req, "packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditDetailUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: AppDetails,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditDetailUpdateCall<'a, C> {}
impl<'a, C> EditDetailUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppDetails)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.details.update",
http_method: hyper::Method::PUT,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/details";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: AppDetails) -> EditDetailUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditDetailUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditDetailUpdateCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditDetailUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditDetailUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditDetailUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDetailUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditDetailUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Fetches the expansion file configuration for the specified APK.
///
/// A builder for the *expansionfiles.get* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().expansionfiles_get("packageName", "editId", -20, "expansionFileType")
/// .doit().await;
/// # }
/// ```
pub struct EditExpansionfileGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_apk_version_code: i32,
_expansion_file_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditExpansionfileGetCall<'a, C> {}
impl<'a, C> EditExpansionfileGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ExpansionFile)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.expansionfiles.get",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"packageName",
"editId",
"apkVersionCode",
"expansionFileType",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("apkVersionCode", self._apk_version_code.to_string());
params.push("expansionFileType", self._expansion_file_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{apkVersionCode}", "apkVersionCode"),
("{expansionFileType}", "expansionFileType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = [
"expansionFileType",
"apkVersionCode",
"editId",
"packageName",
];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The version code of the APK whose expansion file configuration is being read or modified.
///
/// Sets the *apk version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileGetCall<'a, C> {
self._apk_version_code = new_value;
self
}
/// The file type of the file configuration which is being read or modified.
///
/// Sets the *expansion file type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C> {
self._expansion_file_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditExpansionfileGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfileGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfileGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditExpansionfileGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Patches the APK's expansion file configuration to reference another APK's expansion file. To add a new expansion file use the Upload method.
///
/// A builder for the *expansionfiles.patch* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ExpansionFile;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ExpansionFile::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().expansionfiles_patch(req, "packageName", "editId", -65, "expansionFileType")
/// .doit().await;
/// # }
/// ```
pub struct EditExpansionfilePatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ExpansionFile,
_package_name: String,
_edit_id: String,
_apk_version_code: i32,
_expansion_file_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditExpansionfilePatchCall<'a, C> {}
impl<'a, C> EditExpansionfilePatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ExpansionFile)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.expansionfiles.patch",
http_method: hyper::Method::PATCH,
});
for &field in [
"alt",
"packageName",
"editId",
"apkVersionCode",
"expansionFileType",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("apkVersionCode", self._apk_version_code.to_string());
params.push("expansionFileType", self._expansion_file_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{apkVersionCode}", "apkVersionCode"),
("{expansionFileType}", "expansionFileType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = [
"expansionFileType",
"apkVersionCode",
"editId",
"packageName",
];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: ExpansionFile) -> EditExpansionfilePatchCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The version code of the APK whose expansion file configuration is being read or modified.
///
/// Sets the *apk version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfilePatchCall<'a, C> {
self._apk_version_code = new_value;
self
}
/// The file type of the expansion file configuration which is being updated.
///
/// Sets the *expansion file type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C> {
self._expansion_file_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditExpansionfilePatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfilePatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfilePatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfilePatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditExpansionfilePatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates the APK's expansion file configuration to reference another APK's expansion file. To add a new expansion file use the Upload method.
///
/// A builder for the *expansionfiles.update* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ExpansionFile;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ExpansionFile::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().expansionfiles_update(req, "packageName", "editId", -29, "expansionFileType")
/// .doit().await;
/// # }
/// ```
pub struct EditExpansionfileUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ExpansionFile,
_package_name: String,
_edit_id: String,
_apk_version_code: i32,
_expansion_file_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditExpansionfileUpdateCall<'a, C> {}
impl<'a, C> EditExpansionfileUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ExpansionFile)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.expansionfiles.update",
http_method: hyper::Method::PUT,
});
for &field in [
"alt",
"packageName",
"editId",
"apkVersionCode",
"expansionFileType",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("apkVersionCode", self._apk_version_code.to_string());
params.push("expansionFileType", self._expansion_file_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{apkVersionCode}", "apkVersionCode"),
("{expansionFileType}", "expansionFileType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = [
"expansionFileType",
"apkVersionCode",
"editId",
"packageName",
];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: ExpansionFile) -> EditExpansionfileUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The version code of the APK whose expansion file configuration is being read or modified.
///
/// Sets the *apk version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUpdateCall<'a, C> {
self._apk_version_code = new_value;
self
}
/// The file type of the file configuration which is being read or modified.
///
/// Sets the *expansion file type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C> {
self._expansion_file_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditExpansionfileUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfileUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfileUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditExpansionfileUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Uploads a new expansion file and attaches to the specified APK.
///
/// A builder for the *expansionfiles.upload* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use std::fs;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `upload(...)`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().expansionfiles_upload("packageName", "editId", -59, "expansionFileType")
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct EditExpansionfileUploadCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_apk_version_code: i32,
_expansion_file_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditExpansionfileUploadCall<'a, C> {}
impl<'a, C> EditExpansionfileUploadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, ExpansionFilesUploadResponse)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.expansionfiles.upload",
http_method: hyper::Method::POST,
});
for &field in [
"alt",
"packageName",
"editId",
"apkVersionCode",
"expansionFileType",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("apkVersionCode", self._apk_version_code.to_string());
params.push("expansionFileType", self._expansion_file_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
(self.hub._root_url.clone() + "resumable/upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}", "resumable")
} else if protocol == common::UploadProtocol::Simple {
(self.hub._root_url.clone() + "upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}", "multipart")
} else {
unreachable!()
};
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{apkVersionCode}", "apkVersionCode"),
("{expansionFileType}", "expansionFileType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = [
"expansionFileType",
"apkVersionCode",
"editId",
"packageName",
];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2147483648 {
return Err(common::Error::UploadSizeLimitExceeded(size, 2147483648));
}
let mut bytes = Vec::with_capacity(size as usize);
reader.read_to_end(&mut bytes)?;
req_builder
.header(CONTENT_TYPE, reader_mime_type.to_string())
.header(CONTENT_LENGTH, size)
.body(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2147483648 {
return Err(common::Error::UploadSizeLimitExceeded(size, 2147483648));
}
let upload_result = {
let url_str = &parts
.headers
.get("Location")
.expect("LOCATION header is part of protocol")
.to_str()
.unwrap();
if upload_url_from_server {
dlg.store_upload_url(Some(url_str));
}
common::ResumableUploadHelper {
client: &self.hub.client,
delegate: dlg,
start_at: if upload_url_from_server {
Some(0)
} else {
None
},
auth: &self.hub.auth,
user_agent: &self.hub._user_agent,
// TODO: Check this assumption
auth_header: format!(
"Bearer {}",
token
.ok_or_else(|| common::Error::MissingToken(
"resumable upload requires token".into()
))?
.as_str()
),
url: url_str,
reader: &mut reader,
media_type: reader_mime_type.clone(),
content_length: size,
}
.upload()
.await
};
match upload_result {
None => {
dlg.finished(false);
return Err(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Upload media in a resumable fashion.
/// Even if the upload fails or is interrupted, it can be resumed for a
/// certain amount of time as the server maintains state temporarily.
///
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
/// `cancel_chunk_upload(...)`.
///
/// * *multipart*: yes
/// * *max size*: 2147483648
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload_resumable<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ExpansionFilesUploadResponse)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::UploadProtocol::Resumable,
)
.await
}
/// Upload media all at once.
/// If the upload fails for whichever reason, all progress is lost.
///
/// * *multipart*: yes
/// * *max size*: 2147483648
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ExpansionFilesUploadResponse)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::UploadProtocol::Simple)
.await
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The version code of the APK whose expansion file configuration is being read or modified.
///
/// Sets the *apk version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUploadCall<'a, C> {
self._apk_version_code = new_value;
self
}
/// The file type of the expansion file configuration which is being updated.
///
/// Sets the *expansion file type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn expansion_file_type(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C> {
self._expansion_file_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditExpansionfileUploadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileUploadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditExpansionfileUploadCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditExpansionfileUploadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditExpansionfileUploadCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes the image (specified by id) from the edit.
///
/// A builder for the *images.delete* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().images_delete("packageName", "editId", "language", "imageType", "imageId")
/// .doit().await;
/// # }
/// ```
pub struct EditImageDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_language: String,
_image_type: String,
_image_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditImageDeleteCall<'a, C> {}
impl<'a, C> EditImageDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.images.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "editId", "language", "imageType", "imageId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.push("imageType", self._image_type);
params.push("imageId", self._image_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}/{imageId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
("{imageType}", "imageType"),
("{imageId}", "imageId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["imageId", "imageType", "language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
self._language = new_value.to_string();
self
}
/// Type of the Image.
///
/// Sets the *image type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn image_type(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
self._image_type = new_value.to_string();
self
}
/// Unique identifier an image within the set of images attached to this edit.
///
/// Sets the *image id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn image_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, C> {
self._image_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditImageDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditImageDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditImageDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditImageDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes all images for the specified language and image type. Returns an empty response if no images are found.
///
/// A builder for the *images.deleteall* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().images_deleteall("packageName", "editId", "language", "imageType")
/// .doit().await;
/// # }
/// ```
pub struct EditImageDeleteallCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_language: String,
_image_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditImageDeleteallCall<'a, C> {}
impl<'a, C> EditImageDeleteallCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ImagesDeleteAllResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.images.deleteall",
http_method: hyper::Method::DELETE,
});
for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.push("imageType", self._image_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
("{imageType}", "imageType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["imageType", "language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German). Providing a language that is not supported by the App is a no-op.
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
self._language = new_value.to_string();
self
}
/// Type of the Image. Providing an image type that refers to no images is a no-op.
///
/// Sets the *image type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn image_type(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C> {
self._image_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditImageDeleteallCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditImageDeleteallCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditImageDeleteallCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageDeleteallCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditImageDeleteallCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all images. The response may be empty.
///
/// A builder for the *images.list* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().images_list("packageName", "editId", "language", "imageType")
/// .doit().await;
/// # }
/// ```
pub struct EditImageListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_language: String,
_image_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditImageListCall<'a, C> {}
impl<'a, C> EditImageListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ImagesListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.images.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.push("imageType", self._image_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
("{imageType}", "imageType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["imageType", "language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditImageListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditImageListCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German). There must be a store listing for the specified language.
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditImageListCall<'a, C> {
self._language = new_value.to_string();
self
}
/// Type of the Image. Providing an image type that refers to no images will return an empty response.
///
/// Sets the *image type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn image_type(mut self, new_value: &str) -> EditImageListCall<'a, C> {
self._image_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditImageListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditImageListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditImageListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditImageListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Uploads an image of the specified language and image type, and adds to the edit.
///
/// A builder for the *images.upload* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use std::fs;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `upload_resumable(...)`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().images_upload("packageName", "editId", "language", "imageType")
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct EditImageUploadCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_language: String,
_image_type: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditImageUploadCall<'a, C> {}
impl<'a, C> EditImageUploadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, ImagesUploadResponse)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.images.upload",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.push("imageType", self._image_type);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
(self.hub._root_url.clone() + "resumable/upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}", "resumable")
} else if protocol == common::UploadProtocol::Simple {
(self.hub._root_url.clone() + "upload/androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}", "multipart")
} else {
unreachable!()
};
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
("{imageType}", "imageType"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["imageType", "language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 15728640 {
return Err(common::Error::UploadSizeLimitExceeded(size, 15728640));
}
let mut bytes = Vec::with_capacity(size as usize);
reader.read_to_end(&mut bytes)?;
req_builder
.header(CONTENT_TYPE, reader_mime_type.to_string())
.header(CONTENT_LENGTH, size)
.body(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 15728640 {
return Err(common::Error::UploadSizeLimitExceeded(size, 15728640));
}
let upload_result = {
let url_str = &parts
.headers
.get("Location")
.expect("LOCATION header is part of protocol")
.to_str()
.unwrap();
if upload_url_from_server {
dlg.store_upload_url(Some(url_str));
}
common::ResumableUploadHelper {
client: &self.hub.client,
delegate: dlg,
start_at: if upload_url_from_server {
Some(0)
} else {
None
},
auth: &self.hub.auth,
user_agent: &self.hub._user_agent,
// TODO: Check this assumption
auth_header: format!(
"Bearer {}",
token
.ok_or_else(|| common::Error::MissingToken(
"resumable upload requires token".into()
))?
.as_str()
),
url: url_str,
reader: &mut reader,
media_type: reader_mime_type.clone(),
content_length: size,
}
.upload()
.await
};
match upload_result {
None => {
dlg.finished(false);
return Err(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Upload media in a resumable fashion.
/// Even if the upload fails or is interrupted, it can be resumed for a
/// certain amount of time as the server maintains state temporarily.
///
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
/// `cancel_chunk_upload(...)`.
///
/// * *multipart*: yes
/// * *max size*: 15728640
/// * *valid mime types*: 'image/*'
pub async fn upload_resumable<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ImagesUploadResponse)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::UploadProtocol::Resumable,
)
.await
}
/// Upload media all at once.
/// If the upload fails for whichever reason, all progress is lost.
///
/// * *multipart*: yes
/// * *max size*: 15728640
/// * *valid mime types*: 'image/*'
pub async fn upload<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ImagesUploadResponse)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::UploadProtocol::Simple)
.await
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German). Providing a language that is not supported by the App is a no-op.
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
self._language = new_value.to_string();
self
}
/// Type of the Image.
///
/// Sets the *image type* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn image_type(mut self, new_value: &str) -> EditImageUploadCall<'a, C> {
self._image_type = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditImageUploadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditImageUploadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditImageUploadCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditImageUploadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditImageUploadCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes a localized store listing.
///
/// A builder for the *listings.delete* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().listings_delete("packageName", "editId", "language")
/// .doit().await;
/// # }
/// ```
pub struct EditListingDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_language: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditListingDeleteCall<'a, C> {}
impl<'a, C> EditListingDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.listings.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "editId", "language"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditListingDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditListingDeleteCall<'a, C> {
self._language = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditListingDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditListingDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditListingDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditListingDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes all store listings.
///
/// A builder for the *listings.deleteall* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().listings_deleteall("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditListingDeleteallCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditListingDeleteallCall<'a, C> {}
impl<'a, C> EditListingDeleteallCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.listings.deleteall",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditListingDeleteallCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteallCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditListingDeleteallCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditListingDeleteallCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditListingDeleteallCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingDeleteallCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditListingDeleteallCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets a localized store listing.
///
/// A builder for the *listings.get* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().listings_get("packageName", "editId", "language")
/// .doit().await;
/// # }
/// ```
pub struct EditListingGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_language: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditListingGetCall<'a, C> {}
impl<'a, C> EditListingGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Listing)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.listings.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId", "language"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditListingGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditListingGetCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditListingGetCall<'a, C> {
self._language = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditListingGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditListingGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditListingGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditListingGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all localized store listings.
///
/// A builder for the *listings.list* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().listings_list("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditListingListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditListingListCall<'a, C> {}
impl<'a, C> EditListingListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ListingsListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.listings.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditListingListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditListingListCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditListingListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditListingListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditListingListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditListingListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Patches a localized store listing.
///
/// A builder for the *listings.patch* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Listing;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Listing::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().listings_patch(req, "packageName", "editId", "language")
/// .doit().await;
/// # }
/// ```
pub struct EditListingPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Listing,
_package_name: String,
_edit_id: String,
_language: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditListingPatchCall<'a, C> {}
impl<'a, C> EditListingPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Listing)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.listings.patch",
http_method: hyper::Method::PATCH,
});
for &field in ["alt", "packageName", "editId", "language"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Listing) -> EditListingPatchCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditListingPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditListingPatchCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditListingPatchCall<'a, C> {
self._language = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditListingPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditListingPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditListingPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditListingPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates or updates a localized store listing.
///
/// A builder for the *listings.update* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Listing;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Listing::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().listings_update(req, "packageName", "editId", "language")
/// .doit().await;
/// # }
/// ```
pub struct EditListingUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Listing,
_package_name: String,
_edit_id: String,
_language: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditListingUpdateCall<'a, C> {}
impl<'a, C> EditListingUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Listing)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.listings.update",
http_method: hyper::Method::PUT,
});
for &field in ["alt", "packageName", "editId", "language"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("language", self._language);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/listings/{language}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{language}", "language"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["language", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Listing) -> EditListingUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditListingUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditListingUpdateCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Language localization code (a BCP-47 language tag; for example, "de-AT" for Austrian German).
///
/// Sets the *language* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn language(mut self, new_value: &str) -> EditListingUpdateCall<'a, C> {
self._language = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditListingUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditListingUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditListingUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditListingUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditListingUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets testers. Note: Testers resource does not support email lists.
///
/// A builder for the *testers.get* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().testers_get("packageName", "editId", "track")
/// .doit().await;
/// # }
/// ```
pub struct EditTesterGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_track: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTesterGetCall<'a, C> {}
impl<'a, C> EditTesterGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Testers)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.testers.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId", "track"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("track", self._track);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/testers/{track}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{track}", "track"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["track", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTesterGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTesterGetCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The track to read from.
///
/// Sets the *track* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn track(mut self, new_value: &str) -> EditTesterGetCall<'a, C> {
self._track = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditTesterGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTesterGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTesterGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTesterGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTesterGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Patches testers. Note: Testers resource does not support email lists.
///
/// A builder for the *testers.patch* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Testers;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Testers::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().testers_patch(req, "packageName", "editId", "track")
/// .doit().await;
/// # }
/// ```
pub struct EditTesterPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Testers,
_package_name: String,
_edit_id: String,
_track: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTesterPatchCall<'a, C> {}
impl<'a, C> EditTesterPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Testers)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.testers.patch",
http_method: hyper::Method::PATCH,
});
for &field in ["alt", "packageName", "editId", "track"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("track", self._track);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/testers/{track}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{track}", "track"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["track", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Testers) -> EditTesterPatchCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTesterPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTesterPatchCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The track to update.
///
/// Sets the *track* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn track(mut self, new_value: &str) -> EditTesterPatchCall<'a, C> {
self._track = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditTesterPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTesterPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTesterPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTesterPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTesterPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates testers. Note: Testers resource does not support email lists.
///
/// A builder for the *testers.update* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Testers;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Testers::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().testers_update(req, "packageName", "editId", "track")
/// .doit().await;
/// # }
/// ```
pub struct EditTesterUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Testers,
_package_name: String,
_edit_id: String,
_track: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTesterUpdateCall<'a, C> {}
impl<'a, C> EditTesterUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Testers)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.testers.update",
http_method: hyper::Method::PUT,
});
for &field in ["alt", "packageName", "editId", "track"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("track", self._track);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/testers/{track}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{track}", "track"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["track", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Testers) -> EditTesterUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The track to update.
///
/// Sets the *track* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn track(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C> {
self._track = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditTesterUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTesterUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTesterUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTesterUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTesterUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates a new track.
///
/// A builder for the *tracks.create* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::TrackConfig;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = TrackConfig::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().tracks_create(req, "packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditTrackCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: TrackConfig,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTrackCreateCall<'a, C> {}
impl<'a, C> EditTrackCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Track)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.tracks.create",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/tracks";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: TrackConfig) -> EditTrackCreateCall<'a, C> {
self._request = new_value;
self
}
/// Required. Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTrackCreateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTrackCreateCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditTrackCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTrackCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTrackCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTrackCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets a track.
///
/// A builder for the *tracks.get* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().tracks_get("packageName", "editId", "track")
/// .doit().await;
/// # }
/// ```
pub struct EditTrackGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_track: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTrackGetCall<'a, C> {}
impl<'a, C> EditTrackGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Track)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.tracks.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId", "track"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("track", self._track);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/tracks/{track}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{track}", "track"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["track", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTrackGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTrackGetCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Identifier of the track. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
///
/// Sets the *track* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn track(mut self, new_value: &str) -> EditTrackGetCall<'a, C> {
self._track = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditTrackGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTrackGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTrackGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTrackGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all tracks.
///
/// A builder for the *tracks.list* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().tracks_list("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditTrackListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTrackListCall<'a, C> {}
impl<'a, C> EditTrackListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, TracksListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.tracks.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/tracks";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTrackListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTrackListCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditTrackListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTrackListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTrackListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTrackListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Patches a track.
///
/// A builder for the *tracks.patch* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Track;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Track::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().tracks_patch(req, "packageName", "editId", "track")
/// .doit().await;
/// # }
/// ```
pub struct EditTrackPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Track,
_package_name: String,
_edit_id: String,
_track: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTrackPatchCall<'a, C> {}
impl<'a, C> EditTrackPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Track)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.tracks.patch",
http_method: hyper::Method::PATCH,
});
for &field in ["alt", "packageName", "editId", "track"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("track", self._track);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/tracks/{track}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{track}", "track"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["track", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Track) -> EditTrackPatchCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTrackPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTrackPatchCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Identifier of the track. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
///
/// Sets the *track* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn track(mut self, new_value: &str) -> EditTrackPatchCall<'a, C> {
self._track = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditTrackPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTrackPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTrackPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTrackPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates a track.
///
/// A builder for the *tracks.update* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Track;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Track::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().tracks_update(req, "packageName", "editId", "track")
/// .doit().await;
/// # }
/// ```
pub struct EditTrackUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Track,
_package_name: String,
_edit_id: String,
_track: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditTrackUpdateCall<'a, C> {}
impl<'a, C> EditTrackUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Track)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.tracks.update",
http_method: hyper::Method::PUT,
});
for &field in ["alt", "packageName", "editId", "track"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.push("track", self._track);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}/tracks/{track}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{editId}", "editId"),
("{track}", "track"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["track", "editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Track) -> EditTrackUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// Identifier of the track. [More on track name](https://developers.google.com/android-publisher/tracks#ff-track-name)
///
/// Sets the *track* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn track(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C> {
self._track = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> EditTrackUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditTrackUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditTrackUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditTrackUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditTrackUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Commits an app edit.
///
/// A builder for the *commit* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().commit("packageName", "editId")
/// .changes_not_sent_for_review(false)
/// .doit().await;
/// # }
/// ```
pub struct EditCommitCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_changes_not_sent_for_review: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditCommitCall<'a, C> {}
impl<'a, C> EditCommitCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.commit",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "editId", "changesNotSentForReview"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
if let Some(value) = self._changes_not_sent_for_review.as_ref() {
params.push("changesNotSentForReview", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}:commit";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditCommitCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditCommitCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// When a rejection happens, the parameter will make sure that the changes in this edit won't be reviewed until they are explicitly sent for review from within the Google Play Console UI. These changes will be added to any other changes that are not yet sent for review.
///
/// Sets the *changes not sent for review* query property to the given value.
pub fn changes_not_sent_for_review(mut self, new_value: bool) -> EditCommitCall<'a, C> {
self._changes_not_sent_for_review = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditCommitCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditCommitCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditCommitCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditCommitCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditCommitCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes an app edit.
///
/// A builder for the *delete* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().delete("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditDeleteCall<'a, C> {}
impl<'a, C> EditDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditDeleteCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets an app edit.
///
/// A builder for the *get* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().get("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditGetCall<'a, C> {}
impl<'a, C> EditGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditGetCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates a new edit for an app.
///
/// A builder for the *insert* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::AppEdit;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = AppEdit::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().insert(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct EditInsertCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: AppEdit,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditInsertCall<'a, C> {}
impl<'a, C> EditInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.insert",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url =
self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/edits";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: AppEdit) -> EditInsertCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditInsertCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditInsertCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditInsertCall<'a, C> {
self._scopes.clear();
self
}
}
/// Validates an app edit.
///
/// A builder for the *validate* method supported by a *edit* resource.
/// It is not used directly, but through a [`EditMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.edits().validate("packageName", "editId")
/// .doit().await;
/// # }
/// ```
pub struct EditValidateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_edit_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for EditValidateCall<'a, C> {}
impl<'a, C> EditValidateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AppEdit)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.edits.validate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "editId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("editId", self._edit_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/edits/{editId}:validate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{editId}", "editId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["editId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> EditValidateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Identifier of the edit.
///
/// Sets the *edit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn edit_id(mut self, new_value: &str) -> EditValidateCall<'a, C> {
self._edit_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EditValidateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> EditValidateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> EditValidateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> EditValidateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> EditValidateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates a new external transaction.
///
/// A builder for the *createexternaltransaction* method supported by a *externaltransaction* resource.
/// It is not used directly, but through a [`ExternaltransactionMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ExternalTransaction;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ExternalTransaction::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.externaltransactions().createexternaltransaction(req, "parent")
/// .external_transaction_id("sit")
/// .doit().await;
/// # }
/// ```
pub struct ExternaltransactionCreateexternaltransactionCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ExternalTransaction,
_parent: String,
_external_transaction_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ExternaltransactionCreateexternaltransactionCall<'a, C> {}
impl<'a, C> ExternaltransactionCreateexternaltransactionCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ExternalTransaction)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.externaltransactions.createexternaltransaction",
http_method: hyper::Method::POST,
});
for &field in ["alt", "parent", "externalTransactionId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("parent", self._parent);
if let Some(value) = self._external_transaction_id.as_ref() {
params.push("externalTransactionId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url =
self.hub._base_url.clone() + "androidpublisher/v3/{+parent}/externalTransactions";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["parent"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ExternalTransaction,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent resource where this external transaction will be created. Format: applications/{package_name}
///
/// Sets the *parent* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn parent(
mut self,
new_value: &str,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C> {
self._parent = new_value.to_string();
self
}
/// Required. The id to use for the external transaction. Must be unique across all other transactions for the app. This value should be 1-63 characters and valid characters are /a-zA-Z0-9_-/. Do not use this field to store any Personally Identifiable Information (PII) such as emails. Attempting to store PII in this field may result in requests being blocked.
///
/// Sets the *external transaction id* query property to the given value.
pub fn external_transaction_id(
mut self,
new_value: &str,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C> {
self._external_transaction_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> ExternaltransactionCreateexternaltransactionCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ExternaltransactionCreateexternaltransactionCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets an existing external transaction.
///
/// A builder for the *getexternaltransaction* method supported by a *externaltransaction* resource.
/// It is not used directly, but through a [`ExternaltransactionMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.externaltransactions().getexternaltransaction("name")
/// .doit().await;
/// # }
/// ```
pub struct ExternaltransactionGetexternaltransactionCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ExternaltransactionGetexternaltransactionCall<'a, C> {}
impl<'a, C> ExternaltransactionGetexternaltransactionCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ExternalTransaction)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.externaltransactions.getexternaltransaction",
http_method: hyper::Method::GET,
});
for &field in ["alt", "name"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("name", self._name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+name}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+name}", "name")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["name"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The name of the external transaction to retrieve. Format: applications/{package_name}/externalTransactions/{external_transaction}
///
/// Sets the *name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn name(mut self, new_value: &str) -> ExternaltransactionGetexternaltransactionCall<'a, C> {
self._name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ExternaltransactionGetexternaltransactionCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> ExternaltransactionGetexternaltransactionCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> ExternaltransactionGetexternaltransactionCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> ExternaltransactionGetexternaltransactionCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ExternaltransactionGetexternaltransactionCall<'a, C> {
self._scopes.clear();
self
}
}
/// Refunds or partially refunds an existing external transaction.
///
/// A builder for the *refundexternaltransaction* method supported by a *externaltransaction* resource.
/// It is not used directly, but through a [`ExternaltransactionMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::RefundExternalTransactionRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = RefundExternalTransactionRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.externaltransactions().refundexternaltransaction(req, "name")
/// .doit().await;
/// # }
/// ```
pub struct ExternaltransactionRefundexternaltransactionCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: RefundExternalTransactionRequest,
_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ExternaltransactionRefundexternaltransactionCall<'a, C> {}
impl<'a, C> ExternaltransactionRefundexternaltransactionCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ExternalTransaction)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.externaltransactions.refundexternaltransaction",
http_method: hyper::Method::POST,
});
for &field in ["alt", "name"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("name", self._name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+name}:refund";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+name}", "name")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["name"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: RefundExternalTransactionRequest,
) -> ExternaltransactionRefundexternaltransactionCall<'a, C> {
self._request = new_value;
self
}
/// Required. The name of the external transaction that will be refunded. Format: applications/{package_name}/externalTransactions/{external_transaction}
///
/// Sets the *name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn name(
mut self,
new_value: &str,
) -> ExternaltransactionRefundexternaltransactionCall<'a, C> {
self._name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> ExternaltransactionRefundexternaltransactionCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> ExternaltransactionRefundexternaltransactionCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> ExternaltransactionRefundexternaltransactionCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> ExternaltransactionRefundexternaltransactionCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ExternaltransactionRefundexternaltransactionCall<'a, C> {
self._scopes.clear();
self
}
}
/// Downloads a single signed APK generated from an app bundle.
///
/// This method supports **media download**. To enable it, adjust the builder like this:
/// `.param("alt", "media")`.
///
/// A builder for the *download* method supported by a *generatedapk* resource.
/// It is not used directly, but through a [`GeneratedapkMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.generatedapks().download("packageName", -17, "downloadId")
/// .doit().await;
/// # }
/// ```
pub struct GeneratedapkDownloadCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_version_code: i32,
_download_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for GeneratedapkDownloadCall<'a, C> {}
impl<'a, C> GeneratedapkDownloadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.generatedapks.download",
http_method: hyper::Method::GET,
});
for &field in ["packageName", "versionCode", "downloadId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("versionCode", self._version_code.to_string());
params.push("downloadId", self._download_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/generatedApks/{versionCode}/downloads/{downloadId}:download";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{versionCode}", "versionCode"),
("{downloadId}", "downloadId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["downloadId", "versionCode", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> GeneratedapkDownloadCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Version code of the app bundle.
///
/// Sets the *version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn version_code(mut self, new_value: i32) -> GeneratedapkDownloadCall<'a, C> {
self._version_code = new_value;
self
}
/// Download ID, which uniquely identifies the APK to download. Can be obtained from the response of `generatedapks.list` method.
///
/// Sets the *download id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn download_id(mut self, new_value: &str) -> GeneratedapkDownloadCall<'a, C> {
self._download_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> GeneratedapkDownloadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> GeneratedapkDownloadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> GeneratedapkDownloadCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> GeneratedapkDownloadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> GeneratedapkDownloadCall<'a, C> {
self._scopes.clear();
self
}
}
/// Returns download metadata for all APKs that were generated from a given app bundle.
///
/// A builder for the *list* method supported by a *generatedapk* resource.
/// It is not used directly, but through a [`GeneratedapkMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.generatedapks().list("packageName", -25)
/// .doit().await;
/// # }
/// ```
pub struct GeneratedapkListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_version_code: i32,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for GeneratedapkListCall<'a, C> {}
impl<'a, C> GeneratedapkListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, GeneratedApksListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.generatedapks.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "versionCode"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("versionCode", self._version_code.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/generatedApks/{versionCode}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{versionCode}", "versionCode"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["versionCode", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> GeneratedapkListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Version code of the app bundle.
///
/// Sets the *version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn version_code(mut self, new_value: i32) -> GeneratedapkListCall<'a, C> {
self._version_code = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> GeneratedapkListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> GeneratedapkListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> GeneratedapkListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> GeneratedapkListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> GeneratedapkListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Grant access for a user to the given package.
///
/// A builder for the *create* method supported by a *grant* resource.
/// It is not used directly, but through a [`GrantMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Grant;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Grant::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.grants().create(req, "parent")
/// .doit().await;
/// # }
/// ```
pub struct GrantCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Grant,
_parent: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for GrantCreateCall<'a, C> {}
impl<'a, C> GrantCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Grant)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.grants.create",
http_method: hyper::Method::POST,
});
for &field in ["alt", "parent"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("parent", self._parent);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+parent}/grants";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["parent"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Grant) -> GrantCreateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The user which needs permission. Format: developers/{developer}/users/{user}
///
/// Sets the *parent* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn parent(mut self, new_value: &str) -> GrantCreateCall<'a, C> {
self._parent = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> GrantCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> GrantCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> GrantCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> GrantCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> GrantCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Removes all access for the user to the given package or developer account.
///
/// A builder for the *delete* method supported by a *grant* resource.
/// It is not used directly, but through a [`GrantMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.grants().delete("name")
/// .doit().await;
/// # }
/// ```
pub struct GrantDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for GrantDeleteCall<'a, C> {}
impl<'a, C> GrantDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.grants.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["name"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(2 + self._additional_params.len());
params.push("name", self._name);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+name}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+name}", "name")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["name"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The name of the grant to delete. Format: developers/{developer}/users/{email}/grants/{package_name}
///
/// Sets the *name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn name(mut self, new_value: &str) -> GrantDeleteCall<'a, C> {
self._name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> GrantDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> GrantDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> GrantDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> GrantDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> GrantDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates access for the user to the given package.
///
/// A builder for the *patch* method supported by a *grant* resource.
/// It is not used directly, but through a [`GrantMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Grant;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Grant::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.grants().patch(req, "name")
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .doit().await;
/// # }
/// ```
pub struct GrantPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Grant,
_name: String,
_update_mask: Option<common::FieldMask>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for GrantPatchCall<'a, C> {}
impl<'a, C> GrantPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Grant)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.grants.patch",
http_method: hyper::Method::PATCH,
});
for &field in ["alt", "name", "updateMask"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("name", self._name);
if let Some(value) = self._update_mask.as_ref() {
params.push("updateMask", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+name}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+name}", "name")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["name"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Grant) -> GrantPatchCall<'a, C> {
self._request = new_value;
self
}
/// Required. Resource name for this grant, following the pattern "developers/{developer}/users/{email}/grants/{package_name}". If this grant is for a draft app, the app ID will be used in this resource name instead of the package name.
///
/// Sets the *name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn name(mut self, new_value: &str) -> GrantPatchCall<'a, C> {
self._name = new_value.to_string();
self
}
/// Optional. The list of fields to be updated.
///
/// Sets the *update mask* query property to the given value.
pub fn update_mask(mut self, new_value: common::FieldMask) -> GrantPatchCall<'a, C> {
self._update_mask = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> GrantPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> GrantPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> GrantPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> GrantPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> GrantPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes in-app products (managed products or subscriptions). Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput. This method should not be used to delete subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *batchDelete* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::InappproductsBatchDeleteRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = InappproductsBatchDeleteRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().batch_delete(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct InappproductBatchDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: InappproductsBatchDeleteRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductBatchDeleteCall<'a, C> {}
impl<'a, C> InappproductBatchDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.batchDelete",
http_method: hyper::Method::POST,
});
for &field in ["packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts:batchDelete";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: InappproductsBatchDeleteRequest,
) -> InappproductBatchDeleteCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductBatchDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductBatchDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductBatchDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductBatchDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductBatchDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductBatchDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads multiple in-app products, which can be managed products or subscriptions. This method should not be used to retrieve subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *batchGet* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().batch_get("packageName")
/// .add_sku("eirmod")
/// .doit().await;
/// # }
/// ```
pub struct InappproductBatchGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_sku: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductBatchGetCall<'a, C> {}
impl<'a, C> InappproductBatchGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, InappproductsBatchGetResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.batchGet",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "sku"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
if !self._sku.is_empty() {
for f in self._sku.iter() {
params.push("sku", f);
}
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts:batchGet";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductBatchGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for the in-app products.
///
/// Append the given value to the *sku* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
pub fn add_sku(mut self, new_value: &str) -> InappproductBatchGetCall<'a, C> {
self._sku.push(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductBatchGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductBatchGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductBatchGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductBatchGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductBatchGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates or inserts one or more in-app products (managed products or subscriptions). Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput. This method should no longer be used to update subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *batchUpdate* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::InappproductsBatchUpdateRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = InappproductsBatchUpdateRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().batch_update(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct InappproductBatchUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: InappproductsBatchUpdateRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductBatchUpdateCall<'a, C> {}
impl<'a, C> InappproductBatchUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, InappproductsBatchUpdateResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.batchUpdate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts:batchUpdate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: InappproductsBatchUpdateRequest,
) -> InappproductBatchUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductBatchUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductBatchUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductBatchUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductBatchUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductBatchUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductBatchUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes an in-app product (a managed product or a subscription). This method should no longer be used to delete subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *delete* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().delete("packageName", "sku")
/// .latency_tolerance("erat")
/// .doit().await;
/// # }
/// ```
pub struct InappproductDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_sku: String,
_latency_tolerance: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductDeleteCall<'a, C> {}
impl<'a, C> InappproductDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "sku", "latencyTolerance"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("sku", self._sku);
if let Some(value) = self._latency_tolerance.as_ref() {
params.push("latencyTolerance", value);
}
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts/{sku}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["sku", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for the in-app product.
///
/// Sets the *sku* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn sku(mut self, new_value: &str) -> InappproductDeleteCall<'a, C> {
self._sku = new_value.to_string();
self
}
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
///
/// Sets the *latency tolerance* query property to the given value.
pub fn latency_tolerance(mut self, new_value: &str) -> InappproductDeleteCall<'a, C> {
self._latency_tolerance = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets an in-app product, which can be a managed product or a subscription. This method should no longer be used to retrieve subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *get* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().get("packageName", "sku")
/// .doit().await;
/// # }
/// ```
pub struct InappproductGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_sku: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductGetCall<'a, C> {}
impl<'a, C> InappproductGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "sku"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("sku", self._sku);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts/{sku}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["sku", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for the in-app product.
///
/// Sets the *sku* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn sku(mut self, new_value: &str) -> InappproductGetCall<'a, C> {
self._sku = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates an in-app product (a managed product or a subscription). This method should no longer be used to create subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *insert* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::InAppProduct;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = InAppProduct::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().insert(req, "packageName")
/// .auto_convert_missing_prices(true)
/// .doit().await;
/// # }
/// ```
pub struct InappproductInsertCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: InAppProduct,
_package_name: String,
_auto_convert_missing_prices: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductInsertCall<'a, C> {}
impl<'a, C> InappproductInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.insert",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "autoConvertMissingPrices"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._auto_convert_missing_prices.as_ref() {
params.push("autoConvertMissingPrices", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: InAppProduct) -> InappproductInsertCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductInsertCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// 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.
///
/// Sets the *auto convert missing prices* query property to the given value.
pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductInsertCall<'a, C> {
self._auto_convert_missing_prices = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductInsertCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductInsertCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all in-app products - both managed products and subscriptions. If an app has a large number of in-app products, the response may be paginated. In this case the response field `tokenPagination.nextPageToken` will be set and the caller should provide its value as a `token` request parameter to retrieve the next page. This method should no longer be used to retrieve subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *list* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().list("packageName")
/// .token("et")
/// .start_index(24)
/// .max_results(97)
/// .doit().await;
/// # }
/// ```
pub struct InappproductListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_token: Option<String>,
_start_index: Option<u32>,
_max_results: Option<u32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductListCall<'a, C> {}
impl<'a, C> InappproductListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, InappproductsListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "token", "startIndex", "maxResults"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._token.as_ref() {
params.push("token", value);
}
if let Some(value) = self._start_index.as_ref() {
params.push("startIndex", value.to_string());
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Pagination token. If empty, list starts at the first product.
///
/// Sets the *token* query property to the given value.
pub fn token(mut self, new_value: &str) -> InappproductListCall<'a, C> {
self._token = Some(new_value.to_string());
self
}
/// Deprecated and ignored. Set the `token` parameter to retrieve the next page.
///
/// Sets the *start index* query property to the given value.
pub fn start_index(mut self, new_value: u32) -> InappproductListCall<'a, C> {
self._start_index = Some(new_value);
self
}
/// Deprecated and ignored. The page size is determined by the server.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> InappproductListCall<'a, C> {
self._max_results = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Patches an in-app product (a managed product or a subscription). This method should no longer be used to update subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *patch* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::InAppProduct;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = InAppProduct::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().patch(req, "packageName", "sku")
/// .latency_tolerance("erat")
/// .auto_convert_missing_prices(true)
/// .doit().await;
/// # }
/// ```
pub struct InappproductPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: InAppProduct,
_package_name: String,
_sku: String,
_latency_tolerance: Option<String>,
_auto_convert_missing_prices: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductPatchCall<'a, C> {}
impl<'a, C> InappproductPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.patch",
http_method: hyper::Method::PATCH,
});
for &field in [
"alt",
"packageName",
"sku",
"latencyTolerance",
"autoConvertMissingPrices",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("sku", self._sku);
if let Some(value) = self._latency_tolerance.as_ref() {
params.push("latencyTolerance", value);
}
if let Some(value) = self._auto_convert_missing_prices.as_ref() {
params.push("autoConvertMissingPrices", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts/{sku}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["sku", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: InAppProduct) -> InappproductPatchCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for the in-app product.
///
/// Sets the *sku* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn sku(mut self, new_value: &str) -> InappproductPatchCall<'a, C> {
self._sku = new_value.to_string();
self
}
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
///
/// Sets the *latency tolerance* query property to the given value.
pub fn latency_tolerance(mut self, new_value: &str) -> InappproductPatchCall<'a, C> {
self._latency_tolerance = Some(new_value.to_string());
self
}
/// 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.
///
/// Sets the *auto convert missing prices* query property to the given value.
pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductPatchCall<'a, C> {
self._auto_convert_missing_prices = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates an in-app product (a managed product or a subscription). This method should no longer be used to update subscriptions. See [this article](https://android-developers.googleblog.com/2023/06/changes-to-google-play-developer-api-june-2023.html) for more information.
///
/// A builder for the *update* method supported by a *inappproduct* resource.
/// It is not used directly, but through a [`InappproductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::InAppProduct;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = InAppProduct::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.inappproducts().update(req, "packageName", "sku")
/// .latency_tolerance("justo")
/// .auto_convert_missing_prices(true)
/// .allow_missing(false)
/// .doit().await;
/// # }
/// ```
pub struct InappproductUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: InAppProduct,
_package_name: String,
_sku: String,
_latency_tolerance: Option<String>,
_auto_convert_missing_prices: Option<bool>,
_allow_missing: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InappproductUpdateCall<'a, C> {}
impl<'a, C> InappproductUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, InAppProduct)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.inappproducts.update",
http_method: hyper::Method::PUT,
});
for &field in [
"alt",
"packageName",
"sku",
"latencyTolerance",
"autoConvertMissingPrices",
"allowMissing",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("sku", self._sku);
if let Some(value) = self._latency_tolerance.as_ref() {
params.push("latencyTolerance", value);
}
if let Some(value) = self._auto_convert_missing_prices.as_ref() {
params.push("autoConvertMissingPrices", value.to_string());
}
if let Some(value) = self._allow_missing.as_ref() {
params.push("allowMissing", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/inappproducts/{sku}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["sku", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: InAppProduct) -> InappproductUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> InappproductUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for the in-app product.
///
/// Sets the *sku* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn sku(mut self, new_value: &str) -> InappproductUpdateCall<'a, C> {
self._sku = new_value.to_string();
self
}
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
///
/// Sets the *latency tolerance* query property to the given value.
pub fn latency_tolerance(mut self, new_value: &str) -> InappproductUpdateCall<'a, C> {
self._latency_tolerance = Some(new_value.to_string());
self
}
/// 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.
///
/// Sets the *auto convert missing prices* query property to the given value.
pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductUpdateCall<'a, C> {
self._auto_convert_missing_prices = Some(new_value);
self
}
/// If set to true, and the in-app product with the given package_name and sku doesn't exist, the in-app product will be created.
///
/// Sets the *allow missing* query property to the given value.
pub fn allow_missing(mut self, new_value: bool) -> InappproductUpdateCall<'a, C> {
self._allow_missing = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InappproductUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InappproductUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InappproductUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InappproductUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InappproductUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Uploads an APK to internal app sharing. 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 [Timeouts and Errors](https://developers.google.com/api-client-library/java/google-api-java-client/errors) for an example in java.
///
/// A builder for the *uploadapk* method supported by a *internalappsharingartifact* resource.
/// It is not used directly, but through a [`InternalappsharingartifactMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use std::fs;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `upload(...)`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.internalappsharingartifacts().uploadapk("packageName")
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct InternalappsharingartifactUploadapkCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InternalappsharingartifactUploadapkCall<'a, C> {}
impl<'a, C> InternalappsharingartifactUploadapkCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, InternalAppSharingArtifact)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.internalappsharingartifacts.uploadapk",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
(self.hub._root_url.clone() + "resumable/upload/androidpublisher/v3/applications/internalappsharing/{packageName}/artifacts/apk", "resumable")
} else if protocol == common::UploadProtocol::Simple {
(self.hub._root_url.clone() + "upload/androidpublisher/v3/applications/internalappsharing/{packageName}/artifacts/apk", "multipart")
} else {
unreachable!()
};
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 1073741824 {
return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
}
let mut bytes = Vec::with_capacity(size as usize);
reader.read_to_end(&mut bytes)?;
req_builder
.header(CONTENT_TYPE, reader_mime_type.to_string())
.header(CONTENT_LENGTH, size)
.body(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 1073741824 {
return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
}
let upload_result = {
let url_str = &parts
.headers
.get("Location")
.expect("LOCATION header is part of protocol")
.to_str()
.unwrap();
if upload_url_from_server {
dlg.store_upload_url(Some(url_str));
}
common::ResumableUploadHelper {
client: &self.hub.client,
delegate: dlg,
start_at: if upload_url_from_server {
Some(0)
} else {
None
},
auth: &self.hub.auth,
user_agent: &self.hub._user_agent,
// TODO: Check this assumption
auth_header: format!(
"Bearer {}",
token
.ok_or_else(|| common::Error::MissingToken(
"resumable upload requires token".into()
))?
.as_str()
),
url: url_str,
reader: &mut reader,
media_type: reader_mime_type.clone(),
content_length: size,
}
.upload()
.await
};
match upload_result {
None => {
dlg.finished(false);
return Err(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Upload media in a resumable fashion.
/// Even if the upload fails or is interrupted, it can be resumed for a
/// certain amount of time as the server maintains state temporarily.
///
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
/// `cancel_chunk_upload(...)`.
///
/// * *multipart*: yes
/// * *max size*: 1073741824
/// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
pub async fn upload_resumable<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, InternalAppSharingArtifact)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::UploadProtocol::Resumable,
)
.await
}
/// Upload media all at once.
/// If the upload fails for whichever reason, all progress is lost.
///
/// * *multipart*: yes
/// * *max size*: 1073741824
/// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
pub async fn upload<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, InternalAppSharingArtifact)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::UploadProtocol::Simple)
.await
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> InternalappsharingartifactUploadapkCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InternalappsharingartifactUploadapkCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> InternalappsharingartifactUploadapkCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InternalappsharingartifactUploadapkCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> InternalappsharingartifactUploadapkCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InternalappsharingartifactUploadapkCall<'a, C> {
self._scopes.clear();
self
}
}
/// Uploads an app bundle to internal app sharing. 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 [Timeouts and Errors](https://developers.google.com/api-client-library/java/google-api-java-client/errors) for an example in java.
///
/// A builder for the *uploadbundle* method supported by a *internalappsharingartifact* resource.
/// It is not used directly, but through a [`InternalappsharingartifactMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use std::fs;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `upload(...)`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.internalappsharingartifacts().uploadbundle("packageName")
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct InternalappsharingartifactUploadbundleCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for InternalappsharingartifactUploadbundleCall<'a, C> {}
impl<'a, C> InternalappsharingartifactUploadbundleCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, InternalAppSharingArtifact)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.internalappsharingartifacts.uploadbundle",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
(self.hub._root_url.clone() + "resumable/upload/androidpublisher/v3/applications/internalappsharing/{packageName}/artifacts/bundle", "resumable")
} else if protocol == common::UploadProtocol::Simple {
(self.hub._root_url.clone() + "upload/androidpublisher/v3/applications/internalappsharing/{packageName}/artifacts/bundle", "multipart")
} else {
unreachable!()
};
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 10737418240 {
return Err(common::Error::UploadSizeLimitExceeded(size, 10737418240));
}
let mut bytes = Vec::with_capacity(size as usize);
reader.read_to_end(&mut bytes)?;
req_builder
.header(CONTENT_TYPE, reader_mime_type.to_string())
.header(CONTENT_LENGTH, size)
.body(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 10737418240 {
return Err(common::Error::UploadSizeLimitExceeded(size, 10737418240));
}
let upload_result = {
let url_str = &parts
.headers
.get("Location")
.expect("LOCATION header is part of protocol")
.to_str()
.unwrap();
if upload_url_from_server {
dlg.store_upload_url(Some(url_str));
}
common::ResumableUploadHelper {
client: &self.hub.client,
delegate: dlg,
start_at: if upload_url_from_server {
Some(0)
} else {
None
},
auth: &self.hub.auth,
user_agent: &self.hub._user_agent,
// TODO: Check this assumption
auth_header: format!(
"Bearer {}",
token
.ok_or_else(|| common::Error::MissingToken(
"resumable upload requires token".into()
))?
.as_str()
),
url: url_str,
reader: &mut reader,
media_type: reader_mime_type.clone(),
content_length: size,
}
.upload()
.await
};
match upload_result {
None => {
dlg.finished(false);
return Err(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Upload media in a resumable fashion.
/// Even if the upload fails or is interrupted, it can be resumed for a
/// certain amount of time as the server maintains state temporarily.
///
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
/// `cancel_chunk_upload(...)`.
///
/// * *multipart*: yes
/// * *max size*: 10737418240
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload_resumable<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, InternalAppSharingArtifact)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::UploadProtocol::Resumable,
)
.await
}
/// Upload media all at once.
/// If the upload fails for whichever reason, all progress is lost.
///
/// * *multipart*: yes
/// * *max size*: 10737418240
/// * *valid mime types*: 'application/octet-stream'
pub async fn upload<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, InternalAppSharingArtifact)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::UploadProtocol::Simple)
.await
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> InternalappsharingartifactUploadbundleCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> InternalappsharingartifactUploadbundleCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> InternalappsharingartifactUploadbundleCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> InternalappsharingartifactUploadbundleCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> InternalappsharingartifactUploadbundleCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> InternalappsharingartifactUploadbundleCall<'a, C> {
self._scopes.clear();
self
}
}
/// Activates a one-time product offer.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.activate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ActivateOneTimeProductOfferRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ActivateOneTimeProductOfferRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_activate(req, "packageName", "productId", "purchaseOptionId", "offerId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ActivateOneTimeProductOfferRequest,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_offer_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C>
{
}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, OneTimeProductOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.activate",
http_method: hyper::Method::POST,
});
for &field in [
"alt",
"packageName",
"productId",
"purchaseOptionId",
"offerId",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
params.push("offerId", self._offer_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers/{offerId}:activate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ActivateOneTimeProductOfferRequest,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the offer to activate.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent one-time product (ID) of the offer to activate.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent purchase option (ID) of the offer to activate.
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// Required. The offer ID of the offer to activate.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionOfferActivateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes one or more one-time product offers.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.batchDelete* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchDeleteOneTimeProductOffersRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchDeleteOneTimeProductOffersRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_batch_delete(req, "packageName", "productId", "purchaseOptionId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchDeleteOneTimeProductOffersRequest,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C>
{
}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.batchDelete",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "productId", "purchaseOptionId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers:batchDelete";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchDeleteOneTimeProductOffersRequest,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the offers to delete. Must be equal to the package_name field on all the OneTimeProductOffer resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent one-time product, if all offers to delete belong to the same product. If this request spans multiple one-time products, set this field to "-".
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent purchase option (ID) for which the offers should be deleted. May be specified as '-' to update offers from multiple purchase options.
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads one or more one-time product offers.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.batchGet* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchGetOneTimeProductOffersRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchGetOneTimeProductOffersRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_batch_get(req, "packageName", "productId", "purchaseOptionId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchGetOneTimeProductOffersRequest,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C>
{
}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchGetOneTimeProductOffersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.batchGet",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "purchaseOptionId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers:batchGet";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchGetOneTimeProductOffersRequest,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the updated offers. Must be equal to the package_name field on all the updated OneTimeProductOffer resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent one-time product, if all updated offers belong to the same product. If this request spans multiple one-time products, set this field to "-".
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent purchase option (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple purchase options.
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates or updates one or more one-time product offers.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.batchUpdate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdateOneTimeProductOffersRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdateOneTimeProductOffersRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_batch_update(req, "packageName", "productId", "purchaseOptionId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdateOneTimeProductOffersRequest,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C>
{
}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchUpdateOneTimeProductOffersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.batchUpdate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "purchaseOptionId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers:batchUpdate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdateOneTimeProductOffersRequest,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the updated offers. Must be equal to the package_name field on all the updated OneTimeProductOffer resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent one-time product, if all updated offers belong to the same product. If this request spans multiple one-time products, set this field to "-".
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent purchase option (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple purchase options.
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates a batch of one-time product offer states.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.batchUpdateStates* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdateOneTimeProductOfferStatesRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdateOneTimeProductOfferStatesRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_batch_update_states(req, "packageName", "productId", "purchaseOptionId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdateOneTimeProductOfferStatesRequest,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C>
{
}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(
common::Response,
BatchUpdateOneTimeProductOfferStatesResponse,
)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo { id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.batchUpdateStates",
http_method: hyper::Method::POST });
for &field in ["alt", "packageName", "productId", "purchaseOptionId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers:batchUpdateStates";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdateOneTimeProductOfferStatesRequest,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the updated one-time product offers.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent one-time product, if all updated offers belong to the same one-time product. If this batch update spans multiple one-time products, set this field to "-".
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The purchase option ID of the parent purchase option, if all updated offers belong to the same purchase option. If this batch update spans multiple purchase options, set this field to "-".
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionOfferBatchUpdateStateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Cancels a one-time product offer.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.cancel* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::CancelOneTimeProductOfferRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = CancelOneTimeProductOfferRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_cancel(req, "packageName", "productId", "purchaseOptionId", "offerId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: CancelOneTimeProductOfferRequest,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_offer_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, OneTimeProductOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.cancel",
http_method: hyper::Method::POST,
});
for &field in [
"alt",
"packageName",
"productId",
"purchaseOptionId",
"offerId",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
params.push("offerId", self._offer_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers/{offerId}:cancel";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: CancelOneTimeProductOfferRequest,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the offer to cancel.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent one-time product (ID) of the offer to cancel.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent purchase option (ID) of the offer to cancel.
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// Required. The offer ID of the offer to cancel.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionOfferCancelCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deactivates a one-time product offer.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.deactivate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::DeactivateOneTimeProductOfferRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = DeactivateOneTimeProductOfferRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_deactivate(req, "packageName", "productId", "purchaseOptionId", "offerId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: DeactivateOneTimeProductOfferRequest,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_offer_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C>
{
}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, OneTimeProductOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.deactivate",
http_method: hyper::Method::POST,
});
for &field in [
"alt",
"packageName",
"productId",
"purchaseOptionId",
"offerId",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
params.push("offerId", self._offer_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers/{offerId}:deactivate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: DeactivateOneTimeProductOfferRequest,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the offer to deactivate.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent one-time product (ID) of the offer to deactivate.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent purchase option (ID) of the offer to deactivate.
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// Required. The offer ID of the offer to deactivate.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionOfferDeactivateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all offers under a given app, product, or purchase option.
///
/// A builder for the *onetimeproducts.purchaseOptions.offers.list* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_offers_list("packageName", "productId", "purchaseOptionId")
/// .page_token("sed")
/// .page_size(-13)
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_purchase_option_id: String,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, ListOneTimeProductOffersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.offers.list",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"packageName",
"productId",
"purchaseOptionId",
"pageToken",
"pageSize",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("purchaseOptionId", self._purchase_option_id);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions/{purchaseOptionId}/offers";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{purchaseOptionId}", "purchaseOptionId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["purchaseOptionId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) for which the offers should be read.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent one-time product (ID) for which the offers should be read. May be specified as '-' to read all offers under an app.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent purchase option (ID) for which the offers should be read. May be specified as '-' to read all offers under a one-time product or an app. Must be specified as '-' if product_id is specified as '-'.
///
/// Sets the *purchase option id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn purchase_option_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
self._purchase_option_id = new_value.to_string();
self
}
/// Optional. A page token, received from a previous `ListOneTimeProductsOffers` call. Provide this to retrieve the subsequent page. When paginating, product_id, package_name and purchase_option_id provided to `ListOneTimeProductsOffersRequest` must match the call that provided the page token.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
/// Optional. The maximum number of offers to return. The service may return fewer than this value. If unspecified, at most 50 offers will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
///
/// Sets the *page size* query property to the given value.
pub fn page_size(
mut self,
new_value: i32,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
self._page_size = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductPurchaseOptionOfferListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes purchase options across one or multiple one-time products. By default this operation will fail if there are any existing offers under the deleted purchase options. Use the force parameter to override the default behavior.
///
/// A builder for the *onetimeproducts.purchaseOptions.batchDelete* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchDeletePurchaseOptionsRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchDeletePurchaseOptionsRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_batch_delete(req, "packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchDeletePurchaseOptionsRequest,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.batchDelete",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions:batchDelete";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchDeletePurchaseOptionsRequest,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the purchase options to delete.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent one-time product, if all purchase options to delete belong to the same one-time product. If this batch delete spans multiple one-time products, set this field to "-".
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionBatchDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Activates or deactivates purchase options across one or multiple one-time products.
///
/// A builder for the *onetimeproducts.purchaseOptions.batchUpdateStates* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdatePurchaseOptionStatesRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdatePurchaseOptionStatesRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_purchase_options_batch_update_states(req, "packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdatePurchaseOptionStatesRequest,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C>
{
}
impl<'a, C> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchUpdatePurchaseOptionStatesResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.purchaseOptions.batchUpdateStates",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}/purchaseOptions:batchUpdateStates";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdatePurchaseOptionStatesRequest,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the updated purchase options.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent one-time product, if all updated purchase options belong to the same one-time product. If this batch update spans multiple one-time products, set this field to "-".
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationOnetimeproductPurchaseOptionBatchUpdateStateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes one or more one-time products.
///
/// A builder for the *onetimeproducts.batchDelete* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchDeleteOneTimeProductsRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchDeleteOneTimeProductsRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_batch_delete(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductBatchDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchDeleteOneTimeProductsRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductBatchDeleteCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductBatchDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.batchDelete",
http_method: hyper::Method::POST,
});
for &field in ["packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/oneTimeProducts:batchDelete";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchDeleteOneTimeProductsRequest,
) -> MonetizationOnetimeproductBatchDeleteCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) for which the one-time products should be deleted. Must be equal to the package_name field on all the OneTimeProduct resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductBatchDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductBatchDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationOnetimeproductBatchDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationOnetimeproductBatchDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductBatchDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductBatchDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads one or more one-time products.
///
/// A builder for the *onetimeproducts.batchGet* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_batch_get("packageName")
/// .add_product_ids("eos")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductBatchGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_ids: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductBatchGetCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductBatchGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchGetOneTimeProductsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.batchGet",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "productIds"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
if !self._product_ids.is_empty() {
for f in self._product_ids.iter() {
params.push("productIds", f);
}
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/oneTimeProducts:batchGet";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) for which the products should be retrieved. Must be equal to the package_name field on all requests.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductBatchGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. A list of up to 100 product IDs to retrieve. All IDs must be different.
///
/// Append the given value to the *product ids* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
pub fn add_product_ids(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductBatchGetCall<'a, C> {
self._product_ids.push(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductBatchGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationOnetimeproductBatchGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationOnetimeproductBatchGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationOnetimeproductBatchGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductBatchGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates or updates one or more one-time products.
///
/// A builder for the *onetimeproducts.batchUpdate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdateOneTimeProductsRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdateOneTimeProductsRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_batch_update(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductBatchUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdateOneTimeProductsRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductBatchUpdateCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductBatchUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchUpdateOneTimeProductsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.batchUpdate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/oneTimeProducts:batchUpdate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdateOneTimeProductsRequest,
) -> MonetizationOnetimeproductBatchUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) for which the one-time products should be updated. Must be equal to the package_name field on all the OneTimeProduct resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductBatchUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductBatchUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationOnetimeproductBatchUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationOnetimeproductBatchUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationOnetimeproductBatchUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductBatchUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes a one-time product.
///
/// A builder for the *onetimeproducts.delete* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_delete("packageName", "productId")
/// .latency_tolerance("ut")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_latency_tolerance: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductDeleteCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "productId", "latencyTolerance"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
if let Some(value) = self._latency_tolerance.as_ref() {
params.push("latencyTolerance", value);
}
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) of the one-time product to delete.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationOnetimeproductDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The one-time product ID of the one-time product to delete.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> MonetizationOnetimeproductDeleteCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
///
/// Sets the *latency tolerance* query property to the given value.
pub fn latency_tolerance(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductDeleteCall<'a, C> {
self._latency_tolerance = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationOnetimeproductDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationOnetimeproductDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationOnetimeproductDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads a single one-time product.
///
/// A builder for the *onetimeproducts.get* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_get("packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductGetCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, OneTimeProduct)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/oneTimeProducts/{productId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) of the product to retrieve.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationOnetimeproductGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the product to retrieve.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> MonetizationOnetimeproductGetCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationOnetimeproductGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationOnetimeproductGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationOnetimeproductGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all one-time products under a given app.
///
/// A builder for the *onetimeproducts.list* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_list("packageName")
/// .page_token("duo")
/// .page_size(-45)
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductListCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ListOneTimeProductsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "pageToken", "pageSize"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/oneTimeProducts";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) for which the one-time product should be read.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationOnetimeproductListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Optional. A page token, received from a previous `ListOneTimeProducts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListOneTimeProducts` must match the call that provided the page token.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(mut self, new_value: &str) -> MonetizationOnetimeproductListCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
/// Optional. The maximum number of one-time product to return. The service may return fewer than this value. If unspecified, at most 50 one-time products will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
///
/// Sets the *page size* query property to the given value.
pub fn page_size(mut self, new_value: i32) -> MonetizationOnetimeproductListCall<'a, C> {
self._page_size = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationOnetimeproductListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationOnetimeproductListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationOnetimeproductListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates or updates a one-time product.
///
/// A builder for the *onetimeproducts.patch* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::OneTimeProduct;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = OneTimeProduct::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().onetimeproducts_patch(req, "packageName", "productId")
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .regions_version_version("duo")
/// .latency_tolerance("kasd")
/// .allow_missing(false)
/// .doit().await;
/// # }
/// ```
pub struct MonetizationOnetimeproductPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: OneTimeProduct,
_package_name: String,
_product_id: String,
_update_mask: Option<common::FieldMask>,
_regions_version_version: Option<String>,
_latency_tolerance: Option<String>,
_allow_missing: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationOnetimeproductPatchCall<'a, C> {}
impl<'a, C> MonetizationOnetimeproductPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, OneTimeProduct)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.onetimeproducts.patch",
http_method: hyper::Method::PATCH,
});
for &field in [
"alt",
"packageName",
"productId",
"updateMask",
"regionsVersion.version",
"latencyTolerance",
"allowMissing",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(9 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
if let Some(value) = self._update_mask.as_ref() {
params.push("updateMask", value.to_string());
}
if let Some(value) = self._regions_version_version.as_ref() {
params.push("regionsVersion.version", value);
}
if let Some(value) = self._latency_tolerance.as_ref() {
params.push("latencyTolerance", value);
}
if let Some(value) = self._allow_missing.as_ref() {
params.push("allowMissing", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/onetimeproducts/{productId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: OneTimeProduct,
) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._request = new_value;
self
}
/// Required. Immutable. Package name of the parent app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. Immutable. Unique product ID of the product. Unique within the parent app. Product IDs must start with a number or lowercase letter, and can contain numbers (0-9), lowercase letters (a-z), underscores (_), and periods (.).
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The list of fields to be updated.
///
/// Sets the *update mask* query property to the given value.
pub fn update_mask(
mut self,
new_value: common::FieldMask,
) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._update_mask = Some(new_value);
self
}
/// Required. A string representing the version of available regions being used for the specified resource. Regional prices and latest supported version for the resource have to be specified according to the information published in [this article](https://support.google.com/googleplay/android-developer/answer/10532353). Each time the supported locations substantially change, the version will be incremented. Using this field will ensure that creating and updating the resource with an older region's version and set of regional prices and currencies will succeed even though a new version is available.
///
/// Sets the *regions version.version* query property to the given value.
pub fn regions_version_version(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._regions_version_version = Some(new_value.to_string());
self
}
/// Optional. The latency tolerance for the propagation of this product upsert. Defaults to latency-sensitive.
///
/// Sets the *latency tolerance* query property to the given value.
pub fn latency_tolerance(
mut self,
new_value: &str,
) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._latency_tolerance = Some(new_value.to_string());
self
}
/// Optional. If set to true, and the one-time product with the given package_name and product_id doesn't exist, the one-time product will be created. If a new one-time product is created, update_mask is ignored.
///
/// Sets the *allow missing* query property to the given value.
pub fn allow_missing(mut self, new_value: bool) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._allow_missing = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationOnetimeproductPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationOnetimeproductPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationOnetimeproductPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationOnetimeproductPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Activates a subscription offer. Once activated, subscription offers will be available to new subscribers.
///
/// A builder for the *subscriptions.basePlans.offers.activate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ActivateSubscriptionOfferRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ActivateSubscriptionOfferRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_activate(req, "packageName", "productId", "basePlanId", "offerId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferActivateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ActivateSubscriptionOfferRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_offer_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.activate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId", "offerId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.push("offerId", self._offer_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers/{offerId}:activate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ActivateSubscriptionOfferRequest,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the offer to activate.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) of the offer to activate.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) of the offer to activate.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// Required. The unique offer ID of the offer to activate.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferActivateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads one or more subscription offers.
///
/// A builder for the *subscriptions.basePlans.offers.batchGet* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchGetSubscriptionOffersRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchGetSubscriptionOffersRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_batch_get(req, "packageName", "productId", "basePlanId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchGetSubscriptionOffersRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchGetSubscriptionOffersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.batchGet",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers:batchGet";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchGetSubscriptionOffersRequest,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) for which the subscriptions should be created or updated. Must be equal to the package_name field on all the requests.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this request spans multiple subscriptions, set this field to "-". Must be set.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) for which the offers should be read. May be specified as '-' to read offers from multiple base plans.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferBatchGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates a batch of subscription offers. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// A builder for the *subscriptions.basePlans.offers.batchUpdate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdateSubscriptionOffersRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdateSubscriptionOffersRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_batch_update(req, "packageName", "productId", "basePlanId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdateSubscriptionOffersRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchUpdateSubscriptionOffersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.batchUpdate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers:batchUpdate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdateSubscriptionOffersRequest,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the updated subscription offers. Must be equal to the package_name field on all the updated SubscriptionOffer resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this request spans multiple subscriptions, set this field to "-". Must be set.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple base plans.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferBatchUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates a batch of subscription offer states. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// A builder for the *subscriptions.basePlans.offers.batchUpdateStates* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdateSubscriptionOfferStatesRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdateSubscriptionOfferStatesRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_batch_update_states(req, "packageName", "productId", "basePlanId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdateSubscriptionOfferStatesRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder
for MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C>
{
}
impl<'a, C> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchUpdateSubscriptionOfferStatesResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.batchUpdateStates",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers:batchUpdateStates";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdateSubscriptionOfferStatesRequest,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the updated subscription offers. Must be equal to the package_name field on all the updated SubscriptionOffer resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this request spans multiple subscriptions, set this field to "-". Must be set.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) for which the offers should be updated. May be specified as '-' to update offers from multiple base plans.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(
mut self,
) -> MonetizationSubscriptionBasePlanOfferBatchUpdateStateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates a new subscription offer. Only auto-renewing base plans can have subscription offers. The offer state will be DRAFT until it is activated.
///
/// A builder for the *subscriptions.basePlans.offers.create* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::SubscriptionOffer;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = SubscriptionOffer::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_create(req, "packageName", "productId", "basePlanId")
/// .regions_version_version("dolores")
/// .offer_id("consetetur")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: SubscriptionOffer,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_regions_version_version: Option<String>,
_offer_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.create",
http_method: hyper::Method::POST,
});
for &field in [
"alt",
"packageName",
"productId",
"basePlanId",
"regionsVersion.version",
"offerId",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
if let Some(value) = self._regions_version_version.as_ref() {
params.push("regionsVersion.version", value);
}
if let Some(value) = self._offer_id.as_ref() {
params.push("offerId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: SubscriptionOffer,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) for which the offer should be created. Must be equal to the package_name field on the Subscription resource.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) for which the offer should be created. Must be equal to the product_id field on the SubscriptionOffer resource.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) for which the offer should be created. Must be equal to the base_plan_id field on the SubscriptionOffer resource.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// Required. A string representing the version of available regions being used for the specified resource. Regional prices and latest supported version for the resource have to be specified according to the information published in [this article](https://support.google.com/googleplay/android-developer/answer/10532353). Each time the supported locations substantially change, the version will be incremented. Using this field will ensure that creating and updating the resource with an older region's version and set of regional prices and currencies will succeed even though a new version is available.
///
/// Sets the *regions version.version* query property to the given value.
pub fn regions_version_version(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._regions_version_version = Some(new_value.to_string());
self
}
/// Required. The ID to use for the offer. For the requirements on this format, see the documentation of the offer_id field on the SubscriptionOffer resource.
///
/// Sets the *offer id* query property to the given value.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._offer_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deactivates a subscription offer. Once deactivated, existing subscribers will maintain their subscription, but the offer will become unavailable to new subscribers.
///
/// A builder for the *subscriptions.basePlans.offers.deactivate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::DeactivateSubscriptionOfferRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = DeactivateSubscriptionOfferRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_deactivate(req, "packageName", "productId", "basePlanId", "offerId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: DeactivateSubscriptionOfferRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_offer_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.deactivate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId", "offerId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.push("offerId", self._offer_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers/{offerId}:deactivate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: DeactivateSubscriptionOfferRequest,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the offer to deactivate.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) of the offer to deactivate.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) of the offer to deactivate.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// Required. The unique offer ID of the offer to deactivate.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferDeactivateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes a subscription offer. Can only be done for draft offers. This action is irreversible.
///
/// A builder for the *subscriptions.basePlans.offers.delete* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_delete("packageName", "productId", "basePlanId", "offerId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_offer_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "productId", "basePlanId", "offerId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.push("offerId", self._offer_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers/{offerId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) of the offer to delete.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) of the offer to delete.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) of the offer to delete.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// Required. The unique offer ID of the offer to delete.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads a single offer
///
/// A builder for the *subscriptions.basePlans.offers.get* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_get("packageName", "productId", "basePlanId", "offerId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_offer_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "productId", "basePlanId", "offerId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.push("offerId", self._offer_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers/{offerId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) of the offer to get.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) of the offer to get.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) of the offer to get.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// Required. The unique offer ID of the offer to get.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all offers under a given subscription.
///
/// A builder for the *subscriptions.basePlans.offers.list* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_list("packageName", "productId", "basePlanId")
/// .page_token("takimata")
/// .page_size(-99)
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferListCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, ListSubscriptionOffersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.list",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"packageName",
"productId",
"basePlanId",
"pageToken",
"pageSize",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) for which the subscriptions should be read.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) for which the offers should be read. May be specified as '-' to read all offers under an app.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The parent base plan (ID) for which the offers should be read. May be specified as '-' to read all offers under a subscription or an app. Must be specified as '-' if product_id is specified as '-'.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// A page token, received from a previous `ListSubscriptionsOffers` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSubscriptionOffers` must match the call that provided the page token.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
/// The maximum number of subscriptions to return. The service may return fewer than this value. If unspecified, at most 50 subscriptions will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
///
/// Sets the *page size* query property to the given value.
pub fn page_size(
mut self,
new_value: i32,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
self._page_size = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates an existing subscription offer.
///
/// A builder for the *subscriptions.basePlans.offers.patch* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::SubscriptionOffer;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = SubscriptionOffer::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_offers_patch(req, "packageName", "productId", "basePlanId", "offerId")
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .regions_version_version("ipsum")
/// .latency_tolerance("accusam")
/// .allow_missing(false)
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanOfferPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: SubscriptionOffer,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_offer_id: String,
_update_mask: Option<common::FieldMask>,
_regions_version_version: Option<String>,
_latency_tolerance: Option<String>,
_allow_missing: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionOffer)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.offers.patch",
http_method: hyper::Method::PATCH,
});
for &field in [
"alt",
"packageName",
"productId",
"basePlanId",
"offerId",
"updateMask",
"regionsVersion.version",
"latencyTolerance",
"allowMissing",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(11 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.push("offerId", self._offer_id);
if let Some(value) = self._update_mask.as_ref() {
params.push("updateMask", value.to_string());
}
if let Some(value) = self._regions_version_version.as_ref() {
params.push("regionsVersion.version", value);
}
if let Some(value) = self._latency_tolerance.as_ref() {
params.push("latencyTolerance", value);
}
if let Some(value) = self._allow_missing.as_ref() {
params.push("allowMissing", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}/offers/{offerId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
("{offerId}", "offerId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["offerId", "basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: SubscriptionOffer,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._request = new_value;
self
}
/// Required. Immutable. The package name of the app the parent subscription belongs to.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. Immutable. The ID of the parent subscription this offer belongs to.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. Immutable. The ID of the base plan to which this offer is an extension.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// Required. Immutable. Unique ID of this subscription offer. Must be unique within the base plan.
///
/// Sets the *offer id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn offer_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._offer_id = new_value.to_string();
self
}
/// Required. The list of fields to be updated.
///
/// Sets the *update mask* query property to the given value.
pub fn update_mask(
mut self,
new_value: common::FieldMask,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._update_mask = Some(new_value);
self
}
/// Required. A string representing the version of available regions being used for the specified resource. Regional prices and latest supported version for the resource have to be specified according to the information published in [this article](https://support.google.com/googleplay/android-developer/answer/10532353). Each time the supported locations substantially change, the version will be incremented. Using this field will ensure that creating and updating the resource with an older region's version and set of regional prices and currencies will succeed even though a new version is available.
///
/// Sets the *regions version.version* query property to the given value.
pub fn regions_version_version(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._regions_version_version = Some(new_value.to_string());
self
}
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
///
/// Sets the *latency tolerance* query property to the given value.
pub fn latency_tolerance(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._latency_tolerance = Some(new_value.to_string());
self
}
/// Optional. If set to true, and the subscription offer with the given package_name, product_id, base_plan_id and offer_id doesn't exist, an offer will be created. If a new offer is created, update_mask is ignored.
///
/// Sets the *allow missing* query property to the given value.
pub fn allow_missing(
mut self,
new_value: bool,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._allow_missing = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanOfferPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Activates a base plan. Once activated, base plans will be available to new subscribers.
///
/// A builder for the *subscriptions.basePlans.activate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ActivateBasePlanRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ActivateBasePlanRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_activate(req, "packageName", "productId", "basePlanId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanActivateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ActivateBasePlanRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanActivateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanActivateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.activate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}:activate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ActivateBasePlanRequest,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the base plan to activate.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) of the base plan to activate.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The unique base plan ID of the base plan to activate.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionBasePlanActivateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanActivateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanActivateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Batch variant of the MigrateBasePlanPrices endpoint. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// A builder for the *subscriptions.basePlans.batchMigratePrices* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchMigrateBasePlanPricesRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchMigrateBasePlanPricesRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_batch_migrate_prices(req, "packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchMigrateBasePlanPricesRequest,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchMigrateBasePlanPricesResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.batchMigratePrices",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans:batchMigratePrices";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchMigrateBasePlanPricesRequest,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) for which the subscriptions should be created or updated. Must be equal to the package_name field on all the Subscription resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent subscription, if all updated offers belong to the same subscription. If this batch update spans multiple subscriptions, set this field to "-". Must be set.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanBatchMigratePriceCall<'a, C> {
self._scopes.clear();
self
}
}
/// Activates or deactivates base plans across one or multiple subscriptions. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// A builder for the *subscriptions.basePlans.batchUpdateStates* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdateBasePlanStatesRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdateBasePlanStatesRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_batch_update_states(req, "packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdateBasePlanStatesRequest,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchUpdateBasePlanStatesResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.batchUpdateStates",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans:batchUpdateStates";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdateBasePlanStatesRequest,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the updated base plans.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The product ID of the parent subscription, if all updated base plans belong to the same subscription. If this batch update spans multiple subscriptions, set this field to "-". Must be set.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanBatchUpdateStateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deactivates a base plan. Once deactivated, the base plan will become unavailable to new subscribers, but existing subscribers will maintain their subscription
///
/// A builder for the *subscriptions.basePlans.deactivate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::DeactivateBasePlanRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = DeactivateBasePlanRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_deactivate(req, "packageName", "productId", "basePlanId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanDeactivateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: DeactivateBasePlanRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanDeactivateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.deactivate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}:deactivate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: DeactivateBasePlanRequest,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the base plan to deactivate.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) of the base plan to deactivate.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The unique base plan ID of the base plan to deactivate.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanDeactivateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes a base plan. Can only be done for draft base plans. This action is irreversible.
///
/// A builder for the *subscriptions.basePlans.delete* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_delete("packageName", "productId", "basePlanId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanDeleteCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "productId", "basePlanId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) of the base plan to delete.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The parent subscription (ID) of the base plan to delete.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The unique offer ID of the base plan to delete.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Migrates subscribers from one or more legacy price cohorts to the current price. Requests result in Google Play notifying affected subscribers. Only up to 250 simultaneous legacy price cohorts are supported.
///
/// A builder for the *subscriptions.basePlans.migratePrices* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::MigrateBasePlanPricesRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = MigrateBasePlanPricesRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_base_plans_migrate_prices(req, "packageName", "productId", "basePlanId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBasePlanMigratePriceCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: MigrateBasePlanPricesRequest,
_package_name: String,
_product_id: String,
_base_plan_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, MigrateBasePlanPricesResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.basePlans.migratePrices",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId", "basePlanId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("basePlanId", self._base_plan_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}/basePlans/{basePlanId}:migratePrices";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{basePlanId}", "basePlanId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["basePlanId", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: MigrateBasePlanPricesRequest,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {
self._request = new_value;
self
}
/// Required. Package name of the parent app. Must be equal to the package_name field on the Subscription resource.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The ID of the subscription to update. Must be equal to the product_id field on the Subscription resource.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The unique base plan ID of the base plan to update prices on.
///
/// Sets the *base plan id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn base_plan_id(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {
self._base_plan_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(
mut self,
scope: St,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBasePlanMigratePriceCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deprecated: subscription archiving is not supported.
///
/// A builder for the *subscriptions.archive* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ArchiveSubscriptionRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ArchiveSubscriptionRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_archive(req, "packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionArchiveCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ArchiveSubscriptionRequest,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionArchiveCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionArchiveCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.archive",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}:archive";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ArchiveSubscriptionRequest,
) -> MonetizationSubscriptionArchiveCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) of the app of the subscription to delete.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationSubscriptionArchiveCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The unique product ID of the subscription to delete.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> MonetizationSubscriptionArchiveCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionArchiveCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionArchiveCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionArchiveCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionArchiveCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionArchiveCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads one or more subscriptions.
///
/// A builder for the *subscriptions.batchGet* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_batch_get("packageName")
/// .add_product_ids("ipsum")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBatchGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_ids: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBatchGetCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBatchGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchGetSubscriptionsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.batchGet",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "productIds"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
if !self._product_ids.is_empty() {
for f in self._product_ids.iter() {
params.push("productIds", f);
}
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions:batchGet";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) for which the subscriptions should be retrieved. Must be equal to the package_name field on all the requests.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationSubscriptionBatchGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. A list of up to 100 subscription product IDs to retrieve. All the IDs must be different.
///
/// Append the given value to the *product ids* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
pub fn add_product_ids(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBatchGetCall<'a, C> {
self._product_ids.push(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBatchGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionBatchGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionBatchGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionBatchGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBatchGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates a batch of subscriptions. Set the latencyTolerance field on nested requests to PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT to achieve maximum update throughput.
///
/// A builder for the *subscriptions.batchUpdate* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::BatchUpdateSubscriptionsRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = BatchUpdateSubscriptionsRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_batch_update(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionBatchUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: BatchUpdateSubscriptionsRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionBatchUpdateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionBatchUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, BatchUpdateSubscriptionsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.batchUpdate",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions:batchUpdate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: BatchUpdateSubscriptionsRequest,
) -> MonetizationSubscriptionBatchUpdateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) for which the subscriptions should be updated. Must be equal to the package_name field on all the Subscription resources.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> MonetizationSubscriptionBatchUpdateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionBatchUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionBatchUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionBatchUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionBatchUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionBatchUpdateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates a new subscription. Newly added base plans will remain in draft state until activated.
///
/// A builder for the *subscriptions.create* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Subscription;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Subscription::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_create(req, "packageName")
/// .regions_version_version("ea")
/// .product_id("At")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Subscription,
_package_name: String,
_regions_version_version: Option<String>,
_product_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionCreateCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.create",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "regionsVersion.version", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._regions_version_version.as_ref() {
params.push("regionsVersion.version", value);
}
if let Some(value) = self._product_id.as_ref() {
params.push("productId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Subscription) -> MonetizationSubscriptionCreateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The parent app (package name) for which the subscription should be created. Must be equal to the package_name field on the Subscription resource.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationSubscriptionCreateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. A string representing the version of available regions being used for the specified resource. Regional prices and latest supported version for the resource have to be specified according to the information published in [this article](https://support.google.com/googleplay/android-developer/answer/10532353). Each time the supported locations substantially change, the version will be incremented. Using this field will ensure that creating and updating the resource with an older region's version and set of regional prices and currencies will succeed even though a new version is available.
///
/// Sets the *regions version.version* query property to the given value.
pub fn regions_version_version(
mut self,
new_value: &str,
) -> MonetizationSubscriptionCreateCall<'a, C> {
self._regions_version_version = Some(new_value.to_string());
self
}
/// Required. The ID to use for the subscription. For the requirements on this format, see the documentation of the product_id field on the Subscription resource.
///
/// Sets the *product id* query property to the given value.
pub fn product_id(mut self, new_value: &str) -> MonetizationSubscriptionCreateCall<'a, C> {
self._product_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deletes a subscription. A subscription can only be deleted if it has never had a base plan published.
///
/// A builder for the *subscriptions.delete* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_delete("packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionDeleteCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) of the app of the subscription to delete.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationSubscriptionDeleteCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The unique product ID of the subscription to delete.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> MonetizationSubscriptionDeleteCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Reads a single subscription.
///
/// A builder for the *subscriptions.get* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_get("packageName", "productId")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionGetCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) of the subscription to get.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationSubscriptionGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The unique product ID of the subscription to get.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> MonetizationSubscriptionGetCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all subscriptions under a given app.
///
/// A builder for the *subscriptions.list* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_list("packageName")
/// .show_archived(false)
/// .page_token("erat")
/// .page_size(-19)
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_show_archived: Option<bool>,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionListCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ListSubscriptionsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.list",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"packageName",
"showArchived",
"pageToken",
"pageSize",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._show_archived.as_ref() {
params.push("showArchived", value.to_string());
}
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The parent app (package name) for which the subscriptions should be read.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationSubscriptionListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Deprecated: subscription archiving is not supported.
///
/// Sets the *show archived* query property to the given value.
pub fn show_archived(mut self, new_value: bool) -> MonetizationSubscriptionListCall<'a, C> {
self._show_archived = Some(new_value);
self
}
/// A page token, received from a previous `ListSubscriptions` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSubscriptions` must match the call that provided the page token.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(mut self, new_value: &str) -> MonetizationSubscriptionListCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
/// The maximum number of subscriptions to return. The service may return fewer than this value. If unspecified, at most 50 subscriptions will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
///
/// Sets the *page size* query property to the given value.
pub fn page_size(mut self, new_value: i32) -> MonetizationSubscriptionListCall<'a, C> {
self._page_size = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates an existing subscription.
///
/// A builder for the *subscriptions.patch* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Subscription;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Subscription::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().subscriptions_patch(req, "packageName", "productId")
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .regions_version_version("eos")
/// .latency_tolerance("duo")
/// .allow_missing(false)
/// .doit().await;
/// # }
/// ```
pub struct MonetizationSubscriptionPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Subscription,
_package_name: String,
_product_id: String,
_update_mask: Option<common::FieldMask>,
_regions_version_version: Option<String>,
_latency_tolerance: Option<String>,
_allow_missing: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationSubscriptionPatchCall<'a, C> {}
impl<'a, C> MonetizationSubscriptionPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.subscriptions.patch",
http_method: hyper::Method::PATCH,
});
for &field in [
"alt",
"packageName",
"productId",
"updateMask",
"regionsVersion.version",
"latencyTolerance",
"allowMissing",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(9 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
if let Some(value) = self._update_mask.as_ref() {
params.push("updateMask", value.to_string());
}
if let Some(value) = self._regions_version_version.as_ref() {
params.push("regionsVersion.version", value);
}
if let Some(value) = self._latency_tolerance.as_ref() {
params.push("latencyTolerance", value);
}
if let Some(value) = self._allow_missing.as_ref() {
params.push("allowMissing", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/subscriptions/{productId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Subscription) -> MonetizationSubscriptionPatchCall<'a, C> {
self._request = new_value;
self
}
/// Immutable. Package name of the parent app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationSubscriptionPatchCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Immutable. Unique product ID of the product. Unique within the parent app. Product IDs must be composed of lower-case letters (a-z), numbers (0-9), underscores (_) and dots (.). It must start with a lower-case letter or number, and be between 1 and 40 (inclusive) characters in length.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> MonetizationSubscriptionPatchCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// Required. The list of fields to be updated.
///
/// Sets the *update mask* query property to the given value.
pub fn update_mask(
mut self,
new_value: common::FieldMask,
) -> MonetizationSubscriptionPatchCall<'a, C> {
self._update_mask = Some(new_value);
self
}
/// Required. A string representing the version of available regions being used for the specified resource. Regional prices and latest supported version for the resource have to be specified according to the information published in [this article](https://support.google.com/googleplay/android-developer/answer/10532353). Each time the supported locations substantially change, the version will be incremented. Using this field will ensure that creating and updating the resource with an older region's version and set of regional prices and currencies will succeed even though a new version is available.
///
/// Sets the *regions version.version* query property to the given value.
pub fn regions_version_version(
mut self,
new_value: &str,
) -> MonetizationSubscriptionPatchCall<'a, C> {
self._regions_version_version = Some(new_value.to_string());
self
}
/// Optional. The latency tolerance for the propagation of this product update. Defaults to latency-sensitive.
///
/// Sets the *latency tolerance* query property to the given value.
pub fn latency_tolerance(
mut self,
new_value: &str,
) -> MonetizationSubscriptionPatchCall<'a, C> {
self._latency_tolerance = Some(new_value.to_string());
self
}
/// Optional. If set to true, and the subscription with the given package_name and product_id doesn't exist, the subscription will be created. If a new subscription is created, update_mask is ignored.
///
/// Sets the *allow missing* query property to the given value.
pub fn allow_missing(mut self, new_value: bool) -> MonetizationSubscriptionPatchCall<'a, C> {
self._allow_missing = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationSubscriptionPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationSubscriptionPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationSubscriptionPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationSubscriptionPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationSubscriptionPatchCall<'a, C> {
self._scopes.clear();
self
}
}
/// Calculates the region prices, using today's exchange rate and country-specific pricing patterns, based on the price in the request for a set of regions.
///
/// A builder for the *convertRegionPrices* method supported by a *monetization* resource.
/// It is not used directly, but through a [`MonetizationMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ConvertRegionPricesRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ConvertRegionPricesRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.monetization().convert_region_prices(req, "packageName")
/// .doit().await;
/// # }
/// ```
pub struct MonetizationConvertRegionPriceCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ConvertRegionPricesRequest,
_package_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MonetizationConvertRegionPriceCall<'a, C> {}
impl<'a, C> MonetizationConvertRegionPriceCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ConvertRegionPricesResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.monetization.convertRegionPrices",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/pricing:convertRegionPrices";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ConvertRegionPricesRequest,
) -> MonetizationConvertRegionPriceCall<'a, C> {
self._request = new_value;
self
}
/// Required. The app package name.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> MonetizationConvertRegionPriceCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> MonetizationConvertRegionPriceCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MonetizationConvertRegionPriceCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> MonetizationConvertRegionPriceCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MonetizationConvertRegionPriceCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MonetizationConvertRegionPriceCall<'a, C> {
self._scopes.clear();
self
}
}
/// Get order details for a list of orders.
///
/// A builder for the *batchget* method supported by a *order* resource.
/// It is not used directly, but through a [`OrderMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.orders().batchget("packageName")
/// .add_order_ids("clita")
/// .doit().await;
/// # }
/// ```
pub struct OrderBatchgetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_order_ids: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for OrderBatchgetCall<'a, C> {}
impl<'a, C> OrderBatchgetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, BatchGetOrdersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.orders.batchget",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "orderIds"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
if !self._order_ids.is_empty() {
for f in self._order_ids.iter() {
params.push("orderIds", f);
}
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/orders:batchGet";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> OrderBatchgetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The list of order IDs to retrieve order details for. There must be between 1 and 1000 (inclusive) order IDs per request. If any order ID is not found or does not match the provided package, the entire request will fail with an error. The order IDs must be distinct.
///
/// Append the given value to the *order ids* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
pub fn add_order_ids(mut self, new_value: &str) -> OrderBatchgetCall<'a, C> {
self._order_ids.push(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderBatchgetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> OrderBatchgetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> OrderBatchgetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderBatchgetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> OrderBatchgetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Get order details for a single order.
///
/// A builder for the *get* method supported by a *order* resource.
/// It is not used directly, but through a [`OrderMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.orders().get("packageName", "orderId")
/// .doit().await;
/// # }
/// ```
pub struct OrderGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_order_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for OrderGetCall<'a, C> {}
impl<'a, C> OrderGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Order)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.orders.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("orderId", self._order_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/orders/{orderId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{orderId}", "orderId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["orderId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> OrderGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The order ID provided to the user when the subscription or in-app order was purchased.
///
/// Sets the *order id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn order_id(mut self, new_value: &str) -> OrderGetCall<'a, C> {
self._order_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> OrderGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> OrderGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> OrderGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Refunds a user's subscription or in-app purchase order. Orders older than 3 years cannot be refunded.
///
/// A builder for the *refund* method supported by a *order* resource.
/// It is not used directly, but through a [`OrderMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.orders().refund("packageName", "orderId")
/// .revoke(true)
/// .doit().await;
/// # }
/// ```
pub struct OrderRefundCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_order_id: String,
_revoke: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for OrderRefundCall<'a, C> {}
impl<'a, C> OrderRefundCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.orders.refund",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "orderId", "revoke"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("orderId", self._order_id);
if let Some(value) = self._revoke.as_ref() {
params.push("revoke", value.to_string());
}
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/orders/{orderId}:refund";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{orderId}", "orderId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["orderId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> OrderRefundCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The order ID provided to the user when the subscription or in-app order was purchased.
///
/// Sets the *order id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn order_id(mut self, new_value: &str) -> OrderRefundCall<'a, C> {
self._order_id = new_value.to_string();
self
}
/// 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).
///
/// Sets the *revoke* query property to the given value.
pub fn revoke(mut self, new_value: bool) -> OrderRefundCall<'a, C> {
self._revoke = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderRefundCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> OrderRefundCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> OrderRefundCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderRefundCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> OrderRefundCall<'a, C> {
self._scopes.clear();
self
}
}
/// Acknowledges a purchase of an inapp item.
///
/// A builder for the *products.acknowledge* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ProductPurchasesAcknowledgeRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ProductPurchasesAcknowledgeRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().products_acknowledge(req, "packageName", "productId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseProductAcknowledgeCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ProductPurchasesAcknowledgeRequest,
_package_name: String,
_product_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseProductAcknowledgeCall<'a, C> {}
impl<'a, C> PurchaseProductAcknowledgeCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.products.acknowledge",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "productId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:acknowledge";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: ProductPurchasesAcknowledgeRequest,
) -> PurchaseProductAcknowledgeCall<'a, C> {
self._request = new_value;
self
}
/// The package name of the application the inapp product was sold in (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseProductAcknowledgeCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The inapp product SKU (for example, 'com.some.thing.inapp1').
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> PurchaseProductAcknowledgeCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The token provided to the user's device when the inapp product was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseProductAcknowledgeCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseProductAcknowledgeCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseProductAcknowledgeCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseProductAcknowledgeCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseProductAcknowledgeCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseProductAcknowledgeCall<'a, C> {
self._scopes.clear();
self
}
}
/// Consumes a purchase for an inapp item.
///
/// A builder for the *products.consume* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().products_consume("packageName", "productId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseProductConsumeCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseProductConsumeCall<'a, C> {}
impl<'a, C> PurchaseProductConsumeCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.products.consume",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "productId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:consume";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application the inapp product was sold in (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseProductConsumeCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The inapp product SKU (for example, 'com.some.thing.inapp1').
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> PurchaseProductConsumeCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The token provided to the user's device when the inapp product was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseProductConsumeCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseProductConsumeCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseProductConsumeCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseProductConsumeCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseProductConsumeCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseProductConsumeCall<'a, C> {
self._scopes.clear();
self
}
}
/// Checks the purchase and consumption status of an inapp item.
///
/// A builder for the *products.get* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().products_get("packageName", "productId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseProductGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_product_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseProductGetCall<'a, C> {}
impl<'a, C> PurchaseProductGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ProductPurchase)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.products.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "productId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("productId", self._product_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{productId}", "productId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "productId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application the inapp product was sold in (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The inapp product SKU (for example, 'com.some.thing.inapp1').
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C> {
self._product_id = new_value.to_string();
self
}
/// The token provided to the user's device when the inapp product was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseProductGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseProductGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseProductGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseProductGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseProductGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Checks the purchase and consumption status of an inapp item.
///
/// A builder for the *productsv2.getproductpurchasev2* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().productsv2_getproductpurchasev2("packageName", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseProductsv2Getproductpurchasev2Call<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseProductsv2Getproductpurchasev2Call<'a, C> {}
impl<'a, C> PurchaseProductsv2Getproductpurchasev2Call<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ProductPurchaseV2)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.productsv2.getproductpurchasev2",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("token", self._token);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/purchases/productsv2/tokens/{token}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{token}", "token")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application the inapp product was sold in (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(
mut self,
new_value: &str,
) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The token provided to the user's device when the inapp product was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(
mut self,
name: T,
value: T,
) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseProductsv2Getproductpurchasev2Call<'a, C> {
self._scopes.clear();
self
}
}
/// Acknowledges a subscription purchase.
///
/// A builder for the *subscriptions.acknowledge* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::SubscriptionPurchasesAcknowledgeRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = SubscriptionPurchasesAcknowledgeRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptions_acknowledge(req, "packageName", "subscriptionId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionAcknowledgeCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: SubscriptionPurchasesAcknowledgeRequest,
_package_name: String,
_subscription_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionAcknowledgeCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionAcknowledgeCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptions.acknowledge",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "subscriptionId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("subscriptionId", self._subscription_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{subscriptionId}", "subscriptionId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "subscriptionId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: SubscriptionPurchasesAcknowledgeRequest,
) -> PurchaseSubscriptionAcknowledgeCall<'a, C> {
self._request = new_value;
self
}
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionAcknowledgeCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Note: Since May 21, 2025, subscription_id is not required, and not recommended for subscription with add-ons. The purchased subscription ID (for example, 'monthly001').
///
/// Sets the *subscription id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn subscription_id(
mut self,
new_value: &str,
) -> PurchaseSubscriptionAcknowledgeCall<'a, C> {
self._subscription_id = new_value.to_string();
self
}
/// The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionAcknowledgeCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionAcknowledgeCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionAcknowledgeCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionAcknowledgeCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionAcknowledgeCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionAcknowledgeCall<'a, C> {
self._scopes.clear();
self
}
}
/// Cancels a user's subscription purchase. The subscription remains valid until its expiration time. Newer version is available at purchases.subscriptionsv2.cancel for better client library support.
///
/// A builder for the *subscriptions.cancel* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptions_cancel("packageName", "subscriptionId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionCancelCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_subscription_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionCancelCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionCancelCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptions.cancel",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "subscriptionId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("subscriptionId", self._subscription_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:cancel";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{subscriptionId}", "subscriptionId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "subscriptionId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Note: Since May 21, 2025, subscription_id is not required, and not recommended for subscription with add-ons. The purchased subscription ID (for example, 'monthly001').
///
/// Sets the *subscription id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C> {
self._subscription_id = new_value.to_string();
self
}
/// The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionCancelCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionCancelCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionCancelCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionCancelCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionCancelCall<'a, C> {
self._scopes.clear();
self
}
}
/// Defers a user's subscription purchase until a specified future expiration time.
///
/// A builder for the *subscriptions.defer* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::SubscriptionPurchasesDeferRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = SubscriptionPurchasesDeferRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptions_defer(req, "packageName", "subscriptionId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionDeferCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: SubscriptionPurchasesDeferRequest,
_package_name: String,
_subscription_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionDeferCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionDeferCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, SubscriptionPurchasesDeferResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptions.defer",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "subscriptionId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("subscriptionId", self._subscription_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:defer";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{subscriptionId}", "subscriptionId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "subscriptionId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: SubscriptionPurchasesDeferRequest,
) -> PurchaseSubscriptionDeferCall<'a, C> {
self._request = new_value;
self
}
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The purchased subscription ID (for example, 'monthly001').
///
/// Sets the *subscription id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C> {
self._subscription_id = new_value.to_string();
self
}
/// The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionDeferCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionDeferCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionDeferCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionDeferCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionDeferCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deprecated: Use purchases.subscriptionsv2.get instead. Checks whether a user's subscription purchase is valid and returns its expiry time.
///
/// A builder for the *subscriptions.get* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptions_get("packageName", "subscriptionId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_subscription_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionGetCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionPurchase)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptions.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "subscriptionId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("subscriptionId", self._subscription_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{subscriptionId}", "subscriptionId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "subscriptionId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The purchased subscription ID (for example, 'monthly001').
///
/// Sets the *subscription id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C> {
self._subscription_id = new_value.to_string();
self
}
/// The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deprecated: Use orders.refund instead. Refunds a user's subscription purchase, but the subscription remains valid until its expiration time and it will continue to recur.
///
/// A builder for the *subscriptions.refund* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptions_refund("packageName", "subscriptionId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionRefundCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_subscription_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionRefundCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionRefundCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptions.refund",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "subscriptionId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("subscriptionId", self._subscription_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:refund";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{subscriptionId}", "subscriptionId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "subscriptionId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// "The purchased subscription ID (for example, 'monthly001').
///
/// Sets the *subscription id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C> {
self._subscription_id = new_value.to_string();
self
}
/// The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionRefundCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionRefundCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionRefundCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionRefundCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionRefundCall<'a, C> {
self._scopes.clear();
self
}
}
/// Deprecated: Use purchases.subscriptionsv2.revoke instead. Refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.
///
/// A builder for the *subscriptions.revoke* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptions_revoke("packageName", "subscriptionId", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionRevokeCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_subscription_id: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionRevokeCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionRevokeCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptions.revoke",
http_method: hyper::Method::POST,
});
for &field in ["packageName", "subscriptionId", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("subscriptionId", self._subscription_id);
params.push("token", self._token);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:revoke";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{subscriptionId}", "subscriptionId"),
("{token}", "token"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "subscriptionId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The purchased subscription ID (for example, 'monthly001').
///
/// Sets the *subscription id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C> {
self._subscription_id = new_value.to_string();
self
}
/// The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionRevokeCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionRevokeCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionRevokeCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionRevokeCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionRevokeCall<'a, C> {
self._scopes.clear();
self
}
}
/// Cancel a subscription purchase for the user.
///
/// A builder for the *subscriptionsv2.cancel* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::CancelSubscriptionPurchaseRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = CancelSubscriptionPurchaseRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptionsv2_cancel(req, "packageName", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionsv2CancelCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: CancelSubscriptionPurchaseRequest,
_package_name: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionsv2CancelCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionsv2CancelCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, CancelSubscriptionPurchaseResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptionsv2.cancel",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("token", self._token);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}:cancel";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{token}", "token")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: CancelSubscriptionPurchaseRequest,
) -> PurchaseSubscriptionsv2CancelCall<'a, C> {
self._request = new_value;
self
}
/// Required. The package of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionsv2CancelCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionsv2CancelCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionsv2CancelCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionsv2CancelCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionsv2CancelCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionsv2CancelCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionsv2CancelCall<'a, C> {
self._scopes.clear();
self
}
}
/// Get metadata about a subscription
///
/// A builder for the *subscriptionsv2.get* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptionsv2_get("packageName", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionsv2GetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionsv2GetCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionsv2GetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionPurchaseV2)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptionsv2.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("token", self._token);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{token}", "token")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionsv2GetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionsv2GetCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionsv2GetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionsv2GetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionsv2GetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionsv2GetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionsv2GetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Revoke a subscription purchase for the user.
///
/// A builder for the *subscriptionsv2.revoke* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::RevokeSubscriptionPurchaseRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = RevokeSubscriptionPurchaseRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().subscriptionsv2_revoke(req, "packageName", "token")
/// .doit().await;
/// # }
/// ```
pub struct PurchaseSubscriptionsv2RevokeCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: RevokeSubscriptionPurchaseRequest,
_package_name: String,
_token: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseSubscriptionsv2RevokeCall<'a, C> {}
impl<'a, C> PurchaseSubscriptionsv2RevokeCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, RevokeSubscriptionPurchaseResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.subscriptionsv2.revoke",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("token", self._token);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}:revoke";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{token}", "token")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["token", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(
mut self,
new_value: RevokeSubscriptionPurchaseRequest,
) -> PurchaseSubscriptionsv2RevokeCall<'a, C> {
self._request = new_value;
self
}
/// Required. The package of the application for which this subscription was purchased (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionsv2RevokeCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Required. The token provided to the user's device when the subscription was purchased.
///
/// Sets the *token* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionsv2RevokeCall<'a, C> {
self._token = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseSubscriptionsv2RevokeCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionsv2RevokeCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseSubscriptionsv2RevokeCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseSubscriptionsv2RevokeCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseSubscriptionsv2RevokeCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists the purchases that were canceled, refunded or charged-back.
///
/// A builder for the *voidedpurchases.list* method supported by a *purchase* resource.
/// It is not used directly, but through a [`PurchaseMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.purchases().voidedpurchases_list("packageName")
/// .type_(-60)
/// .token("ipsum")
/// .start_time(-5)
/// .start_index(77)
/// .max_results(7)
/// .include_quantity_based_partial_refund(false)
/// .end_time(-4)
/// .doit().await;
/// # }
/// ```
pub struct PurchaseVoidedpurchaseListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_type_: Option<i32>,
_token: Option<String>,
_start_time: Option<i64>,
_start_index: Option<u32>,
_max_results: Option<u32>,
_include_quantity_based_partial_refund: Option<bool>,
_end_time: Option<i64>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PurchaseVoidedpurchaseListCall<'a, C> {}
impl<'a, C> PurchaseVoidedpurchaseListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, VoidedPurchasesListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.purchases.voidedpurchases.list",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"packageName",
"type",
"token",
"startTime",
"startIndex",
"maxResults",
"includeQuantityBasedPartialRefund",
"endTime",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(10 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._type_.as_ref() {
params.push("type", value.to_string());
}
if let Some(value) = self._token.as_ref() {
params.push("token", value);
}
if let Some(value) = self._start_time.as_ref() {
params.push("startTime", value.to_string());
}
if let Some(value) = self._start_index.as_ref() {
params.push("startIndex", value.to_string());
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", value.to_string());
}
if let Some(value) = self._include_quantity_based_partial_refund.as_ref() {
params.push("includeQuantityBasedPartialRefund", value.to_string());
}
if let Some(value) = self._end_time.as_ref() {
params.push("endTime", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/purchases/voidedpurchases";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The package name of the application for which voided purchases need to be returned (for example, 'com.some.thing').
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The type of voided purchases that you want to see in the response. Possible values are: 0. Only voided in-app product purchases will be returned in the response. This is the default value. 1. Both voided in-app purchases and voided subscription purchases will be returned in the response. Note: Before requesting to receive voided subscription purchases, you must switch to use orderId in the response which uniquely identifies one-time purchases and subscriptions. Otherwise, you will receive multiple subscription orders with the same PurchaseToken, because subscription renewal orders share the same PurchaseToken.
///
/// Sets the *type* query property to the given value.
pub fn type_(mut self, new_value: i32) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._type_ = Some(new_value);
self
}
/// Defines the token of the page to return, usually taken from TokenPagination. This can only be used if token paging is enabled.
///
/// Sets the *token* query property to the given value.
pub fn token(mut self, new_value: &str) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._token = Some(new_value.to_string());
self
}
/// 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.
///
/// Sets the *start time* query property to the given value.
pub fn start_time(mut self, new_value: i64) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._start_time = Some(new_value);
self
}
/// Defines the index of the first element to return. This can only be used if indexed paging is enabled.
///
/// Sets the *start index* query property to the given value.
pub fn start_index(mut self, new_value: u32) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._start_index = Some(new_value);
self
}
/// Defines how many results the list operation should return. The default number depends on the resource collection.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._max_results = Some(new_value);
self
}
/// Optional. Whether to include voided purchases of quantity-based partial refunds, which are applicable only to multi-quantity purchases. If true, additional voided purchases may be returned with voidedQuantity that indicates the refund quantity of a quantity-based partial refund. The default value is false.
///
/// Sets the *include quantity based partial refund* query property to the given value.
pub fn include_quantity_based_partial_refund(
mut self,
new_value: bool,
) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._include_quantity_based_partial_refund = Some(new_value);
self
}
/// 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.
///
/// Sets the *end time* query property to the given value.
pub fn end_time(mut self, new_value: i64) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._end_time = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PurchaseVoidedpurchaseListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> PurchaseVoidedpurchaseListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PurchaseVoidedpurchaseListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PurchaseVoidedpurchaseListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Gets a single review.
///
/// A builder for the *get* method supported by a *review* resource.
/// It is not used directly, but through a [`ReviewMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.reviews().get("packageName", "reviewId")
/// .translation_language("dolor")
/// .doit().await;
/// # }
/// ```
pub struct ReviewGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_review_id: String,
_translation_language: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ReviewGetCall<'a, C> {}
impl<'a, C> ReviewGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Review)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.reviews.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "reviewId", "translationLanguage"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("reviewId", self._review_id);
if let Some(value) = self._translation_language.as_ref() {
params.push("translationLanguage", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/reviews/{reviewId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{reviewId}", "reviewId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["reviewId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ReviewGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for a review.
///
/// Sets the *review id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn review_id(mut self, new_value: &str) -> ReviewGetCall<'a, C> {
self._review_id = new_value.to_string();
self
}
/// Language localization code.
///
/// Sets the *translation language* query property to the given value.
pub fn translation_language(mut self, new_value: &str) -> ReviewGetCall<'a, C> {
self._translation_language = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReviewGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ReviewGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ReviewGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ReviewGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ReviewGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all reviews.
///
/// A builder for the *list* method supported by a *review* resource.
/// It is not used directly, but through a [`ReviewMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.reviews().list("packageName")
/// .translation_language("et")
/// .token("sit")
/// .start_index(50)
/// .max_results(60)
/// .doit().await;
/// # }
/// ```
pub struct ReviewListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_translation_language: Option<String>,
_token: Option<String>,
_start_index: Option<u32>,
_max_results: Option<u32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ReviewListCall<'a, C> {}
impl<'a, C> ReviewListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ReviewsListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.reviews.list",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"packageName",
"translationLanguage",
"token",
"startIndex",
"maxResults",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("packageName", self._package_name);
if let Some(value) = self._translation_language.as_ref() {
params.push("translationLanguage", value);
}
if let Some(value) = self._token.as_ref() {
params.push("token", value);
}
if let Some(value) = self._start_index.as_ref() {
params.push("startIndex", value.to_string());
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url =
self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/reviews";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ReviewListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Language localization code.
///
/// Sets the *translation language* query property to the given value.
pub fn translation_language(mut self, new_value: &str) -> ReviewListCall<'a, C> {
self._translation_language = Some(new_value.to_string());
self
}
/// Pagination token. If empty, list starts at the first review.
///
/// Sets the *token* query property to the given value.
pub fn token(mut self, new_value: &str) -> ReviewListCall<'a, C> {
self._token = Some(new_value.to_string());
self
}
/// The index of the first element to return.
///
/// Sets the *start index* query property to the given value.
pub fn start_index(mut self, new_value: u32) -> ReviewListCall<'a, C> {
self._start_index = Some(new_value);
self
}
/// How many results the list operation should return.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> ReviewListCall<'a, C> {
self._max_results = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReviewListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ReviewListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ReviewListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ReviewListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ReviewListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Replies to a single review, or updates an existing reply.
///
/// A builder for the *reply* method supported by a *review* resource.
/// It is not used directly, but through a [`ReviewMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::ReviewsReplyRequest;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = ReviewsReplyRequest::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.reviews().reply(req, "packageName", "reviewId")
/// .doit().await;
/// # }
/// ```
pub struct ReviewReplyCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: ReviewsReplyRequest,
_package_name: String,
_review_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ReviewReplyCall<'a, C> {}
impl<'a, C> ReviewReplyCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ReviewsReplyResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.reviews.reply",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "reviewId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("reviewId", self._review_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/reviews/{reviewId}:reply";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in
[("{packageName}", "packageName"), ("{reviewId}", "reviewId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["reviewId", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: ReviewsReplyRequest) -> ReviewReplyCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> ReviewReplyCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// Unique identifier for a review.
///
/// Sets the *review id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn review_id(mut self, new_value: &str) -> ReviewReplyCall<'a, C> {
self._review_id = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReviewReplyCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ReviewReplyCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> ReviewReplyCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ReviewReplyCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ReviewReplyCall<'a, C> {
self._scopes.clear();
self
}
}
/// Creates an APK which is suitable for inclusion in a system image from an already uploaded Android App Bundle.
///
/// A builder for the *variants.create* method supported by a *systemapk* resource.
/// It is not used directly, but through a [`SystemapkMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::Variant;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Variant::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.systemapks().variants_create(req, "packageName", -15)
/// .doit().await;
/// # }
/// ```
pub struct SystemapkVariantCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: Variant,
_package_name: String,
_version_code: i64,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SystemapkVariantCreateCall<'a, C> {}
impl<'a, C> SystemapkVariantCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Variant)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.systemapks.variants.create",
http_method: hyper::Method::POST,
});
for &field in ["alt", "packageName", "versionCode"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("versionCode", self._version_code.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/systemApks/{versionCode}/variants";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{versionCode}", "versionCode"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["versionCode", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: Variant) -> SystemapkVariantCreateCall<'a, C> {
self._request = new_value;
self
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> SystemapkVariantCreateCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The version code of the App Bundle.
///
/// Sets the *version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn version_code(mut self, new_value: i64) -> SystemapkVariantCreateCall<'a, C> {
self._version_code = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> SystemapkVariantCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> SystemapkVariantCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> SystemapkVariantCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> SystemapkVariantCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> SystemapkVariantCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Downloads a previously created system APK which is suitable for inclusion in a system image.
///
/// This method supports **media download**. To enable it, adjust the builder like this:
/// `.param("alt", "media")`.
///
/// A builder for the *variants.download* method supported by a *systemapk* resource.
/// It is not used directly, but through a [`SystemapkMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.systemapks().variants_download("packageName", -77, 9)
/// .doit().await;
/// # }
/// ```
pub struct SystemapkVariantDownloadCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_version_code: i64,
_variant_id: u32,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SystemapkVariantDownloadCall<'a, C> {}
impl<'a, C> SystemapkVariantDownloadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.systemapks.variants.download",
http_method: hyper::Method::GET,
});
for &field in ["packageName", "versionCode", "variantId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("versionCode", self._version_code.to_string());
params.push("variantId", self._variant_id.to_string());
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/systemApks/{versionCode}/variants/{variantId}:download";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{versionCode}", "versionCode"),
("{variantId}", "variantId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["variantId", "versionCode", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> SystemapkVariantDownloadCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The version code of the App Bundle.
///
/// Sets the *version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn version_code(mut self, new_value: i64) -> SystemapkVariantDownloadCall<'a, C> {
self._version_code = new_value;
self
}
/// The ID of a previously created system APK variant.
///
/// Sets the *variant id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn variant_id(mut self, new_value: u32) -> SystemapkVariantDownloadCall<'a, C> {
self._variant_id = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> SystemapkVariantDownloadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> SystemapkVariantDownloadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> SystemapkVariantDownloadCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> SystemapkVariantDownloadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> SystemapkVariantDownloadCall<'a, C> {
self._scopes.clear();
self
}
}
/// Returns a previously created system APK variant.
///
/// A builder for the *variants.get* method supported by a *systemapk* resource.
/// It is not used directly, but through a [`SystemapkMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.systemapks().variants_get("packageName", -77, 11)
/// .doit().await;
/// # }
/// ```
pub struct SystemapkVariantGetCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_version_code: i64,
_variant_id: u32,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SystemapkVariantGetCall<'a, C> {}
impl<'a, C> SystemapkVariantGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Variant)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.systemapks.variants.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "versionCode", "variantId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("versionCode", self._version_code.to_string());
params.push("variantId", self._variant_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/applications/{packageName}/systemApks/{versionCode}/variants/{variantId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{versionCode}", "versionCode"),
("{variantId}", "variantId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["variantId", "versionCode", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> SystemapkVariantGetCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The version code of the App Bundle.
///
/// Sets the *version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn version_code(mut self, new_value: i64) -> SystemapkVariantGetCall<'a, C> {
self._version_code = new_value;
self
}
/// The ID of a previously created system APK variant.
///
/// Sets the *variant id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn variant_id(mut self, new_value: u32) -> SystemapkVariantGetCall<'a, C> {
self._variant_id = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> SystemapkVariantGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> SystemapkVariantGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> SystemapkVariantGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> SystemapkVariantGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> SystemapkVariantGetCall<'a, C> {
self._scopes.clear();
self
}
}
/// Returns the list of previously created system APK variants.
///
/// A builder for the *variants.list* method supported by a *systemapk* resource.
/// It is not used directly, but through a [`SystemapkMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.systemapks().variants_list("packageName", -20)
/// .doit().await;
/// # }
/// ```
pub struct SystemapkVariantListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_package_name: String,
_version_code: i64,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SystemapkVariantListCall<'a, C> {}
impl<'a, C> SystemapkVariantListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SystemApksListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.systemapks.variants.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "packageName", "versionCode"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("packageName", self._package_name);
params.push("versionCode", self._version_code.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "androidpublisher/v3/applications/{packageName}/systemApks/{versionCode}/variants";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{packageName}", "packageName"),
("{versionCode}", "versionCode"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["versionCode", "packageName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Package name of the app.
///
/// Sets the *package name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn package_name(mut self, new_value: &str) -> SystemapkVariantListCall<'a, C> {
self._package_name = new_value.to_string();
self
}
/// The version code of the App Bundle.
///
/// Sets the *version code* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn version_code(mut self, new_value: i64) -> SystemapkVariantListCall<'a, C> {
self._version_code = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> SystemapkVariantListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> SystemapkVariantListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> SystemapkVariantListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> SystemapkVariantListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> SystemapkVariantListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Grant access for a user to the given developer account.
///
/// A builder for the *create* method supported by a *user* resource.
/// It is not used directly, but through a [`UserMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::User;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = User::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.users().create(req, "parent")
/// .doit().await;
/// # }
/// ```
pub struct UserCreateCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: User,
_parent: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for UserCreateCall<'a, C> {}
impl<'a, C> UserCreateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, User)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.users.create",
http_method: hyper::Method::POST,
});
for &field in ["alt", "parent"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("parent", self._parent);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+parent}/users";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["parent"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: User) -> UserCreateCall<'a, C> {
self._request = new_value;
self
}
/// Required. The developer account to add the user to. Format: developers/{developer}
///
/// Sets the *parent* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn parent(mut self, new_value: &str) -> UserCreateCall<'a, C> {
self._parent = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserCreateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> UserCreateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> UserCreateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserCreateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> UserCreateCall<'a, C> {
self._scopes.clear();
self
}
}
/// Removes all access for the user to the given developer account.
///
/// A builder for the *delete* method supported by a *user* resource.
/// It is not used directly, but through a [`UserMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.users().delete("name")
/// .doit().await;
/// # }
/// ```
pub struct UserDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_name: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for UserDeleteCall<'a, C> {}
impl<'a, C> UserDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.users.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["name"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(2 + self._additional_params.len());
params.push("name", self._name);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+name}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+name}", "name")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["name"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The name of the user to delete. Format: developers/{developer}/users/{email}
///
/// Sets the *name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn name(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
self._name = new_value.to_string();
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> UserDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> UserDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> UserDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
/// Lists all users with access to a developer account.
///
/// A builder for the *list* method supported by a *user* resource.
/// It is not used directly, but through a [`UserMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.users().list("parent")
/// .page_token("accusam")
/// .page_size(-24)
/// .doit().await;
/// # }
/// ```
pub struct UserListCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_parent: String,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for UserListCall<'a, C> {}
impl<'a, C> UserListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ListUsersResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.users.list",
http_method: hyper::Method::GET,
});
for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("parent", self._parent);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+parent}/users";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["parent"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The developer account to fetch users from. Format: developers/{developer}
///
/// Sets the *parent* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn parent(mut self, new_value: &str) -> UserListCall<'a, C> {
self._parent = new_value.to_string();
self
}
/// A token received from a previous call to this method, in order to retrieve further results.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(mut self, new_value: &str) -> UserListCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
/// The maximum number of results to return. This must be set to -1 to disable pagination.
///
/// Sets the *page size* query property to the given value.
pub fn page_size(mut self, new_value: i32) -> UserListCall<'a, C> {
self._page_size = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> UserListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> UserListCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> UserListCall<'a, C> {
self._scopes.clear();
self
}
}
/// Updates access for the user to the developer account.
///
/// A builder for the *patch* method supported by a *user* resource.
/// It is not used directly, but through a [`UserMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_androidpublisher3 as androidpublisher3;
/// use androidpublisher3::api::User;
/// # async fn dox() {
/// # use androidpublisher3::{AndroidPublisher, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = AndroidPublisher::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = User::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.users().patch(req, "name")
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .doit().await;
/// # }
/// ```
pub struct UserPatchCall<'a, C>
where
C: 'a,
{
hub: &'a AndroidPublisher<C>,
_request: User,
_name: String,
_update_mask: Option<common::FieldMask>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for UserPatchCall<'a, C> {}
impl<'a, C> UserPatchCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, User)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "androidpublisher.users.patch",
http_method: hyper::Method::PATCH,
});
for &field in ["alt", "name", "updateMask"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("name", self._name);
if let Some(value) = self._update_mask.as_ref() {
params.push("updateMask", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "androidpublisher/v3/{+name}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::Full.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{+name}", "name")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["name"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader = {
let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PATCH)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn request(mut self, new_value: User) -> UserPatchCall<'a, C> {
self._request = new_value;
self
}
/// Required. Resource name for this user, following the pattern "developers/{developer}/users/{email}".
///
/// Sets the *name* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn name(mut self, new_value: &str) -> UserPatchCall<'a, C> {
self._name = new_value.to_string();
self
}
/// Optional. The list of fields to be updated.
///
/// Sets the *update mask* query property to the given value.
pub fn update_mask(mut self, new_value: common::FieldMask) -> UserPatchCall<'a, C> {
self._update_mask = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known parameters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *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.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> UserPatchCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::Full`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<St>(mut self, scope: St) -> UserPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserPatchCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> UserPatchCall<'a, C> {
self._scopes.clear();
self
}
}