use super::*; /// 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", -62, "language") /// .doit().await; /// # } /// ``` pub struct EditApklistingDeleteCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApklistingDeleteCall<'a, S> {} impl<'a, S> EditApklistingDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apklistings.delete", http_method: hyper::Method::DELETE }); for &field in ["packageName", "editId", "apkVersionCode", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("language", &self._language); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// 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) -> EditApklistingDeleteCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The APK version code whose APK-specific listings should be read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingDeleteCall<'a, S> { self._apk_version_code = new_value; self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditApklistingDeleteCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApklistingDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApklistingDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApklistingDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApklistingDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApklistingDeleteCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", -4) /// .doit().await; /// # } /// ``` pub struct EditApklistingDeleteallCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApklistingDeleteallCall<'a, S> {} impl<'a, S> EditApklistingDeleteallCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apklistings.deleteall", http_method: hyper::Method::DELETE }); for &field in ["packageName", "editId", "apkVersionCode"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// 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) -> EditApklistingDeleteallCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApklistingDeleteallCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The APK version code whose APK-specific listings should be read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingDeleteallCall<'a, S> { self._apk_version_code = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApklistingDeleteallCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApklistingDeleteallCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApklistingDeleteallCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApklistingDeleteallCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApklistingDeleteallCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", -88, "language") /// .doit().await; /// # } /// ``` pub struct EditApklistingGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApklistingGetCall<'a, S> {} impl<'a, S> EditApklistingGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ApkListing)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apklistings.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("language", &self._language); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// 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) -> EditApklistingGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApklistingGetCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The APK version code whose APK-specific listings should be read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingGetCall<'a, S> { self._apk_version_code = new_value; self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditApklistingGetCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApklistingGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApklistingGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApklistingGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApklistingGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApklistingGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", -93) /// .doit().await; /// # } /// ``` pub struct EditApklistingListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApklistingListCall<'a, S> {} impl<'a, S> EditApklistingListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ApkListingsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apklistings.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId", "apkVersionCode"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// 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) -> EditApklistingListCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApklistingListCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The APK version code whose APK-specific listings should be read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingListCall<'a, S> { self._apk_version_code = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApklistingListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApklistingListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApklistingListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApklistingListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApklistingListCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::ApkListing; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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(); /// /// // 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", -16, "language") /// .doit().await; /// # } /// ``` pub struct EditApklistingPatchCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: ApkListing, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApklistingPatchCall<'a, S> {} impl<'a, S> EditApklistingPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ApkListing)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apklistings.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("language", &self._language); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// 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) -> EditApklistingPatchCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApklistingPatchCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The APK version code whose APK-specific listings should be read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingPatchCall<'a, S> { self._apk_version_code = new_value; self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditApklistingPatchCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApklistingPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApklistingPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApklistingPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApklistingPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApklistingPatchCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::ApkListing; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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(); /// /// // 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", -7, "language") /// .doit().await; /// # } /// ``` pub struct EditApklistingUpdateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: ApkListing, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApklistingUpdateCall<'a, S> {} impl<'a, S> EditApklistingUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ApkListing)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apklistings.update", http_method: hyper::Method::PUT }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("language", &self._language); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// 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) -> EditApklistingUpdateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The APK version code whose APK-specific listings should be read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditApklistingUpdateCall<'a, S> { self._apk_version_code = new_value; self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditApklistingUpdateCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApklistingUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApklistingUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApklistingUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApklistingUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApklistingUpdateCall<'a, S> { self._scopes.clear(); self } } /// Creates a new APK without uploading the APK itself to Google Play, instead hosting the APK at a specified URL. This function is only available to 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::ApksAddExternallyHostedRequest; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ApksAddExternallyHostedRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().apks_addexternallyhosted(req, "packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditApkAddexternallyhostedCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: ApksAddExternallyHostedRequest, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApkAddexternallyhostedCall<'a, S> {} impl<'a, S> EditApkAddexternallyhostedCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ApksAddExternallyHostedResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apks.addexternallyhosted", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/externallyHosted"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApkAddexternallyhostedCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApkAddexternallyhostedCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApkAddexternallyhostedCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApkAddexternallyhostedCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApkAddexternallyhostedCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApkAddexternallyhostedCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().apks_list("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditApkListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApkListCall<'a, S> {} impl<'a, S> EditApkListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ApksListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apks.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditApkListCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApkListCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApkListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApkListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApkListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApkListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApkListCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().apks_upload("packageName", "editId") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct EditApkUploadCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditApkUploadCall<'a, S> {} impl<'a, S> EditApkUploadCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, Apk)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.apks.upload", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let (mut url, upload_type) = if protocol == client::UploadProtocol::Resumable { (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks", "resumable") } else if protocol == client::UploadProtocol::Simple { (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks", "multipart") } else { unreachable!() }; params.push("uploadType", upload_type); if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; 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; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } upload_url_from_server = true; if protocol == client::UploadProtocol::Resumable { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let request = if protocol == client::UploadProtocol::Simple { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 1073741824 { return Err(client::Error::UploadSizeLimitExceeded(size, 1073741824)) } let mut bytes = Vec::with_capacity(size as usize); reader.read_to_end(&mut bytes)?; req_builder.header(CONTENT_TYPE, reader_mime_type.to_string()) .header(CONTENT_LENGTH, size) .body(hyper::body::Body::from(bytes)) } else { req_builder.body(hyper::body::Body::from(Vec::new())) }; client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == client::UploadProtocol::Resumable { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 1073741824 { return Err(client::Error::UploadSizeLimitExceeded(size, 1073741824)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, // TODO: Check this assumption auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 1GB /// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Apk)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 1GB /// * *valid mime types*: 'application/octet-stream' and 'application/vnd.android.package-archive' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Apk)> where RS: client::ReadSeek { self.doit(stream, mime_type, client::UploadProtocol::Simple).await } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditApkUploadCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditApkUploadCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditApkUploadCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditApkUploadCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditApkUploadCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditApkUploadCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditApkUploadCall<'a, S> { self._scopes.clear(); self } } /// A builder for the *bundles.list* method supported by a *edit* resource. /// It is not used directly, but through a [`EditMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().bundles_list("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditBundleListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditBundleListCall<'a, S> {} impl<'a, S> EditBundleListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, BundlesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.bundles.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/bundles"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditBundleListCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditBundleListCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditBundleListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditBundleListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditBundleListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditBundleListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditBundleListCall<'a, S> { self._scopes.clear(); self } } /// Uploads a new Android App Bundle to this edit. If you are using the Google API client libraries, please increase the timeout of the http request before calling this endpoint (a timeout of 2 minutes is recommended). See: https://developers.google.com/api-client-library/java/google-api-java-client/errors for an example in java. /// /// A builder for the *bundles.upload* method supported by a *edit* resource. /// It is not used directly, but through a [`EditMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().bundles_upload("packageName", "editId") /// .ack_bundle_installation_warning(true) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct EditBundleUploadCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _ack_bundle_installation_warning: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditBundleUploadCall<'a, S> {} impl<'a, S> EditBundleUploadCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, Bundle)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.bundles.upload", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId", "ackBundleInstallationWarning"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); if let Some(value) = self._ack_bundle_installation_warning.as_ref() { params.push("ackBundleInstallationWarning", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let (mut url, upload_type) = if protocol == client::UploadProtocol::Resumable { (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/bundles", "resumable") } else if protocol == client::UploadProtocol::Simple { (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/bundles", "multipart") } else { unreachable!() }; params.push("uploadType", upload_type); if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; 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; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } upload_url_from_server = true; if protocol == client::UploadProtocol::Resumable { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let request = if protocol == client::UploadProtocol::Simple { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 2147483648 { return Err(client::Error::UploadSizeLimitExceeded(size, 2147483648)) } let mut bytes = Vec::with_capacity(size as usize); reader.read_to_end(&mut bytes)?; req_builder.header(CONTENT_TYPE, reader_mime_type.to_string()) .header(CONTENT_LENGTH, size) .body(hyper::body::Body::from(bytes)) } else { req_builder.body(hyper::body::Body::from(Vec::new())) }; client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == client::UploadProtocol::Resumable { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 2147483648 { return Err(client::Error::UploadSizeLimitExceeded(size, 2147483648)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, // TODO: Check this assumption auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 2GB /// * *valid mime types*: 'application/octet-stream' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Bundle)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 2GB /// * *valid mime types*: 'application/octet-stream' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Bundle)> where RS: client::ReadSeek { self.doit(stream, mime_type, client::UploadProtocol::Simple).await } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditBundleUploadCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditBundleUploadCall<'a, S> { self._edit_id = new_value.to_string(); self } /// Must be set to true if the bundle installation may trigger a warning on user devices (for example, if installation size may be over a threshold, typically 100 MB). /// /// Sets the *ack bundle installation warning* query property to the given value. pub fn ack_bundle_installation_warning(mut self, new_value: bool) -> EditBundleUploadCall<'a, S> { self._ack_bundle_installation_warning = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditBundleUploadCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditBundleUploadCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditBundleUploadCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditBundleUploadCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditBundleUploadCall<'a, S> { self._scopes.clear(); self } } /// Uploads the deobfuscation file of the specified APK. If a deobfuscation file already exists, it will be replaced. /// /// A builder for the *deobfuscationfiles.upload* method supported by a *edit* resource. /// It is not used directly, but through a [`EditMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().deobfuscationfiles_upload("packageName", "editId", -76, &Default::default()) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct EditDeobfuscationfileUploadCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _deobfuscation_file_type: EditDeobfuscationFileTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditDeobfuscationfileUploadCall<'a, S> {} impl<'a, S> EditDeobfuscationfileUploadCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, DeobfuscationFilesUploadResponse)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.deobfuscationfiles.upload", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "deobfuscationFileType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("deobfuscationFileType", &self._deobfuscation_file_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let (mut url, upload_type) = if protocol == client::UploadProtocol::Resumable { (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/deobfuscationFiles/{deobfuscationFileType}", "resumable") } else if protocol == client::UploadProtocol::Simple { (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/deobfuscationFiles/{deobfuscationFileType}", "multipart") } else { unreachable!() }; params.push("uploadType", upload_type); if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{deobfuscationFileType}", "deobfuscationFileType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["deobfuscationFileType", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; 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; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } upload_url_from_server = true; if protocol == client::UploadProtocol::Resumable { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let request = if protocol == client::UploadProtocol::Simple { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 314572800 { return Err(client::Error::UploadSizeLimitExceeded(size, 314572800)) } let mut bytes = Vec::with_capacity(size as usize); reader.read_to_end(&mut bytes)?; req_builder.header(CONTENT_TYPE, reader_mime_type.to_string()) .header(CONTENT_LENGTH, size) .body(hyper::body::Body::from(bytes)) } else { req_builder.body(hyper::body::Body::from(Vec::new())) }; client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == client::UploadProtocol::Resumable { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 314572800 { return Err(client::Error::UploadSizeLimitExceeded(size, 314572800)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, // TODO: Check this assumption auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 300MB /// * *valid mime types*: 'application/octet-stream' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, DeobfuscationFilesUploadResponse)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 300MB /// * *valid mime types*: 'application/octet-stream' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, DeobfuscationFilesUploadResponse)> where RS: client::ReadSeek { self.doit(stream, mime_type, client::UploadProtocol::Simple).await } /// Unique identifier of the Android app for which the deobfuscatiuon files are being uploaded; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditDeobfuscationfileUploadCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditDeobfuscationfileUploadCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The version code of the APK whose deobfuscation file is being uploaded. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditDeobfuscationfileUploadCall<'a, S> { self._apk_version_code = new_value; self } /// /// Sets the *deobfuscation file type* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn deobfuscation_file_type(mut self, new_value: &EditDeobfuscationFileTypeEnum) -> EditDeobfuscationfileUploadCall<'a, S> { self._deobfuscation_file_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditDeobfuscationfileUploadCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditDeobfuscationfileUploadCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditDeobfuscationfileUploadCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditDeobfuscationfileUploadCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditDeobfuscationfileUploadCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().details_get("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditDetailGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditDetailGetCall<'a, S> {} impl<'a, S> EditDetailGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppDetails)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.details.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/details"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditDetailGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditDetailGetCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditDetailGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditDetailGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditDetailGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditDetailGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditDetailGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::AppDetails; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AppDetails::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().details_patch(req, "packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditDetailPatchCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: AppDetails, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditDetailPatchCall<'a, S> {} impl<'a, S> EditDetailPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppDetails)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.details.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/details"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditDetailPatchCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditDetailPatchCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditDetailPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditDetailPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditDetailPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditDetailPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditDetailPatchCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::AppDetails; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AppDetails::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().details_update(req, "packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditDetailUpdateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: AppDetails, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditDetailUpdateCall<'a, S> {} impl<'a, S> EditDetailUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppDetails)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.details.update", http_method: hyper::Method::PUT }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/details"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditDetailUpdateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditDetailUpdateCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditDetailUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditDetailUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditDetailUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditDetailUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditDetailUpdateCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", -92, &Default::default()) /// .doit().await; /// # } /// ``` pub struct EditExpansionfileGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _expansion_file_type: EditExpansionFileTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditExpansionfileGetCall<'a, S> {} impl<'a, S> EditExpansionfileGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ExpansionFile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.expansionfiles.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("expansionFileType", &self._expansion_file_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["expansionFileType", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileGetCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The version code of the APK whose Expansion File configuration is being read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileGetCall<'a, S> { 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: &EditExpansionFileTypeEnum) -> EditExpansionfileGetCall<'a, S> { self._expansion_file_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditExpansionfileGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditExpansionfileGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditExpansionfileGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditExpansionfileGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditExpansionfileGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::ExpansionFile; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ExpansionFile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().expansionfiles_patch(req, "packageName", "editId", -22, &Default::default()) /// .doit().await; /// # } /// ``` pub struct EditExpansionfilePatchCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: ExpansionFile, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _expansion_file_type: EditExpansionFileTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditExpansionfilePatchCall<'a, S> {} impl<'a, S> EditExpansionfilePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ExpansionFile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.expansionfiles.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("expansionFileType", &self._expansion_file_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["expansionFileType", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditExpansionfilePatchCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The version code of the APK whose Expansion File configuration is being read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfilePatchCall<'a, S> { 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: &EditExpansionFileTypeEnum) -> EditExpansionfilePatchCall<'a, S> { self._expansion_file_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditExpansionfilePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditExpansionfilePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditExpansionfilePatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditExpansionfilePatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditExpansionfilePatchCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::ExpansionFile; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ExpansionFile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().expansionfiles_update(req, "packageName", "editId", -99, &Default::default()) /// .doit().await; /// # } /// ``` pub struct EditExpansionfileUpdateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: ExpansionFile, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _expansion_file_type: EditExpansionFileTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditExpansionfileUpdateCall<'a, S> {} impl<'a, S> EditExpansionfileUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ExpansionFile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.expansionfiles.update", http_method: hyper::Method::PUT }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("expansionFileType", &self._expansion_file_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["expansionFileType", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUpdateCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The version code of the APK whose Expansion File configuration is being read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUpdateCall<'a, S> { 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: &EditExpansionFileTypeEnum) -> EditExpansionfileUpdateCall<'a, S> { self._expansion_file_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditExpansionfileUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditExpansionfileUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditExpansionfileUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditExpansionfileUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditExpansionfileUpdateCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().expansionfiles_upload("packageName", "editId", -76, &Default::default()) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct EditExpansionfileUploadCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _apk_version_code: i32, pub(super) _expansion_file_type: EditExpansionFileTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditExpansionfileUploadCall<'a, S> {} impl<'a, S> EditExpansionfileUploadCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, ExpansionFilesUploadResponse)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.expansionfiles.upload", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId", "apkVersionCode", "expansionFileType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("apkVersionCode", &self._apk_version_code.to_string()); params.push("expansionFileType", &self._expansion_file_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let (mut url, upload_type) = if protocol == client::UploadProtocol::Resumable { (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}", "resumable") } else if protocol == client::UploadProtocol::Simple { (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks/{apkVersionCode}/expansionFiles/{expansionFileType}", "multipart") } else { unreachable!() }; params.push("uploadType", upload_type); if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{apkVersionCode}", "apkVersionCode"), ("{expansionFileType}", "expansionFileType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["expansionFileType", "apkVersionCode", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; 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; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } upload_url_from_server = true; if protocol == client::UploadProtocol::Resumable { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let request = if protocol == client::UploadProtocol::Simple { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 2147483648 { return Err(client::Error::UploadSizeLimitExceeded(size, 2147483648)) } let mut bytes = Vec::with_capacity(size as usize); reader.read_to_end(&mut bytes)?; req_builder.header(CONTENT_TYPE, reader_mime_type.to_string()) .header(CONTENT_LENGTH, size) .body(hyper::body::Body::from(bytes)) } else { req_builder.body(hyper::body::Body::from(Vec::new())) }; client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == client::UploadProtocol::Resumable { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 2147483648 { return Err(client::Error::UploadSizeLimitExceeded(size, 2147483648)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, // TODO: Check this assumption auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 2048MB /// * *valid mime types*: 'application/octet-stream' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ExpansionFilesUploadResponse)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 2048MB /// * *valid mime types*: 'application/octet-stream' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ExpansionFilesUploadResponse)> where RS: client::ReadSeek { self.doit(stream, mime_type, client::UploadProtocol::Simple).await } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditExpansionfileUploadCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The version code of the APK whose Expansion File configuration is being read or modified. /// /// Sets the *apk version code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn apk_version_code(mut self, new_value: i32) -> EditExpansionfileUploadCall<'a, S> { 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: &EditExpansionFileTypeEnum) -> EditExpansionfileUploadCall<'a, S> { self._expansion_file_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditExpansionfileUploadCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditExpansionfileUploadCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditExpansionfileUploadCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditExpansionfileUploadCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditExpansionfileUploadCall<'a, S> { self._scopes.clear(); self } } /// Deletes the image (specified by id) from the edit. /// /// A builder for the *images.delete* method supported by a *edit* resource. /// It is not used directly, but through a [`EditMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", &Default::default(), "imageId") /// .doit().await; /// # } /// ``` pub struct EditImageDeleteCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _image_type: EditImageTypeEnum, pub(super) _image_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditImageDeleteCall<'a, S> {} impl<'a, S> EditImageDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.images.delete", http_method: hyper::Method::DELETE }); for &field in ["packageName", "editId", "language", "imageType", "imageId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.push("imageType", &self._image_type); params.push("imageId", &self._image_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}/{imageType}/{imageId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType"), ("{imageId}", "imageId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["imageId", "imageType", "language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditImageDeleteCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditImageDeleteCall<'a, S> { 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: &EditImageTypeEnum) -> EditImageDeleteCall<'a, S> { self._image_type = new_value.clone(); self } /// Unique identifier an image within the set of images attached to this edit. /// /// Sets the *image id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn image_id(mut self, new_value: &str) -> EditImageDeleteCall<'a, S> { self._image_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditImageDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditImageDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditImageDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditImageDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditImageDeleteCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", &Default::default()) /// .doit().await; /// # } /// ``` pub struct EditImageDeleteallCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _image_type: EditImageTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditImageDeleteallCall<'a, S> {} impl<'a, S> EditImageDeleteallCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ImagesDeleteAllResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.images.deleteall", http_method: hyper::Method::DELETE }); for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.push("imageType", &self._image_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}/{imageType}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["imageType", "language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditImageDeleteallCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditImageDeleteallCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditImageDeleteallCall<'a, S> { 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: &EditImageTypeEnum) -> EditImageDeleteallCall<'a, S> { self._image_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditImageDeleteallCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditImageDeleteallCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditImageDeleteallCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditImageDeleteallCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditImageDeleteallCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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", &Default::default()) /// .doit().await; /// # } /// ``` pub struct EditImageListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _image_type: EditImageTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditImageListCall<'a, S> {} impl<'a, S> EditImageListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ImagesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.images.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.push("imageType", &self._image_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}/{imageType}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["imageType", "language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditImageListCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditImageListCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditImageListCall<'a, S> { 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: &EditImageTypeEnum) -> EditImageListCall<'a, S> { self._image_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditImageListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditImageListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditImageListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditImageListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditImageListCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().images_upload("packageName", "editId", "language", &Default::default()) /// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct EditImageUploadCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _image_type: EditImageTypeEnum, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditImageUploadCall<'a, S> {} impl<'a, S> EditImageUploadCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, ImagesUploadResponse)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.images.upload", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId", "language", "imageType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.push("imageType", &self._image_type); params.extend(self._additional_params.iter()); params.push("alt", "json"); let (mut url, upload_type) = if protocol == client::UploadProtocol::Resumable { (self.hub._root_url.clone() + "resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}", "resumable") } else if protocol == client::UploadProtocol::Simple { (self.hub._root_url.clone() + "upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}", "multipart") } else { unreachable!() }; params.push("uploadType", upload_type); if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language"), ("{imageType}", "imageType")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["imageType", "language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; 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; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } upload_url_from_server = true; if protocol == client::UploadProtocol::Resumable { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let request = if protocol == client::UploadProtocol::Simple { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 15728640 { return Err(client::Error::UploadSizeLimitExceeded(size, 15728640)) } let mut bytes = Vec::with_capacity(size as usize); reader.read_to_end(&mut bytes)?; req_builder.header(CONTENT_TYPE, reader_mime_type.to_string()) .header(CONTENT_LENGTH, size) .body(hyper::body::Body::from(bytes)) } else { req_builder.body(hyper::body::Body::from(Vec::new())) }; client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == client::UploadProtocol::Resumable { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 15728640 { return Err(client::Error::UploadSizeLimitExceeded(size, 15728640)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, // TODO: Check this assumption auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 15MB /// * *valid mime types*: 'image/*' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ImagesUploadResponse)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 15MB /// * *valid mime types*: 'image/*' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ImagesUploadResponse)> where RS: client::ReadSeek { self.doit(stream, mime_type, client::UploadProtocol::Simple).await } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditImageUploadCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditImageUploadCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditImageUploadCall<'a, S> { 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: &EditImageTypeEnum) -> EditImageUploadCall<'a, S> { self._image_type = new_value.clone(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditImageUploadCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditImageUploadCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditImageUploadCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditImageUploadCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditImageUploadCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().listings_delete("packageName", "editId", "language") /// .doit().await; /// # } /// ``` pub struct EditListingDeleteCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditListingDeleteCall<'a, S> {} impl<'a, S> EditListingDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.listings.delete", http_method: hyper::Method::DELETE }); for &field in ["packageName", "editId", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditListingDeleteCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditListingDeleteCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditListingDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditListingDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditListingDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditListingDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditListingDeleteCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().listings_deleteall("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditListingDeleteallCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditListingDeleteallCall<'a, S> {} impl<'a, S> EditListingDeleteallCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.listings.deleteall", http_method: hyper::Method::DELETE }); for &field in ["packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditListingDeleteallCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditListingDeleteallCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditListingDeleteallCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditListingDeleteallCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditListingDeleteallCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditListingDeleteallCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditListingDeleteallCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().listings_get("packageName", "editId", "language") /// .doit().await; /// # } /// ``` pub struct EditListingGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditListingGetCall<'a, S> {} impl<'a, S> EditListingGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Listing)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.listings.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditListingGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditListingGetCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditListingGetCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditListingGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditListingGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditListingGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditListingGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditListingGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().listings_list("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditListingListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditListingListCall<'a, S> {} impl<'a, S> EditListingListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListingsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.listings.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditListingListCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditListingListCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditListingListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditListingListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditListingListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditListingListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditListingListCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::Listing; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Listing::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().listings_patch(req, "packageName", "editId", "language") /// .doit().await; /// # } /// ``` pub struct EditListingPatchCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: Listing, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditListingPatchCall<'a, S> {} impl<'a, S> EditListingPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Listing)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.listings.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "packageName", "editId", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditListingPatchCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditListingPatchCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditListingPatchCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditListingPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditListingPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditListingPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditListingPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditListingPatchCall<'a, S> { self._scopes.clear(); self } } /// Creates or updates a localized store listing. /// /// A builder for the *listings.update* method supported by a *edit* resource. /// It is not used directly, but through a [`EditMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::Listing; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Listing::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().listings_update(req, "packageName", "editId", "language") /// .doit().await; /// # } /// ``` pub struct EditListingUpdateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: Listing, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _language: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditListingUpdateCall<'a, S> {} impl<'a, S> EditListingUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Listing)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.listings.update", http_method: hyper::Method::PUT }); for &field in ["alt", "packageName", "editId", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("language", &self._language); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/listings/{language}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{language}", "language")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["language", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditListingUpdateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditListingUpdateCall<'a, S> { self._edit_id = new_value.to_string(); self } /// 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". /// /// Sets the *language* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn language(mut self, new_value: &str) -> EditListingUpdateCall<'a, S> { self._language = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditListingUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditListingUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditListingUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditListingUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditListingUpdateCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().testers_get("packageName", "editId", "track") /// .doit().await; /// # } /// ``` pub struct EditTesterGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _track: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditTesterGetCall<'a, S> {} impl<'a, S> EditTesterGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Testers)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.testers.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId", "track"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("track", &self._track); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/testers/{track}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["track", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditTesterGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditTesterGetCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The track to read or modify. /// /// 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, S> { self._track = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditTesterGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditTesterGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditTesterGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditTesterGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditTesterGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::Testers; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Testers::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().testers_patch(req, "packageName", "editId", "track") /// .doit().await; /// # } /// ``` pub struct EditTesterPatchCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: Testers, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _track: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditTesterPatchCall<'a, S> {} impl<'a, S> EditTesterPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Testers)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.testers.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "packageName", "editId", "track"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("track", &self._track); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/testers/{track}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["track", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditTesterPatchCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditTesterPatchCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The track to read or modify. /// /// 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, S> { self._track = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditTesterPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditTesterPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditTesterPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditTesterPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditTesterPatchCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::Testers; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Testers::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().testers_update(req, "packageName", "editId", "track") /// .doit().await; /// # } /// ``` pub struct EditTesterUpdateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: Testers, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _track: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditTesterUpdateCall<'a, S> {} impl<'a, S> EditTesterUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Testers)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.testers.update", http_method: hyper::Method::PUT }); for &field in ["alt", "packageName", "editId", "track"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("track", &self._track); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/testers/{track}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["track", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditTesterUpdateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditTesterUpdateCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The track to read or modify. /// /// 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, S> { self._track = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditTesterUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditTesterUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditTesterUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditTesterUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditTesterUpdateCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().tracks_get("packageName", "editId", "track") /// .doit().await; /// # } /// ``` pub struct EditTrackGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _track: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditTrackGetCall<'a, S> {} impl<'a, S> EditTrackGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Track)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.tracks.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId", "track"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("track", &self._track); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks/{track}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["track", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditTrackGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditTrackGetCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The track to read or modify. /// /// Sets the *track* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn track(mut self, new_value: &str) -> EditTrackGetCall<'a, S> { self._track = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditTrackGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditTrackGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditTrackGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditTrackGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditTrackGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().tracks_list("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditTrackListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditTrackListCall<'a, S> {} impl<'a, S> EditTrackListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TracksListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.tracks.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditTrackListCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditTrackListCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditTrackListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditTrackListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditTrackListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditTrackListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditTrackListCall<'a, S> { self._scopes.clear(); self } } /// Updates the track configuration for the specified track type. 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::Track; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Track::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().tracks_patch(req, "packageName", "editId", "track") /// .doit().await; /// # } /// ``` pub struct EditTrackPatchCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: Track, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _track: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditTrackPatchCall<'a, S> {} impl<'a, S> EditTrackPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Track)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.tracks.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "packageName", "editId", "track"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("track", &self._track); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks/{track}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["track", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditTrackPatchCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditTrackPatchCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The track to read or modify. /// /// Sets the *track* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn track(mut self, new_value: &str) -> EditTrackPatchCall<'a, S> { self._track = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditTrackPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditTrackPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditTrackPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditTrackPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditTrackPatchCall<'a, S> { self._scopes.clear(); self } } /// Updates the track configuration for the specified track type. /// /// A builder for the *tracks.update* method supported by a *edit* resource. /// It is not used directly, but through a [`EditMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::Track; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Track::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().tracks_update(req, "packageName", "editId", "track") /// .doit().await; /// # } /// ``` pub struct EditTrackUpdateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: Track, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _track: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditTrackUpdateCall<'a, S> {} impl<'a, S> EditTrackUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Track)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.tracks.update", http_method: hyper::Method::PUT }); for &field in ["alt", "packageName", "editId", "track"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.push("track", &self._track); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}/tracks/{track}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId"), ("{track}", "track")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["track", "editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditTrackUpdateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditTrackUpdateCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The track to read or modify. /// /// Sets the *track* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn track(mut self, new_value: &str) -> EditTrackUpdateCall<'a, S> { self._track = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditTrackUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditTrackUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditTrackUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditTrackUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditTrackUpdateCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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().await; /// # } /// ``` pub struct EditCommitCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditCommitCall<'a, S> {} impl<'a, S> EditCommitCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppEdit)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.commit", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}:commit"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditCommitCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditCommitCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditCommitCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditCommitCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditCommitCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditCommitCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditCommitCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().delete("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditDeleteCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditDeleteCall<'a, S> {} impl<'a, S> EditDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.delete", http_method: hyper::Method::DELETE }); for &field in ["packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditDeleteCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditDeleteCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditDeleteCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().get("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditGetCall<'a, S> {} impl<'a, S> EditGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppEdit)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditGetCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::AppEdit; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AppEdit::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().insert(req, "packageName") /// .doit().await; /// # } /// ``` pub struct EditInsertCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: AppEdit, pub(super) _package_name: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditInsertCall<'a, S> {} impl<'a, S> EditInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppEdit)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.insert", http_method: hyper::Method::POST }); for &field in ["alt", "packageName"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditInsertCall<'a, S> { self._package_name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditInsertCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.edits().validate("packageName", "editId") /// .doit().await; /// # } /// ``` pub struct EditValidateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _edit_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for EditValidateCall<'a, S> {} impl<'a, S> EditValidateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppEdit)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.edits.validate", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "editId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("editId", &self._edit_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/edits/{editId}:validate"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{editId}", "editId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["editId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> EditValidateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for this edit. /// /// Sets the *edit id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn edit_id(mut self, new_value: &str) -> EditValidateCall<'a, S> { self._edit_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EditValidateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EditValidateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> EditValidateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> EditValidateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> EditValidateCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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().await; /// # } /// ``` pub struct InappproductDeleteCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _sku: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for InappproductDeleteCall<'a, S> {} impl<'a, S> InappproductDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.inappproducts.delete", http_method: hyper::Method::DELETE }); for &field in ["packageName", "sku"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("sku", &self._sku); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["sku", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> InappproductDeleteCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for the in-app product. /// /// Sets the *sku* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn sku(mut self, new_value: &str) -> InappproductDeleteCall<'a, S> { self._sku = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InappproductDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InappproductDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> InappproductDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> InappproductDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> InappproductDeleteCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inappproducts().get("packageName", "sku") /// .doit().await; /// # } /// ``` pub struct InappproductGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _sku: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for InappproductGetCall<'a, S> {} impl<'a, S> InappproductGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, InAppProduct)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.inappproducts.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "sku"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("sku", &self._sku); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["sku", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for the in-app product. /// /// Sets the *sku* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn sku(mut self, new_value: &str) -> InappproductGetCall<'a, S> { self._sku = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InappproductGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InappproductGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> InappproductGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> InappproductGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> InappproductGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::InAppProduct; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = InAppProduct::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inappproducts().insert(req, "packageName") /// .auto_convert_missing_prices(false) /// .doit().await; /// # } /// ``` pub struct InappproductInsertCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: InAppProduct, pub(super) _package_name: String, pub(super) _auto_convert_missing_prices: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for InappproductInsertCall<'a, S> {} impl<'a, S> InappproductInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, InAppProduct)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.inappproducts.insert", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "autoConvertMissingPrices"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); if let Some(value) = self._auto_convert_missing_prices.as_ref() { params.push("autoConvertMissingPrices", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> InappproductInsertCall<'a, S> { self._package_name = new_value.to_string(); self } /// If true the prices for all regions targeted by the parent app that don't have a price specified for this in-app product will be auto converted to the target currency based on the default price. Defaults to false. /// /// Sets the *auto convert missing prices* query property to the given value. pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductInsertCall<'a, S> { self._auto_convert_missing_prices = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InappproductInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InappproductInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> InappproductInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> InappproductInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> InappproductInsertCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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("est") /// .start_index(77) /// .max_results(91) /// .doit().await; /// # } /// ``` pub struct InappproductListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _token: Option, pub(super) _start_index: Option, pub(super) _max_results: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for InappproductListCall<'a, S> {} impl<'a, S> InappproductListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, InappproductsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.inappproducts.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "token", "startIndex", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); if let Some(value) = self._token.as_ref() { params.push("token", value); } if let Some(value) = self._start_index.as_ref() { params.push("startIndex", value.to_string()); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app with in-app products; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> InappproductListCall<'a, S> { 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, S> { 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, S> { 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, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InappproductListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InappproductListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> InappproductListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> InappproductListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> InappproductListCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::InAppProduct; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = InAppProduct::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inappproducts().patch(req, "packageName", "sku") /// .auto_convert_missing_prices(true) /// .doit().await; /// # } /// ``` pub struct InappproductPatchCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: InAppProduct, pub(super) _package_name: String, pub(super) _sku: String, pub(super) _auto_convert_missing_prices: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for InappproductPatchCall<'a, S> {} impl<'a, S> InappproductPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, InAppProduct)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.inappproducts.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "packageName", "sku", "autoConvertMissingPrices"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("sku", &self._sku); if let Some(value) = self._auto_convert_missing_prices.as_ref() { params.push("autoConvertMissingPrices", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["sku", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> InappproductPatchCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for the in-app product. /// /// Sets the *sku* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn sku(mut self, new_value: &str) -> InappproductPatchCall<'a, S> { self._sku = new_value.to_string(); self } /// If true the prices for all regions targeted by the parent app that don't have a price specified for this in-app product will be auto converted to the target currency based on the default price. Defaults to false. /// /// Sets the *auto convert missing prices* query property to the given value. pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductPatchCall<'a, S> { self._auto_convert_missing_prices = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InappproductPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InappproductPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> InappproductPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> InappproductPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> InappproductPatchCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::InAppProduct; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = InAppProduct::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inappproducts().update(req, "packageName", "sku") /// .auto_convert_missing_prices(false) /// .doit().await; /// # } /// ``` pub struct InappproductUpdateCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: InAppProduct, pub(super) _package_name: String, pub(super) _sku: String, pub(super) _auto_convert_missing_prices: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for InappproductUpdateCall<'a, S> {} impl<'a, S> InappproductUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, InAppProduct)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.inappproducts.update", http_method: hyper::Method::PUT }); for &field in ["alt", "packageName", "sku", "autoConvertMissingPrices"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("sku", &self._sku); if let Some(value) = self._auto_convert_missing_prices.as_ref() { params.push("autoConvertMissingPrices", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/inappproducts/{sku}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{sku}", "sku")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["sku", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> InappproductUpdateCall<'a, S> { self._package_name = new_value.to_string(); self } /// Unique identifier for the in-app product. /// /// Sets the *sku* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn sku(mut self, new_value: &str) -> InappproductUpdateCall<'a, S> { self._sku = new_value.to_string(); self } /// If true the prices for all regions targeted by the parent app that don't have a price specified for this in-app product will be auto converted to the target currency based on the default price. Defaults to false. /// /// Sets the *auto convert missing prices* query property to the given value. pub fn auto_convert_missing_prices(mut self, new_value: bool) -> InappproductUpdateCall<'a, S> { self._auto_convert_missing_prices = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InappproductUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InappproductUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> InappproductUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> InappproductUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> InappproductUpdateCall<'a, S> { self._scopes.clear(); self } } /// Refund a user's subscription or in-app purchase order. /// /// A builder for the *refund* method supported by a *order* resource. /// It is not used directly, but through a [`OrderMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.orders().refund("packageName", "orderId") /// .revoke(true) /// .doit().await; /// # } /// ``` pub struct OrderRefundCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _order_id: String, pub(super) _revoke: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for OrderRefundCall<'a, S> {} impl<'a, S> OrderRefundCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.orders.refund", http_method: hyper::Method::POST }); for &field in ["packageName", "orderId", "revoke"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("orderId", &self._order_id); if let Some(value) = self._revoke.as_ref() { params.push("revoke", value.to_string()); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/orders/{orderId}:refund"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{orderId}", "orderId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["orderId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The package name of the application for which this subscription or in-app item was purchased (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> OrderRefundCall<'a, S> { self._package_name = new_value.to_string(); self } /// The order ID provided to the user when the subscription or in-app order was purchased. /// /// Sets the *order id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn order_id(mut self, new_value: &str) -> OrderRefundCall<'a, S> { self._order_id = new_value.to_string(); self } /// Whether to revoke the purchased item. If set to true, access to the subscription or in-app item will be terminated immediately. If the item is a recurring subscription, all future payments will also be terminated. Consumed in-app items need to be handled by developer's app. (optional) /// /// Sets the *revoke* query property to the given value. pub fn revoke(mut self, new_value: bool) -> OrderRefundCall<'a, S> { self._revoke = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OrderRefundCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OrderRefundCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> OrderRefundCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> OrderRefundCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> OrderRefundCall<'a, S> { self._scopes.clear(); self } } /// Checks the purchase and consumption status of an inapp item. /// /// A builder for the *products.get* method supported by a *purchase* resource. /// It is not used directly, but through a [`PurchaseMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.purchases().products_get("packageName", "productId", "token") /// .doit().await; /// # } /// ``` pub struct PurchaseProductGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _product_id: String, pub(super) _token: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PurchaseProductGetCall<'a, S> {} impl<'a, S> PurchaseProductGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ProductPurchase)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.purchases.products.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "productId", "token"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("productId", &self._product_id); params.push("token", &self._token); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/purchases/products/{productId}/tokens/{token}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{productId}", "productId"), ("{token}", "token")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["token", "productId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The package name of the application the inapp product was sold in (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> PurchaseProductGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// The inapp product SKU (for example, 'com.some.thing.inapp1'). /// /// Sets the *product id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn product_id(mut self, new_value: &str) -> PurchaseProductGetCall<'a, S> { self._product_id = new_value.to_string(); self } /// The token provided to the user's device when the inapp product was purchased. /// /// Sets the *token* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn token(mut self, new_value: &str) -> PurchaseProductGetCall<'a, S> { self._token = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PurchaseProductGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PurchaseProductGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PurchaseProductGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PurchaseProductGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PurchaseProductGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.purchases().subscriptions_cancel("packageName", "subscriptionId", "token") /// .doit().await; /// # } /// ``` pub struct PurchaseSubscriptionCancelCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _subscription_id: String, pub(super) _token: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PurchaseSubscriptionCancelCall<'a, S> {} impl<'a, S> PurchaseSubscriptionCancelCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.purchases.subscriptions.cancel", http_method: hyper::Method::POST }); for &field in ["packageName", "subscriptionId", "token"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("subscriptionId", &self._subscription_id); params.push("token", &self._token); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:cancel"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["token", "subscriptionId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, S> { self._package_name = new_value.to_string(); self } /// The purchased subscription ID (for example, 'monthly001'). /// /// Sets the *subscription id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, S> { self._subscription_id = new_value.to_string(); self } /// The token provided to the user's device when the subscription was purchased. /// /// Sets the *token* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionCancelCall<'a, S> { self._token = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PurchaseSubscriptionCancelCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PurchaseSubscriptionCancelCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PurchaseSubscriptionCancelCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PurchaseSubscriptionCancelCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PurchaseSubscriptionCancelCall<'a, S> { self._scopes.clear(); self } } /// Defers a user's subscription purchase until a specified future expiration time. /// /// A builder for the *subscriptions.defer* method supported by a *purchase* resource. /// It is not used directly, but through a [`PurchaseMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::SubscriptionPurchasesDeferRequest; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = SubscriptionPurchasesDeferRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.purchases().subscriptions_defer(req, "packageName", "subscriptionId", "token") /// .doit().await; /// # } /// ``` pub struct PurchaseSubscriptionDeferCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: SubscriptionPurchasesDeferRequest, pub(super) _package_name: String, pub(super) _subscription_id: String, pub(super) _token: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PurchaseSubscriptionDeferCall<'a, S> {} impl<'a, S> PurchaseSubscriptionDeferCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, SubscriptionPurchasesDeferResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.purchases.subscriptions.defer", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "subscriptionId", "token"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("subscriptionId", &self._subscription_id); params.push("token", &self._token); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:defer"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["token", "subscriptionId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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, S> { self._request = new_value; self } /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, S> { self._package_name = new_value.to_string(); self } /// The purchased subscription ID (for example, 'monthly001'). /// /// Sets the *subscription id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, S> { self._subscription_id = new_value.to_string(); self } /// The token provided to the user's device when the subscription was purchased. /// /// Sets the *token* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionDeferCall<'a, S> { self._token = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PurchaseSubscriptionDeferCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PurchaseSubscriptionDeferCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PurchaseSubscriptionDeferCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PurchaseSubscriptionDeferCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PurchaseSubscriptionDeferCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.purchases().subscriptions_get("packageName", "subscriptionId", "token") /// .doit().await; /// # } /// ``` pub struct PurchaseSubscriptionGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _subscription_id: String, pub(super) _token: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PurchaseSubscriptionGetCall<'a, S> {} impl<'a, S> PurchaseSubscriptionGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, SubscriptionPurchase)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.purchases.subscriptions.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "subscriptionId", "token"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("subscriptionId", &self._subscription_id); params.push("token", &self._token); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["token", "subscriptionId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// The purchased subscription ID (for example, 'monthly001'). /// /// Sets the *subscription id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, S> { self._subscription_id = new_value.to_string(); self } /// The token provided to the user's device when the subscription was purchased. /// /// Sets the *token* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionGetCall<'a, S> { self._token = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PurchaseSubscriptionGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PurchaseSubscriptionGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PurchaseSubscriptionGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PurchaseSubscriptionGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PurchaseSubscriptionGetCall<'a, S> { self._scopes.clear(); 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 hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.purchases().subscriptions_refund("packageName", "subscriptionId", "token") /// .doit().await; /// # } /// ``` pub struct PurchaseSubscriptionRefundCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _subscription_id: String, pub(super) _token: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PurchaseSubscriptionRefundCall<'a, S> {} impl<'a, S> PurchaseSubscriptionRefundCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.purchases.subscriptions.refund", http_method: hyper::Method::POST }); for &field in ["packageName", "subscriptionId", "token"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("subscriptionId", &self._subscription_id); params.push("token", &self._token); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:refund"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["token", "subscriptionId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, S> { self._package_name = new_value.to_string(); self } /// The purchased subscription ID (for example, 'monthly001'). /// /// Sets the *subscription id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, S> { self._subscription_id = new_value.to_string(); self } /// The token provided to the user's device when the subscription was purchased. /// /// Sets the *token* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRefundCall<'a, S> { self._token = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PurchaseSubscriptionRefundCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PurchaseSubscriptionRefundCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PurchaseSubscriptionRefundCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PurchaseSubscriptionRefundCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PurchaseSubscriptionRefundCall<'a, S> { self._scopes.clear(); self } } /// Refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring. /// /// A builder for the *subscriptions.revoke* method supported by a *purchase* resource. /// It is not used directly, but through a [`PurchaseMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.purchases().subscriptions_revoke("packageName", "subscriptionId", "token") /// .doit().await; /// # } /// ``` pub struct PurchaseSubscriptionRevokeCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _subscription_id: String, pub(super) _token: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PurchaseSubscriptionRevokeCall<'a, S> {} impl<'a, S> PurchaseSubscriptionRevokeCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.purchases.subscriptions.revoke", http_method: hyper::Method::POST }); for &field in ["packageName", "subscriptionId", "token"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("subscriptionId", &self._subscription_id); params.push("token", &self._token); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:revoke"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{subscriptionId}", "subscriptionId"), ("{token}", "token")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["token", "subscriptionId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, S> { self._package_name = new_value.to_string(); self } /// The purchased subscription ID (for example, 'monthly001'). /// /// Sets the *subscription id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn subscription_id(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, S> { self._subscription_id = new_value.to_string(); self } /// The token provided to the user's device when the subscription was purchased. /// /// Sets the *token* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn token(mut self, new_value: &str) -> PurchaseSubscriptionRevokeCall<'a, S> { self._token = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PurchaseSubscriptionRevokeCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PurchaseSubscriptionRevokeCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PurchaseSubscriptionRevokeCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PurchaseSubscriptionRevokeCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PurchaseSubscriptionRevokeCall<'a, S> { self._scopes.clear(); self } } /// Lists the purchases that were canceled, refunded or charged-back. /// /// A builder for the *voidedpurchases.list* method supported by a *purchase* resource. /// It is not used directly, but through a [`PurchaseMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.purchases().voidedpurchases_list("packageName") /// .token("erat") /// .start_time(-73) /// .start_index(91) /// .max_results(42) /// .end_time(-51) /// .doit().await; /// # } /// ``` pub struct PurchaseVoidedpurchaseListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _token: Option, pub(super) _start_time: Option, pub(super) _start_index: Option, pub(super) _max_results: Option, pub(super) _end_time: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PurchaseVoidedpurchaseListCall<'a, S> {} impl<'a, S> PurchaseVoidedpurchaseListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, VoidedPurchasesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.purchases.voidedpurchases.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "token", "startTime", "startIndex", "maxResults", "endTime"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(8 + self._additional_params.len()); params.push("packageName", &self._package_name); if let Some(value) = self._token.as_ref() { params.push("token", value); } if let Some(value) = self._start_time.as_ref() { params.push("startTime", value.to_string()); } if let Some(value) = self._start_index.as_ref() { params.push("startIndex", value.to_string()); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } if let Some(value) = self._end_time.as_ref() { params.push("endTime", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/purchases/voidedpurchases"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The package name of the application for which voided purchases need to be returned (for example, 'com.some.thing'). /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> PurchaseVoidedpurchaseListCall<'a, S> { 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) -> PurchaseVoidedpurchaseListCall<'a, S> { self._token = Some(new_value.to_string()); self } /// The time, in milliseconds since the Epoch, of the oldest voided purchase that you want to see in the response. The value of this parameter cannot be older than 30 days and is ignored if a pagination token is set. Default value is current time minus 30 days. Note: This filter is applied on the time at which the record is seen as voided by our systems and not the actual voided time returned in the response. /// /// Sets the *start time* query property to the given value. pub fn start_time(mut self, new_value: i64) -> PurchaseVoidedpurchaseListCall<'a, S> { self._start_time = Some(new_value); self } /// /// Sets the *start index* query property to the given value. pub fn start_index(mut self, new_value: u32) -> PurchaseVoidedpurchaseListCall<'a, S> { 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) -> PurchaseVoidedpurchaseListCall<'a, S> { self._max_results = Some(new_value); self } /// The time, in milliseconds since the Epoch, of the newest voided purchase that you want to see in the response. The value of this parameter cannot be greater than the current time and is ignored if a pagination token is set. Default value is current time. Note: This filter is applied on the time at which the record is seen as voided by our systems and not the actual voided time returned in the response. /// /// Sets the *end time* query property to the given value. pub fn end_time(mut self, new_value: i64) -> PurchaseVoidedpurchaseListCall<'a, S> { self._end_time = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PurchaseVoidedpurchaseListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PurchaseVoidedpurchaseListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PurchaseVoidedpurchaseListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PurchaseVoidedpurchaseListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PurchaseVoidedpurchaseListCall<'a, S> { self._scopes.clear(); self } } /// Returns a single review. /// /// A builder for the *get* method supported by a *review* resource. /// It is not used directly, but through a [`ReviewMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reviews().get("packageName", "reviewId") /// .translation_language("dolor") /// .doit().await; /// # } /// ``` pub struct ReviewGetCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _review_id: String, pub(super) _translation_language: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReviewGetCall<'a, S> {} impl<'a, S> ReviewGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Review)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.reviews.get", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "reviewId", "translationLanguage"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("reviewId", &self._review_id); if let Some(value) = self._translation_language.as_ref() { params.push("translationLanguage", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/reviews/{reviewId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{reviewId}", "reviewId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["reviewId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> ReviewGetCall<'a, S> { self._package_name = new_value.to_string(); self } /// /// Sets the *review id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn review_id(mut self, new_value: &str) -> ReviewGetCall<'a, S> { self._review_id = new_value.to_string(); self } /// /// Sets the *translation language* query property to the given value. pub fn translation_language(mut self, new_value: &str) -> ReviewGetCall<'a, S> { self._translation_language = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReviewGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReviewGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReviewGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReviewGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReviewGetCall<'a, S> { self._scopes.clear(); self } } /// Returns a list of reviews. Only reviews from last week will be returned. /// /// A builder for the *list* method supported by a *review* resource. /// It is not used directly, but through a [`ReviewMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reviews().list("packageName") /// .translation_language("sit") /// .token("erat") /// .start_index(91) /// .max_results(60) /// .doit().await; /// # } /// ``` pub struct ReviewListCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _package_name: String, pub(super) _translation_language: Option, pub(super) _token: Option, pub(super) _start_index: Option, pub(super) _max_results: Option, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReviewListCall<'a, S> {} impl<'a, S> ReviewListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ReviewsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.reviews.list", http_method: hyper::Method::GET }); for &field in ["alt", "packageName", "translationLanguage", "token", "startIndex", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("packageName", &self._package_name); if let Some(value) = self._translation_language.as_ref() { params.push("translationLanguage", value); } if let Some(value) = self._token.as_ref() { params.push("token", value); } if let Some(value) = self._start_index.as_ref() { params.push("startIndex", value.to_string()); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/reviews"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> ReviewListCall<'a, S> { self._package_name = new_value.to_string(); self } /// /// Sets the *translation language* query property to the given value. pub fn translation_language(mut self, new_value: &str) -> ReviewListCall<'a, S> { self._translation_language = Some(new_value.to_string()); self } /// /// Sets the *token* query property to the given value. pub fn token(mut self, new_value: &str) -> ReviewListCall<'a, S> { 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) -> ReviewListCall<'a, S> { 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) -> ReviewListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReviewListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReviewListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReviewListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReviewListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReviewListCall<'a, S> { self._scopes.clear(); self } } /// Reply to a single review, or update an existing reply. /// /// A builder for the *reply* method supported by a *review* resource. /// It is not used directly, but through a [`ReviewMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidpublisher2 as androidpublisher2; /// use androidpublisher2::api::ReviewsReplyRequest; /// use androidpublisher2::api::enums::*; /// # async fn dox() { /// # use std::default::Default; /// # use androidpublisher2::{AndroidPublisher, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidPublisher::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ReviewsReplyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reviews().reply(req, "packageName", "reviewId") /// .doit().await; /// # } /// ``` pub struct ReviewReplyCall<'a, S> where S: 'a { pub(super) hub: &'a AndroidPublisher, pub(super) _request: ReviewsReplyRequest, pub(super) _package_name: String, pub(super) _review_id: String, pub(super) _delegate: Option<&'a mut dyn client::Delegate>, pub(super) _additional_params: HashMap, pub(super) _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReviewReplyCall<'a, S> {} impl<'a, S> ReviewReplyCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ReviewsReplyResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "androidpublisher.reviews.reply", http_method: hyper::Method::POST }); for &field in ["alt", "packageName", "reviewId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("packageName", &self._package_name); params.push("reviewId", &self._review_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "{packageName}/reviews/{reviewId}:reply"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{packageName}", "packageName"), ("{reviewId}", "reviewId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["reviewId", "packageName"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, 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: ReviewsReplyRequest) -> ReviewReplyCall<'a, S> { self._request = new_value; self } /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". /// /// Sets the *package name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn package_name(mut self, new_value: &str) -> ReviewReplyCall<'a, S> { self._package_name = new_value.to_string(); self } /// /// Sets the *review id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn review_id(mut self, new_value: &str) -> ReviewReplyCall<'a, S> { self._review_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReviewReplyCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReviewReplyCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReviewReplyCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReviewReplyCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReviewReplyCall<'a, S> { self._scopes.clear(); self } }