use std::collections::HashMap;
use std::cell::RefCell;
use std::default::Default;
use std::collections::BTreeSet;
use std::error::Error as StdError;
use serde_json as json;
use std::io;
use std::fs;
use std::mem;
use hyper::client::connect;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::time::sleep;
use tower_service;
use serde::{Serialize, Deserialize};
use crate::{client, client::GetToken, client::serde_with};
// ##############
// UTILITIES ###
// ############
// ########
// HUB ###
// ######
/// Central instance to access all Tenor related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_tenor2 as tenor2;
/// use tenor2::api::GoogleSearchTenorV2RegisterShareRequest;
/// use tenor2::{Result, Error};
/// # async fn dox() {
/// use std::default::Default;
/// use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
/// let secret: oauth2::ApplicationSecret = Default::default();
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
/// // unless you replace `None` with the desired Flow.
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
/// // retrieve them from storage.
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = Tenor::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 = GoogleSearchTenorV2RegisterShareRequest::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.methods().registershare(req)
/// .doit().await;
///
/// match result {
/// Err(e) => match e {
/// // The Error enum provides details about what exactly happened.
/// // You can also just use its `Debug`, `Display` or `Error` traits
/// Error::HttpError(_)
/// |Error::Io(_)
/// |Error::MissingAPIKey
/// |Error::MissingToken(_)
/// |Error::Cancelled
/// |Error::UploadSizeLimitExceeded(_, _)
/// |Error::Failure(_)
/// |Error::BadRequest(_)
/// |Error::FieldClash(_)
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
/// },
/// Ok(res) => println!("Success: {:?}", res),
/// }
/// # }
/// ```
#[derive(Clone)]
pub struct Tenor<S> {
pub client: hyper::Client<S, hyper::body::Body>,
pub auth: Box<dyn client::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
}
impl<'a, S> client::Hub for Tenor<S> {}
impl<'a, S> Tenor<S> {
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> Tenor<S> {
Tenor {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/5.0.5".to_string(),
_base_url: "https://tenor.googleapis.com/".to_string(),
_root_url: "https://tenor.googleapis.com/".to_string(),
}
}
pub fn content(&'a self) -> ContentMethods<'a, S> {
ContentMethods { hub: &self }
}
pub fn methods(&'a self) -> MethodMethods<'a, S> {
MethodMethods { hub: &self }
}
pub fn posts(&'a self) -> PostMethods<'a, S> {
PostMethods { hub: &self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/5.0.5`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
mem::replace(&mut self._user_agent, agent_name)
}
/// Set the base url to use in all requests to the server.
/// It defaults to `https://tenor.googleapis.com/`.
///
/// Returns the previously set base url.
pub fn base_url(&mut self, new_base_url: String) -> String {
mem::replace(&mut self._base_url, new_base_url)
}
/// Set the root url to use in all requests to the server.
/// It defaults to `https://tenor.googleapis.com/`.
///
/// Returns the previously set root url.
pub fn root_url(&mut self, new_root_url: String) -> String {
mem::replace(&mut self._root_url, new_root_url)
}
}
// ############
// SCHEMAS ###
// ##########
/// Message that represents an arbitrary HTTP body. It should only be used for payload formats that can’t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [render_caption](MethodRenderCaptionCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleApiHttpBody {
/// The HTTP Content-Type header value specifying the content type of the body.
#[serde(rename="contentType")]
pub content_type: Option<String>,
/// The HTTP request/response body as raw binary.
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub data: Option<Vec<u8>>,
/// Application specific response metadata. Must be set in the first response for streaming APIs.
pub extensions: Option<Vec<HashMap<String, json::Value>>>,
}
impl client::ResponseResult for GoogleApiHttpBody {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [block add content](ContentBlockAddCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2AddContentBlockResponse {
/// Post ID (pid) of the post from request that partner_block_flag(s) was applied to.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub id: Option<u64>,
}
impl client::ResponseResult for GoogleSearchTenorV2AddContentBlockResponse {}
/// Request message to get an anonymous ID for a user.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [anonid](MethodAnonidCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2AnonIdRequest {
/// Pseudonymous user id tied to the user.
#[serde(rename="anonId")]
pub anon_id: Option<String>,
/// Client application version, e.g., "3.1".
pub appversion: Option<String>,
/// Client application identifier, e.g., "gboard".
#[serde(rename="clientKey")]
pub client_key: Option<String>,
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
pub component: Option<String>,
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
pub country: Option<String>,
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
pub locale: Option<String>,
}
impl client::RequestValue for GoogleSearchTenorV2AnonIdRequest {}
/// Response message to get an anonymous ID for a user.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [anonid](MethodAnonidCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2AnonIdResponse {
/// An anonymous id used to represent a user.
pub anon_id: Option<String>,
}
impl client::ResponseResult for GoogleSearchTenorV2AnonIdResponse {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [autocomplete](MethodAutocompleteCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2AutocompleteResponse {
/// Locale applicable to the completed queries.
pub locale: Option<String>,
/// List of completed queries.
pub results: Option<Vec<String>>,
}
impl client::ResponseResult for GoogleSearchTenorV2AutocompleteResponse {}
/// Categories response that returns the locale and a list of Category object for each searchterm.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [categories](MethodCategoryCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2CategoriesResponse {
/// The locale for which the results are in. If the results cannot be translated to the requested locale, this fields defaults to 'en'.
pub locale: Option<String>,
/// The categories results is a list of Category objects based on the list of searchterms. The list of searchterms is manually changed on occasion and rotated by 2 daily.
pub tags: Option<Vec<GoogleSearchTenorV2Category>>,
}
impl client::ResponseResult for GoogleSearchTenorV2CategoriesResponse {}
/// Category object for each searchterm in the Category list.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2Category {
/// An url to the media source for the category’s example GIF.
pub image: Option<String>,
/// Category name to overlay over the image. The name will be translated to match the locale of the corresponding request.
pub name: Option<String>,
/// The search url to request if the user selects the category.
pub path: Option<String>,
/// The search term that corresponds to the category.
pub searchterm: Option<String>,
}
impl client::Part for GoogleSearchTenorV2Category {}
/// Response message for partners to list all currently blocked posts.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [block list content](ContentBlockListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2ContentBlocksResponse {
/// Token to be passed as |pos| in request for next page of results.
pub next: Option<String>,
/// The posts with content block currently enabled. Results will be ordered by descending post timestamp (published_usec in schema).
pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
}
impl client::ResponseResult for GoogleSearchTenorV2ContentBlocksResponse {}
/// Response that returns featured expression posts.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [featured](MethodFeaturedCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2FeaturedPostsResponse {
/// The locale for which the results are in. If there is no result in the requested locale, this fields defaults to 'en'.
pub locale: Option<String>,
/// Token to be passed as |pos| in request for next page of results.
pub next: Option<String>,
/// The featured posts.
pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
}
impl client::ResponseResult for GoogleSearchTenorV2FeaturedPostsResponse {}
/// Response that returns a list of requested posts.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list posts](PostListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2ListPostsResponse {
/// The featured posts.
pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
}
impl client::ResponseResult for GoogleSearchTenorV2ListPostsResponse {}
/// Metadata for a GIF file type/format. The format name is keyed in the map containing the MediaTypes.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2MediaType {
/// Dimensions of the GIF, i.e. width and height in pixels. e.g. [width, height].
pub dims: Option<Vec<i32>>,
/// The duration of the video/GIF.
pub duration: Option<f64>,
/// The URL to the GIF preview.
pub preview: Option<String>,
/// The file size in bytes.
pub size: Option<i32>,
/// The URL to the video/GIF format.
pub url: Option<String>,
}
impl client::Part for GoogleSearchTenorV2MediaType {}
/// Next ID: 27 Result of post search including various metadata about a GIF.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2PostResult {
/// A short description of the post that can be used for accessibility.
pub content_description: Option<String>,
/// The source of the description.
pub content_description_source: Option<String>,
/// The timestamp of creation of the GIF, in seconds since Unix epoch.
pub created: Option<f64>,
/// List of flags associated with the Post. e.g., ["sticker", "static"]
pub flags: Option<Vec<String>>,
/// True if this post contains audio (only video formats support audio, the gif image file format can not contain audio information).
pub hasaudio: Option<bool>,
/// The identifier for the Post.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub id: Option<u64>,
/// The item url string is an embeddable url.
pub itemurl: Option<String>,
/// The different formats for this GIF, keyed by the format name.
pub media_formats: Option<HashMap<String, GoogleSearchTenorV2MediaType>>,
/// List of tags associated with the Post.
pub tags: Option<Vec<String>>,
/// Title of the GIF/Post.
pub title: Option<String>,
/// The url string is a tenor landing page url.
pub url: Option<String>,
}
impl client::Part for GoogleSearchTenorV2PostResult {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [registershare](MethodRegistershareCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2RegisterShareRequest {
/// Pseudonymous user id tied to a client installation on a user's device.
#[serde(rename="anonId")]
pub anon_id: Option<String>,
/// Used as a session/journey identifier for client events.
pub apirefid: Option<String>,
/// Client application version, e.g., "3.1".
pub appversion: Option<String>,
/// Client application identifier, e.g., "gboard".
#[serde(rename="clientKey")]
pub client_key: Option<String>,
/// Client-specific. UI component where the share was initiated.
pub component: Option<String>,
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
pub country: Option<String>,
/// Post id (pid) of the GIF_OBJECT shared.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub id: Option<u64>,
/// Position of the shared post in the search results list, starting at 0 for the first result. If the share did not result from the user clicking on a result returned by the v2/search endpoint, this value should be -1 to indicate that there is no meaningful index.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub index: Option<i64>,
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
pub locale: Option<String>,
/// Number of people this post was shared to.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub multi: Option<i64>,
/// The query that led to this share, if any.
pub q: Option<String>,
/// Result token pulled from the result in the SearchPostsResponse.
#[serde(rename="resultToken")]
pub result_token: Option<String>,
/// Search filter string used in the search query that led to the share. An empty search filter string will default to '-static,-sticker' and the string 'none' will apply no search filter.
pub searchfilter: Option<String>,
}
impl client::RequestValue for GoogleSearchTenorV2RegisterShareRequest {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [registershare](MethodRegistershareCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2RegisterShareResponse {
/// "ok" if share registration was successful. Maintained for backwards compatibility with v1. v2 clients should rely on RPC status.
pub status: Option<String>,
}
impl client::ResponseResult for GoogleSearchTenorV2RegisterShareResponse {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [block remove content](ContentBlockRemoveCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2RemoveContentBlockResponse {
/// Post ID (pid) of the post from request that partner_block_flag(s) was removed from.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub id: Option<u64>,
}
impl client::ResponseResult for GoogleSearchTenorV2RemoveContentBlockResponse {}
/// Search response that returns expression posts.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [search](MethodSearchCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2SearchPostsResponse {
/// Token to be passed as |pos| in request for next page of results.
pub next: Option<String>,
/// The search results.
pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
}
impl client::ResponseResult for GoogleSearchTenorV2SearchPostsResponse {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [search_suggestions](MethodSearchSuggestionCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2SearchSuggestionsResponse {
/// Locale applicable to the suggested queries.
pub locale: Option<String>,
/// List of suggested queries.
pub results: Option<Vec<String>>,
}
impl client::ResponseResult for GoogleSearchTenorV2SearchSuggestionsResponse {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [trending_terms](MethodTrendingTermCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GoogleSearchTenorV2TrendingTermsResponse {
/// Locale applicable to the trending terms returned, in BCP 47 language tag format, e.g., "fr", "pt-BR".
pub locale: Option<String>,
/// List of trending terms.
pub results: Option<Vec<String>>,
}
impl client::ResponseResult for GoogleSearchTenorV2TrendingTermsResponse {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *content* resources.
/// It is not used directly, but through the [`Tenor`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_tenor2 as tenor2;
///
/// # async fn dox() {
/// use std::default::Default;
/// use tenor2::{Tenor, 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 = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `block_add(...)`, `block_list(...)` and `block_remove(...)`
/// // to build up your call.
/// let rb = hub.content();
/// # }
/// ```
pub struct ContentMethods<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
}
impl<'a, S> client::MethodsBuilder for ContentMethods<'a, S> {}
impl<'a, S> ContentMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Add content block (add partner_block_flag to post).
pub fn block_add(&self) -> ContentBlockAddCall<'a, S> {
ContentBlockAddCall {
hub: self.hub,
_token: Default::default(),
_id: Default::default(),
_client_key: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List content blocks (list all posts blocked by partner).
pub fn block_list(&self) -> ContentBlockListCall<'a, S> {
ContentBlockListCall {
hub: self.hub,
_token: Default::default(),
_pos: Default::default(),
_limit: Default::default(),
_client_key: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Remove content block (remove partner_block_flag from post).
pub fn block_remove(&self) -> ContentBlockRemoveCall<'a, S> {
ContentBlockRemoveCall {
hub: self.hub,
_token: Default::default(),
_id: Default::default(),
_client_key: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *post* resources.
/// It is not used directly, but through the [`Tenor`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_tenor2 as tenor2;
///
/// # async fn dox() {
/// use std::default::Default;
/// use tenor2::{Tenor, 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 = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `list(...)`
/// // to build up your call.
/// let rb = hub.posts();
/// # }
/// ```
pub struct PostMethods<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
}
impl<'a, S> client::MethodsBuilder for PostMethods<'a, S> {}
impl<'a, S> PostMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Get a list of posts by IDs.
pub fn list(&self) -> PostListCall<'a, S> {
PostListCall {
hub: self.hub,
_media_filter: Default::default(),
_locale: Default::default(),
_ids: Default::default(),
_country: Default::default(),
_component: Default::default(),
_client_key: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all free methods, which are not associated with a particular resource.
/// It is not used directly, but through the [`Tenor`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_tenor2 as tenor2;
///
/// # async fn dox() {
/// use std::default::Default;
/// use tenor2::{Tenor, 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 = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `anonid(...)`, `autocomplete(...)`, `categories(...)`, `featured(...)`, `registershare(...)`, `render_caption(...)`, `search(...)`, `search_suggestions(...)` and `trending_terms(...)`
/// // to build up your call.
/// let rb = hub.methods();
/// # }
/// ```
pub struct MethodMethods<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
}
impl<'a, S> client::MethodsBuilder for MethodMethods<'a, S> {}
impl<'a, S> MethodMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Request anonymous ID for a new user.
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn anonid(&self, request: GoogleSearchTenorV2AnonIdRequest) -> MethodAnonidCall<'a, S> {
MethodAnonidCall {
hub: self.hub,
_request: request,
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Complete a partial input query.
pub fn autocomplete(&self) -> MethodAutocompleteCall<'a, S> {
MethodAutocompleteCall {
hub: self.hub,
_q: Default::default(),
_locale: Default::default(),
_limit: Default::default(),
_country: Default::default(),
_component: Default::default(),
_client_key: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Categories.
pub fn categories(&self) -> MethodCategoryCall<'a, S> {
MethodCategoryCall {
hub: self.hub,
_type_: Default::default(),
_searchfilter: Default::default(),
_locale: Default::default(),
_country: Default::default(),
_contentfilter: Default::default(),
_component: Default::default(),
_client_key: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Featured Posts.
pub fn featured(&self) -> MethodFeaturedCall<'a, S> {
MethodFeaturedCall {
hub: self.hub,
_searchfilter: Default::default(),
_q: Default::default(),
_pos: Default::default(),
_media_filter: Default::default(),
_locale: Default::default(),
_limit: Default::default(),
_country: Default::default(),
_contentfilter: Default::default(),
_component: Default::default(),
_collection: Default::default(),
_client_key: Default::default(),
_ar_range: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Register share.
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn registershare(&self, request: GoogleSearchTenorV2RegisterShareRequest) -> MethodRegistershareCall<'a, S> {
MethodRegistershareCall {
hub: self.hub,
_request: request,
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get a post with the provided caption rendered.
pub fn render_caption(&self) -> MethodRenderCaptionCall<'a, S> {
MethodRenderCaptionCall {
hub: self.hub,
_width: Default::default(),
_top_percent: Default::default(),
_right_percent: Default::default(),
_locale: Default::default(),
_left_percent: Default::default(),
_id: Default::default(),
_height: Default::default(),
_format: Default::default(),
_country: Default::default(),
_component: Default::default(),
_client_key: Default::default(),
_caption: Default::default(),
_bottom_percent: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Searches for posts (i.e., GIFs).
pub fn search(&self) -> MethodSearchCall<'a, S> {
MethodSearchCall {
hub: self.hub,
_searchfilter: Default::default(),
_random: Default::default(),
_q: Default::default(),
_pos: Default::default(),
_media_filter: Default::default(),
_locale: Default::default(),
_limit: Default::default(),
_country: Default::default(),
_contentfilter: Default::default(),
_component: Default::default(),
_client_key: Default::default(),
_ar_range: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Search Suggestions.
pub fn search_suggestions(&self) -> MethodSearchSuggestionCall<'a, S> {
MethodSearchSuggestionCall {
hub: self.hub,
_q: Default::default(),
_locale: Default::default(),
_limit: Default::default(),
_country: Default::default(),
_component: Default::default(),
_client_key: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Trending terms.
pub fn trending_terms(&self) -> MethodTrendingTermCall<'a, S> {
MethodTrendingTermCall {
hub: self.hub,
_locale: Default::default(),
_limit: Default::default(),
_country: Default::default(),
_component: Default::default(),
_client_key: Default::default(),
_appversion: Default::default(),
_anon_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
/// Add content block (add partner_block_flag to post).
///
/// A builder for the *block.add* method supported by a *content* resource.
/// It is not used directly, but through a [`ContentMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.content().block_add()
/// .token("et")
/// .id(68)
/// .client_key("no")
/// .doit().await;
/// # }
/// ```
pub struct ContentBlockAddCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_token: Option<String>,
_id: Option<u64>,
_client_key: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for ContentBlockAddCall<'a, S> {}
impl<'a, S> ContentBlockAddCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2AddContentBlockResponse)> {
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: "tenor.content.block.add",
http_method: hyper::Method::GET });
for &field in ["alt", "token", "id", "clientKey"].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());
if let Some(value) = self._token.as_ref() {
params.push("token", value);
}
if let Some(value) = self._id.as_ref() {
params.push("id", value.to_string());
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/content/block/add";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Access token to validate partner access. Required.
///
/// Sets the *token* query property to the given value.
pub fn token(mut self, new_value: &str) -> ContentBlockAddCall<'a, S> {
self._token = Some(new_value.to_string());
self
}
/// Post ID (pid) of the post to apply partner_block_flag(s) to. Required.
///
/// Sets the *id* query property to the given value.
pub fn id(mut self, new_value: u64) -> ContentBlockAddCall<'a, S> {
self._id = Some(new_value);
self
}
/// Client application identifier, e.g., "gboard". Required.
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> ContentBlockAddCall<'a, S> {
self._client_key = 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) -> ContentBlockAddCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ContentBlockAddCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// List content blocks (list all posts blocked by partner).
///
/// A builder for the *block.list* method supported by a *content* resource.
/// It is not used directly, but through a [`ContentMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.content().block_list()
/// .token("ipsum")
/// .pos("voluptua.")
/// .limit(-27)
/// .client_key("sanctus")
/// .doit().await;
/// # }
/// ```
pub struct ContentBlockListCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_token: Option<String>,
_pos: Option<String>,
_limit: Option<i32>,
_client_key: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for ContentBlockListCall<'a, S> {}
impl<'a, S> ContentBlockListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2ContentBlocksResponse)> {
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: "tenor.content.block.list",
http_method: hyper::Method::GET });
for &field in ["alt", "token", "pos", "limit", "clientKey"].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());
if let Some(value) = self._token.as_ref() {
params.push("token", value);
}
if let Some(value) = self._pos.as_ref() {
params.push("pos", value);
}
if let Some(value) = self._limit.as_ref() {
params.push("limit", value.to_string());
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/content/block/list";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Access token to validate partner access.
///
/// Sets the *token* query property to the given value.
pub fn token(mut self, new_value: &str) -> ContentBlockListCall<'a, S> {
self._token = Some(new_value.to_string());
self
}
/// For paging, the position in the result set at which to start. This should be set to the value returned as 'next' in the previous page. The default is '0', meaning start from the beginning.
///
/// Sets the *pos* query property to the given value.
pub fn pos(mut self, new_value: &str) -> ContentBlockListCall<'a, S> {
self._pos = Some(new_value.to_string());
self
}
/// The maximum number of results to be returned. The default is 20.
///
/// Sets the *limit* query property to the given value.
pub fn limit(mut self, new_value: i32) -> ContentBlockListCall<'a, S> {
self._limit = Some(new_value);
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> ContentBlockListCall<'a, S> {
self._client_key = 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) -> ContentBlockListCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ContentBlockListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Remove content block (remove partner_block_flag from post).
///
/// A builder for the *block.remove* method supported by a *content* resource.
/// It is not used directly, but through a [`ContentMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.content().block_remove()
/// .token("sed")
/// .id(99)
/// .client_key("takimata")
/// .doit().await;
/// # }
/// ```
pub struct ContentBlockRemoveCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_token: Option<String>,
_id: Option<u64>,
_client_key: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for ContentBlockRemoveCall<'a, S> {}
impl<'a, S> ContentBlockRemoveCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2RemoveContentBlockResponse)> {
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: "tenor.content.block.remove",
http_method: hyper::Method::GET });
for &field in ["alt", "token", "id", "clientKey"].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());
if let Some(value) = self._token.as_ref() {
params.push("token", value);
}
if let Some(value) = self._id.as_ref() {
params.push("id", value.to_string());
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/content/block/remove";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Access token to validate partner access. Required.
///
/// Sets the *token* query property to the given value.
pub fn token(mut self, new_value: &str) -> ContentBlockRemoveCall<'a, S> {
self._token = Some(new_value.to_string());
self
}
/// Post ID (pid) of the post to remove partner_block_flag(s) from. Required.
///
/// Sets the *id* query property to the given value.
pub fn id(mut self, new_value: u64) -> ContentBlockRemoveCall<'a, S> {
self._id = Some(new_value);
self
}
/// Client application identifier, e.g., "gboard". Required.
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> ContentBlockRemoveCall<'a, S> {
self._client_key = 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) -> ContentBlockRemoveCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> ContentBlockRemoveCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Get a list of posts by IDs.
///
/// A builder for the *list* method supported by a *post* resource.
/// It is not used directly, but through a [`PostMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.posts().list()
/// .media_filter("amet.")
/// .locale("duo")
/// .ids("ipsum")
/// .country("gubergren")
/// .component("Lorem")
/// .client_key("gubergren")
/// .appversion("eos")
/// .anon_id("dolor")
/// .doit().await;
/// # }
/// ```
pub struct PostListCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_media_filter: Option<String>,
_locale: Option<String>,
_ids: Option<String>,
_country: Option<String>,
_component: Option<String>,
_client_key: Option<String>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for PostListCall<'a, S> {}
impl<'a, S> PostListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2ListPostsResponse)> {
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: "tenor.posts.list",
http_method: hyper::Method::GET });
for &field in ["alt", "mediaFilter", "locale", "ids", "country", "component", "clientKey", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(10 + self._additional_params.len());
if let Some(value) = self._media_filter.as_ref() {
params.push("mediaFilter", value);
}
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._ids.as_ref() {
params.push("ids", value);
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/posts";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Specifies image formats returned in results. Use 'minimal' for tinygif, gif, and mp4. Use 'basic' for nanomp4, tinygif, tinymp4, gif, mp4, and nanogif. Or comma separate list of format names.
///
/// Sets the *media filter* query property to the given value.
pub fn media_filter(mut self, new_value: &str) -> PostListCall<'a, S> {
self._media_filter = Some(new_value.to_string());
self
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> PostListCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// A comma separated list of post IDs for which a post will be retrieved. Duplicates are handled as they are, and invalid IDs will be skipped.
///
/// Sets the *ids* query property to the given value.
pub fn ids(mut self, new_value: &str) -> PostListCall<'a, S> {
self._ids = Some(new_value.to_string());
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> PostListCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> PostListCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> PostListCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> PostListCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> PostListCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PostListCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> PostListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Request anonymous ID for a new user.
///
/// A builder for the *anonid* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// use tenor2::api::GoogleSearchTenorV2AnonIdRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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 = GoogleSearchTenorV2AnonIdRequest::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.methods().anonid(req)
/// .doit().await;
/// # }
/// ```
pub struct MethodAnonidCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_request: GoogleSearchTenorV2AnonIdRequest,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodAnonidCall<'a, S> {}
impl<'a, S> MethodAnonidCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2AnonIdResponse)> {
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: "tenor.anonid",
http_method: hyper::Method::POST });
for &field in ["alt"].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.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/anonid";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
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 {
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());
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::<serde_json::Value>(&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: GoogleSearchTenorV2AnonIdRequest) -> MethodAnonidCall<'a, S> {
self._request = 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) -> MethodAnonidCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodAnonidCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Complete a partial input query.
///
/// A builder for the *autocomplete* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.methods().autocomplete()
/// .q("ea")
/// .locale("ipsum")
/// .limit(-88)
/// .country("amet")
/// .component("duo")
/// .client_key("ipsum")
/// .appversion("sed")
/// .anon_id("ut")
/// .doit().await;
/// # }
/// ```
pub struct MethodAutocompleteCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_q: Option<String>,
_locale: Option<String>,
_limit: Option<i32>,
_country: Option<String>,
_component: Option<String>,
_client_key: Option<String>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodAutocompleteCall<'a, S> {}
impl<'a, S> MethodAutocompleteCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2AutocompleteResponse)> {
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: "tenor.autocomplete",
http_method: hyper::Method::GET });
for &field in ["alt", "q", "locale", "limit", "country", "component", "clientKey", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(10 + self._additional_params.len());
if let Some(value) = self._q.as_ref() {
params.push("q", value);
}
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._limit.as_ref() {
params.push("limit", value.to_string());
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/autocomplete";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Required. The current search query.
///
/// Sets the *q* query property to the given value.
pub fn q(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
self._q = Some(new_value.to_string());
self
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// The maximum number of results to be returned. The default is 20.
///
/// Sets the *limit* query property to the given value.
pub fn limit(mut self, new_value: i32) -> MethodAutocompleteCall<'a, S> {
self._limit = Some(new_value);
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodAutocompleteCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodAutocompleteCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Categories.
///
/// A builder for the *categories* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.methods().categories()
/// .type_("gubergren")
/// .searchfilter("rebum.")
/// .locale("est")
/// .country("ipsum")
/// .contentfilter("ipsum")
/// .component("est")
/// .client_key("gubergren")
/// .appversion("ea")
/// .anon_id("dolor")
/// .doit().await;
/// # }
/// ```
pub struct MethodCategoryCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_type_: Option<String>,
_searchfilter: Option<String>,
_locale: Option<String>,
_country: Option<String>,
_contentfilter: Option<String>,
_component: Option<String>,
_client_key: Option<String>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodCategoryCall<'a, S> {}
impl<'a, S> MethodCategoryCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2CategoriesResponse)> {
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: "tenor.categories",
http_method: hyper::Method::GET });
for &field in ["alt", "type", "searchfilter", "locale", "country", "contentfilter", "component", "clientKey", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(11 + self._additional_params.len());
if let Some(value) = self._type_.as_ref() {
params.push("type", value);
}
if let Some(value) = self._searchfilter.as_ref() {
params.push("searchfilter", value);
}
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._contentfilter.as_ref() {
params.push("contentfilter", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/categories";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Type of categories. Supported types are "featured" (default), "emoji", and "trending".
///
/// Sets the *type* query property to the given value.
pub fn type_(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._type_ = Some(new_value.to_string());
self
}
/// If "sticker", returns image url of the top sticker search result.
///
/// Sets the *searchfilter* query property to the given value.
pub fn searchfilter(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._searchfilter = Some(new_value.to_string());
self
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// The content filter level. The default is configurable per client.
///
/// Sets the *contentfilter* query property to the given value.
pub fn contentfilter(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._contentfilter = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodCategoryCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodCategoryCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Featured Posts.
///
/// A builder for the *featured* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.methods().featured()
/// .searchfilter("Lorem")
/// .q("eos")
/// .pos("labore")
/// .media_filter("sed")
/// .locale("duo")
/// .limit(-80)
/// .country("no")
/// .contentfilter("Stet")
/// .component("kasd")
/// .collection("et")
/// .client_key("sed")
/// .ar_range("et")
/// .appversion("et")
/// .anon_id("vero")
/// .doit().await;
/// # }
/// ```
pub struct MethodFeaturedCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_searchfilter: Option<String>,
_q: Option<String>,
_pos: Option<String>,
_media_filter: Option<String>,
_locale: Option<String>,
_limit: Option<i32>,
_country: Option<String>,
_contentfilter: Option<String>,
_component: Option<String>,
_collection: Option<String>,
_client_key: Option<String>,
_ar_range: Option<String>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodFeaturedCall<'a, S> {}
impl<'a, S> MethodFeaturedCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2FeaturedPostsResponse)> {
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: "tenor.featured",
http_method: hyper::Method::GET });
for &field in ["alt", "searchfilter", "q", "pos", "mediaFilter", "locale", "limit", "country", "contentfilter", "component", "collection", "clientKey", "arRange", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(16 + self._additional_params.len());
if let Some(value) = self._searchfilter.as_ref() {
params.push("searchfilter", value);
}
if let Some(value) = self._q.as_ref() {
params.push("q", value);
}
if let Some(value) = self._pos.as_ref() {
params.push("pos", value);
}
if let Some(value) = self._media_filter.as_ref() {
params.push("mediaFilter", value);
}
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._limit.as_ref() {
params.push("limit", value.to_string());
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._contentfilter.as_ref() {
params.push("contentfilter", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._collection.as_ref() {
params.push("collection", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._ar_range.as_ref() {
params.push("arRange", value);
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/featured";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Filter on various properties of posts. Supported values are as follows: 'sticker' include only sticker content in results '-sticker' exclude sticker content in results 'static' include only static content in results '-static' exclude static content in results Input is given as a comma-separated list. For example: searchfilter=sticker,static. If no parameter is given (searchfilter=''), the default behavior will be to exclude static and sticker content.
///
/// Sets the *searchfilter* query property to the given value.
pub fn searchfilter(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._searchfilter = Some(new_value.to_string());
self
}
/// Query string when retrieving from a collection.
///
/// Sets the *q* query property to the given value.
pub fn q(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._q = Some(new_value.to_string());
self
}
/// For paging, the position in the result set at which to start. This should be set to the value returned as 'next' in the previous page. The default is '0', meaning start from the beginning.
///
/// Sets the *pos* query property to the given value.
pub fn pos(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._pos = Some(new_value.to_string());
self
}
/// Specifies image formats returned in results. Use 'minimal' for tinygif, gif, and mp4. Use 'basic' for nanomp4, tinygif, tinymp4, gif, mp4, and nanogif. Or comma separate list of format names.
///
/// Sets the *media filter* query property to the given value.
pub fn media_filter(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._media_filter = Some(new_value.to_string());
self
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// The maximum number of results to be returned. The default is 20.
///
/// Sets the *limit* query property to the given value.
pub fn limit(mut self, new_value: i32) -> MethodFeaturedCall<'a, S> {
self._limit = Some(new_value);
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// The content filter level. The default is configurable per client.
///
/// Sets the *contentfilter* query property to the given value.
pub fn contentfilter(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._contentfilter = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Name of a collection of assets (which can be GIFs, stickers, or mixture of them). Specifying the collection will retrieve the posts from the collection.
///
/// Sets the *collection* query property to the given value.
pub fn collection(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._collection = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Filter the response to only include posts having aspect ratio within the given range. Supported values are: 'all': no constraints, 'wide': [0.42, 2.36], and 'standard': [0.56, 1.78].
///
/// Sets the *ar range* query property to the given value.
pub fn ar_range(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._ar_range = Some(new_value.to_string());
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodFeaturedCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodFeaturedCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Register share.
///
/// A builder for the *registershare* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// use tenor2::api::GoogleSearchTenorV2RegisterShareRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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 = GoogleSearchTenorV2RegisterShareRequest::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.methods().registershare(req)
/// .doit().await;
/// # }
/// ```
pub struct MethodRegistershareCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_request: GoogleSearchTenorV2RegisterShareRequest,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodRegistershareCall<'a, S> {}
impl<'a, S> MethodRegistershareCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2RegisterShareResponse)> {
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: "tenor.registershare",
http_method: hyper::Method::POST });
for &field in ["alt"].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.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/registershare";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
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 {
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());
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::<serde_json::Value>(&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: GoogleSearchTenorV2RegisterShareRequest) -> MethodRegistershareCall<'a, S> {
self._request = 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) -> MethodRegistershareCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodRegistershareCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Get a post with the provided caption rendered.
///
/// A builder for the *render_caption* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.methods().render_caption()
/// .width(-31)
/// .top_percent(0.06730027227364666)
/// .right_percent(0.5254434270373415)
/// .locale("et")
/// .left_percent(0.9697780726648698)
/// .id(99)
/// .height(-96)
/// .format("diam")
/// .country("dolor")
/// .component("et")
/// .client_key("et")
/// .caption("sadipscing")
/// .bottom_percent(0.6755988748158552)
/// .appversion("duo")
/// .anon_id("vero")
/// .doit().await;
/// # }
/// ```
pub struct MethodRenderCaptionCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_width: Option<i32>,
_top_percent: Option<f32>,
_right_percent: Option<f32>,
_locale: Option<String>,
_left_percent: Option<f32>,
_id: Option<u64>,
_height: Option<i32>,
_format: Option<String>,
_country: Option<String>,
_component: Option<String>,
_client_key: Option<String>,
_caption: Option<String>,
_bottom_percent: Option<f32>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodRenderCaptionCall<'a, S> {}
impl<'a, S> MethodRenderCaptionCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleApiHttpBody)> {
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: "tenor.render_caption",
http_method: hyper::Method::GET });
for &field in ["alt", "width", "topPercent", "rightPercent", "locale", "leftPercent", "id", "height", "format", "country", "component", "clientKey", "caption", "bottomPercent", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(17 + self._additional_params.len());
if let Some(value) = self._width.as_ref() {
params.push("width", value.to_string());
}
if let Some(value) = self._top_percent.as_ref() {
params.push("topPercent", value.to_string());
}
if let Some(value) = self._right_percent.as_ref() {
params.push("rightPercent", value.to_string());
}
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._left_percent.as_ref() {
params.push("leftPercent", value.to_string());
}
if let Some(value) = self._id.as_ref() {
params.push("id", value.to_string());
}
if let Some(value) = self._height.as_ref() {
params.push("height", value.to_string());
}
if let Some(value) = self._format.as_ref() {
params.push("format", value);
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._caption.as_ref() {
params.push("caption", value);
}
if let Some(value) = self._bottom_percent.as_ref() {
params.push("bottomPercent", value.to_string());
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/render_caption";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Requested width of the captioned media.
///
/// Sets the *width* query property to the given value.
pub fn width(mut self, new_value: i32) -> MethodRenderCaptionCall<'a, S> {
self._width = Some(new_value);
self
}
/// Percentage of top side of the bounding box.
///
/// Sets the *top percent* query property to the given value.
pub fn top_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
self._top_percent = Some(new_value);
self
}
/// Percentage of right side of the bounding box.
///
/// Sets the *right percent* query property to the given value.
pub fn right_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
self._right_percent = Some(new_value);
self
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// Bounding box of the caption textbox in relation to the underlying gif. Values are percents and can be negative or greater than 100%. Left must be < right and top must be < bottom. Percentage of left side of the bounding box.
///
/// Sets the *left percent* query property to the given value.
pub fn left_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
self._left_percent = Some(new_value);
self
}
/// ID of a post to use as the background media that is being captioned.
///
/// Sets the *id* query property to the given value.
pub fn id(mut self, new_value: u64) -> MethodRenderCaptionCall<'a, S> {
self._id = Some(new_value);
self
}
/// Requested height of the captioned media.
///
/// Sets the *height* query property to the given value.
pub fn height(mut self, new_value: i32) -> MethodRenderCaptionCall<'a, S> {
self._height = Some(new_value);
self
}
/// Requested output media format.
///
/// Sets the *format* query property to the given value.
pub fn format(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._format = Some(new_value.to_string());
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Caption text requested by the user.
///
/// Sets the *caption* query property to the given value.
pub fn caption(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._caption = Some(new_value.to_string());
self
}
/// Percentage of bottom side of the bounding box.
///
/// Sets the *bottom percent* query property to the given value.
pub fn bottom_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
self._bottom_percent = Some(new_value);
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodRenderCaptionCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodRenderCaptionCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Searches for posts (i.e., GIFs).
///
/// A builder for the *search* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.methods().search()
/// .searchfilter("vero")
/// .random(false)
/// .q("Stet")
/// .pos("vero")
/// .media_filter("elitr")
/// .locale("Lorem")
/// .limit(-29)
/// .country("no")
/// .contentfilter("ipsum")
/// .component("accusam")
/// .client_key("takimata")
/// .ar_range("consetetur")
/// .appversion("voluptua.")
/// .anon_id("et")
/// .doit().await;
/// # }
/// ```
pub struct MethodSearchCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_searchfilter: Option<String>,
_random: Option<bool>,
_q: Option<String>,
_pos: Option<String>,
_media_filter: Option<String>,
_locale: Option<String>,
_limit: Option<i32>,
_country: Option<String>,
_contentfilter: Option<String>,
_component: Option<String>,
_client_key: Option<String>,
_ar_range: Option<String>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodSearchCall<'a, S> {}
impl<'a, S> MethodSearchCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2SearchPostsResponse)> {
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: "tenor.search",
http_method: hyper::Method::GET });
for &field in ["alt", "searchfilter", "random", "q", "pos", "mediaFilter", "locale", "limit", "country", "contentfilter", "component", "clientKey", "arRange", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(16 + self._additional_params.len());
if let Some(value) = self._searchfilter.as_ref() {
params.push("searchfilter", value);
}
if let Some(value) = self._random.as_ref() {
params.push("random", value.to_string());
}
if let Some(value) = self._q.as_ref() {
params.push("q", value);
}
if let Some(value) = self._pos.as_ref() {
params.push("pos", value);
}
if let Some(value) = self._media_filter.as_ref() {
params.push("mediaFilter", value);
}
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._limit.as_ref() {
params.push("limit", value.to_string());
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._contentfilter.as_ref() {
params.push("contentfilter", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._ar_range.as_ref() {
params.push("arRange", value);
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/search";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Filter on various properties of posts. Supported values are as follows: 'sticker' include only sticker content in results '-sticker' exclude sticker content in results 'static' include only static content in results '-static' exclude static content in results 'official' include only licensed partner content in results '-official' exclude licensed partner content in results 'none' do not filter results (will include sticker, non-sticker, static, non-static, official, and non-official results) Input is given as a comma-separated list. For example: searchfilter=sticker,-static. If no parameter is given (searchfilter=''), the default behavior will be to exclude static and sticker content e.g. searchfilter=-static,-sticker.
///
/// Sets the *searchfilter* query property to the given value.
pub fn searchfilter(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._searchfilter = Some(new_value.to_string());
self
}
/// Whether or not randomize the search results in the response.
///
/// Sets the *random* query property to the given value.
pub fn random(mut self, new_value: bool) -> MethodSearchCall<'a, S> {
self._random = Some(new_value);
self
}
/// Required. The search query.
///
/// Sets the *q* query property to the given value.
pub fn q(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._q = Some(new_value.to_string());
self
}
/// For paging, the position in the result set at which to start. This should be set to the value returned as 'next' in the previous page. '0' is the same as the default, meaning start from the beginning.
///
/// Sets the *pos* query property to the given value.
pub fn pos(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._pos = Some(new_value.to_string());
self
}
/// Specifies image formats returned in the search result. Use 'minimal' for tinygif, gif, and mp4. Use 'basic' for nanomp4, tinygif, tinymp4, gif, mp4, and nanogif. Or comma separate list of format names.
///
/// Sets the *media filter* query property to the given value.
pub fn media_filter(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._media_filter = Some(new_value.to_string());
self
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// The maximum number of results to be returned. The default is 20.
///
/// Sets the *limit* query property to the given value.
pub fn limit(mut self, new_value: i32) -> MethodSearchCall<'a, S> {
self._limit = Some(new_value);
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// The content filter level. The default is configurable per client.
///
/// Sets the *contentfilter* query property to the given value.
pub fn contentfilter(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._contentfilter = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Filter the response to only include posts having aspect ratio within the given range. Supported values are: 'all': no constraints, 'wide': [0.42, 2.36], and 'standard': [0.56, 1.78].
///
/// Sets the *ar range* query property to the given value.
pub fn ar_range(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._ar_range = Some(new_value.to_string());
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodSearchCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodSearchCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Search Suggestions.
///
/// A builder for the *search_suggestions* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.methods().search_suggestions()
/// .q("erat")
/// .locale("consetetur")
/// .limit(-2)
/// .country("sed")
/// .component("takimata")
/// .client_key("dolores")
/// .appversion("gubergren")
/// .anon_id("et")
/// .doit().await;
/// # }
/// ```
pub struct MethodSearchSuggestionCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_q: Option<String>,
_locale: Option<String>,
_limit: Option<i32>,
_country: Option<String>,
_component: Option<String>,
_client_key: Option<String>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodSearchSuggestionCall<'a, S> {}
impl<'a, S> MethodSearchSuggestionCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2SearchSuggestionsResponse)> {
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: "tenor.search_suggestions",
http_method: hyper::Method::GET });
for &field in ["alt", "q", "locale", "limit", "country", "component", "clientKey", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(10 + self._additional_params.len());
if let Some(value) = self._q.as_ref() {
params.push("q", value);
}
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._limit.as_ref() {
params.push("limit", value.to_string());
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/search_suggestions";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// Required. The search query.
///
/// Sets the *q* query property to the given value.
pub fn q(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
self._q = Some(new_value.to_string());
self
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// The maximum number of results to be returned. The default is 8.
///
/// Sets the *limit* query property to the given value.
pub fn limit(mut self, new_value: i32) -> MethodSearchSuggestionCall<'a, S> {
self._limit = Some(new_value);
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodSearchSuggestionCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodSearchSuggestionCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
/// Trending terms.
///
/// A builder for the *trending_terms* method.
/// It is not used directly, but through a [`MethodMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_tenor2 as tenor2;
/// # async fn dox() {
/// # use std::default::Default;
/// # use tenor2::{Tenor, 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 = Tenor::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.methods().trending_terms()
/// .locale("accusam")
/// .limit(-78)
/// .country("dolore")
/// .component("dolore")
/// .client_key("dolore")
/// .appversion("voluptua.")
/// .anon_id("amet.")
/// .doit().await;
/// # }
/// ```
pub struct MethodTrendingTermCall<'a, S>
where S: 'a {
hub: &'a Tenor<S>,
_locale: Option<String>,
_limit: Option<i64>,
_country: Option<String>,
_component: Option<String>,
_client_key: Option<String>,
_appversion: Option<String>,
_anon_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for MethodTrendingTermCall<'a, S> {}
impl<'a, S> MethodTrendingTermCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2TrendingTermsResponse)> {
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: "tenor.trending_terms",
http_method: hyper::Method::GET });
for &field in ["alt", "locale", "limit", "country", "component", "clientKey", "appversion", "anonId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(9 + self._additional_params.len());
if let Some(value) = self._locale.as_ref() {
params.push("locale", value);
}
if let Some(value) = self._limit.as_ref() {
params.push("limit", value.to_string());
}
if let Some(value) = self._country.as_ref() {
params.push("country", value);
}
if let Some(value) = self._component.as_ref() {
params.push("component", value);
}
if let Some(value) = self._client_key.as_ref() {
params.push("clientKey", value);
}
if let Some(value) = self._appversion.as_ref() {
params.push("appversion", value);
}
if let Some(value) = self._anon_id.as_ref() {
params.push("anonId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v2/trending_terms";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
loop {
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());
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::<serde_json::Value>(&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)
}
}
}
}
/// User's preferred locale as BCP 47 language tag, e.g. "en", "en-US". Note that this is not dependent on the user's current location.
///
/// Sets the *locale* query property to the given value.
pub fn locale(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
self._locale = Some(new_value.to_string());
self
}
/// The number of terms desired. The default is 20 and the max is 50.
///
/// Sets the *limit* query property to the given value.
pub fn limit(mut self, new_value: i64) -> MethodTrendingTermCall<'a, S> {
self._limit = Some(new_value);
self
}
/// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
///
/// Sets the *country* query property to the given value.
pub fn country(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
self._country = Some(new_value.to_string());
self
}
/// UI component where the action was initiated, e.g., "trending". This string is client specific.
///
/// Sets the *component* query property to the given value.
pub fn component(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
self._component = Some(new_value.to_string());
self
}
/// Client application identifier, e.g., "gboard".
///
/// Sets the *client key* query property to the given value.
pub fn client_key(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
self._client_key = Some(new_value.to_string());
self
}
/// Client application version, e.g., "3.1".
///
/// Sets the *appversion* query property to the given value.
pub fn appversion(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
self._appversion = Some(new_value.to_string());
self
}
/// Pseudonymous user id tied to the user.
///
/// Sets the *anon id* query property to the given value.
pub fn anon_id(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
self._anon_id = Some(new_value.to_string());
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodTrendingTermCall<'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
///
/// * *$.xgafv* (query-string) - V1 error format.
/// * *access_token* (query-string) - OAuth access token.
/// * *alt* (query-string) - Data format for response.
/// * *callback* (query-string) - JSONP
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
pub fn param<T>(mut self, name: T, value: T) -> MethodTrendingTermCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}