mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-05 02:55:32 +01:00
This also includes crate files to remember which crates we have published already. Related to #44
16033 lines
717 KiB
Rust
16033 lines
717 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
//! This documentation was generated from *Android Publisher* crate version *0.1.2+20150128*, where *20150128* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.2*.
|
|
//!
|
|
//! Everything else about the *Android Publisher* *v2* API can be found at the
|
|
//! [official documentation site](https://developers.google.com/android-publisher).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/androidpublisher2).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.AndroidPublisher.html) ...
|
|
//!
|
|
//! * edits
|
|
//! * [*apklistings delete*](struct.EditApklistingDeleteCall.html), [*apklistings deleteall*](struct.EditApklistingDeleteallCall.html), [*apklistings get*](struct.EditApklistingGetCall.html), [*apklistings list*](struct.EditApklistingListCall.html), [*apklistings patch*](struct.EditApklistingPatchCall.html), [*apklistings update*](struct.EditApklistingUpdateCall.html), [*apks addexternallyhosted*](struct.EditApkAddexternallyhostedCall.html), [*apks list*](struct.EditApkListCall.html), [*apks upload*](struct.EditApkUploadCall.html), [*commit*](struct.EditCommitCall.html), [*delete*](struct.EditDeleteCall.html), [*details get*](struct.EditDetailGetCall.html), [*details patch*](struct.EditDetailPatchCall.html), [*details update*](struct.EditDetailUpdateCall.html), [*expansionfiles get*](struct.EditExpansionfileGetCall.html), [*expansionfiles patch*](struct.EditExpansionfilePatchCall.html), [*expansionfiles update*](struct.EditExpansionfileUpdateCall.html), [*expansionfiles upload*](struct.EditExpansionfileUploadCall.html), [*get*](struct.EditGetCall.html), [*images delete*](struct.EditImageDeleteCall.html), [*images deleteall*](struct.EditImageDeleteallCall.html), [*images list*](struct.EditImageListCall.html), [*images upload*](struct.EditImageUploadCall.html), [*insert*](struct.EditInsertCall.html), [*listings delete*](struct.EditListingDeleteCall.html), [*listings deleteall*](struct.EditListingDeleteallCall.html), [*listings get*](struct.EditListingGetCall.html), [*listings list*](struct.EditListingListCall.html), [*listings patch*](struct.EditListingPatchCall.html), [*listings update*](struct.EditListingUpdateCall.html), [*testers get*](struct.EditTesterGetCall.html), [*testers patch*](struct.EditTesterPatchCall.html), [*testers update*](struct.EditTesterUpdateCall.html), [*tracks get*](struct.EditTrackGetCall.html), [*tracks list*](struct.EditTrackListCall.html), [*tracks patch*](struct.EditTrackPatchCall.html), [*tracks update*](struct.EditTrackUpdateCall.html) and [*validate*](struct.EditValidateCall.html)
|
|
//! * inappproducts
|
|
//! * [*batch*](struct.InappproductBatchCall.html), [*delete*](struct.InappproductDeleteCall.html), [*get*](struct.InappproductGetCall.html), [*insert*](struct.InappproductInsertCall.html), [*list*](struct.InappproductListCall.html), [*patch*](struct.InappproductPatchCall.html) and [*update*](struct.InappproductUpdateCall.html)
|
|
//! * purchases
|
|
//! * [*products get*](struct.PurchaseProductGetCall.html), [*subscriptions cancel*](struct.PurchaseSubscriptionCancelCall.html), [*subscriptions defer*](struct.PurchaseSubscriptionDeferCall.html), [*subscriptions get*](struct.PurchaseSubscriptionGetCall.html), [*subscriptions refund*](struct.PurchaseSubscriptionRefundCall.html) and [*subscriptions revoke*](struct.PurchaseSubscriptionRevokeCall.html)
|
|
//!
|
|
//!
|
|
//! Upload supported by ...
|
|
//!
|
|
//! * [*images upload edits*](struct.EditImageUploadCall.html)
|
|
//! * [*expansionfiles upload edits*](struct.EditExpansionfileUploadCall.html)
|
|
//! * [*apks upload edits*](struct.EditApkUploadCall.html)
|
|
//!
|
|
//!
|
|
//!
|
|
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html).
|
|
//!
|
|
//! # Structure of this Library
|
|
//!
|
|
//! The API is structured into the following primary items:
|
|
//!
|
|
//! * **[Hub](struct.AndroidPublisher.html)**
|
|
//! * a central object to maintain state and allow accessing all *Activities*
|
|
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
|
|
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
|
|
//! * **[Resources](trait.Resource.html)**
|
|
//! * primary types that you can apply *Activities* to
|
|
//! * a collection of properties and *Parts*
|
|
//! * **[Parts](trait.Part.html)**
|
|
//! * a collection of properties
|
|
//! * never directly used in *Activities*
|
|
//! * **[Activities](trait.CallBuilder.html)**
|
|
//! * operations to apply to *Resources*
|
|
//!
|
|
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
|
|
//!
|
|
//! Generally speaking, you can invoke *Activities* like this:
|
|
//!
|
|
//! ```Rust,ignore
|
|
//! let r = hub.resource().activity(...).doit()
|
|
//! ```
|
|
//!
|
|
//! Or specifically ...
|
|
//!
|
|
//! ```ignore
|
|
//! let r = hub.inappproducts().patch(...).doit()
|
|
//! let r = hub.inappproducts().insert(...).doit()
|
|
//! let r = hub.inappproducts().get(...).doit()
|
|
//! let r = hub.inappproducts().update(...).doit()
|
|
//! ```
|
|
//!
|
|
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
|
|
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
|
|
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
|
|
//! The `doit()` method performs the actual communication with the server and returns the respective result.
|
|
//!
|
|
//! # Usage
|
|
//!
|
|
//! ## Setting up your Project
|
|
//!
|
|
//! To use this library, you would put the following lines into your `Cargo.toml` file:
|
|
//!
|
|
//! ```toml
|
|
//! [dependencies]
|
|
//! google-androidpublisher2 = "*"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate "yup-oauth2" as oauth2;
|
|
//! extern crate "google-androidpublisher2" as androidpublisher2;
|
|
//! use androidpublisher2::InAppProduct;
|
|
//! use androidpublisher2::{Result, Error};
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use androidpublisher2::AndroidPublisher;
|
|
//!
|
|
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
//! // `client_secret`, among other things.
|
|
//! let secret: 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 auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
//! hyper::Client::new(),
|
|
//! <MemoryStorage as Default>::default(), None);
|
|
//! let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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")
|
|
//! .auto_convert_missing_prices(true)
|
|
//! .doit();
|
|
//!
|
|
//! match result {
|
|
//! Err(e) => match e {
|
|
//! Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
//! Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
//! Error::MissingToken => println!("OAuth2: Missing Token"),
|
|
//! Error::Cancelled => println!("Operation canceled by user"),
|
|
//! Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
//! Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
//! Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
//! Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
//! },
|
|
//! Ok(_) => println!("Success (value doesn't print)"),
|
|
//! }
|
|
//! # }
|
|
//! ```
|
|
//! ## Handling Errors
|
|
//!
|
|
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
|
//! the doit() methods, or handed as possibly intermediate results to either the
|
|
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../yup-oauth2/trait.AuthenticatorDelegate.html).
|
|
//!
|
|
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
|
//! makes the system potentially resilient to all kinds of errors.
|
|
//!
|
|
//! ## Uploads and Downloads
|
|
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
|
//! read by you to obtain the media.
|
|
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
|
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
|
//! this call: `.param("alt", "media")`.
|
|
//!
|
|
//! Methods supporting uploads can do so using up to 2 different protocols:
|
|
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
|
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
|
//!
|
|
//! ## Customization and Callbacks
|
|
//!
|
|
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
|
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
|
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
|
//! retry on failure.
|
|
//!
|
|
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
|
//!
|
|
//! ## Optional Parts in Server-Requests
|
|
//!
|
|
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
|
|
//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
|
//! are valid.
|
|
//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to
|
|
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
|
//!
|
|
//! ## Builder Arguments
|
|
//!
|
|
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
|
//! These will always take a single argument, for which the following statements are true.
|
|
//!
|
|
//! * [PODs][wiki-pod] are handed by copy
|
|
//! * strings are passed as `&str`
|
|
//! * [request values](trait.RequestValue.html) are borrowed
|
|
//!
|
|
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
|
//!
|
|
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
|
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
|
//! [google-go-api]: https://github.com/google/google-api-go-client
|
|
//!
|
|
//!
|
|
#![feature(core,io,thread_sleep)]
|
|
// Unused attributes happen thanks to defined, but unused structures
|
|
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
|
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
|
// unused imports in fully featured APIs. Same with unused_mut ... .
|
|
#![allow(unused_imports, unused_mut, dead_code)]
|
|
// Required for serde annotations
|
|
#![feature(custom_derive, custom_attribute, plugin)]
|
|
#![plugin(serde_macros)]
|
|
|
|
#[macro_use]
|
|
extern crate hyper;
|
|
extern crate serde;
|
|
extern crate "yup-oauth2" as oauth2;
|
|
extern crate mime;
|
|
extern crate url;
|
|
|
|
mod cmn;
|
|
|
|
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::borrow::BorrowMut;
|
|
use std::default::Default;
|
|
use std::collections::BTreeMap;
|
|
use std::marker::PhantomData;
|
|
use serde::json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::thread::sleep;
|
|
|
|
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError};
|
|
|
|
|
|
// ##############
|
|
// 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, Hash)]
|
|
pub enum Scope {
|
|
/// View and manage your Google Play Android Developer account
|
|
Full,
|
|
}
|
|
|
|
impl Str for Scope {
|
|
fn as_slice(&self) -> &str {
|
|
match *self {
|
|
Scope::Full => "https://www.googleapis.com/auth/androidpublisher",
|
|
}
|
|
}
|
|
}
|
|
|
|
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 "yup-oauth2" as oauth2;
|
|
/// extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::InAppProduct;
|
|
/// use androidpublisher2::{Result, Error};
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
/// // `client_secret`, among other things.
|
|
/// let secret: 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 auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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")
|
|
/// .auto_convert_missing_prices(true)
|
|
/// .doit();
|
|
///
|
|
/// match result {
|
|
/// Err(e) => match e {
|
|
/// Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
/// Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
/// Error::MissingToken => println!("OAuth2: Missing Token"),
|
|
/// Error::Cancelled => println!("Operation canceled by user"),
|
|
/// Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
/// Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
/// Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
/// Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
/// },
|
|
/// Ok(_) => println!("Success (value doesn't print)"),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
pub struct AndroidPublisher<C, NC, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
|
|
_m: PhantomData<NC>
|
|
}
|
|
|
|
impl<'a, C, NC, A> Hub for AndroidPublisher<C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AndroidPublisher<C, NC, A>
|
|
where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> AndroidPublisher<C, NC, A> {
|
|
AndroidPublisher {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/0.1.2".to_string(),
|
|
_m: PhantomData
|
|
}
|
|
}
|
|
|
|
pub fn edits(&'a self) -> EditMethods<'a, C, NC, A> {
|
|
EditMethods { hub: &self }
|
|
}
|
|
pub fn inappproducts(&'a self) -> InappproductMethods<'a, C, NC, A> {
|
|
InappproductMethods { hub: &self }
|
|
}
|
|
pub fn purchases(&'a self) -> PurchaseMethods<'a, C, NC, A> {
|
|
PurchaseMethods { hub: &self }
|
|
}
|
|
|
|
/// Set the user-agent header field to use in all requests to the server.
|
|
/// It defaults to `google-api-rust-client/0.1.2`.
|
|
///
|
|
/// Returns the previously set user-agent.
|
|
pub fn user_agent(&mut self, agent_name: String) -> String {
|
|
let prev = self._user_agent.clone();
|
|
self._user_agent = agent_name;
|
|
prev
|
|
}
|
|
}
|
|
|
|
|
|
// ############
|
|
// SCHEMAS ###
|
|
// ##########
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InappproductsUpdateResponse {
|
|
/// no description provided
|
|
pub inappproduct: InAppProduct,
|
|
}
|
|
|
|
impl Part for InappproductsUpdateResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [patch inappproducts](struct.InappproductPatchCall.html) (request|response)
|
|
/// * [insert inappproducts](struct.InappproductInsertCall.html) (request|response)
|
|
/// * [get inappproducts](struct.InappproductGetCall.html) (response)
|
|
/// * [update inappproducts](struct.InappproductUpdateCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct InAppProduct {
|
|
/// The stock-keeping-unit (SKU) of the product, unique within an app.
|
|
pub sku: Option<String>,
|
|
/// no description provided
|
|
pub status: Option<String>,
|
|
/// The period of the subscription (if any), i.e. period at which payments must happen. Defined as ISO 8601 duration, i.e. "P1M" for 1 month period.
|
|
#[serde(alias="subscriptionPeriod")]
|
|
pub subscription_period: Option<String>,
|
|
/// Definition of a season for a seasonal subscription. Can be defined only for yearly subscriptions.
|
|
pub season: Option<Season>,
|
|
/// The package name of the parent app.
|
|
#[serde(alias="packageName")]
|
|
pub package_name: Option<String>,
|
|
/// List of localized title and description data.
|
|
pub listings: Option<HashMap<String, InAppProductListing>>,
|
|
/// Trial period, specified in ISO 8601 format. Acceptable values are anything between "P7D" (seven days) and "P999D" (999 days). Seasonal subscriptions cannot have a trial period.
|
|
#[serde(alias="trialPeriod")]
|
|
pub trial_period: Option<String>,
|
|
/// Purchase type enum value. Unmodifiable after creation.
|
|
#[serde(alias="purchaseType")]
|
|
pub purchase_type: Option<String>,
|
|
/// The default language of the localized data, as defined by BCP 47. e.g. "en-US", "en-GB".
|
|
#[serde(alias="defaultLanguage")]
|
|
pub default_language: Option<String>,
|
|
/// Prices per buyer region. None of these prices should be zero. In-app products can never be free.
|
|
pub prices: Option<HashMap<String, Price>>,
|
|
/// Default price cannot be zero. In-app products can never be free. Default price is always in the developer's Checkout merchant currency.
|
|
#[serde(alias="defaultPrice")]
|
|
pub default_price: Option<Price>,
|
|
}
|
|
|
|
impl RequestValue for InAppProduct {}
|
|
impl Resource for InAppProduct {}
|
|
impl ResponseResult for InAppProduct {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditImageListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ImagesListResponse {
|
|
/// no description provided
|
|
pub images: Vec<Image>,
|
|
}
|
|
|
|
impl ResponseResult for ImagesListResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditExpansionfileUploadCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ExpansionFilesUploadResponse {
|
|
/// no description provided
|
|
#[serde(alias="expansionFile")]
|
|
pub expansion_file: ExpansionFile,
|
|
}
|
|
|
|
impl ResponseResult for ExpansionFilesUploadResponse {}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct SubscriptionDeferralInfo {
|
|
/// 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(alias="expectedExpiryTimeMillis")]
|
|
pub expected_expiry_time_millis: String,
|
|
/// The desired next expiry time for the subscription in milliseconds since Epoch. The given time must be after the current expiry time for the subscription.
|
|
#[serde(alias="desiredExpiryTimeMillis")]
|
|
pub desired_expiry_time_millis: String,
|
|
}
|
|
|
|
impl Part for SubscriptionDeferralInfo {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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 update edits](struct.EditListingUpdateCall.html) (request|response)
|
|
/// * [listings patch edits](struct.EditListingPatchCall.html) (request|response)
|
|
/// * [listings get edits](struct.EditListingGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Listing {
|
|
/// URL of a promotional YouTube video for the app.
|
|
pub video: Option<String>,
|
|
/// Short description of the app (previously known as promo text); this may be up to 80 characters in length.
|
|
#[serde(alias="shortDescription")]
|
|
pub short_description: Option<String>,
|
|
/// Full description of the app; this may be up to 4000 characters in length.
|
|
#[serde(alias="fullDescription")]
|
|
pub full_description: Option<String>,
|
|
/// Language localization code (for example, "de-AT" for Austrian German).
|
|
pub language: Option<String>,
|
|
/// App's localized title.
|
|
pub title: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for Listing {}
|
|
impl ResponseResult for Listing {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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 inappproducts](struct.InappproductBatchCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct InappproductsBatchRequest {
|
|
/// no description provided
|
|
pub entrys: Option<Vec<InappproductsBatchRequestEntry>>,
|
|
}
|
|
|
|
impl RequestValue for InappproductsBatchRequest {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct MonthDay {
|
|
/// Day of a month, value in [1, 31] range. Valid range depends on the specified month.
|
|
pub day: u32,
|
|
/// Month of a year. e.g. 1 = JAN, 2 = FEB etc.
|
|
pub month: u32,
|
|
}
|
|
|
|
impl Part for MonthDay {}
|
|
|
|
|
|
/// 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](struct.PurchaseProductGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ProductPurchase {
|
|
/// The consumption state of the inapp product. Possible values are:
|
|
/// - Yet to be consumed
|
|
/// - Consumed
|
|
#[serde(alias="consumptionState")]
|
|
pub consumption_state: i32,
|
|
/// A developer-specified string that contains supplemental information about an order.
|
|
#[serde(alias="developerPayload")]
|
|
pub developer_payload: String,
|
|
/// This kind represents an inappPurchase object in the androidpublisher service.
|
|
pub kind: String,
|
|
/// The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
|
|
#[serde(alias="purchaseTimeMillis")]
|
|
pub purchase_time_millis: String,
|
|
/// The purchase state of the order. Possible values are:
|
|
/// - Purchased
|
|
/// - Cancelled
|
|
#[serde(alias="purchaseState")]
|
|
pub purchase_state: i32,
|
|
}
|
|
|
|
impl ResponseResult for ProductPurchase {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [apklistings list edits](struct.EditApklistingListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ApkListingsListResponse {
|
|
/// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#apkListingsListResponse".
|
|
pub kind: String,
|
|
/// no description provided
|
|
pub listings: Vec<ApkListing>,
|
|
}
|
|
|
|
impl ResponseResult for ApkListingsListResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditImageDeleteallCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ImagesDeleteAllResponse {
|
|
/// no description provided
|
|
pub deleted: Vec<Image>,
|
|
}
|
|
|
|
impl ResponseResult for ImagesDeleteAllResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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 update edits](struct.EditTrackUpdateCall.html) (request|response)
|
|
/// * [tracks patch edits](struct.EditTrackPatchCall.html) (request|response)
|
|
/// * [tracks get edits](struct.EditTrackGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Track {
|
|
/// no description provided
|
|
pub track: Option<String>,
|
|
/// no description provided
|
|
#[serde(alias="userFraction")]
|
|
pub user_fraction: Option<f64>,
|
|
/// no description provided
|
|
#[serde(alias="versionCodes")]
|
|
pub version_codes: Option<Vec<i32>>,
|
|
}
|
|
|
|
impl RequestValue for Track {}
|
|
impl ResponseResult for Track {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Season {
|
|
/// Inclusive start date of the recurrence period.
|
|
pub start: MonthDay,
|
|
/// Inclusive end date of the recurrence period.
|
|
pub end: MonthDay,
|
|
}
|
|
|
|
impl Part for Season {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct InAppProductListing {
|
|
/// no description provided
|
|
pub description: String,
|
|
/// no description provided
|
|
pub title: String,
|
|
}
|
|
|
|
impl Part for InAppProductListing {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.PurchaseSubscriptionDeferCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct SubscriptionPurchasesDeferRequest {
|
|
/// The information about the new desired expiry time for the subscription.
|
|
#[serde(alias="deferralInfo")]
|
|
pub deferral_info: Option<SubscriptionDeferralInfo>,
|
|
}
|
|
|
|
impl RequestValue for SubscriptionPurchasesDeferRequest {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InappproductsInsertResponse {
|
|
/// no description provided
|
|
pub inappproduct: InAppProduct,
|
|
}
|
|
|
|
impl Part for InappproductsInsertResponse {}
|
|
|
|
|
|
/// Defines an APK available for this application that is hosted externally and not uploaded to Google Play. This function is only available to enterprises who are using Android for Work, and whos application is restricted to the enterprise private channel
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ExternallyHostedApk {
|
|
/// The icon image from the APK, as a base64 encoded byte array.
|
|
#[serde(alias="iconBase64")]
|
|
pub icon_base64: String,
|
|
/// A certificate (or array of certificates if a certificate-chain is used) used to signed this APK, represented as a base64 encoded byte array.
|
|
#[serde(alias="certificateBase64s")]
|
|
pub certificate_base64s: Vec<String>,
|
|
/// The URL at which the APK is hosted. This must be an https URL.
|
|
#[serde(alias="externallyHostedUrl")]
|
|
pub externally_hosted_url: String,
|
|
/// The maximum SDK supported by this APK (optional).
|
|
#[serde(alias="maximumSdk")]
|
|
pub maximum_sdk: i32,
|
|
/// The SHA256 checksum of this APK, represented as a base64 encoded byte array.
|
|
#[serde(alias="fileSha256Base64")]
|
|
pub file_sha256_base64: String,
|
|
/// The permissions requested by this APK.
|
|
#[serde(alias="usesPermissions")]
|
|
pub uses_permissions: Vec<ExternallyHostedApkUsesPermission>,
|
|
/// The SHA1 checksum of this APK, represented as a base64 encoded byte array.
|
|
#[serde(alias="fileSha1Base64")]
|
|
pub file_sha1_base64: String,
|
|
/// The features required by this APK (optional).
|
|
#[serde(alias="usesFeatures")]
|
|
pub uses_features: Vec<String>,
|
|
/// The native code environments supported by this APK (optional).
|
|
#[serde(alias="nativeCodes")]
|
|
pub native_codes: Vec<String>,
|
|
/// The file size in bytes of this APK.
|
|
#[serde(alias="fileSize")]
|
|
pub file_size: String,
|
|
/// The version name of this APK.
|
|
#[serde(alias="versionName")]
|
|
pub version_name: String,
|
|
/// The version code of this APK.
|
|
#[serde(alias="versionCode")]
|
|
pub version_code: i32,
|
|
/// The minimum SDK targeted by this APK.
|
|
#[serde(alias="minimumSdk")]
|
|
pub minimum_sdk: i32,
|
|
/// The application label.
|
|
#[serde(alias="applicationLabel")]
|
|
pub application_label: String,
|
|
/// The package name.
|
|
#[serde(alias="packageName")]
|
|
pub package_name: String,
|
|
}
|
|
|
|
impl Part for ExternallyHostedApk {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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 patch edits](struct.EditDetailPatchCall.html) (request|response)
|
|
/// * [details update edits](struct.EditDetailUpdateCall.html) (request|response)
|
|
/// * [details get edits](struct.EditDetailGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AppDetails {
|
|
/// The user-visible support email for this app.
|
|
#[serde(alias="contactEmail")]
|
|
pub contact_email: Option<String>,
|
|
/// The user-visible support telephone number for this app.
|
|
#[serde(alias="contactPhone")]
|
|
pub contact_phone: Option<String>,
|
|
/// The user-visible website for this app.
|
|
#[serde(alias="contactWebsite")]
|
|
pub contact_website: Option<String>,
|
|
/// Default language code, in BCP 47 format (eg "en-US").
|
|
#[serde(alias="defaultLanguage")]
|
|
pub default_language: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for AppDetails {}
|
|
impl ResponseResult for AppDetails {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InappproductsBatchResponseEntry {
|
|
/// no description provided
|
|
#[serde(alias="batchId")]
|
|
pub batch_id: u32,
|
|
/// no description provided
|
|
pub inappproductsinsertresponse: InappproductsInsertResponse,
|
|
/// no description provided
|
|
pub inappproductsupdateresponse: InappproductsUpdateResponse,
|
|
}
|
|
|
|
impl Part for InappproductsBatchResponseEntry {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct InappproductsInsertRequest {
|
|
/// no description provided
|
|
pub inappproduct: InAppProduct,
|
|
}
|
|
|
|
impl Part for InappproductsInsertRequest {}
|
|
|
|
|
|
/// A permission used by this APK.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ExternallyHostedApkUsesPermission {
|
|
/// Optionally, the maximum SDK version for which the permission is required.
|
|
#[serde(alias="maxSdkVersion")]
|
|
pub max_sdk_version: i32,
|
|
/// The name of the permission requested.
|
|
pub name: String,
|
|
}
|
|
|
|
impl Part for ExternallyHostedApkUsesPermission {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct InappproductsBatchRequestEntry {
|
|
/// no description provided
|
|
#[serde(alias="batchId")]
|
|
pub batch_id: u32,
|
|
/// no description provided
|
|
pub inappproductsinsertrequest: InappproductsInsertRequest,
|
|
/// no description provided
|
|
#[serde(alias="methodName")]
|
|
pub method_name: String,
|
|
/// no description provided
|
|
pub inappproductsupdaterequest: InappproductsUpdateRequest,
|
|
}
|
|
|
|
impl Part for InappproductsBatchRequestEntry {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditTrackListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct TracksListResponse {
|
|
/// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#tracksListResponse".
|
|
pub kind: String,
|
|
/// no description provided
|
|
pub tracks: Vec<Track>,
|
|
}
|
|
|
|
impl ResponseResult for TracksListResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.PurchaseSubscriptionDeferCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct SubscriptionPurchasesDeferResponse {
|
|
/// The new expiry time for the subscription in milliseconds since the Epoch.
|
|
#[serde(alias="newExpiryTimeMillis")]
|
|
pub new_expiry_time_millis: String,
|
|
}
|
|
|
|
impl ResponseResult for SubscriptionPurchasesDeferResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.InappproductListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InappproductsListResponse {
|
|
/// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#inappproductsListResponse".
|
|
pub kind: String,
|
|
/// no description provided
|
|
#[serde(alias="tokenPagination")]
|
|
pub token_pagination: TokenPagination,
|
|
/// no description provided
|
|
#[serde(alias="pageInfo")]
|
|
pub page_info: PageInfo,
|
|
/// no description provided
|
|
pub inappproduct: Vec<InAppProduct>,
|
|
}
|
|
|
|
impl ResponseResult for InappproductsListResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct TokenPagination {
|
|
/// no description provided
|
|
#[serde(alias="nextPageToken")]
|
|
pub next_page_token: String,
|
|
/// no description provided
|
|
#[serde(alias="previousPageToken")]
|
|
pub previous_page_token: String,
|
|
}
|
|
|
|
impl Part for TokenPagination {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [apklistings get edits](struct.EditApklistingGetCall.html) (response)
|
|
/// * [apklistings patch edits](struct.EditApklistingPatchCall.html) (request|response)
|
|
/// * [apklistings update edits](struct.EditApklistingUpdateCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ApkListing {
|
|
/// Describe what's new in your APK.
|
|
#[serde(alias="recentChanges")]
|
|
pub recent_changes: Option<String>,
|
|
/// The language code, in BCP 47 format (eg "en-US").
|
|
pub language: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for ApkListing {}
|
|
impl ResponseResult for ApkListing {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditTesterGetCall.html) (response)
|
|
/// * [testers patch edits](struct.EditTesterPatchCall.html) (request|response)
|
|
/// * [testers update edits](struct.EditTesterUpdateCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Testers {
|
|
/// no description provided
|
|
#[serde(alias="googleGroups")]
|
|
pub google_groups: Option<Vec<String>>,
|
|
/// no description provided
|
|
#[serde(alias="googlePlusCommunities")]
|
|
pub google_plus_communities: Option<Vec<String>>,
|
|
}
|
|
|
|
impl RequestValue for Testers {}
|
|
impl ResponseResult for Testers {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditExpansionfileGetCall.html) (response)
|
|
/// * [expansionfiles patch edits](struct.EditExpansionfilePatchCall.html) (request|response)
|
|
/// * [expansionfiles update edits](struct.EditExpansionfileUpdateCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ExpansionFile {
|
|
/// If set this APK's Expansion File references another APK's Expansion File. The file_size field will not be set.
|
|
#[serde(alias="referencesVersion")]
|
|
pub references_version: Option<i32>,
|
|
/// 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(alias="fileSize")]
|
|
pub file_size: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for ExpansionFile {}
|
|
impl ResponseResult for ExpansionFile {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditApkAddexternallyhostedCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ApksAddExternallyHostedResponse {
|
|
/// The definition of the externally-hosted APK and where it is located.
|
|
#[serde(alias="externallyHostedApk")]
|
|
pub externally_hosted_apk: ExternallyHostedApk,
|
|
}
|
|
|
|
impl ResponseResult for ApksAddExternallyHostedResponse {}
|
|
|
|
|
|
/// 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](struct.PurchaseSubscriptionGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct SubscriptionPurchase {
|
|
/// Whether the subscription will automatically be renewed when it reaches its current expiry time.
|
|
#[serde(alias="autoRenewing")]
|
|
pub auto_renewing: bool,
|
|
/// This kind represents a subscriptionPurchase object in the androidpublisher service.
|
|
pub kind: String,
|
|
/// Time at which the subscription will expire, in milliseconds since Epoch.
|
|
#[serde(alias="expiryTimeMillis")]
|
|
pub expiry_time_millis: String,
|
|
/// Time at which the subscription was granted, in milliseconds since Epoch.
|
|
#[serde(alias="startTimeMillis")]
|
|
pub start_time_millis: String,
|
|
}
|
|
|
|
impl ResponseResult for SubscriptionPurchase {}
|
|
|
|
|
|
/// Represents an edit of an app. An edit allows clients to make multiple changes before committing them in one operation.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [insert edits](struct.EditInsertCall.html) (request|response)
|
|
/// * [commit edits](struct.EditCommitCall.html) (response)
|
|
/// * [validate edits](struct.EditValidateCall.html) (response)
|
|
/// * [get edits](struct.EditGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AppEdit {
|
|
/// The time at which the edit will expire and will be no longer valid for use in any subsequent API calls (encoded as seconds since the Epoch).
|
|
#[serde(alias="expiryTimeSeconds")]
|
|
pub expiry_time_seconds: Option<String>,
|
|
/// The ID of the edit that can be used in subsequent API calls.
|
|
pub id: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for AppEdit {}
|
|
impl ResponseResult for AppEdit {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditApkListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ApksListResponse {
|
|
/// no description provided
|
|
pub apks: Vec<Apk>,
|
|
/// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#apksListResponse".
|
|
pub kind: String,
|
|
}
|
|
|
|
impl ResponseResult for ApksListResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct InappproductsUpdateRequest {
|
|
/// no description provided
|
|
pub inappproduct: InAppProduct,
|
|
}
|
|
|
|
impl Part for InappproductsUpdateRequest {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct PageInfo {
|
|
/// no description provided
|
|
#[serde(alias="resultPerPage")]
|
|
pub result_per_page: i32,
|
|
/// no description provided
|
|
#[serde(alias="startIndex")]
|
|
pub start_index: i32,
|
|
/// no description provided
|
|
#[serde(alias="totalResults")]
|
|
pub total_results: i32,
|
|
}
|
|
|
|
impl Part for PageInfo {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditImageUploadCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ImagesUploadResponse {
|
|
/// no description provided
|
|
pub image: Image,
|
|
}
|
|
|
|
impl ResponseResult for ImagesUploadResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditApkUploadCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Apk {
|
|
/// The version code of the APK, as specified in the APK's manifest file.
|
|
#[serde(alias="versionCode")]
|
|
pub version_code: i32,
|
|
/// Information about the binary payload of this APK.
|
|
pub binary: ApkBinary,
|
|
}
|
|
|
|
impl ResponseResult for Apk {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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 inappproducts](struct.InappproductBatchCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InappproductsBatchResponse {
|
|
/// no description provided
|
|
pub entrys: Vec<InappproductsBatchResponseEntry>,
|
|
/// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#inappproductsBatchResponse".
|
|
pub kind: String,
|
|
}
|
|
|
|
impl ResponseResult for InappproductsBatchResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Image {
|
|
/// A URL that will serve a preview of the image.
|
|
pub url: String,
|
|
/// A sha1 hash of the image that was uploaded.
|
|
pub sha1: String,
|
|
/// A unique id representing this image.
|
|
pub id: String,
|
|
}
|
|
|
|
impl Part for Image {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditApkAddexternallyhostedCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct ApksAddExternallyHostedRequest {
|
|
/// The definition of the externally-hosted APK and where it is located.
|
|
#[serde(alias="externallyHostedApk")]
|
|
pub externally_hosted_apk: Option<ExternallyHostedApk>,
|
|
}
|
|
|
|
impl RequestValue for ApksAddExternallyHostedRequest {}
|
|
|
|
|
|
/// Represents the binary payload of an APK.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, 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: String,
|
|
}
|
|
|
|
impl Part for ApkBinary {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Price {
|
|
/// 3 letter Currency code, as defined by ISO 4217.
|
|
pub currency: String,
|
|
/// The price in millionths of the currency base unit represented as a string.
|
|
#[serde(alias="priceMicros")]
|
|
pub price_micros: String,
|
|
}
|
|
|
|
impl Part for Price {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # 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](struct.EditListingListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ListingsListResponse {
|
|
/// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#listingsListResponse".
|
|
pub kind: String,
|
|
/// no description provided
|
|
pub listings: Vec<Listing>,
|
|
}
|
|
|
|
impl ResponseResult for ListingsListResponse {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// extern crate "google-androidpublisher2" as androidpublisher2;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = AndroidPublisher::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `products_get(...)`, `subscriptions_cancel(...)`, `subscriptions_defer(...)`, `subscriptions_get(...)`, `subscriptions_refund(...)` and `subscriptions_revoke(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.purchases();
|
|
/// # }
|
|
/// ```
|
|
pub struct PurchaseMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> MethodsBuilder for PurchaseMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> PurchaseMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// 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, NC, A> {
|
|
PurchaseSubscriptionRevokeCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_subscription_id: subscription_id.to_string(),
|
|
_token: token.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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, NC, A> {
|
|
PurchaseProductGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_product_id: product_id.to_string(),
|
|
_token: token.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// 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, NC, A> {
|
|
PurchaseSubscriptionGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_subscription_id: subscription_id.to_string(),
|
|
_token: token.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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.
|
|
///
|
|
/// # 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_cancel(&self, package_name: &str, subscription_id: &str, token: &str) -> PurchaseSubscriptionCancelCall<'a, C, NC, A> {
|
|
PurchaseSubscriptionCancelCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_subscription_id: subscription_id.to_string(),
|
|
_token: token.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// 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, NC, A> {
|
|
PurchaseSubscriptionRefundCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_subscription_id: subscription_id.to_string(),
|
|
_token: token.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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, NC, A> {
|
|
PurchaseSubscriptionDeferCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_subscription_id: subscription_id.to_string(),
|
|
_token: token.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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 "yup-oauth2" as oauth2;
|
|
/// extern crate "google-androidpublisher2" as androidpublisher2;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = AndroidPublisher::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `apklistings_delete(...)`, `apklistings_deleteall(...)`, `apklistings_get(...)`, `apklistings_list(...)`, `apklistings_patch(...)`, `apklistings_update(...)`, `apks_addexternallyhosted(...)`, `apks_list(...)`, `apks_upload(...)`, `commit(...)`, `delete(...)`, `details_get(...)`, `details_patch(...)`, `details_update(...)`, `expansionfiles_get(...)`, `expansionfiles_patch(...)`, `expansionfiles_update(...)`, `expansionfiles_upload(...)`, `get(...)`, `images_delete(...)`, `images_deleteall(...)`, `images_list(...)`, `images_upload(...)`, `insert(...)`, `listings_delete(...)`, `listings_deleteall(...)`, `listings_get(...)`, `listings_list(...)`, `listings_patch(...)`, `listings_update(...)`, `testers_get(...)`, `testers_patch(...)`, `testers_update(...)`, `tracks_get(...)`, `tracks_list(...)`, `tracks_patch(...)`, `tracks_update(...)` and `validate(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.edits();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> MethodsBuilder for EditMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Uploads a new image and adds it to the list of images for the specified language and image type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
/// * `imageType` - No description provided.
|
|
pub fn images_upload(&self, package_name: &str, edit_id: &str, language: &str, image_type: &str) -> EditImageUploadCall<'a, C, NC, A> {
|
|
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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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 Files. To add a new Expansion File use the Upload method.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
|
|
/// * `expansionFileType` - No description provided.
|
|
pub fn expansionfiles_update(&self, request: &ExpansionFile, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfileUpdateCall<'a, C, NC, A> {
|
|
EditExpansionfileUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Fetches app details for this edit. This includes the default language and developer support contact information.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn details_get(&self, package_name: &str, edit_id: &str) -> EditDetailGetCall<'a, C, NC, A> {
|
|
EditDetailGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes the APK-specific localized listing for a specified APK and language code.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn apklistings_delete(&self, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingDeleteCall<'a, C, NC, A> {
|
|
EditApklistingDeleteCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_apk_version_code: apk_version_code,
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes all localized listings from an edit.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn listings_deleteall(&self, package_name: &str, edit_id: &str) -> EditListingDeleteallCall<'a, C, NC, A> {
|
|
EditListingDeleteallCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// 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 enterprises using Google Play for work whose application is configured to restrict distribution to the enterprise domain.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn apks_addexternallyhosted(&self, request: &ApksAddExternallyHostedRequest, package_name: &str, edit_id: &str) -> EditApkAddexternallyhostedCall<'a, C, NC, A> {
|
|
EditApkAddexternallyhostedCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes all the APK-specific localized listings for a specified APK.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apklistings_deleteall(&self, package_name: &str, edit_id: &str, apk_version_code: i32) -> EditApklistingDeleteallCall<'a, C, NC, A> {
|
|
EditApklistingDeleteallCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_apk_version_code: apk_version_code,
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates app details for this edit.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn details_update(&self, request: &AppDetails, package_name: &str, edit_id: &str) -> EditDetailUpdateCall<'a, C, NC, A> {
|
|
EditDetailUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Fetches the track configuration for the specified track type. Includes the APK version codes that are in this track.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `track` - The track type to read or modify.
|
|
pub fn tracks_get(&self, package_name: &str, edit_id: &str, track: &str) -> EditTrackGetCall<'a, C, NC, A> {
|
|
EditTrackGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_track: track.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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 Files. To add a new Expansion File use the Upload method. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
|
|
/// * `expansionFileType` - No description provided.
|
|
pub fn expansionfiles_patch(&self, request: &ExpansionFile, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfilePatchCall<'a, C, NC, A> {
|
|
EditExpansionfilePatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists all images for the specified language and image type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
/// * `imageType` - No description provided.
|
|
pub fn images_list(&self, package_name: &str, edit_id: &str, language: &str, image_type: &str) -> EditImageListCall<'a, C, NC, A> {
|
|
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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates the track configuration for the specified track type. When halted, the rollout track cannot be updated without adding new APKs, and adding new APKs will cause it to resume.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `track` - The track type to read or modify.
|
|
pub fn tracks_update(&self, request: &Track, package_name: &str, edit_id: &str, track: &str) -> EditTrackUpdateCall<'a, C, NC, A> {
|
|
EditTrackUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_track: track.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates or updates a localized store listing. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn listings_patch(&self, request: &Listing, package_name: &str, edit_id: &str, language: &str) -> EditListingPatchCall<'a, C, NC, A> {
|
|
EditListingPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns information about the edit specified. Calls will fail if the edit is no long active (e.g. has been deleted, superseded or expired).
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn get(&self, package_name: &str, edit_id: &str) -> EditGetCall<'a, C, NC, A> {
|
|
EditGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes the image (specified by id) from the edit.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
/// * `imageType` - No description provided.
|
|
/// * `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, NC, A> {
|
|
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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn apks_upload(&self, package_name: &str, edit_id: &str) -> EditApkUploadCall<'a, C, NC, A> {
|
|
EditApkUploadCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates or creates the APK-specific localized listing for a specified APK and language code.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn apklistings_update(&self, request: &ApkListing, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingUpdateCall<'a, C, NC, A> {
|
|
EditApklistingUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_apk_version_code: apk_version_code,
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn apks_list(&self, package_name: &str, edit_id: &str) -> EditApkListCall<'a, C, NC, A> {
|
|
EditApkListCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates or creates the APK-specific localized listing for a specified APK and language code. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn apklistings_patch(&self, request: &ApkListing, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingPatchCall<'a, C, NC, A> {
|
|
EditApklistingPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_apk_version_code: apk_version_code,
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Fetches information about a localized store listing.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn listings_get(&self, package_name: &str, edit_id: &str, language: &str) -> EditListingGetCall<'a, C, NC, A> {
|
|
EditListingGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `track` - No description provided.
|
|
pub fn testers_get(&self, package_name: &str, edit_id: &str, track: &str) -> EditTesterGetCall<'a, C, NC, A> {
|
|
EditTesterGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_track: track.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes an edit for an app. Creating a new edit will automatically delete any of your previous edits so this method need only be called if you want to preemptively abandon an edit.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn delete(&self, package_name: &str, edit_id: &str) -> EditDeleteCall<'a, C, NC, A> {
|
|
EditDeleteCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Uploads and attaches a new Expansion File to the APK specified.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
|
|
/// * `expansionFileType` - No description provided.
|
|
pub fn expansionfiles_upload(&self, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfileUploadCall<'a, C, NC, A> {
|
|
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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates a new edit for an app, populated with the app's current state.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn insert(&self, request: &AppEdit, package_name: &str) -> EditInsertCall<'a, C, NC, A> {
|
|
EditInsertCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns all of the localized store listings attached to this edit.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn listings_list(&self, package_name: &str, edit_id: &str) -> EditListingListCall<'a, C, NC, A> {
|
|
EditListingListCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `track` - No description provided.
|
|
pub fn testers_patch(&self, request: &Testers, package_name: &str, edit_id: &str, track: &str) -> EditTesterPatchCall<'a, C, NC, A> {
|
|
EditTesterPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_track: track.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Commits/applies the changes made in this edit back to the app.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn commit(&self, package_name: &str, edit_id: &str) -> EditCommitCall<'a, C, NC, A> {
|
|
EditCommitCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists all the track configurations for this edit.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn tracks_list(&self, package_name: &str, edit_id: &str) -> EditTrackListCall<'a, C, NC, A> {
|
|
EditTrackListCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Checks that the edit can be successfully committed. The edit's changes are not applied to the live app.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn validate(&self, package_name: &str, edit_id: &str) -> EditValidateCall<'a, C, NC, A> {
|
|
EditValidateCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn listings_update(&self, request: &Listing, package_name: &str, edit_id: &str, language: &str) -> EditListingUpdateCall<'a, C, NC, A> {
|
|
EditListingUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Fetches the Expansion File configuration for the APK specified.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified.
|
|
/// * `expansionFileType` - No description provided.
|
|
pub fn expansionfiles_get(&self, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfileGetCall<'a, C, NC, A> {
|
|
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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes all images for the specified language and image type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
/// * `imageType` - No description provided.
|
|
pub fn images_deleteall(&self, package_name: &str, edit_id: &str, language: &str, image_type: &str) -> EditImageDeleteallCall<'a, C, NC, A> {
|
|
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(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates app details for this edit. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
pub fn details_patch(&self, request: &AppDetails, package_name: &str, edit_id: &str) -> EditDetailPatchCall<'a, C, NC, A> {
|
|
EditDetailPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates the track configuration for the specified track type. When halted, the rollout track cannot be updated without adding new APKs, and adding new APKs will cause it to resume. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `track` - The track type to read or modify.
|
|
pub fn tracks_patch(&self, request: &Track, package_name: &str, edit_id: &str, track: &str) -> EditTrackPatchCall<'a, C, NC, A> {
|
|
EditTrackPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_track: track.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes the specified localized store listing from an edit.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn listings_delete(&self, package_name: &str, edit_id: &str, language: &str) -> EditListingDeleteCall<'a, C, NC, A> {
|
|
EditListingDeleteCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Fetches the APK-specific localized listing for a specified APK and language code.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
|
|
/// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn apklistings_get(&self, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingGetCall<'a, C, NC, A> {
|
|
EditApklistingGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_apk_version_code: apk_version_code,
|
|
_language: language.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `track` - No description provided.
|
|
pub fn testers_update(&self, request: &Testers, package_name: &str, edit_id: &str, track: &str) -> EditTesterUpdateCall<'a, C, NC, A> {
|
|
EditTesterUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_track: track.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists all the APK-specific localized listings for a specified APK.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
/// * `editId` - Unique identifier for this edit.
|
|
/// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apklistings_list(&self, package_name: &str, edit_id: &str, apk_version_code: i32) -> EditApklistingListCall<'a, C, NC, A> {
|
|
EditApklistingListCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_edit_id: edit_id.to_string(),
|
|
_apk_version_code: apk_version_code,
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: 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 "yup-oauth2" as oauth2;
|
|
/// extern crate "google-androidpublisher2" as androidpublisher2;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = AndroidPublisher::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `batch(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.inappproducts();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> MethodsBuilder for InappproductMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductMethods<'a, C, NC, A> {
|
|
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
pub fn batch(&self, request: &InappproductsBatchRequest) -> InappproductBatchCall<'a, C, NC, A> {
|
|
InappproductBatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// List all the in-app products for an Android app, both subscriptions and managed in-app products..
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app with in-app products; for example, "com.spiffygame".
|
|
pub fn list(&self, package_name: &str) -> InappproductListCall<'a, C, NC, A> {
|
|
InappproductListCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_token: Default::default(),
|
|
_start_index: Default::default(),
|
|
_max_results: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates a new in-app product for an app.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app; for example, "com.spiffygame".
|
|
pub fn insert(&self, request: &InAppProduct, package_name: &str) -> InappproductInsertCall<'a, C, NC, A> {
|
|
InappproductInsertCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_auto_convert_missing_prices: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Delete an in-app product for an app.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
|
|
/// * `sku` - Unique identifier for the in-app product.
|
|
pub fn delete(&self, package_name: &str, sku: &str) -> InappproductDeleteCall<'a, C, NC, A> {
|
|
InappproductDeleteCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_sku: sku.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns information about the in-app product specified.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `packageName` - No description provided.
|
|
/// * `sku` - Unique identifier for the in-app product.
|
|
pub fn get(&self, package_name: &str, sku: &str) -> InappproductGetCall<'a, C, NC, A> {
|
|
InappproductGetCall {
|
|
hub: self.hub,
|
|
_package_name: package_name.to_string(),
|
|
_sku: sku.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates the details of an in-app product.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
|
|
/// * `sku` - Unique identifier for the in-app product.
|
|
pub fn update(&self, request: &InAppProduct, package_name: &str, sku: &str) -> InappproductUpdateCall<'a, C, NC, A> {
|
|
InappproductUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_sku: sku.to_string(),
|
|
_auto_convert_missing_prices: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates the details of an in-app product. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
|
|
/// * `sku` - Unique identifier for the in-app product.
|
|
pub fn patch(&self, request: &InAppProduct, package_name: &str, sku: &str) -> InappproductPatchCall<'a, C, NC, A> {
|
|
InappproductPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_package_name: package_name.to_string(),
|
|
_sku: sku.to_string(),
|
|
_auto_convert_missing_prices: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct PurchaseSubscriptionRevokeCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_subscription_id: String,
|
|
_token: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for PurchaseSubscriptionRevokeCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> PurchaseSubscriptionRevokeCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.purchases.subscriptions.revoke",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("subscriptionId", self._subscription_id.to_string()));
|
|
params.push(("token", self._token.to_string()));
|
|
for &field in ["packageName", "subscriptionId", "token"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:revoke".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "subscriptionId", "token"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
|
|
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The purchased subscription ID (for example, 'monthly001').
|
|
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C, NC, A> {
|
|
self._subscription_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The token provided to the user's device when the subscription was purchased.
|
|
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, C, NC, A> {
|
|
self._token = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> PurchaseSubscriptionRevokeCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionRevokeCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> PurchaseSubscriptionRevokeCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct PurchaseProductGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_product_id: String,
|
|
_token: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for PurchaseProductGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> PurchaseProductGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ProductPurchase)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.purchases.products.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("productId", self._product_id.to_string()));
|
|
params.push(("token", self._token.to_string()));
|
|
for &field in ["alt", "packageName", "productId", "token"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/purchases/products/{productId}/tokens/{token}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{productId}", "productId"), ("{token}", "token")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "productId", "token"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// The package name of the application the inapp product was sold in (for example, 'com.some.thing').
|
|
pub fn package_name(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The inapp product SKU (for example, 'com.some.thing.inapp1').
|
|
pub fn product_id(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C, NC, A> {
|
|
self._product_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The token provided to the user's device when the inapp product was purchased.
|
|
pub fn token(mut self, new_value: &str) -> PurchaseProductGetCall<'a, C, NC, A> {
|
|
self._token = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> PurchaseProductGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> PurchaseProductGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> PurchaseProductGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct PurchaseSubscriptionGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_subscription_id: String,
|
|
_token: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for PurchaseSubscriptionGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> PurchaseSubscriptionGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, SubscriptionPurchase)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.purchases.subscriptions.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("subscriptionId", self._subscription_id.to_string()));
|
|
params.push(("token", self._token.to_string()));
|
|
for &field in ["alt", "packageName", "subscriptionId", "token"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "subscriptionId", "token"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
|
|
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The purchased subscription ID (for example, 'monthly001').
|
|
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C, NC, A> {
|
|
self._subscription_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The token provided to the user's device when the subscription was purchased.
|
|
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, C, NC, A> {
|
|
self._token = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> PurchaseSubscriptionGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> PurchaseSubscriptionGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Cancels a user's subscription purchase. The subscription remains valid until its expiration time.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct PurchaseSubscriptionCancelCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_subscription_id: String,
|
|
_token: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for PurchaseSubscriptionCancelCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> PurchaseSubscriptionCancelCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.purchases.subscriptions.cancel",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("subscriptionId", self._subscription_id.to_string()));
|
|
params.push(("token", self._token.to_string()));
|
|
for &field in ["packageName", "subscriptionId", "token"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:cancel".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "subscriptionId", "token"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
|
|
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The purchased subscription ID (for example, 'monthly001').
|
|
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C, NC, A> {
|
|
self._subscription_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The token provided to the user's device when the subscription was purchased.
|
|
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, C, NC, A> {
|
|
self._token = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> PurchaseSubscriptionCancelCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionCancelCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> PurchaseSubscriptionCancelCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct PurchaseSubscriptionRefundCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_subscription_id: String,
|
|
_token: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for PurchaseSubscriptionRefundCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> PurchaseSubscriptionRefundCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.purchases.subscriptions.refund",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("subscriptionId", self._subscription_id.to_string()));
|
|
params.push(("token", self._token.to_string()));
|
|
for &field in ["packageName", "subscriptionId", "token"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:refund".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "subscriptionId", "token"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
|
|
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The purchased subscription ID (for example, 'monthly001').
|
|
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C, NC, A> {
|
|
self._subscription_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The token provided to the user's device when the subscription was purchased.
|
|
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, C, NC, A> {
|
|
self._token = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> PurchaseSubscriptionRefundCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionRefundCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> PurchaseSubscriptionRefundCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::SubscriptionPurchasesDeferRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct PurchaseSubscriptionDeferCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: SubscriptionPurchasesDeferRequest,
|
|
_package_name: String,
|
|
_subscription_id: String,
|
|
_token: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for PurchaseSubscriptionDeferCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> PurchaseSubscriptionDeferCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, SubscriptionPurchasesDeferResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.purchases.subscriptions.defer",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("subscriptionId", self._subscription_id.to_string()));
|
|
params.push(("token", self._token.to_string()));
|
|
for &field in ["alt", "packageName", "subscriptionId", "token"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:defer".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "subscriptionId", "token"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The package name of the application for which this subscription was purchased (for example, 'com.some.thing').
|
|
pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The purchased subscription ID (for example, 'monthly001').
|
|
pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C, NC, A> {
|
|
self._subscription_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The token provided to the user's device when the subscription was purchased.
|
|
pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, C, NC, A> {
|
|
self._token = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> PurchaseSubscriptionDeferCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> PurchaseSubscriptionDeferCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> PurchaseSubscriptionDeferCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Uploads a new image and adds it to the list of images for the specified language and image type.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use std::fs;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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().images_upload("packageName", "editId", "language", "imageType")
|
|
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
|
/// # }
|
|
/// ```
|
|
pub struct EditImageUploadCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_image_type: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditImageUploadCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditImageUploadCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, ImagesUploadResponse)>
|
|
where RS: ReadSeek {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.images.upload",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
params.push(("imageType", self._image_type.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = if protocol == "simple" {
|
|
"https://www.googleapis.com/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string()
|
|
} else if protocol == "resumable" {
|
|
"https://www.googleapis.com/resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string()
|
|
} else {
|
|
unreachable!()
|
|
};
|
|
params.push(("uploadType", protocol.to_string()));
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "language", "imageType"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
let mut should_ask_dlg_for_url = false;
|
|
let mut upload_url_from_server;
|
|
let mut upload_url: Option<String> = None;
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() {
|
|
should_ask_dlg_for_url = false;
|
|
upload_url_from_server = false;
|
|
let mut response = hyper::client::Response::new(Box::new(cmn::DummyNetworkStream));
|
|
match response {
|
|
Ok(ref mut res) => {
|
|
res.status = hyper::status::StatusCode::Ok;
|
|
res.headers.set(Location(upload_url.as_ref().unwrap().clone()))
|
|
}
|
|
_ => unreachable!(),
|
|
}
|
|
response
|
|
} else {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
if protocol == "simple" {
|
|
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
if size > 15728640 {
|
|
return Err(Error::UploadSizeLimitExceeded(size, 15728640))
|
|
}
|
|
req = req.header(ContentType(reader_mime_type.clone()))
|
|
.header(ContentLength(size))
|
|
.body(&mut reader);
|
|
}
|
|
upload_url_from_server = true;
|
|
if protocol == "resumable" {
|
|
req = req.header(cmn::XUploadContentType(reader_mime_type.clone()));
|
|
}
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
}
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
if protocol == "resumable" {
|
|
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
if size > 15728640 {
|
|
return Err(Error::UploadSizeLimitExceeded(size, 15728640))
|
|
}
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let upload_result = {
|
|
let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0;
|
|
if upload_url_from_server {
|
|
dlg.store_upload_url(url);
|
|
}
|
|
|
|
cmn::ResumableUploadHelper {
|
|
client: &mut client.borrow_mut(),
|
|
delegate: dlg,
|
|
start_at: if upload_url_from_server { Some(0) } else { None },
|
|
auth: &mut *self.hub.auth.borrow_mut(),
|
|
user_agent: &self.hub._user_agent,
|
|
auth_header: auth_header.clone(),
|
|
url: url,
|
|
reader: &mut reader,
|
|
media_type: reader_mime_type.clone(),
|
|
content_length: size
|
|
}.upload()
|
|
};
|
|
match upload_result {
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::Cancelled)
|
|
}
|
|
Some(Err(err)) => {
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Some(Ok(upload_result)) => {
|
|
res = upload_result;
|
|
if !res.status.is_success() {
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Upload media all at once.
|
|
/// If the upload fails for whichever reason, all progress is lost.
|
|
///
|
|
/// * *max size*: 15MB
|
|
/// * *multipart*: yes
|
|
/// * *valid mime types*: 'image/*'
|
|
pub fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, ImagesUploadResponse)>
|
|
where RS: ReadSeek {
|
|
self.doit(stream, mime_type, "simple")
|
|
}
|
|
/// 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(...)`.
|
|
///
|
|
/// * *max size*: 15MB
|
|
/// * *multipart*: yes
|
|
/// * *valid mime types*: 'image/*'
|
|
pub fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, ImagesUploadResponse)>
|
|
where RS: ReadSeek {
|
|
self.doit(resumeable_stream, mime_type, "resumable")
|
|
}
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditImageUploadCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditImageUploadCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditImageUploadCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._image_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditImageUploadCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditImageUploadCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditImageUploadCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates the APK's Expansion File configuration to reference another APK's Expansion Files. 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::ExpansionFile;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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", -75, "expansionFileType")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditExpansionfileUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: ExpansionFile,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_expansion_file_type: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditExpansionfileUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditExpansionfileUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ExpansionFile)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.expansionfiles.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("expansionFileType", self._expansion_file_type.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The version code of the APK whose Expansion File configuration is being read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUpdateCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._expansion_file_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditExpansionfileUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditExpansionfileUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Fetches app details for this edit. This includes the default language and developer support contact information.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditDetailGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditDetailGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditDetailGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AppDetails)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.details.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/details".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditDetailGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditDetailGetCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditDetailGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditDetailGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditDetailGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes the APK-specific localized listing for a specified APK and language code.
|
|
///
|
|
/// A builder for the *apklistings.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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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().apklistings_delete("packageName", "editId", -97, "language")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApklistingDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApklistingDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApklistingDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apklistings.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingDeleteCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApklistingDeleteCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApklistingDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApklistingDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes all localized listings from an edit.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditListingDeleteallCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditListingDeleteallCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditListingDeleteallCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.listings.deleteall",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditListingDeleteallCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteallCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditListingDeleteallCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditListingDeleteallCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditListingDeleteallCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
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 enterprises using Google Play for work whose application is configured to restrict distribution to the enterprise domain.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::ApksAddExternallyHostedRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApkAddexternallyhostedCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: ApksAddExternallyHostedRequest,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApkAddexternallyhostedCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApkAddexternallyhostedCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ApksAddExternallyHostedResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apks.addexternallyhosted",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/externallyHosted".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApkAddexternallyhostedCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApkAddexternallyhostedCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApkAddexternallyhostedCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes all the APK-specific localized listings for a specified APK.
|
|
///
|
|
/// A builder for the *apklistings.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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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().apklistings_deleteall("packageName", "editId", -56)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApklistingDeleteallCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApklistingDeleteallCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApklistingDeleteallCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apklistings.deleteall",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
for &field in ["packageName", "editId", "apkVersionCode"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/listings".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "apkVersionCode"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApklistingDeleteallCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApklistingDeleteallCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingDeleteallCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApklistingDeleteallCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApklistingDeleteallCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApklistingDeleteallCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates app details for this edit.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::AppDetails;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditDetailUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: AppDetails,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditDetailUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditDetailUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AppDetails)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.details.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/details".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditDetailUpdateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditDetailUpdateCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditDetailUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditDetailUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditDetailUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Fetches the track configuration for the specified track type. Includes the APK version codes that are in this 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditTrackGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_track: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditTrackGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditTrackGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Track)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.tracks.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("track", self._track.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "track"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/tracks/{track}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "track"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditTrackGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditTrackGetCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The track type to read or modify.
|
|
pub fn track(mut self, new_value: &str) -> EditTrackGetCall<'a, C, NC, A> {
|
|
self._track = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditTrackGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditTrackGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditTrackGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates the APK's Expansion File configuration to reference another APK's Expansion Files. To add a new Expansion File use the Upload method. This method supports patch semantics.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::ExpansionFile;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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", -46, "expansionFileType")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditExpansionfilePatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: ExpansionFile,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_expansion_file_type: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditExpansionfilePatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditExpansionfilePatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ExpansionFile)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.expansionfiles.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("expansionFileType", self._expansion_file_type.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The version code of the APK whose Expansion File configuration is being read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfilePatchCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._expansion_file_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditExpansionfilePatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfilePatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditExpansionfilePatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists all images for the specified language and image type.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditImageListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_image_type: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditImageListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditImageListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ImagesListResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.images.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
params.push(("imageType", self._image_type.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "language", "imageType"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditImageListCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditImageListCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditImageListCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._image_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditImageListCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditImageListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditImageListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates the track configuration for the specified track type. When halted, the rollout track cannot be updated without adding new APKs, and adding new APKs will cause it to resume.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::Track;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditTrackUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: Track,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_track: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditTrackUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditTrackUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Track)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.tracks.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("track", self._track.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "track"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/tracks/{track}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "track"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The track type to read or modify.
|
|
pub fn track(mut self, new_value: &str) -> EditTrackUpdateCall<'a, C, NC, A> {
|
|
self._track = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditTrackUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditTrackUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditTrackUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Creates or updates a localized store listing. This method supports patch semantics.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::Listing;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditListingPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: Listing,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditListingPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditListingPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Listing)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.listings.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditListingPatchCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditListingPatchCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditListingPatchCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditListingPatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditListingPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditListingPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns information about the edit specified. Calls will fail if the edit is no long active (e.g. has been deleted, superseded or expired).
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AppEdit)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditGetCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditImageDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_image_type: String,
|
|
_image_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditImageDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditImageDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.images.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
params.push(("imageType", self._image_type.to_string()));
|
|
params.push(("imageId", self._image_id.to_string()));
|
|
for &field in ["packageName", "editId", "language", "imageType", "imageId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}/{imageId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType"), ("{imageId}", "imageId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(5);
|
|
for param_name in ["packageName", "editId", "language", "imageType", "imageId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditImageDeleteCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditImageDeleteCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._image_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier an image within the set of images attached to this edit.
|
|
pub fn image_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, C, NC, A> {
|
|
self._image_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditImageDeleteCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditImageDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditImageDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use std::fs;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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().apks_upload("packageName", "editId")
|
|
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApkUploadCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApkUploadCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApkUploadCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, Apk)>
|
|
where RS: ReadSeek {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apks.upload",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = if protocol == "simple" {
|
|
"https://www.googleapis.com/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks".to_string()
|
|
} else if protocol == "resumable" {
|
|
"https://www.googleapis.com/resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks".to_string()
|
|
} else {
|
|
unreachable!()
|
|
};
|
|
params.push(("uploadType", protocol.to_string()));
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
let mut should_ask_dlg_for_url = false;
|
|
let mut upload_url_from_server;
|
|
let mut upload_url: Option<String> = None;
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() {
|
|
should_ask_dlg_for_url = false;
|
|
upload_url_from_server = false;
|
|
let mut response = hyper::client::Response::new(Box::new(cmn::DummyNetworkStream));
|
|
match response {
|
|
Ok(ref mut res) => {
|
|
res.status = hyper::status::StatusCode::Ok;
|
|
res.headers.set(Location(upload_url.as_ref().unwrap().clone()))
|
|
}
|
|
_ => unreachable!(),
|
|
}
|
|
response
|
|
} else {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
if protocol == "simple" {
|
|
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
if size > 1073741824 {
|
|
return Err(Error::UploadSizeLimitExceeded(size, 1073741824))
|
|
}
|
|
req = req.header(ContentType(reader_mime_type.clone()))
|
|
.header(ContentLength(size))
|
|
.body(&mut reader);
|
|
}
|
|
upload_url_from_server = true;
|
|
if protocol == "resumable" {
|
|
req = req.header(cmn::XUploadContentType(reader_mime_type.clone()));
|
|
}
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
}
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
if protocol == "resumable" {
|
|
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
if size > 1073741824 {
|
|
return Err(Error::UploadSizeLimitExceeded(size, 1073741824))
|
|
}
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let upload_result = {
|
|
let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0;
|
|
if upload_url_from_server {
|
|
dlg.store_upload_url(url);
|
|
}
|
|
|
|
cmn::ResumableUploadHelper {
|
|
client: &mut client.borrow_mut(),
|
|
delegate: dlg,
|
|
start_at: if upload_url_from_server { Some(0) } else { None },
|
|
auth: &mut *self.hub.auth.borrow_mut(),
|
|
user_agent: &self.hub._user_agent,
|
|
auth_header: auth_header.clone(),
|
|
url: url,
|
|
reader: &mut reader,
|
|
media_type: reader_mime_type.clone(),
|
|
content_length: size
|
|
}.upload()
|
|
};
|
|
match upload_result {
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::Cancelled)
|
|
}
|
|
Some(Err(err)) => {
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Some(Ok(upload_result)) => {
|
|
res = upload_result;
|
|
if !res.status.is_success() {
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Upload media all at once.
|
|
/// If the upload fails for whichever reason, all progress is lost.
|
|
///
|
|
/// * *max size*: 1GB
|
|
/// * *multipart*: yes
|
|
/// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
|
|
pub fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Apk)>
|
|
where RS: ReadSeek {
|
|
self.doit(stream, mime_type, "simple")
|
|
}
|
|
/// 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(...)`.
|
|
///
|
|
/// * *max size*: 1GB
|
|
/// * *multipart*: yes
|
|
/// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive'
|
|
pub fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Apk)>
|
|
where RS: ReadSeek {
|
|
self.doit(resumeable_stream, mime_type, "resumable")
|
|
}
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApkUploadCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApkUploadCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApkUploadCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApkUploadCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApkUploadCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates or creates the APK-specific localized listing for a specified APK and language code.
|
|
///
|
|
/// A builder for the *apklistings.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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::ApkListing;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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: ApkListing = Default::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().apklistings_update(&req, "packageName", "editId", -95, "language")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApklistingUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: ApkListing,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApklistingUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApklistingUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ApkListing)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apklistings.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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: &ApkListing) -> EditApklistingUpdateCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingUpdateCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApklistingUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApklistingUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApklistingUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApkListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApkListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApkListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ApksListResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apks.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApkListCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApkListCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApkListCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApkListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApkListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates or creates the APK-specific localized listing for a specified APK and language code. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *apklistings.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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::ApkListing;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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: ApkListing = Default::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().apklistings_patch(&req, "packageName", "editId", -5, "language")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApklistingPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: ApkListing,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApklistingPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApklistingPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ApkListing)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apklistings.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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: &ApkListing) -> EditApklistingPatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApklistingPatchCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApklistingPatchCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingPatchCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditApklistingPatchCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApklistingPatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApklistingPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApklistingPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Fetches information about 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditListingGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditListingGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditListingGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Listing)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.listings.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditListingGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditListingGetCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditListingGetCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditListingGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditListingGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditListingGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditTesterGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_track: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditTesterGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditTesterGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Testers)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.testers.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("track", self._track.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "track"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/testers/{track}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "track"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditTesterGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditTesterGetCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._track = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditTesterGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditTesterGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditTesterGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes an edit for an app. Creating a new edit will automatically delete any of your previous edits so this method need only be called if you want to preemptively abandon an edit.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditDeleteCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditDeleteCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditDeleteCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Uploads and attaches a new Expansion File to the APK specified.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use std::fs;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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().expansionfiles_upload("packageName", "editId", -66, "expansionFileType")
|
|
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
|
/// # }
|
|
/// ```
|
|
pub struct EditExpansionfileUploadCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_expansion_file_type: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditExpansionfileUploadCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditExpansionfileUploadCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, ExpansionFilesUploadResponse)>
|
|
where RS: ReadSeek {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.expansionfiles.upload",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("expansionFileType", self._expansion_file_type.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = if protocol == "simple" {
|
|
"https://www.googleapis.com/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}".to_string()
|
|
} else if protocol == "resumable" {
|
|
"https://www.googleapis.com/resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}".to_string()
|
|
} else {
|
|
unreachable!()
|
|
};
|
|
params.push(("uploadType", protocol.to_string()));
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
let mut should_ask_dlg_for_url = false;
|
|
let mut upload_url_from_server;
|
|
let mut upload_url: Option<String> = None;
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() {
|
|
should_ask_dlg_for_url = false;
|
|
upload_url_from_server = false;
|
|
let mut response = hyper::client::Response::new(Box::new(cmn::DummyNetworkStream));
|
|
match response {
|
|
Ok(ref mut res) => {
|
|
res.status = hyper::status::StatusCode::Ok;
|
|
res.headers.set(Location(upload_url.as_ref().unwrap().clone()))
|
|
}
|
|
_ => unreachable!(),
|
|
}
|
|
response
|
|
} else {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
if protocol == "simple" {
|
|
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
if size > 2147483648 {
|
|
return Err(Error::UploadSizeLimitExceeded(size, 2147483648))
|
|
}
|
|
req = req.header(ContentType(reader_mime_type.clone()))
|
|
.header(ContentLength(size))
|
|
.body(&mut reader);
|
|
}
|
|
upload_url_from_server = true;
|
|
if protocol == "resumable" {
|
|
req = req.header(cmn::XUploadContentType(reader_mime_type.clone()));
|
|
}
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
}
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
if protocol == "resumable" {
|
|
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
if size > 2147483648 {
|
|
return Err(Error::UploadSizeLimitExceeded(size, 2147483648))
|
|
}
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let upload_result = {
|
|
let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0;
|
|
if upload_url_from_server {
|
|
dlg.store_upload_url(url);
|
|
}
|
|
|
|
cmn::ResumableUploadHelper {
|
|
client: &mut client.borrow_mut(),
|
|
delegate: dlg,
|
|
start_at: if upload_url_from_server { Some(0) } else { None },
|
|
auth: &mut *self.hub.auth.borrow_mut(),
|
|
user_agent: &self.hub._user_agent,
|
|
auth_header: auth_header.clone(),
|
|
url: url,
|
|
reader: &mut reader,
|
|
media_type: reader_mime_type.clone(),
|
|
content_length: size
|
|
}.upload()
|
|
};
|
|
match upload_result {
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::Cancelled)
|
|
}
|
|
Some(Err(err)) => {
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Some(Ok(upload_result)) => {
|
|
res = upload_result;
|
|
if !res.status.is_success() {
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Upload media all at once.
|
|
/// If the upload fails for whichever reason, all progress is lost.
|
|
///
|
|
/// * *max size*: 2048MB
|
|
/// * *multipart*: yes
|
|
/// * *valid mime types*: 'application/octet-stream'
|
|
pub fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, ExpansionFilesUploadResponse)>
|
|
where RS: ReadSeek {
|
|
self.doit(stream, mime_type, "simple")
|
|
}
|
|
/// 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(...)`.
|
|
///
|
|
/// * *max size*: 2048MB
|
|
/// * *multipart*: yes
|
|
/// * *valid mime types*: 'application/octet-stream'
|
|
pub fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, ExpansionFilesUploadResponse)>
|
|
where RS: ReadSeek {
|
|
self.doit(resumeable_stream, mime_type, "resumable")
|
|
}
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The version code of the APK whose Expansion File configuration is being read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUploadCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._expansion_file_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditExpansionfileUploadCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileUploadCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditExpansionfileUploadCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Creates a new edit for an app, populated with the app's current state.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::AppEdit;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: AppEdit,
|
|
_package_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AppEdit)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.insert",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
for &field in ["alt", "packageName"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["packageName"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditInsertCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditInsertCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns all of the localized store listings attached to this edit.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditListingListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditListingListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditListingListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ListingsListResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.listings.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditListingListCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditListingListCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditListingListCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditListingListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditListingListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::Testers;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditTesterPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: Testers,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_track: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditTesterPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditTesterPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Testers)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.testers.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("track", self._track.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "track"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/testers/{track}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "track"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditTesterPatchCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditTesterPatchCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._track = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditTesterPatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditTesterPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditTesterPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Commits/applies the changes made in this edit back to the app.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditCommitCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditCommitCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditCommitCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AppEdit)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.commit",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}:commit".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditCommitCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditCommitCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditCommitCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditCommitCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditCommitCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists all the track configurations for this edit.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditTrackListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditTrackListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditTrackListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, TracksListResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.tracks.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/tracks".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditTrackListCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditTrackListCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditTrackListCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditTrackListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditTrackListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Checks that the edit can be successfully committed. The edit's changes are not applied to the live app.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditValidateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditValidateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditValidateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AppEdit)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.validate",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}:validate".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditValidateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditValidateCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditValidateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditValidateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditValidateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::Listing;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditListingUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: Listing,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditListingUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditListingUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Listing)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.listings.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditListingUpdateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditListingUpdateCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditListingUpdateCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditListingUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditListingUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditListingUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Fetches the Expansion File configuration for the APK specified.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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", -54, "expansionFileType")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditExpansionfileGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_expansion_file_type: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditExpansionfileGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditExpansionfileGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ExpansionFile)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.expansionfiles.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("expansionFileType", self._expansion_file_type.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "expansionFileType"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The version code of the APK whose Expansion File configuration is being read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileGetCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._expansion_file_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditExpansionfileGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditExpansionfileGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditExpansionfileGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes all images for the specified language and image type.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditImageDeleteallCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_image_type: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditImageDeleteallCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditImageDeleteallCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ImagesDeleteAllResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.images.deleteall",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
params.push(("imageType", self._image_type.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "language", "imageType"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditImageDeleteallCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._image_type = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditImageDeleteallCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditImageDeleteallCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditImageDeleteallCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates app details for this edit. This method supports patch semantics.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::AppDetails;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditDetailPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: AppDetails,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditDetailPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditDetailPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AppDetails)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.details.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
for &field in ["alt", "packageName", "editId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/details".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "editId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditDetailPatchCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditDetailPatchCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditDetailPatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditDetailPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditDetailPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates the track configuration for the specified track type. When halted, the rollout track cannot be updated without adding new APKs, and adding new APKs will cause it to resume. This method supports patch semantics.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::Track;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditTrackPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: Track,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_track: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditTrackPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditTrackPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Track)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.tracks.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("track", self._track.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "track"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/tracks/{track}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "track"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditTrackPatchCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditTrackPatchCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The track type to read or modify.
|
|
pub fn track(mut self, new_value: &str) -> EditTrackPatchCall<'a, C, NC, A> {
|
|
self._track = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditTrackPatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditTrackPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditTrackPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes the specified localized store listing from an edit.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditListingDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditListingDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditListingDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.listings.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["packageName", "editId", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditListingDeleteCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditListingDeleteCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditListingDeleteCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditListingDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditListingDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Fetches the APK-specific localized listing for a specified APK and language code.
|
|
///
|
|
/// A builder for the *apklistings.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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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().apklistings_get("packageName", "editId", -87, "language")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApklistingGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_language: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApklistingGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApklistingGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ApkListing)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apklistings.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
params.push(("language", self._language.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4);
|
|
for param_name in ["packageName", "editId", "apkVersionCode", "language"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApklistingGetCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApklistingGetCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingGetCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".
|
|
pub fn language(mut self, new_value: &str) -> EditApklistingGetCall<'a, C, NC, A> {
|
|
self._language = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApklistingGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApklistingGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApklistingGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::Testers;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditTesterUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: Testers,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_track: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditTesterUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditTesterUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Testers)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.testers.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("track", self._track.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "track"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/testers/{track}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "track"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditTesterUpdateCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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, NC, A> {
|
|
self._track = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditTesterUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditTesterUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditTesterUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists all the APK-specific localized listings for a specified APK.
|
|
///
|
|
/// A builder for the *apklistings.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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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().apklistings_list("packageName", "editId", -67)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EditApklistingListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_edit_id: String,
|
|
_apk_version_code: i32,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EditApklistingListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EditApklistingListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ApkListingsListResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.edits.apklistings.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("editId", self._edit_id.to_string()));
|
|
params.push(("apkVersionCode", self._apk_version_code.to_string()));
|
|
for &field in ["alt", "packageName", "editId", "apkVersionCode"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/listings".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["packageName", "editId", "apkVersionCode"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app that is being updated; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> EditApklistingListCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for this edit.
|
|
pub fn edit_id(mut self, new_value: &str) -> EditApklistingListCall<'a, C, NC, A> {
|
|
self._edit_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// The APK version code whose APK-specific listings should be read or modified.
|
|
pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingListCall<'a, C, NC, A> {
|
|
self._apk_version_code = new_value;
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EditApklistingListCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EditApklistingListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> EditApklistingListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// A builder for the *batch* 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::InappproductsBatchRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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: InappproductsBatchRequest = Default::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(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductBatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: InappproductsBatchRequest,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for InappproductBatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductBatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, InappproductsBatchResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.inappproducts.batch",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
for &field in ["alt"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/inappproducts/batch".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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: &InappproductsBatchRequest) -> InappproductBatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> InappproductBatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> InappproductBatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> InappproductBatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// List all the in-app products for an Android app, both subscriptions and managed in-app products..
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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(53)
|
|
/// .max_results(60)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_token: Option<String>,
|
|
_start_index: Option<u32>,
|
|
_max_results: Option<u32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for InappproductListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, InappproductsListResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.inappproducts.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
if let Some(value) = self._token {
|
|
params.push(("token", value.to_string()));
|
|
}
|
|
if let Some(value) = self._start_index {
|
|
params.push(("startIndex", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "packageName", "token", "startIndex", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/inappproducts".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["packageName"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app with in-app products; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> InappproductListCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *token* query property to the given value.
|
|
///
|
|
///
|
|
pub fn token(mut self, new_value: &str) -> InappproductListCall<'a, C, NC, A> {
|
|
self._token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *start index* query property to the given value.
|
|
///
|
|
///
|
|
pub fn start_index(mut self, new_value: u32) -> InappproductListCall<'a, C, NC, A> {
|
|
self._start_index = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
pub fn max_results(mut self, new_value: u32) -> InappproductListCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> InappproductListCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> InappproductListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> InappproductListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Creates a new in-app product for an app.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::InAppProduct;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: InAppProduct,
|
|
_package_name: String,
|
|
_auto_convert_missing_prices: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for InappproductInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, InAppProduct)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.inappproducts.insert",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
if let Some(value) = self._auto_convert_missing_prices {
|
|
params.push(("autoConvertMissingPrices", value.to_string()));
|
|
}
|
|
for &field in ["alt", "packageName", "autoConvertMissingPrices"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/inappproducts".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["packageName"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> InappproductInsertCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *auto convert missing prices* query property to the given value.
|
|
///
|
|
///
|
|
/// 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.
|
|
pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductInsertCall<'a, C, NC, A> {
|
|
self._auto_convert_missing_prices = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> InappproductInsertCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> InappproductInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> InappproductInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Delete an in-app product for an app.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_sku: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for InappproductDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.inappproducts.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("sku", self._sku.to_string()));
|
|
for &field in ["packageName", "sku"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/inappproducts/{sku}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "sku"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> InappproductDeleteCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the in-app product.
|
|
pub fn sku(mut self, new_value: &str) -> InappproductDeleteCall<'a, C, NC, A> {
|
|
self._sku = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> InappproductDeleteCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> InappproductDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> InappproductDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns information about the in-app product specified.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_package_name: String,
|
|
_sku: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for InappproductGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, InAppProduct)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.inappproducts.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("sku", self._sku.to_string()));
|
|
for &field in ["alt", "packageName", "sku"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/inappproducts/{sku}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "sku"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the in-app product.
|
|
pub fn sku(mut self, new_value: &str) -> InappproductGetCall<'a, C, NC, A> {
|
|
self._sku = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> InappproductGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> InappproductGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> InappproductGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates the details of an in-app product.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::InAppProduct;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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")
|
|
/// .auto_convert_missing_prices(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: InAppProduct,
|
|
_package_name: String,
|
|
_sku: String,
|
|
_auto_convert_missing_prices: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for InappproductUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, InAppProduct)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.inappproducts.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("sku", self._sku.to_string()));
|
|
if let Some(value) = self._auto_convert_missing_prices {
|
|
params.push(("autoConvertMissingPrices", value.to_string()));
|
|
}
|
|
for &field in ["alt", "packageName", "sku", "autoConvertMissingPrices"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/inappproducts/{sku}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "sku"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> InappproductUpdateCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the in-app product.
|
|
pub fn sku(mut self, new_value: &str) -> InappproductUpdateCall<'a, C, NC, A> {
|
|
self._sku = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *auto convert missing prices* query property to the given value.
|
|
///
|
|
///
|
|
/// 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.
|
|
pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductUpdateCall<'a, C, NC, A> {
|
|
self._auto_convert_missing_prices = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> InappproductUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> InappproductUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> InappproductUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates the details of an in-app product. This method supports patch semantics.
|
|
///
|
|
/// 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 "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-androidpublisher2" as androidpublisher2;
|
|
/// use androidpublisher2::InAppProduct;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use androidpublisher2::AndroidPublisher;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = AndroidPublisher::new(hyper::Client::new(), 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::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")
|
|
/// .auto_convert_missing_prices(true)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct InappproductPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a AndroidPublisher<C, NC, A>,
|
|
_request: InAppProduct,
|
|
_package_name: String,
|
|
_sku: String,
|
|
_auto_convert_missing_prices: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for InappproductPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> InappproductPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, InAppProduct)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "androidpublisher.inappproducts.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("packageName", self._package_name.to_string()));
|
|
params.push(("sku", self._sku.to_string()));
|
|
if let Some(value) = self._auto_convert_missing_prices {
|
|
params.push(("autoConvertMissingPrices", value.to_string()));
|
|
}
|
|
for &field in ["alt", "packageName", "sku", "autoConvertMissingPrices"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/androidpublisher/v2/applications/{packageName}/inappproducts/{sku}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["packageName", "sku"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// 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, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".
|
|
pub fn package_name(mut self, new_value: &str) -> InappproductPatchCall<'a, C, NC, A> {
|
|
self._package_name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Unique identifier for the in-app product.
|
|
pub fn sku(mut self, new_value: &str) -> InappproductPatchCall<'a, C, NC, A> {
|
|
self._sku = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *auto convert missing prices* query property to the given value.
|
|
///
|
|
///
|
|
/// 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.
|
|
pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductPatchCall<'a, C, NC, A> {
|
|
self._auto_convert_missing_prices = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> InappproductPatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> InappproductPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> InappproductPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|