google_tenor2/api.rs
1use std::collections::HashMap;
2use std::cell::RefCell;
3use std::default::Default;
4use std::collections::BTreeSet;
5use std::error::Error as StdError;
6use serde_json as json;
7use std::io;
8use std::fs;
9use std::mem;
10
11use hyper::client::connect;
12use tokio::io::{AsyncRead, AsyncWrite};
13use tokio::time::sleep;
14use tower_service;
15use serde::{Serialize, Deserialize};
16
17use crate::{client, client::GetToken, client::serde_with};
18
19// ##############
20// UTILITIES ###
21// ############
22
23
24
25
26// ########
27// HUB ###
28// ######
29
30/// Central instance to access all Tenor related resource activities
31///
32/// # Examples
33///
34/// Instantiate a new hub
35///
36/// ```test_harness,no_run
37/// extern crate hyper;
38/// extern crate hyper_rustls;
39/// extern crate google_tenor2 as tenor2;
40/// use tenor2::api::GoogleSearchTenorV2RegisterShareRequest;
41/// use tenor2::{Result, Error};
42/// # async fn dox() {
43/// use std::default::Default;
44/// use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
45///
46/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
47/// // `client_secret`, among other things.
48/// let secret: oauth2::ApplicationSecret = Default::default();
49/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
50/// // unless you replace `None` with the desired Flow.
51/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
52/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
53/// // retrieve them from storage.
54/// let auth = oauth2::InstalledFlowAuthenticator::builder(
55/// secret,
56/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
57/// ).build().await.unwrap();
58/// let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
59/// // As the method needs a request, you would usually fill it with the desired information
60/// // into the respective structure. Some of the parts shown here might not be applicable !
61/// // Values shown here are possibly random and not representative !
62/// let mut req = GoogleSearchTenorV2RegisterShareRequest::default();
63///
64/// // You can configure optional parameters by calling the respective setters at will, and
65/// // execute the final call using `doit()`.
66/// // Values shown here are possibly random and not representative !
67/// let result = hub.methods().registershare(req)
68/// .doit().await;
69///
70/// match result {
71/// Err(e) => match e {
72/// // The Error enum provides details about what exactly happened.
73/// // You can also just use its `Debug`, `Display` or `Error` traits
74/// Error::HttpError(_)
75/// |Error::Io(_)
76/// |Error::MissingAPIKey
77/// |Error::MissingToken(_)
78/// |Error::Cancelled
79/// |Error::UploadSizeLimitExceeded(_, _)
80/// |Error::Failure(_)
81/// |Error::BadRequest(_)
82/// |Error::FieldClash(_)
83/// |Error::JsonDecodeError(_, _) => println!("{}", e),
84/// },
85/// Ok(res) => println!("Success: {:?}", res),
86/// }
87/// # }
88/// ```
89#[derive(Clone)]
90pub struct Tenor<S> {
91 pub client: hyper::Client<S, hyper::body::Body>,
92 pub auth: Box<dyn client::GetToken>,
93 _user_agent: String,
94 _base_url: String,
95 _root_url: String,
96}
97
98impl<'a, S> client::Hub for Tenor<S> {}
99
100impl<'a, S> Tenor<S> {
101
102 pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> Tenor<S> {
103 Tenor {
104 client,
105 auth: Box::new(auth),
106 _user_agent: "google-api-rust-client/5.0.5".to_string(),
107 _base_url: "https://tenor.googleapis.com/".to_string(),
108 _root_url: "https://tenor.googleapis.com/".to_string(),
109 }
110 }
111
112 pub fn content(&'a self) -> ContentMethods<'a, S> {
113 ContentMethods { hub: &self }
114 }
115 pub fn methods(&'a self) -> MethodMethods<'a, S> {
116 MethodMethods { hub: &self }
117 }
118 pub fn posts(&'a self) -> PostMethods<'a, S> {
119 PostMethods { hub: &self }
120 }
121
122 /// Set the user-agent header field to use in all requests to the server.
123 /// It defaults to `google-api-rust-client/5.0.5`.
124 ///
125 /// Returns the previously set user-agent.
126 pub fn user_agent(&mut self, agent_name: String) -> String {
127 mem::replace(&mut self._user_agent, agent_name)
128 }
129
130 /// Set the base url to use in all requests to the server.
131 /// It defaults to `https://tenor.googleapis.com/`.
132 ///
133 /// Returns the previously set base url.
134 pub fn base_url(&mut self, new_base_url: String) -> String {
135 mem::replace(&mut self._base_url, new_base_url)
136 }
137
138 /// Set the root url to use in all requests to the server.
139 /// It defaults to `https://tenor.googleapis.com/`.
140 ///
141 /// Returns the previously set root url.
142 pub fn root_url(&mut self, new_root_url: String) -> String {
143 mem::replace(&mut self._root_url, new_root_url)
144 }
145}
146
147
148// ############
149// SCHEMAS ###
150// ##########
151/// 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.
152///
153/// # Activities
154///
155/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
156/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
157///
158/// * [render_caption](MethodRenderCaptionCall) (response)
159#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
160#[serde_with::serde_as(crate = "::client::serde_with")]
161#[derive(Default, Clone, Debug, Serialize, Deserialize)]
162pub struct GoogleApiHttpBody {
163 /// The HTTP Content-Type header value specifying the content type of the body.
164 #[serde(rename="contentType")]
165
166 pub content_type: Option<String>,
167 /// The HTTP request/response body as raw binary.
168
169 #[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
170 pub data: Option<Vec<u8>>,
171 /// Application specific response metadata. Must be set in the first response for streaming APIs.
172
173 pub extensions: Option<Vec<HashMap<String, json::Value>>>,
174}
175
176impl client::ResponseResult for GoogleApiHttpBody {}
177
178
179/// There is no detailed description.
180///
181/// # Activities
182///
183/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
184/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
185///
186/// * [block add content](ContentBlockAddCall) (response)
187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
188#[serde_with::serde_as(crate = "::client::serde_with")]
189#[derive(Default, Clone, Debug, Serialize, Deserialize)]
190pub struct GoogleSearchTenorV2AddContentBlockResponse {
191 /// Post ID (pid) of the post from request that partner_block_flag(s) was applied to.
192
193 #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
194 pub id: Option<u64>,
195}
196
197impl client::ResponseResult for GoogleSearchTenorV2AddContentBlockResponse {}
198
199
200/// Request message to get an anonymous ID for a user.
201///
202/// # Activities
203///
204/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
205/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
206///
207/// * [anonid](MethodAnonidCall) (request)
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as(crate = "::client::serde_with")]
210#[derive(Default, Clone, Debug, Serialize, Deserialize)]
211pub struct GoogleSearchTenorV2AnonIdRequest {
212 /// Pseudonymous user id tied to the user.
213 #[serde(rename="anonId")]
214
215 pub anon_id: Option<String>,
216 /// Client application version, e.g., "3.1".
217
218 pub appversion: Option<String>,
219 /// Client application identifier, e.g., "gboard".
220 #[serde(rename="clientKey")]
221
222 pub client_key: Option<String>,
223 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
224
225 pub component: Option<String>,
226 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
227
228 pub country: Option<String>,
229 /// 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.
230
231 pub locale: Option<String>,
232}
233
234impl client::RequestValue for GoogleSearchTenorV2AnonIdRequest {}
235
236
237/// Response message to get an anonymous ID for a user.
238///
239/// # Activities
240///
241/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
242/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
243///
244/// * [anonid](MethodAnonidCall) (response)
245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
246#[serde_with::serde_as(crate = "::client::serde_with")]
247#[derive(Default, Clone, Debug, Serialize, Deserialize)]
248pub struct GoogleSearchTenorV2AnonIdResponse {
249 /// An anonymous id used to represent a user.
250
251 pub anon_id: Option<String>,
252}
253
254impl client::ResponseResult for GoogleSearchTenorV2AnonIdResponse {}
255
256
257/// There is no detailed description.
258///
259/// # Activities
260///
261/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
262/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
263///
264/// * [autocomplete](MethodAutocompleteCall) (response)
265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
266#[serde_with::serde_as(crate = "::client::serde_with")]
267#[derive(Default, Clone, Debug, Serialize, Deserialize)]
268pub struct GoogleSearchTenorV2AutocompleteResponse {
269 /// Locale applicable to the completed queries.
270
271 pub locale: Option<String>,
272 /// List of completed queries.
273
274 pub results: Option<Vec<String>>,
275}
276
277impl client::ResponseResult for GoogleSearchTenorV2AutocompleteResponse {}
278
279
280/// Categories response that returns the locale and a list of Category object for each searchterm.
281///
282/// # Activities
283///
284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
286///
287/// * [categories](MethodCategoryCall) (response)
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as(crate = "::client::serde_with")]
290#[derive(Default, Clone, Debug, Serialize, Deserialize)]
291pub struct GoogleSearchTenorV2CategoriesResponse {
292 /// The locale for which the results are in. If the results cannot be translated to the requested locale, this fields defaults to 'en'.
293
294 pub locale: Option<String>,
295 /// 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.
296
297 pub tags: Option<Vec<GoogleSearchTenorV2Category>>,
298}
299
300impl client::ResponseResult for GoogleSearchTenorV2CategoriesResponse {}
301
302
303/// Category object for each searchterm in the Category list.
304///
305/// This type is not used in any activity, and only used as *part* of another schema.
306///
307#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
308#[serde_with::serde_as(crate = "::client::serde_with")]
309#[derive(Default, Clone, Debug, Serialize, Deserialize)]
310pub struct GoogleSearchTenorV2Category {
311 /// An url to the media source for the category’s example GIF.
312
313 pub image: Option<String>,
314 /// Category name to overlay over the image. The name will be translated to match the locale of the corresponding request.
315
316 pub name: Option<String>,
317 /// The search url to request if the user selects the category.
318
319 pub path: Option<String>,
320 /// The search term that corresponds to the category.
321
322 pub searchterm: Option<String>,
323}
324
325impl client::Part for GoogleSearchTenorV2Category {}
326
327
328/// Response message for partners to list all currently blocked posts.
329///
330/// # Activities
331///
332/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
333/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
334///
335/// * [block list content](ContentBlockListCall) (response)
336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
337#[serde_with::serde_as(crate = "::client::serde_with")]
338#[derive(Default, Clone, Debug, Serialize, Deserialize)]
339pub struct GoogleSearchTenorV2ContentBlocksResponse {
340 /// Token to be passed as |pos| in request for next page of results.
341
342 pub next: Option<String>,
343 /// The posts with content block currently enabled. Results will be ordered by descending post timestamp (published_usec in schema).
344
345 pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
346}
347
348impl client::ResponseResult for GoogleSearchTenorV2ContentBlocksResponse {}
349
350
351/// Response that returns featured expression posts.
352///
353/// # Activities
354///
355/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
356/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
357///
358/// * [featured](MethodFeaturedCall) (response)
359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
360#[serde_with::serde_as(crate = "::client::serde_with")]
361#[derive(Default, Clone, Debug, Serialize, Deserialize)]
362pub struct GoogleSearchTenorV2FeaturedPostsResponse {
363 /// The locale for which the results are in. If there is no result in the requested locale, this fields defaults to 'en'.
364
365 pub locale: Option<String>,
366 /// Token to be passed as |pos| in request for next page of results.
367
368 pub next: Option<String>,
369 /// The featured posts.
370
371 pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
372}
373
374impl client::ResponseResult for GoogleSearchTenorV2FeaturedPostsResponse {}
375
376
377/// Response that returns a list of requested posts.
378///
379/// # Activities
380///
381/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
382/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
383///
384/// * [list posts](PostListCall) (response)
385#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
386#[serde_with::serde_as(crate = "::client::serde_with")]
387#[derive(Default, Clone, Debug, Serialize, Deserialize)]
388pub struct GoogleSearchTenorV2ListPostsResponse {
389 /// The featured posts.
390
391 pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
392}
393
394impl client::ResponseResult for GoogleSearchTenorV2ListPostsResponse {}
395
396
397/// Metadata for a GIF file type/format. The format name is keyed in the map containing the MediaTypes.
398///
399/// This type is not used in any activity, and only used as *part* of another schema.
400///
401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
402#[serde_with::serde_as(crate = "::client::serde_with")]
403#[derive(Default, Clone, Debug, Serialize, Deserialize)]
404pub struct GoogleSearchTenorV2MediaType {
405 /// Dimensions of the GIF, i.e. width and height in pixels. e.g. [width, height].
406
407 pub dims: Option<Vec<i32>>,
408 /// The duration of the video/GIF.
409
410 pub duration: Option<f64>,
411 /// The URL to the GIF preview.
412
413 pub preview: Option<String>,
414 /// The file size in bytes.
415
416 pub size: Option<i32>,
417 /// The URL to the video/GIF format.
418
419 pub url: Option<String>,
420}
421
422impl client::Part for GoogleSearchTenorV2MediaType {}
423
424
425/// Next ID: 27 Result of post search including various metadata about a GIF.
426///
427/// This type is not used in any activity, and only used as *part* of another schema.
428///
429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
430#[serde_with::serde_as(crate = "::client::serde_with")]
431#[derive(Default, Clone, Debug, Serialize, Deserialize)]
432pub struct GoogleSearchTenorV2PostResult {
433 /// A short description of the post that can be used for accessibility.
434
435 pub content_description: Option<String>,
436 /// The source of the description.
437
438 pub content_description_source: Option<String>,
439 /// The timestamp of creation of the GIF, in seconds since Unix epoch.
440
441 pub created: Option<f64>,
442 /// List of flags associated with the Post. e.g., ["sticker", "static"]
443
444 pub flags: Option<Vec<String>>,
445 /// True if this post contains audio (only video formats support audio, the gif image file format can not contain audio information).
446
447 pub hasaudio: Option<bool>,
448 /// The identifier for the Post.
449
450 #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
451 pub id: Option<u64>,
452 /// The item url string is an embeddable url.
453
454 pub itemurl: Option<String>,
455 /// The different formats for this GIF, keyed by the format name.
456
457 pub media_formats: Option<HashMap<String, GoogleSearchTenorV2MediaType>>,
458 /// List of tags associated with the Post.
459
460 pub tags: Option<Vec<String>>,
461 /// Title of the GIF/Post.
462
463 pub title: Option<String>,
464 /// The url string is a tenor landing page url.
465
466 pub url: Option<String>,
467}
468
469impl client::Part for GoogleSearchTenorV2PostResult {}
470
471
472/// There is no detailed description.
473///
474/// # Activities
475///
476/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
477/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
478///
479/// * [registershare](MethodRegistershareCall) (request)
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as(crate = "::client::serde_with")]
482#[derive(Default, Clone, Debug, Serialize, Deserialize)]
483pub struct GoogleSearchTenorV2RegisterShareRequest {
484 /// Pseudonymous user id tied to a client installation on a user's device.
485 #[serde(rename="anonId")]
486
487 pub anon_id: Option<String>,
488 /// Used as a session/journey identifier for client events.
489
490 pub apirefid: Option<String>,
491 /// Client application version, e.g., "3.1".
492
493 pub appversion: Option<String>,
494 /// Client application identifier, e.g., "gboard".
495 #[serde(rename="clientKey")]
496
497 pub client_key: Option<String>,
498 /// Client-specific. UI component where the share was initiated.
499
500 pub component: Option<String>,
501 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
502
503 pub country: Option<String>,
504 /// Post id (pid) of the GIF_OBJECT shared.
505
506 #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
507 pub id: Option<u64>,
508 /// 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.
509
510 #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
511 pub index: Option<i64>,
512 /// 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.
513
514 pub locale: Option<String>,
515 /// Number of people this post was shared to.
516
517 #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
518 pub multi: Option<i64>,
519 /// The query that led to this share, if any.
520
521 pub q: Option<String>,
522 /// Result token pulled from the result in the SearchPostsResponse.
523 #[serde(rename="resultToken")]
524
525 pub result_token: Option<String>,
526 /// 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.
527
528 pub searchfilter: Option<String>,
529}
530
531impl client::RequestValue for GoogleSearchTenorV2RegisterShareRequest {}
532
533
534/// There is no detailed description.
535///
536/// # Activities
537///
538/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
539/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
540///
541/// * [registershare](MethodRegistershareCall) (response)
542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
543#[serde_with::serde_as(crate = "::client::serde_with")]
544#[derive(Default, Clone, Debug, Serialize, Deserialize)]
545pub struct GoogleSearchTenorV2RegisterShareResponse {
546 /// "ok" if share registration was successful. Maintained for backwards compatibility with v1. v2 clients should rely on RPC status.
547
548 pub status: Option<String>,
549}
550
551impl client::ResponseResult for GoogleSearchTenorV2RegisterShareResponse {}
552
553
554/// There is no detailed description.
555///
556/// # Activities
557///
558/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
559/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
560///
561/// * [block remove content](ContentBlockRemoveCall) (response)
562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
563#[serde_with::serde_as(crate = "::client::serde_with")]
564#[derive(Default, Clone, Debug, Serialize, Deserialize)]
565pub struct GoogleSearchTenorV2RemoveContentBlockResponse {
566 /// Post ID (pid) of the post from request that partner_block_flag(s) was removed from.
567
568 #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
569 pub id: Option<u64>,
570}
571
572impl client::ResponseResult for GoogleSearchTenorV2RemoveContentBlockResponse {}
573
574
575/// Search response that returns expression posts.
576///
577/// # Activities
578///
579/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
580/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
581///
582/// * [search](MethodSearchCall) (response)
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as(crate = "::client::serde_with")]
585#[derive(Default, Clone, Debug, Serialize, Deserialize)]
586pub struct GoogleSearchTenorV2SearchPostsResponse {
587 /// Token to be passed as |pos| in request for next page of results.
588
589 pub next: Option<String>,
590 /// The search results.
591
592 pub results: Option<Vec<GoogleSearchTenorV2PostResult>>,
593}
594
595impl client::ResponseResult for GoogleSearchTenorV2SearchPostsResponse {}
596
597
598/// There is no detailed description.
599///
600/// # Activities
601///
602/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
603/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
604///
605/// * [search_suggestions](MethodSearchSuggestionCall) (response)
606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
607#[serde_with::serde_as(crate = "::client::serde_with")]
608#[derive(Default, Clone, Debug, Serialize, Deserialize)]
609pub struct GoogleSearchTenorV2SearchSuggestionsResponse {
610 /// Locale applicable to the suggested queries.
611
612 pub locale: Option<String>,
613 /// List of suggested queries.
614
615 pub results: Option<Vec<String>>,
616}
617
618impl client::ResponseResult for GoogleSearchTenorV2SearchSuggestionsResponse {}
619
620
621/// There is no detailed description.
622///
623/// # Activities
624///
625/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
626/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
627///
628/// * [trending_terms](MethodTrendingTermCall) (response)
629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
630#[serde_with::serde_as(crate = "::client::serde_with")]
631#[derive(Default, Clone, Debug, Serialize, Deserialize)]
632pub struct GoogleSearchTenorV2TrendingTermsResponse {
633 /// Locale applicable to the trending terms returned, in BCP 47 language tag format, e.g., "fr", "pt-BR".
634
635 pub locale: Option<String>,
636 /// List of trending terms.
637
638 pub results: Option<Vec<String>>,
639}
640
641impl client::ResponseResult for GoogleSearchTenorV2TrendingTermsResponse {}
642
643
644
645// ###################
646// MethodBuilders ###
647// #################
648
649/// A builder providing access to all methods supported on *content* resources.
650/// It is not used directly, but through the [`Tenor`] hub.
651///
652/// # Example
653///
654/// Instantiate a resource builder
655///
656/// ```test_harness,no_run
657/// extern crate hyper;
658/// extern crate hyper_rustls;
659/// extern crate google_tenor2 as tenor2;
660///
661/// # async fn dox() {
662/// use std::default::Default;
663/// use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
664///
665/// let secret: oauth2::ApplicationSecret = Default::default();
666/// let auth = oauth2::InstalledFlowAuthenticator::builder(
667/// secret,
668/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
669/// ).build().await.unwrap();
670/// let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
671/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
672/// // like `block_add(...)`, `block_list(...)` and `block_remove(...)`
673/// // to build up your call.
674/// let rb = hub.content();
675/// # }
676/// ```
677pub struct ContentMethods<'a, S>
678 where S: 'a {
679
680 hub: &'a Tenor<S>,
681}
682
683impl<'a, S> client::MethodsBuilder for ContentMethods<'a, S> {}
684
685impl<'a, S> ContentMethods<'a, S> {
686
687 /// Create a builder to help you perform the following task:
688 ///
689 /// Add content block (add partner_block_flag to post).
690 pub fn block_add(&self) -> ContentBlockAddCall<'a, S> {
691 ContentBlockAddCall {
692 hub: self.hub,
693 _token: Default::default(),
694 _id: Default::default(),
695 _client_key: Default::default(),
696 _delegate: Default::default(),
697 _additional_params: Default::default(),
698 }
699 }
700
701 /// Create a builder to help you perform the following task:
702 ///
703 /// List content blocks (list all posts blocked by partner).
704 pub fn block_list(&self) -> ContentBlockListCall<'a, S> {
705 ContentBlockListCall {
706 hub: self.hub,
707 _token: Default::default(),
708 _pos: Default::default(),
709 _limit: Default::default(),
710 _client_key: Default::default(),
711 _delegate: Default::default(),
712 _additional_params: Default::default(),
713 }
714 }
715
716 /// Create a builder to help you perform the following task:
717 ///
718 /// Remove content block (remove partner_block_flag from post).
719 pub fn block_remove(&self) -> ContentBlockRemoveCall<'a, S> {
720 ContentBlockRemoveCall {
721 hub: self.hub,
722 _token: Default::default(),
723 _id: Default::default(),
724 _client_key: Default::default(),
725 _delegate: Default::default(),
726 _additional_params: Default::default(),
727 }
728 }
729}
730
731
732
733/// A builder providing access to all methods supported on *post* resources.
734/// It is not used directly, but through the [`Tenor`] hub.
735///
736/// # Example
737///
738/// Instantiate a resource builder
739///
740/// ```test_harness,no_run
741/// extern crate hyper;
742/// extern crate hyper_rustls;
743/// extern crate google_tenor2 as tenor2;
744///
745/// # async fn dox() {
746/// use std::default::Default;
747/// use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
748///
749/// let secret: oauth2::ApplicationSecret = Default::default();
750/// let auth = oauth2::InstalledFlowAuthenticator::builder(
751/// secret,
752/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
753/// ).build().await.unwrap();
754/// let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
755/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
756/// // like `list(...)`
757/// // to build up your call.
758/// let rb = hub.posts();
759/// # }
760/// ```
761pub struct PostMethods<'a, S>
762 where S: 'a {
763
764 hub: &'a Tenor<S>,
765}
766
767impl<'a, S> client::MethodsBuilder for PostMethods<'a, S> {}
768
769impl<'a, S> PostMethods<'a, S> {
770
771 /// Create a builder to help you perform the following task:
772 ///
773 /// Get a list of posts by IDs.
774 pub fn list(&self) -> PostListCall<'a, S> {
775 PostListCall {
776 hub: self.hub,
777 _media_filter: Default::default(),
778 _locale: Default::default(),
779 _ids: Default::default(),
780 _country: Default::default(),
781 _component: Default::default(),
782 _client_key: Default::default(),
783 _appversion: Default::default(),
784 _anon_id: Default::default(),
785 _delegate: Default::default(),
786 _additional_params: Default::default(),
787 }
788 }
789}
790
791
792
793/// A builder providing access to all free methods, which are not associated with a particular resource.
794/// It is not used directly, but through the [`Tenor`] hub.
795///
796/// # Example
797///
798/// Instantiate a resource builder
799///
800/// ```test_harness,no_run
801/// extern crate hyper;
802/// extern crate hyper_rustls;
803/// extern crate google_tenor2 as tenor2;
804///
805/// # async fn dox() {
806/// use std::default::Default;
807/// use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
808///
809/// let secret: oauth2::ApplicationSecret = Default::default();
810/// let auth = oauth2::InstalledFlowAuthenticator::builder(
811/// secret,
812/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
813/// ).build().await.unwrap();
814/// let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
815/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
816/// // like `anonid(...)`, `autocomplete(...)`, `categories(...)`, `featured(...)`, `registershare(...)`, `render_caption(...)`, `search(...)`, `search_suggestions(...)` and `trending_terms(...)`
817/// // to build up your call.
818/// let rb = hub.methods();
819/// # }
820/// ```
821pub struct MethodMethods<'a, S>
822 where S: 'a {
823
824 hub: &'a Tenor<S>,
825}
826
827impl<'a, S> client::MethodsBuilder for MethodMethods<'a, S> {}
828
829impl<'a, S> MethodMethods<'a, S> {
830
831 /// Create a builder to help you perform the following task:
832 ///
833 /// Request anonymous ID for a new user.
834 ///
835 /// # Arguments
836 ///
837 /// * `request` - No description provided.
838 pub fn anonid(&self, request: GoogleSearchTenorV2AnonIdRequest) -> MethodAnonidCall<'a, S> {
839 MethodAnonidCall {
840 hub: self.hub,
841 _request: request,
842 _delegate: Default::default(),
843 _additional_params: Default::default(),
844 }
845 }
846
847 /// Create a builder to help you perform the following task:
848 ///
849 /// Complete a partial input query.
850 pub fn autocomplete(&self) -> MethodAutocompleteCall<'a, S> {
851 MethodAutocompleteCall {
852 hub: self.hub,
853 _q: Default::default(),
854 _locale: Default::default(),
855 _limit: Default::default(),
856 _country: Default::default(),
857 _component: Default::default(),
858 _client_key: Default::default(),
859 _appversion: Default::default(),
860 _anon_id: Default::default(),
861 _delegate: Default::default(),
862 _additional_params: Default::default(),
863 }
864 }
865
866 /// Create a builder to help you perform the following task:
867 ///
868 /// Categories.
869 pub fn categories(&self) -> MethodCategoryCall<'a, S> {
870 MethodCategoryCall {
871 hub: self.hub,
872 _type_: Default::default(),
873 _searchfilter: Default::default(),
874 _locale: Default::default(),
875 _country: Default::default(),
876 _contentfilter: Default::default(),
877 _component: Default::default(),
878 _client_key: Default::default(),
879 _appversion: Default::default(),
880 _anon_id: Default::default(),
881 _delegate: Default::default(),
882 _additional_params: Default::default(),
883 }
884 }
885
886 /// Create a builder to help you perform the following task:
887 ///
888 /// Featured Posts.
889 pub fn featured(&self) -> MethodFeaturedCall<'a, S> {
890 MethodFeaturedCall {
891 hub: self.hub,
892 _searchfilter: Default::default(),
893 _q: Default::default(),
894 _pos: Default::default(),
895 _media_filter: Default::default(),
896 _locale: Default::default(),
897 _limit: Default::default(),
898 _country: Default::default(),
899 _contentfilter: Default::default(),
900 _component: Default::default(),
901 _collection: Default::default(),
902 _client_key: Default::default(),
903 _ar_range: Default::default(),
904 _appversion: Default::default(),
905 _anon_id: Default::default(),
906 _delegate: Default::default(),
907 _additional_params: Default::default(),
908 }
909 }
910
911 /// Create a builder to help you perform the following task:
912 ///
913 /// Register share.
914 ///
915 /// # Arguments
916 ///
917 /// * `request` - No description provided.
918 pub fn registershare(&self, request: GoogleSearchTenorV2RegisterShareRequest) -> MethodRegistershareCall<'a, S> {
919 MethodRegistershareCall {
920 hub: self.hub,
921 _request: request,
922 _delegate: Default::default(),
923 _additional_params: Default::default(),
924 }
925 }
926
927 /// Create a builder to help you perform the following task:
928 ///
929 /// Get a post with the provided caption rendered.
930 pub fn render_caption(&self) -> MethodRenderCaptionCall<'a, S> {
931 MethodRenderCaptionCall {
932 hub: self.hub,
933 _width: Default::default(),
934 _top_percent: Default::default(),
935 _right_percent: Default::default(),
936 _locale: Default::default(),
937 _left_percent: Default::default(),
938 _id: Default::default(),
939 _height: Default::default(),
940 _format: Default::default(),
941 _country: Default::default(),
942 _component: Default::default(),
943 _client_key: Default::default(),
944 _caption: Default::default(),
945 _bottom_percent: Default::default(),
946 _appversion: Default::default(),
947 _anon_id: Default::default(),
948 _delegate: Default::default(),
949 _additional_params: Default::default(),
950 }
951 }
952
953 /// Create a builder to help you perform the following task:
954 ///
955 /// Searches for posts (i.e., GIFs).
956 pub fn search(&self) -> MethodSearchCall<'a, S> {
957 MethodSearchCall {
958 hub: self.hub,
959 _searchfilter: Default::default(),
960 _random: Default::default(),
961 _q: Default::default(),
962 _pos: Default::default(),
963 _media_filter: Default::default(),
964 _locale: Default::default(),
965 _limit: Default::default(),
966 _country: Default::default(),
967 _contentfilter: Default::default(),
968 _component: Default::default(),
969 _client_key: Default::default(),
970 _ar_range: Default::default(),
971 _appversion: Default::default(),
972 _anon_id: Default::default(),
973 _delegate: Default::default(),
974 _additional_params: Default::default(),
975 }
976 }
977
978 /// Create a builder to help you perform the following task:
979 ///
980 /// Search Suggestions.
981 pub fn search_suggestions(&self) -> MethodSearchSuggestionCall<'a, S> {
982 MethodSearchSuggestionCall {
983 hub: self.hub,
984 _q: Default::default(),
985 _locale: Default::default(),
986 _limit: Default::default(),
987 _country: Default::default(),
988 _component: Default::default(),
989 _client_key: Default::default(),
990 _appversion: Default::default(),
991 _anon_id: Default::default(),
992 _delegate: Default::default(),
993 _additional_params: Default::default(),
994 }
995 }
996
997 /// Create a builder to help you perform the following task:
998 ///
999 /// Trending terms.
1000 pub fn trending_terms(&self) -> MethodTrendingTermCall<'a, S> {
1001 MethodTrendingTermCall {
1002 hub: self.hub,
1003 _locale: Default::default(),
1004 _limit: Default::default(),
1005 _country: Default::default(),
1006 _component: Default::default(),
1007 _client_key: Default::default(),
1008 _appversion: Default::default(),
1009 _anon_id: Default::default(),
1010 _delegate: Default::default(),
1011 _additional_params: Default::default(),
1012 }
1013 }
1014}
1015
1016
1017
1018
1019
1020// ###################
1021// CallBuilders ###
1022// #################
1023
1024/// Add content block (add partner_block_flag to post).
1025///
1026/// A builder for the *block.add* method supported by a *content* resource.
1027/// It is not used directly, but through a [`ContentMethods`] instance.
1028///
1029/// # Example
1030///
1031/// Instantiate a resource method builder
1032///
1033/// ```test_harness,no_run
1034/// # extern crate hyper;
1035/// # extern crate hyper_rustls;
1036/// # extern crate google_tenor2 as tenor2;
1037/// # async fn dox() {
1038/// # use std::default::Default;
1039/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1040/// #
1041/// # let secret: oauth2::ApplicationSecret = Default::default();
1042/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1043/// # secret,
1044/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1045/// # ).build().await.unwrap();
1046/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
1047/// // You can configure optional parameters by calling the respective setters at will, and
1048/// // execute the final call using `doit()`.
1049/// // Values shown here are possibly random and not representative !
1050/// let result = hub.content().block_add()
1051/// .token("et")
1052/// .id(68)
1053/// .client_key("no")
1054/// .doit().await;
1055/// # }
1056/// ```
1057pub struct ContentBlockAddCall<'a, S>
1058 where S: 'a {
1059
1060 hub: &'a Tenor<S>,
1061 _token: Option<String>,
1062 _id: Option<u64>,
1063 _client_key: Option<String>,
1064 _delegate: Option<&'a mut dyn client::Delegate>,
1065 _additional_params: HashMap<String, String>,
1066}
1067
1068impl<'a, S> client::CallBuilder for ContentBlockAddCall<'a, S> {}
1069
1070impl<'a, S> ContentBlockAddCall<'a, S>
1071where
1072 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1073 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1074 S::Future: Send + Unpin + 'static,
1075 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1076{
1077
1078
1079 /// Perform the operation you have build so far.
1080 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2AddContentBlockResponse)> {
1081 use std::io::{Read, Seek};
1082 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1083 use client::{ToParts, url::Params};
1084 use std::borrow::Cow;
1085
1086 let mut dd = client::DefaultDelegate;
1087 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1088 dlg.begin(client::MethodInfo { id: "tenor.content.block.add",
1089 http_method: hyper::Method::GET });
1090
1091 for &field in ["alt", "token", "id", "clientKey"].iter() {
1092 if self._additional_params.contains_key(field) {
1093 dlg.finished(false);
1094 return Err(client::Error::FieldClash(field));
1095 }
1096 }
1097
1098 let mut params = Params::with_capacity(5 + self._additional_params.len());
1099 if let Some(value) = self._token.as_ref() {
1100 params.push("token", value);
1101 }
1102 if let Some(value) = self._id.as_ref() {
1103 params.push("id", value.to_string());
1104 }
1105 if let Some(value) = self._client_key.as_ref() {
1106 params.push("clientKey", value);
1107 }
1108
1109 params.extend(self._additional_params.iter());
1110
1111 params.push("alt", "json");
1112 let mut url = self.hub._base_url.clone() + "v2/content/block/add";
1113
1114 match dlg.api_key() {
1115 Some(value) => params.push("key", value),
1116 None => {
1117 dlg.finished(false);
1118 return Err(client::Error::MissingAPIKey)
1119 }
1120 }
1121
1122
1123 let url = params.parse_with_url(&url);
1124
1125
1126
1127 loop {
1128 let mut req_result = {
1129 let client = &self.hub.client;
1130 dlg.pre_request();
1131 let mut req_builder = hyper::Request::builder()
1132 .method(hyper::Method::GET)
1133 .uri(url.as_str())
1134 .header(USER_AGENT, self.hub._user_agent.clone());
1135
1136
1137
1138 let request = req_builder
1139 .header(CONTENT_LENGTH, 0_u64)
1140 .body(hyper::body::Body::empty());
1141
1142 client.request(request.unwrap()).await
1143
1144 };
1145
1146 match req_result {
1147 Err(err) => {
1148 if let client::Retry::After(d) = dlg.http_error(&err) {
1149 sleep(d).await;
1150 continue;
1151 }
1152 dlg.finished(false);
1153 return Err(client::Error::HttpError(err))
1154 }
1155 Ok(mut res) => {
1156 if !res.status().is_success() {
1157 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1158 let (parts, _) = res.into_parts();
1159 let body = hyper::Body::from(res_body_string.clone());
1160 let restored_response = hyper::Response::from_parts(parts, body);
1161
1162 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1163
1164 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1165 sleep(d).await;
1166 continue;
1167 }
1168
1169 dlg.finished(false);
1170
1171 return match server_response {
1172 Some(error_value) => Err(client::Error::BadRequest(error_value)),
1173 None => Err(client::Error::Failure(restored_response)),
1174 }
1175 }
1176 let result_value = {
1177 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1178
1179 match json::from_str(&res_body_string) {
1180 Ok(decoded) => (res, decoded),
1181 Err(err) => {
1182 dlg.response_json_decode_error(&res_body_string, &err);
1183 return Err(client::Error::JsonDecodeError(res_body_string, err));
1184 }
1185 }
1186 };
1187
1188 dlg.finished(true);
1189 return Ok(result_value)
1190 }
1191 }
1192 }
1193 }
1194
1195
1196 /// Access token to validate partner access. Required.
1197 ///
1198 /// Sets the *token* query property to the given value.
1199 pub fn token(mut self, new_value: &str) -> ContentBlockAddCall<'a, S> {
1200 self._token = Some(new_value.to_string());
1201 self
1202 }
1203 /// Post ID (pid) of the post to apply partner_block_flag(s) to. Required.
1204 ///
1205 /// Sets the *id* query property to the given value.
1206 pub fn id(mut self, new_value: u64) -> ContentBlockAddCall<'a, S> {
1207 self._id = Some(new_value);
1208 self
1209 }
1210 /// Client application identifier, e.g., "gboard". Required.
1211 ///
1212 /// Sets the *client key* query property to the given value.
1213 pub fn client_key(mut self, new_value: &str) -> ContentBlockAddCall<'a, S> {
1214 self._client_key = Some(new_value.to_string());
1215 self
1216 }
1217 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1218 /// while executing the actual API request.
1219 ///
1220 /// ````text
1221 /// It should be used to handle progress information, and to implement a certain level of resilience.
1222 /// ````
1223 ///
1224 /// Sets the *delegate* property to the given value.
1225 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentBlockAddCall<'a, S> {
1226 self._delegate = Some(new_value);
1227 self
1228 }
1229
1230 /// Set any additional parameter of the query string used in the request.
1231 /// It should be used to set parameters which are not yet available through their own
1232 /// setters.
1233 ///
1234 /// Please note that this method must not be used to set any of the known parameters
1235 /// which have their own setter method. If done anyway, the request will fail.
1236 ///
1237 /// # Additional Parameters
1238 ///
1239 /// * *$.xgafv* (query-string) - V1 error format.
1240 /// * *access_token* (query-string) - OAuth access token.
1241 /// * *alt* (query-string) - Data format for response.
1242 /// * *callback* (query-string) - JSONP
1243 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1244 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1245 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1246 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1247 /// * *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.
1248 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1249 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1250 pub fn param<T>(mut self, name: T, value: T) -> ContentBlockAddCall<'a, S>
1251 where T: AsRef<str> {
1252 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1253 self
1254 }
1255
1256}
1257
1258
1259/// List content blocks (list all posts blocked by partner).
1260///
1261/// A builder for the *block.list* method supported by a *content* resource.
1262/// It is not used directly, but through a [`ContentMethods`] instance.
1263///
1264/// # Example
1265///
1266/// Instantiate a resource method builder
1267///
1268/// ```test_harness,no_run
1269/// # extern crate hyper;
1270/// # extern crate hyper_rustls;
1271/// # extern crate google_tenor2 as tenor2;
1272/// # async fn dox() {
1273/// # use std::default::Default;
1274/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1275/// #
1276/// # let secret: oauth2::ApplicationSecret = Default::default();
1277/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1278/// # secret,
1279/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1280/// # ).build().await.unwrap();
1281/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
1282/// // You can configure optional parameters by calling the respective setters at will, and
1283/// // execute the final call using `doit()`.
1284/// // Values shown here are possibly random and not representative !
1285/// let result = hub.content().block_list()
1286/// .token("ipsum")
1287/// .pos("voluptua.")
1288/// .limit(-27)
1289/// .client_key("sanctus")
1290/// .doit().await;
1291/// # }
1292/// ```
1293pub struct ContentBlockListCall<'a, S>
1294 where S: 'a {
1295
1296 hub: &'a Tenor<S>,
1297 _token: Option<String>,
1298 _pos: Option<String>,
1299 _limit: Option<i32>,
1300 _client_key: Option<String>,
1301 _delegate: Option<&'a mut dyn client::Delegate>,
1302 _additional_params: HashMap<String, String>,
1303}
1304
1305impl<'a, S> client::CallBuilder for ContentBlockListCall<'a, S> {}
1306
1307impl<'a, S> ContentBlockListCall<'a, S>
1308where
1309 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1310 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1311 S::Future: Send + Unpin + 'static,
1312 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1313{
1314
1315
1316 /// Perform the operation you have build so far.
1317 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2ContentBlocksResponse)> {
1318 use std::io::{Read, Seek};
1319 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1320 use client::{ToParts, url::Params};
1321 use std::borrow::Cow;
1322
1323 let mut dd = client::DefaultDelegate;
1324 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1325 dlg.begin(client::MethodInfo { id: "tenor.content.block.list",
1326 http_method: hyper::Method::GET });
1327
1328 for &field in ["alt", "token", "pos", "limit", "clientKey"].iter() {
1329 if self._additional_params.contains_key(field) {
1330 dlg.finished(false);
1331 return Err(client::Error::FieldClash(field));
1332 }
1333 }
1334
1335 let mut params = Params::with_capacity(6 + self._additional_params.len());
1336 if let Some(value) = self._token.as_ref() {
1337 params.push("token", value);
1338 }
1339 if let Some(value) = self._pos.as_ref() {
1340 params.push("pos", value);
1341 }
1342 if let Some(value) = self._limit.as_ref() {
1343 params.push("limit", value.to_string());
1344 }
1345 if let Some(value) = self._client_key.as_ref() {
1346 params.push("clientKey", value);
1347 }
1348
1349 params.extend(self._additional_params.iter());
1350
1351 params.push("alt", "json");
1352 let mut url = self.hub._base_url.clone() + "v2/content/block/list";
1353
1354 match dlg.api_key() {
1355 Some(value) => params.push("key", value),
1356 None => {
1357 dlg.finished(false);
1358 return Err(client::Error::MissingAPIKey)
1359 }
1360 }
1361
1362
1363 let url = params.parse_with_url(&url);
1364
1365
1366
1367 loop {
1368 let mut req_result = {
1369 let client = &self.hub.client;
1370 dlg.pre_request();
1371 let mut req_builder = hyper::Request::builder()
1372 .method(hyper::Method::GET)
1373 .uri(url.as_str())
1374 .header(USER_AGENT, self.hub._user_agent.clone());
1375
1376
1377
1378 let request = req_builder
1379 .header(CONTENT_LENGTH, 0_u64)
1380 .body(hyper::body::Body::empty());
1381
1382 client.request(request.unwrap()).await
1383
1384 };
1385
1386 match req_result {
1387 Err(err) => {
1388 if let client::Retry::After(d) = dlg.http_error(&err) {
1389 sleep(d).await;
1390 continue;
1391 }
1392 dlg.finished(false);
1393 return Err(client::Error::HttpError(err))
1394 }
1395 Ok(mut res) => {
1396 if !res.status().is_success() {
1397 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1398 let (parts, _) = res.into_parts();
1399 let body = hyper::Body::from(res_body_string.clone());
1400 let restored_response = hyper::Response::from_parts(parts, body);
1401
1402 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1403
1404 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1405 sleep(d).await;
1406 continue;
1407 }
1408
1409 dlg.finished(false);
1410
1411 return match server_response {
1412 Some(error_value) => Err(client::Error::BadRequest(error_value)),
1413 None => Err(client::Error::Failure(restored_response)),
1414 }
1415 }
1416 let result_value = {
1417 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1418
1419 match json::from_str(&res_body_string) {
1420 Ok(decoded) => (res, decoded),
1421 Err(err) => {
1422 dlg.response_json_decode_error(&res_body_string, &err);
1423 return Err(client::Error::JsonDecodeError(res_body_string, err));
1424 }
1425 }
1426 };
1427
1428 dlg.finished(true);
1429 return Ok(result_value)
1430 }
1431 }
1432 }
1433 }
1434
1435
1436 /// Access token to validate partner access.
1437 ///
1438 /// Sets the *token* query property to the given value.
1439 pub fn token(mut self, new_value: &str) -> ContentBlockListCall<'a, S> {
1440 self._token = Some(new_value.to_string());
1441 self
1442 }
1443 /// 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.
1444 ///
1445 /// Sets the *pos* query property to the given value.
1446 pub fn pos(mut self, new_value: &str) -> ContentBlockListCall<'a, S> {
1447 self._pos = Some(new_value.to_string());
1448 self
1449 }
1450 /// The maximum number of results to be returned. The default is 20.
1451 ///
1452 /// Sets the *limit* query property to the given value.
1453 pub fn limit(mut self, new_value: i32) -> ContentBlockListCall<'a, S> {
1454 self._limit = Some(new_value);
1455 self
1456 }
1457 /// Client application identifier, e.g., "gboard".
1458 ///
1459 /// Sets the *client key* query property to the given value.
1460 pub fn client_key(mut self, new_value: &str) -> ContentBlockListCall<'a, S> {
1461 self._client_key = Some(new_value.to_string());
1462 self
1463 }
1464 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1465 /// while executing the actual API request.
1466 ///
1467 /// ````text
1468 /// It should be used to handle progress information, and to implement a certain level of resilience.
1469 /// ````
1470 ///
1471 /// Sets the *delegate* property to the given value.
1472 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentBlockListCall<'a, S> {
1473 self._delegate = Some(new_value);
1474 self
1475 }
1476
1477 /// Set any additional parameter of the query string used in the request.
1478 /// It should be used to set parameters which are not yet available through their own
1479 /// setters.
1480 ///
1481 /// Please note that this method must not be used to set any of the known parameters
1482 /// which have their own setter method. If done anyway, the request will fail.
1483 ///
1484 /// # Additional Parameters
1485 ///
1486 /// * *$.xgafv* (query-string) - V1 error format.
1487 /// * *access_token* (query-string) - OAuth access token.
1488 /// * *alt* (query-string) - Data format for response.
1489 /// * *callback* (query-string) - JSONP
1490 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1491 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1492 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1493 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1494 /// * *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.
1495 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1496 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1497 pub fn param<T>(mut self, name: T, value: T) -> ContentBlockListCall<'a, S>
1498 where T: AsRef<str> {
1499 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1500 self
1501 }
1502
1503}
1504
1505
1506/// Remove content block (remove partner_block_flag from post).
1507///
1508/// A builder for the *block.remove* method supported by a *content* resource.
1509/// It is not used directly, but through a [`ContentMethods`] instance.
1510///
1511/// # Example
1512///
1513/// Instantiate a resource method builder
1514///
1515/// ```test_harness,no_run
1516/// # extern crate hyper;
1517/// # extern crate hyper_rustls;
1518/// # extern crate google_tenor2 as tenor2;
1519/// # async fn dox() {
1520/// # use std::default::Default;
1521/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1522/// #
1523/// # let secret: oauth2::ApplicationSecret = Default::default();
1524/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1525/// # secret,
1526/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1527/// # ).build().await.unwrap();
1528/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
1529/// // You can configure optional parameters by calling the respective setters at will, and
1530/// // execute the final call using `doit()`.
1531/// // Values shown here are possibly random and not representative !
1532/// let result = hub.content().block_remove()
1533/// .token("sed")
1534/// .id(99)
1535/// .client_key("takimata")
1536/// .doit().await;
1537/// # }
1538/// ```
1539pub struct ContentBlockRemoveCall<'a, S>
1540 where S: 'a {
1541
1542 hub: &'a Tenor<S>,
1543 _token: Option<String>,
1544 _id: Option<u64>,
1545 _client_key: Option<String>,
1546 _delegate: Option<&'a mut dyn client::Delegate>,
1547 _additional_params: HashMap<String, String>,
1548}
1549
1550impl<'a, S> client::CallBuilder for ContentBlockRemoveCall<'a, S> {}
1551
1552impl<'a, S> ContentBlockRemoveCall<'a, S>
1553where
1554 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1555 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1556 S::Future: Send + Unpin + 'static,
1557 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1558{
1559
1560
1561 /// Perform the operation you have build so far.
1562 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2RemoveContentBlockResponse)> {
1563 use std::io::{Read, Seek};
1564 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1565 use client::{ToParts, url::Params};
1566 use std::borrow::Cow;
1567
1568 let mut dd = client::DefaultDelegate;
1569 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1570 dlg.begin(client::MethodInfo { id: "tenor.content.block.remove",
1571 http_method: hyper::Method::GET });
1572
1573 for &field in ["alt", "token", "id", "clientKey"].iter() {
1574 if self._additional_params.contains_key(field) {
1575 dlg.finished(false);
1576 return Err(client::Error::FieldClash(field));
1577 }
1578 }
1579
1580 let mut params = Params::with_capacity(5 + self._additional_params.len());
1581 if let Some(value) = self._token.as_ref() {
1582 params.push("token", value);
1583 }
1584 if let Some(value) = self._id.as_ref() {
1585 params.push("id", value.to_string());
1586 }
1587 if let Some(value) = self._client_key.as_ref() {
1588 params.push("clientKey", value);
1589 }
1590
1591 params.extend(self._additional_params.iter());
1592
1593 params.push("alt", "json");
1594 let mut url = self.hub._base_url.clone() + "v2/content/block/remove";
1595
1596 match dlg.api_key() {
1597 Some(value) => params.push("key", value),
1598 None => {
1599 dlg.finished(false);
1600 return Err(client::Error::MissingAPIKey)
1601 }
1602 }
1603
1604
1605 let url = params.parse_with_url(&url);
1606
1607
1608
1609 loop {
1610 let mut req_result = {
1611 let client = &self.hub.client;
1612 dlg.pre_request();
1613 let mut req_builder = hyper::Request::builder()
1614 .method(hyper::Method::GET)
1615 .uri(url.as_str())
1616 .header(USER_AGENT, self.hub._user_agent.clone());
1617
1618
1619
1620 let request = req_builder
1621 .header(CONTENT_LENGTH, 0_u64)
1622 .body(hyper::body::Body::empty());
1623
1624 client.request(request.unwrap()).await
1625
1626 };
1627
1628 match req_result {
1629 Err(err) => {
1630 if let client::Retry::After(d) = dlg.http_error(&err) {
1631 sleep(d).await;
1632 continue;
1633 }
1634 dlg.finished(false);
1635 return Err(client::Error::HttpError(err))
1636 }
1637 Ok(mut res) => {
1638 if !res.status().is_success() {
1639 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1640 let (parts, _) = res.into_parts();
1641 let body = hyper::Body::from(res_body_string.clone());
1642 let restored_response = hyper::Response::from_parts(parts, body);
1643
1644 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1645
1646 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1647 sleep(d).await;
1648 continue;
1649 }
1650
1651 dlg.finished(false);
1652
1653 return match server_response {
1654 Some(error_value) => Err(client::Error::BadRequest(error_value)),
1655 None => Err(client::Error::Failure(restored_response)),
1656 }
1657 }
1658 let result_value = {
1659 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1660
1661 match json::from_str(&res_body_string) {
1662 Ok(decoded) => (res, decoded),
1663 Err(err) => {
1664 dlg.response_json_decode_error(&res_body_string, &err);
1665 return Err(client::Error::JsonDecodeError(res_body_string, err));
1666 }
1667 }
1668 };
1669
1670 dlg.finished(true);
1671 return Ok(result_value)
1672 }
1673 }
1674 }
1675 }
1676
1677
1678 /// Access token to validate partner access. Required.
1679 ///
1680 /// Sets the *token* query property to the given value.
1681 pub fn token(mut self, new_value: &str) -> ContentBlockRemoveCall<'a, S> {
1682 self._token = Some(new_value.to_string());
1683 self
1684 }
1685 /// Post ID (pid) of the post to remove partner_block_flag(s) from. Required.
1686 ///
1687 /// Sets the *id* query property to the given value.
1688 pub fn id(mut self, new_value: u64) -> ContentBlockRemoveCall<'a, S> {
1689 self._id = Some(new_value);
1690 self
1691 }
1692 /// Client application identifier, e.g., "gboard". Required.
1693 ///
1694 /// Sets the *client key* query property to the given value.
1695 pub fn client_key(mut self, new_value: &str) -> ContentBlockRemoveCall<'a, S> {
1696 self._client_key = Some(new_value.to_string());
1697 self
1698 }
1699 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1700 /// while executing the actual API request.
1701 ///
1702 /// ````text
1703 /// It should be used to handle progress information, and to implement a certain level of resilience.
1704 /// ````
1705 ///
1706 /// Sets the *delegate* property to the given value.
1707 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentBlockRemoveCall<'a, S> {
1708 self._delegate = Some(new_value);
1709 self
1710 }
1711
1712 /// Set any additional parameter of the query string used in the request.
1713 /// It should be used to set parameters which are not yet available through their own
1714 /// setters.
1715 ///
1716 /// Please note that this method must not be used to set any of the known parameters
1717 /// which have their own setter method. If done anyway, the request will fail.
1718 ///
1719 /// # Additional Parameters
1720 ///
1721 /// * *$.xgafv* (query-string) - V1 error format.
1722 /// * *access_token* (query-string) - OAuth access token.
1723 /// * *alt* (query-string) - Data format for response.
1724 /// * *callback* (query-string) - JSONP
1725 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1726 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1727 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1728 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1729 /// * *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.
1730 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1731 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1732 pub fn param<T>(mut self, name: T, value: T) -> ContentBlockRemoveCall<'a, S>
1733 where T: AsRef<str> {
1734 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1735 self
1736 }
1737
1738}
1739
1740
1741/// Get a list of posts by IDs.
1742///
1743/// A builder for the *list* method supported by a *post* resource.
1744/// It is not used directly, but through a [`PostMethods`] instance.
1745///
1746/// # Example
1747///
1748/// Instantiate a resource method builder
1749///
1750/// ```test_harness,no_run
1751/// # extern crate hyper;
1752/// # extern crate hyper_rustls;
1753/// # extern crate google_tenor2 as tenor2;
1754/// # async fn dox() {
1755/// # use std::default::Default;
1756/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1757/// #
1758/// # let secret: oauth2::ApplicationSecret = Default::default();
1759/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1760/// # secret,
1761/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1762/// # ).build().await.unwrap();
1763/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
1764/// // You can configure optional parameters by calling the respective setters at will, and
1765/// // execute the final call using `doit()`.
1766/// // Values shown here are possibly random and not representative !
1767/// let result = hub.posts().list()
1768/// .media_filter("amet.")
1769/// .locale("duo")
1770/// .ids("ipsum")
1771/// .country("gubergren")
1772/// .component("Lorem")
1773/// .client_key("gubergren")
1774/// .appversion("eos")
1775/// .anon_id("dolor")
1776/// .doit().await;
1777/// # }
1778/// ```
1779pub struct PostListCall<'a, S>
1780 where S: 'a {
1781
1782 hub: &'a Tenor<S>,
1783 _media_filter: Option<String>,
1784 _locale: Option<String>,
1785 _ids: Option<String>,
1786 _country: Option<String>,
1787 _component: Option<String>,
1788 _client_key: Option<String>,
1789 _appversion: Option<String>,
1790 _anon_id: Option<String>,
1791 _delegate: Option<&'a mut dyn client::Delegate>,
1792 _additional_params: HashMap<String, String>,
1793}
1794
1795impl<'a, S> client::CallBuilder for PostListCall<'a, S> {}
1796
1797impl<'a, S> PostListCall<'a, S>
1798where
1799 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1800 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1801 S::Future: Send + Unpin + 'static,
1802 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1803{
1804
1805
1806 /// Perform the operation you have build so far.
1807 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2ListPostsResponse)> {
1808 use std::io::{Read, Seek};
1809 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1810 use client::{ToParts, url::Params};
1811 use std::borrow::Cow;
1812
1813 let mut dd = client::DefaultDelegate;
1814 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1815 dlg.begin(client::MethodInfo { id: "tenor.posts.list",
1816 http_method: hyper::Method::GET });
1817
1818 for &field in ["alt", "mediaFilter", "locale", "ids", "country", "component", "clientKey", "appversion", "anonId"].iter() {
1819 if self._additional_params.contains_key(field) {
1820 dlg.finished(false);
1821 return Err(client::Error::FieldClash(field));
1822 }
1823 }
1824
1825 let mut params = Params::with_capacity(10 + self._additional_params.len());
1826 if let Some(value) = self._media_filter.as_ref() {
1827 params.push("mediaFilter", value);
1828 }
1829 if let Some(value) = self._locale.as_ref() {
1830 params.push("locale", value);
1831 }
1832 if let Some(value) = self._ids.as_ref() {
1833 params.push("ids", value);
1834 }
1835 if let Some(value) = self._country.as_ref() {
1836 params.push("country", value);
1837 }
1838 if let Some(value) = self._component.as_ref() {
1839 params.push("component", value);
1840 }
1841 if let Some(value) = self._client_key.as_ref() {
1842 params.push("clientKey", value);
1843 }
1844 if let Some(value) = self._appversion.as_ref() {
1845 params.push("appversion", value);
1846 }
1847 if let Some(value) = self._anon_id.as_ref() {
1848 params.push("anonId", value);
1849 }
1850
1851 params.extend(self._additional_params.iter());
1852
1853 params.push("alt", "json");
1854 let mut url = self.hub._base_url.clone() + "v2/posts";
1855
1856 match dlg.api_key() {
1857 Some(value) => params.push("key", value),
1858 None => {
1859 dlg.finished(false);
1860 return Err(client::Error::MissingAPIKey)
1861 }
1862 }
1863
1864
1865 let url = params.parse_with_url(&url);
1866
1867
1868
1869 loop {
1870 let mut req_result = {
1871 let client = &self.hub.client;
1872 dlg.pre_request();
1873 let mut req_builder = hyper::Request::builder()
1874 .method(hyper::Method::GET)
1875 .uri(url.as_str())
1876 .header(USER_AGENT, self.hub._user_agent.clone());
1877
1878
1879
1880 let request = req_builder
1881 .header(CONTENT_LENGTH, 0_u64)
1882 .body(hyper::body::Body::empty());
1883
1884 client.request(request.unwrap()).await
1885
1886 };
1887
1888 match req_result {
1889 Err(err) => {
1890 if let client::Retry::After(d) = dlg.http_error(&err) {
1891 sleep(d).await;
1892 continue;
1893 }
1894 dlg.finished(false);
1895 return Err(client::Error::HttpError(err))
1896 }
1897 Ok(mut res) => {
1898 if !res.status().is_success() {
1899 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1900 let (parts, _) = res.into_parts();
1901 let body = hyper::Body::from(res_body_string.clone());
1902 let restored_response = hyper::Response::from_parts(parts, body);
1903
1904 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1905
1906 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1907 sleep(d).await;
1908 continue;
1909 }
1910
1911 dlg.finished(false);
1912
1913 return match server_response {
1914 Some(error_value) => Err(client::Error::BadRequest(error_value)),
1915 None => Err(client::Error::Failure(restored_response)),
1916 }
1917 }
1918 let result_value = {
1919 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1920
1921 match json::from_str(&res_body_string) {
1922 Ok(decoded) => (res, decoded),
1923 Err(err) => {
1924 dlg.response_json_decode_error(&res_body_string, &err);
1925 return Err(client::Error::JsonDecodeError(res_body_string, err));
1926 }
1927 }
1928 };
1929
1930 dlg.finished(true);
1931 return Ok(result_value)
1932 }
1933 }
1934 }
1935 }
1936
1937
1938 /// 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.
1939 ///
1940 /// Sets the *media filter* query property to the given value.
1941 pub fn media_filter(mut self, new_value: &str) -> PostListCall<'a, S> {
1942 self._media_filter = Some(new_value.to_string());
1943 self
1944 }
1945 /// 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.
1946 ///
1947 /// Sets the *locale* query property to the given value.
1948 pub fn locale(mut self, new_value: &str) -> PostListCall<'a, S> {
1949 self._locale = Some(new_value.to_string());
1950 self
1951 }
1952 /// 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.
1953 ///
1954 /// Sets the *ids* query property to the given value.
1955 pub fn ids(mut self, new_value: &str) -> PostListCall<'a, S> {
1956 self._ids = Some(new_value.to_string());
1957 self
1958 }
1959 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
1960 ///
1961 /// Sets the *country* query property to the given value.
1962 pub fn country(mut self, new_value: &str) -> PostListCall<'a, S> {
1963 self._country = Some(new_value.to_string());
1964 self
1965 }
1966 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
1967 ///
1968 /// Sets the *component* query property to the given value.
1969 pub fn component(mut self, new_value: &str) -> PostListCall<'a, S> {
1970 self._component = Some(new_value.to_string());
1971 self
1972 }
1973 /// Client application identifier, e.g., "gboard".
1974 ///
1975 /// Sets the *client key* query property to the given value.
1976 pub fn client_key(mut self, new_value: &str) -> PostListCall<'a, S> {
1977 self._client_key = Some(new_value.to_string());
1978 self
1979 }
1980 /// Client application version, e.g., "3.1".
1981 ///
1982 /// Sets the *appversion* query property to the given value.
1983 pub fn appversion(mut self, new_value: &str) -> PostListCall<'a, S> {
1984 self._appversion = Some(new_value.to_string());
1985 self
1986 }
1987 /// Pseudonymous user id tied to the user.
1988 ///
1989 /// Sets the *anon id* query property to the given value.
1990 pub fn anon_id(mut self, new_value: &str) -> PostListCall<'a, S> {
1991 self._anon_id = Some(new_value.to_string());
1992 self
1993 }
1994 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1995 /// while executing the actual API request.
1996 ///
1997 /// ````text
1998 /// It should be used to handle progress information, and to implement a certain level of resilience.
1999 /// ````
2000 ///
2001 /// Sets the *delegate* property to the given value.
2002 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PostListCall<'a, S> {
2003 self._delegate = Some(new_value);
2004 self
2005 }
2006
2007 /// Set any additional parameter of the query string used in the request.
2008 /// It should be used to set parameters which are not yet available through their own
2009 /// setters.
2010 ///
2011 /// Please note that this method must not be used to set any of the known parameters
2012 /// which have their own setter method. If done anyway, the request will fail.
2013 ///
2014 /// # Additional Parameters
2015 ///
2016 /// * *$.xgafv* (query-string) - V1 error format.
2017 /// * *access_token* (query-string) - OAuth access token.
2018 /// * *alt* (query-string) - Data format for response.
2019 /// * *callback* (query-string) - JSONP
2020 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2021 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2022 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2023 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2024 /// * *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.
2025 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2026 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2027 pub fn param<T>(mut self, name: T, value: T) -> PostListCall<'a, S>
2028 where T: AsRef<str> {
2029 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2030 self
2031 }
2032
2033}
2034
2035
2036/// Request anonymous ID for a new user.
2037///
2038/// A builder for the *anonid* method.
2039/// It is not used directly, but through a [`MethodMethods`] instance.
2040///
2041/// # Example
2042///
2043/// Instantiate a resource method builder
2044///
2045/// ```test_harness,no_run
2046/// # extern crate hyper;
2047/// # extern crate hyper_rustls;
2048/// # extern crate google_tenor2 as tenor2;
2049/// use tenor2::api::GoogleSearchTenorV2AnonIdRequest;
2050/// # async fn dox() {
2051/// # use std::default::Default;
2052/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
2053/// #
2054/// # let secret: oauth2::ApplicationSecret = Default::default();
2055/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
2056/// # secret,
2057/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2058/// # ).build().await.unwrap();
2059/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
2060/// // As the method needs a request, you would usually fill it with the desired information
2061/// // into the respective structure. Some of the parts shown here might not be applicable !
2062/// // Values shown here are possibly random and not representative !
2063/// let mut req = GoogleSearchTenorV2AnonIdRequest::default();
2064///
2065/// // You can configure optional parameters by calling the respective setters at will, and
2066/// // execute the final call using `doit()`.
2067/// // Values shown here are possibly random and not representative !
2068/// let result = hub.methods().anonid(req)
2069/// .doit().await;
2070/// # }
2071/// ```
2072pub struct MethodAnonidCall<'a, S>
2073 where S: 'a {
2074
2075 hub: &'a Tenor<S>,
2076 _request: GoogleSearchTenorV2AnonIdRequest,
2077 _delegate: Option<&'a mut dyn client::Delegate>,
2078 _additional_params: HashMap<String, String>,
2079}
2080
2081impl<'a, S> client::CallBuilder for MethodAnonidCall<'a, S> {}
2082
2083impl<'a, S> MethodAnonidCall<'a, S>
2084where
2085 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
2086 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
2087 S::Future: Send + Unpin + 'static,
2088 S::Error: Into<Box<dyn StdError + Send + Sync>>,
2089{
2090
2091
2092 /// Perform the operation you have build so far.
2093 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2AnonIdResponse)> {
2094 use std::io::{Read, Seek};
2095 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
2096 use client::{ToParts, url::Params};
2097 use std::borrow::Cow;
2098
2099 let mut dd = client::DefaultDelegate;
2100 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
2101 dlg.begin(client::MethodInfo { id: "tenor.anonid",
2102 http_method: hyper::Method::POST });
2103
2104 for &field in ["alt"].iter() {
2105 if self._additional_params.contains_key(field) {
2106 dlg.finished(false);
2107 return Err(client::Error::FieldClash(field));
2108 }
2109 }
2110
2111 let mut params = Params::with_capacity(3 + self._additional_params.len());
2112
2113 params.extend(self._additional_params.iter());
2114
2115 params.push("alt", "json");
2116 let mut url = self.hub._base_url.clone() + "v2/anonid";
2117
2118 match dlg.api_key() {
2119 Some(value) => params.push("key", value),
2120 None => {
2121 dlg.finished(false);
2122 return Err(client::Error::MissingAPIKey)
2123 }
2124 }
2125
2126
2127 let url = params.parse_with_url(&url);
2128
2129 let mut json_mime_type = mime::APPLICATION_JSON;
2130 let mut request_value_reader =
2131 {
2132 let mut value = json::value::to_value(&self._request).expect("serde to work");
2133 client::remove_json_null_values(&mut value);
2134 let mut dst = io::Cursor::new(Vec::with_capacity(128));
2135 json::to_writer(&mut dst, &value).unwrap();
2136 dst
2137 };
2138 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
2139 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2140
2141
2142 loop {
2143 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2144 let mut req_result = {
2145 let client = &self.hub.client;
2146 dlg.pre_request();
2147 let mut req_builder = hyper::Request::builder()
2148 .method(hyper::Method::POST)
2149 .uri(url.as_str())
2150 .header(USER_AGENT, self.hub._user_agent.clone());
2151
2152
2153
2154 let request = req_builder
2155 .header(CONTENT_TYPE, json_mime_type.to_string())
2156 .header(CONTENT_LENGTH, request_size as u64)
2157 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
2158
2159 client.request(request.unwrap()).await
2160
2161 };
2162
2163 match req_result {
2164 Err(err) => {
2165 if let client::Retry::After(d) = dlg.http_error(&err) {
2166 sleep(d).await;
2167 continue;
2168 }
2169 dlg.finished(false);
2170 return Err(client::Error::HttpError(err))
2171 }
2172 Ok(mut res) => {
2173 if !res.status().is_success() {
2174 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2175 let (parts, _) = res.into_parts();
2176 let body = hyper::Body::from(res_body_string.clone());
2177 let restored_response = hyper::Response::from_parts(parts, body);
2178
2179 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
2180
2181 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
2182 sleep(d).await;
2183 continue;
2184 }
2185
2186 dlg.finished(false);
2187
2188 return match server_response {
2189 Some(error_value) => Err(client::Error::BadRequest(error_value)),
2190 None => Err(client::Error::Failure(restored_response)),
2191 }
2192 }
2193 let result_value = {
2194 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2195
2196 match json::from_str(&res_body_string) {
2197 Ok(decoded) => (res, decoded),
2198 Err(err) => {
2199 dlg.response_json_decode_error(&res_body_string, &err);
2200 return Err(client::Error::JsonDecodeError(res_body_string, err));
2201 }
2202 }
2203 };
2204
2205 dlg.finished(true);
2206 return Ok(result_value)
2207 }
2208 }
2209 }
2210 }
2211
2212
2213 ///
2214 /// Sets the *request* property to the given value.
2215 ///
2216 /// Even though the property as already been set when instantiating this call,
2217 /// we provide this method for API completeness.
2218 pub fn request(mut self, new_value: GoogleSearchTenorV2AnonIdRequest) -> MethodAnonidCall<'a, S> {
2219 self._request = new_value;
2220 self
2221 }
2222 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2223 /// while executing the actual API request.
2224 ///
2225 /// ````text
2226 /// It should be used to handle progress information, and to implement a certain level of resilience.
2227 /// ````
2228 ///
2229 /// Sets the *delegate* property to the given value.
2230 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodAnonidCall<'a, S> {
2231 self._delegate = Some(new_value);
2232 self
2233 }
2234
2235 /// Set any additional parameter of the query string used in the request.
2236 /// It should be used to set parameters which are not yet available through their own
2237 /// setters.
2238 ///
2239 /// Please note that this method must not be used to set any of the known parameters
2240 /// which have their own setter method. If done anyway, the request will fail.
2241 ///
2242 /// # Additional Parameters
2243 ///
2244 /// * *$.xgafv* (query-string) - V1 error format.
2245 /// * *access_token* (query-string) - OAuth access token.
2246 /// * *alt* (query-string) - Data format for response.
2247 /// * *callback* (query-string) - JSONP
2248 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2249 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2250 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2251 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2252 /// * *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.
2253 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2254 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2255 pub fn param<T>(mut self, name: T, value: T) -> MethodAnonidCall<'a, S>
2256 where T: AsRef<str> {
2257 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2258 self
2259 }
2260
2261}
2262
2263
2264/// Complete a partial input query.
2265///
2266/// A builder for the *autocomplete* method.
2267/// It is not used directly, but through a [`MethodMethods`] instance.
2268///
2269/// # Example
2270///
2271/// Instantiate a resource method builder
2272///
2273/// ```test_harness,no_run
2274/// # extern crate hyper;
2275/// # extern crate hyper_rustls;
2276/// # extern crate google_tenor2 as tenor2;
2277/// # async fn dox() {
2278/// # use std::default::Default;
2279/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
2280/// #
2281/// # let secret: oauth2::ApplicationSecret = Default::default();
2282/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
2283/// # secret,
2284/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2285/// # ).build().await.unwrap();
2286/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
2287/// // You can configure optional parameters by calling the respective setters at will, and
2288/// // execute the final call using `doit()`.
2289/// // Values shown here are possibly random and not representative !
2290/// let result = hub.methods().autocomplete()
2291/// .q("ea")
2292/// .locale("ipsum")
2293/// .limit(-88)
2294/// .country("amet")
2295/// .component("duo")
2296/// .client_key("ipsum")
2297/// .appversion("sed")
2298/// .anon_id("ut")
2299/// .doit().await;
2300/// # }
2301/// ```
2302pub struct MethodAutocompleteCall<'a, S>
2303 where S: 'a {
2304
2305 hub: &'a Tenor<S>,
2306 _q: Option<String>,
2307 _locale: Option<String>,
2308 _limit: Option<i32>,
2309 _country: Option<String>,
2310 _component: Option<String>,
2311 _client_key: Option<String>,
2312 _appversion: Option<String>,
2313 _anon_id: Option<String>,
2314 _delegate: Option<&'a mut dyn client::Delegate>,
2315 _additional_params: HashMap<String, String>,
2316}
2317
2318impl<'a, S> client::CallBuilder for MethodAutocompleteCall<'a, S> {}
2319
2320impl<'a, S> MethodAutocompleteCall<'a, S>
2321where
2322 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
2323 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
2324 S::Future: Send + Unpin + 'static,
2325 S::Error: Into<Box<dyn StdError + Send + Sync>>,
2326{
2327
2328
2329 /// Perform the operation you have build so far.
2330 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2AutocompleteResponse)> {
2331 use std::io::{Read, Seek};
2332 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
2333 use client::{ToParts, url::Params};
2334 use std::borrow::Cow;
2335
2336 let mut dd = client::DefaultDelegate;
2337 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
2338 dlg.begin(client::MethodInfo { id: "tenor.autocomplete",
2339 http_method: hyper::Method::GET });
2340
2341 for &field in ["alt", "q", "locale", "limit", "country", "component", "clientKey", "appversion", "anonId"].iter() {
2342 if self._additional_params.contains_key(field) {
2343 dlg.finished(false);
2344 return Err(client::Error::FieldClash(field));
2345 }
2346 }
2347
2348 let mut params = Params::with_capacity(10 + self._additional_params.len());
2349 if let Some(value) = self._q.as_ref() {
2350 params.push("q", value);
2351 }
2352 if let Some(value) = self._locale.as_ref() {
2353 params.push("locale", value);
2354 }
2355 if let Some(value) = self._limit.as_ref() {
2356 params.push("limit", value.to_string());
2357 }
2358 if let Some(value) = self._country.as_ref() {
2359 params.push("country", value);
2360 }
2361 if let Some(value) = self._component.as_ref() {
2362 params.push("component", value);
2363 }
2364 if let Some(value) = self._client_key.as_ref() {
2365 params.push("clientKey", value);
2366 }
2367 if let Some(value) = self._appversion.as_ref() {
2368 params.push("appversion", value);
2369 }
2370 if let Some(value) = self._anon_id.as_ref() {
2371 params.push("anonId", value);
2372 }
2373
2374 params.extend(self._additional_params.iter());
2375
2376 params.push("alt", "json");
2377 let mut url = self.hub._base_url.clone() + "v2/autocomplete";
2378
2379 match dlg.api_key() {
2380 Some(value) => params.push("key", value),
2381 None => {
2382 dlg.finished(false);
2383 return Err(client::Error::MissingAPIKey)
2384 }
2385 }
2386
2387
2388 let url = params.parse_with_url(&url);
2389
2390
2391
2392 loop {
2393 let mut req_result = {
2394 let client = &self.hub.client;
2395 dlg.pre_request();
2396 let mut req_builder = hyper::Request::builder()
2397 .method(hyper::Method::GET)
2398 .uri(url.as_str())
2399 .header(USER_AGENT, self.hub._user_agent.clone());
2400
2401
2402
2403 let request = req_builder
2404 .header(CONTENT_LENGTH, 0_u64)
2405 .body(hyper::body::Body::empty());
2406
2407 client.request(request.unwrap()).await
2408
2409 };
2410
2411 match req_result {
2412 Err(err) => {
2413 if let client::Retry::After(d) = dlg.http_error(&err) {
2414 sleep(d).await;
2415 continue;
2416 }
2417 dlg.finished(false);
2418 return Err(client::Error::HttpError(err))
2419 }
2420 Ok(mut res) => {
2421 if !res.status().is_success() {
2422 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2423 let (parts, _) = res.into_parts();
2424 let body = hyper::Body::from(res_body_string.clone());
2425 let restored_response = hyper::Response::from_parts(parts, body);
2426
2427 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
2428
2429 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
2430 sleep(d).await;
2431 continue;
2432 }
2433
2434 dlg.finished(false);
2435
2436 return match server_response {
2437 Some(error_value) => Err(client::Error::BadRequest(error_value)),
2438 None => Err(client::Error::Failure(restored_response)),
2439 }
2440 }
2441 let result_value = {
2442 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2443
2444 match json::from_str(&res_body_string) {
2445 Ok(decoded) => (res, decoded),
2446 Err(err) => {
2447 dlg.response_json_decode_error(&res_body_string, &err);
2448 return Err(client::Error::JsonDecodeError(res_body_string, err));
2449 }
2450 }
2451 };
2452
2453 dlg.finished(true);
2454 return Ok(result_value)
2455 }
2456 }
2457 }
2458 }
2459
2460
2461 /// Required. The current search query.
2462 ///
2463 /// Sets the *q* query property to the given value.
2464 pub fn q(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
2465 self._q = Some(new_value.to_string());
2466 self
2467 }
2468 /// 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.
2469 ///
2470 /// Sets the *locale* query property to the given value.
2471 pub fn locale(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
2472 self._locale = Some(new_value.to_string());
2473 self
2474 }
2475 /// The maximum number of results to be returned. The default is 20.
2476 ///
2477 /// Sets the *limit* query property to the given value.
2478 pub fn limit(mut self, new_value: i32) -> MethodAutocompleteCall<'a, S> {
2479 self._limit = Some(new_value);
2480 self
2481 }
2482 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
2483 ///
2484 /// Sets the *country* query property to the given value.
2485 pub fn country(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
2486 self._country = Some(new_value.to_string());
2487 self
2488 }
2489 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
2490 ///
2491 /// Sets the *component* query property to the given value.
2492 pub fn component(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
2493 self._component = Some(new_value.to_string());
2494 self
2495 }
2496 /// Client application identifier, e.g., "gboard".
2497 ///
2498 /// Sets the *client key* query property to the given value.
2499 pub fn client_key(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
2500 self._client_key = Some(new_value.to_string());
2501 self
2502 }
2503 /// Client application version, e.g., "3.1".
2504 ///
2505 /// Sets the *appversion* query property to the given value.
2506 pub fn appversion(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
2507 self._appversion = Some(new_value.to_string());
2508 self
2509 }
2510 /// Pseudonymous user id tied to the user.
2511 ///
2512 /// Sets the *anon id* query property to the given value.
2513 pub fn anon_id(mut self, new_value: &str) -> MethodAutocompleteCall<'a, S> {
2514 self._anon_id = Some(new_value.to_string());
2515 self
2516 }
2517 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2518 /// while executing the actual API request.
2519 ///
2520 /// ````text
2521 /// It should be used to handle progress information, and to implement a certain level of resilience.
2522 /// ````
2523 ///
2524 /// Sets the *delegate* property to the given value.
2525 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodAutocompleteCall<'a, S> {
2526 self._delegate = Some(new_value);
2527 self
2528 }
2529
2530 /// Set any additional parameter of the query string used in the request.
2531 /// It should be used to set parameters which are not yet available through their own
2532 /// setters.
2533 ///
2534 /// Please note that this method must not be used to set any of the known parameters
2535 /// which have their own setter method. If done anyway, the request will fail.
2536 ///
2537 /// # Additional Parameters
2538 ///
2539 /// * *$.xgafv* (query-string) - V1 error format.
2540 /// * *access_token* (query-string) - OAuth access token.
2541 /// * *alt* (query-string) - Data format for response.
2542 /// * *callback* (query-string) - JSONP
2543 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2544 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2545 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2546 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2547 /// * *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.
2548 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2549 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2550 pub fn param<T>(mut self, name: T, value: T) -> MethodAutocompleteCall<'a, S>
2551 where T: AsRef<str> {
2552 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2553 self
2554 }
2555
2556}
2557
2558
2559/// Categories.
2560///
2561/// A builder for the *categories* method.
2562/// It is not used directly, but through a [`MethodMethods`] instance.
2563///
2564/// # Example
2565///
2566/// Instantiate a resource method builder
2567///
2568/// ```test_harness,no_run
2569/// # extern crate hyper;
2570/// # extern crate hyper_rustls;
2571/// # extern crate google_tenor2 as tenor2;
2572/// # async fn dox() {
2573/// # use std::default::Default;
2574/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
2575/// #
2576/// # let secret: oauth2::ApplicationSecret = Default::default();
2577/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
2578/// # secret,
2579/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2580/// # ).build().await.unwrap();
2581/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
2582/// // You can configure optional parameters by calling the respective setters at will, and
2583/// // execute the final call using `doit()`.
2584/// // Values shown here are possibly random and not representative !
2585/// let result = hub.methods().categories()
2586/// .type_("gubergren")
2587/// .searchfilter("rebum.")
2588/// .locale("est")
2589/// .country("ipsum")
2590/// .contentfilter("ipsum")
2591/// .component("est")
2592/// .client_key("gubergren")
2593/// .appversion("ea")
2594/// .anon_id("dolor")
2595/// .doit().await;
2596/// # }
2597/// ```
2598pub struct MethodCategoryCall<'a, S>
2599 where S: 'a {
2600
2601 hub: &'a Tenor<S>,
2602 _type_: Option<String>,
2603 _searchfilter: Option<String>,
2604 _locale: Option<String>,
2605 _country: Option<String>,
2606 _contentfilter: Option<String>,
2607 _component: Option<String>,
2608 _client_key: Option<String>,
2609 _appversion: Option<String>,
2610 _anon_id: Option<String>,
2611 _delegate: Option<&'a mut dyn client::Delegate>,
2612 _additional_params: HashMap<String, String>,
2613}
2614
2615impl<'a, S> client::CallBuilder for MethodCategoryCall<'a, S> {}
2616
2617impl<'a, S> MethodCategoryCall<'a, S>
2618where
2619 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
2620 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
2621 S::Future: Send + Unpin + 'static,
2622 S::Error: Into<Box<dyn StdError + Send + Sync>>,
2623{
2624
2625
2626 /// Perform the operation you have build so far.
2627 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2CategoriesResponse)> {
2628 use std::io::{Read, Seek};
2629 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
2630 use client::{ToParts, url::Params};
2631 use std::borrow::Cow;
2632
2633 let mut dd = client::DefaultDelegate;
2634 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
2635 dlg.begin(client::MethodInfo { id: "tenor.categories",
2636 http_method: hyper::Method::GET });
2637
2638 for &field in ["alt", "type", "searchfilter", "locale", "country", "contentfilter", "component", "clientKey", "appversion", "anonId"].iter() {
2639 if self._additional_params.contains_key(field) {
2640 dlg.finished(false);
2641 return Err(client::Error::FieldClash(field));
2642 }
2643 }
2644
2645 let mut params = Params::with_capacity(11 + self._additional_params.len());
2646 if let Some(value) = self._type_.as_ref() {
2647 params.push("type", value);
2648 }
2649 if let Some(value) = self._searchfilter.as_ref() {
2650 params.push("searchfilter", value);
2651 }
2652 if let Some(value) = self._locale.as_ref() {
2653 params.push("locale", value);
2654 }
2655 if let Some(value) = self._country.as_ref() {
2656 params.push("country", value);
2657 }
2658 if let Some(value) = self._contentfilter.as_ref() {
2659 params.push("contentfilter", value);
2660 }
2661 if let Some(value) = self._component.as_ref() {
2662 params.push("component", value);
2663 }
2664 if let Some(value) = self._client_key.as_ref() {
2665 params.push("clientKey", value);
2666 }
2667 if let Some(value) = self._appversion.as_ref() {
2668 params.push("appversion", value);
2669 }
2670 if let Some(value) = self._anon_id.as_ref() {
2671 params.push("anonId", value);
2672 }
2673
2674 params.extend(self._additional_params.iter());
2675
2676 params.push("alt", "json");
2677 let mut url = self.hub._base_url.clone() + "v2/categories";
2678
2679 match dlg.api_key() {
2680 Some(value) => params.push("key", value),
2681 None => {
2682 dlg.finished(false);
2683 return Err(client::Error::MissingAPIKey)
2684 }
2685 }
2686
2687
2688 let url = params.parse_with_url(&url);
2689
2690
2691
2692 loop {
2693 let mut req_result = {
2694 let client = &self.hub.client;
2695 dlg.pre_request();
2696 let mut req_builder = hyper::Request::builder()
2697 .method(hyper::Method::GET)
2698 .uri(url.as_str())
2699 .header(USER_AGENT, self.hub._user_agent.clone());
2700
2701
2702
2703 let request = req_builder
2704 .header(CONTENT_LENGTH, 0_u64)
2705 .body(hyper::body::Body::empty());
2706
2707 client.request(request.unwrap()).await
2708
2709 };
2710
2711 match req_result {
2712 Err(err) => {
2713 if let client::Retry::After(d) = dlg.http_error(&err) {
2714 sleep(d).await;
2715 continue;
2716 }
2717 dlg.finished(false);
2718 return Err(client::Error::HttpError(err))
2719 }
2720 Ok(mut res) => {
2721 if !res.status().is_success() {
2722 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2723 let (parts, _) = res.into_parts();
2724 let body = hyper::Body::from(res_body_string.clone());
2725 let restored_response = hyper::Response::from_parts(parts, body);
2726
2727 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
2728
2729 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
2730 sleep(d).await;
2731 continue;
2732 }
2733
2734 dlg.finished(false);
2735
2736 return match server_response {
2737 Some(error_value) => Err(client::Error::BadRequest(error_value)),
2738 None => Err(client::Error::Failure(restored_response)),
2739 }
2740 }
2741 let result_value = {
2742 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2743
2744 match json::from_str(&res_body_string) {
2745 Ok(decoded) => (res, decoded),
2746 Err(err) => {
2747 dlg.response_json_decode_error(&res_body_string, &err);
2748 return Err(client::Error::JsonDecodeError(res_body_string, err));
2749 }
2750 }
2751 };
2752
2753 dlg.finished(true);
2754 return Ok(result_value)
2755 }
2756 }
2757 }
2758 }
2759
2760
2761 /// Type of categories. Supported types are "featured" (default), "emoji", and "trending".
2762 ///
2763 /// Sets the *type* query property to the given value.
2764 pub fn type_(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2765 self._type_ = Some(new_value.to_string());
2766 self
2767 }
2768 /// If "sticker", returns image url of the top sticker search result.
2769 ///
2770 /// Sets the *searchfilter* query property to the given value.
2771 pub fn searchfilter(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2772 self._searchfilter = Some(new_value.to_string());
2773 self
2774 }
2775 /// 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.
2776 ///
2777 /// Sets the *locale* query property to the given value.
2778 pub fn locale(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2779 self._locale = Some(new_value.to_string());
2780 self
2781 }
2782 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
2783 ///
2784 /// Sets the *country* query property to the given value.
2785 pub fn country(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2786 self._country = Some(new_value.to_string());
2787 self
2788 }
2789 /// The content filter level. The default is configurable per client.
2790 ///
2791 /// Sets the *contentfilter* query property to the given value.
2792 pub fn contentfilter(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2793 self._contentfilter = Some(new_value.to_string());
2794 self
2795 }
2796 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
2797 ///
2798 /// Sets the *component* query property to the given value.
2799 pub fn component(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2800 self._component = Some(new_value.to_string());
2801 self
2802 }
2803 /// Client application identifier, e.g., "gboard".
2804 ///
2805 /// Sets the *client key* query property to the given value.
2806 pub fn client_key(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2807 self._client_key = Some(new_value.to_string());
2808 self
2809 }
2810 /// Client application version, e.g., "3.1".
2811 ///
2812 /// Sets the *appversion* query property to the given value.
2813 pub fn appversion(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2814 self._appversion = Some(new_value.to_string());
2815 self
2816 }
2817 /// Pseudonymous user id tied to the user.
2818 ///
2819 /// Sets the *anon id* query property to the given value.
2820 pub fn anon_id(mut self, new_value: &str) -> MethodCategoryCall<'a, S> {
2821 self._anon_id = Some(new_value.to_string());
2822 self
2823 }
2824 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2825 /// while executing the actual API request.
2826 ///
2827 /// ````text
2828 /// It should be used to handle progress information, and to implement a certain level of resilience.
2829 /// ````
2830 ///
2831 /// Sets the *delegate* property to the given value.
2832 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodCategoryCall<'a, S> {
2833 self._delegate = Some(new_value);
2834 self
2835 }
2836
2837 /// Set any additional parameter of the query string used in the request.
2838 /// It should be used to set parameters which are not yet available through their own
2839 /// setters.
2840 ///
2841 /// Please note that this method must not be used to set any of the known parameters
2842 /// which have their own setter method. If done anyway, the request will fail.
2843 ///
2844 /// # Additional Parameters
2845 ///
2846 /// * *$.xgafv* (query-string) - V1 error format.
2847 /// * *access_token* (query-string) - OAuth access token.
2848 /// * *alt* (query-string) - Data format for response.
2849 /// * *callback* (query-string) - JSONP
2850 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2851 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2852 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2853 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2854 /// * *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.
2855 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2856 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2857 pub fn param<T>(mut self, name: T, value: T) -> MethodCategoryCall<'a, S>
2858 where T: AsRef<str> {
2859 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2860 self
2861 }
2862
2863}
2864
2865
2866/// Featured Posts.
2867///
2868/// A builder for the *featured* method.
2869/// It is not used directly, but through a [`MethodMethods`] instance.
2870///
2871/// # Example
2872///
2873/// Instantiate a resource method builder
2874///
2875/// ```test_harness,no_run
2876/// # extern crate hyper;
2877/// # extern crate hyper_rustls;
2878/// # extern crate google_tenor2 as tenor2;
2879/// # async fn dox() {
2880/// # use std::default::Default;
2881/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
2882/// #
2883/// # let secret: oauth2::ApplicationSecret = Default::default();
2884/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
2885/// # secret,
2886/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2887/// # ).build().await.unwrap();
2888/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
2889/// // You can configure optional parameters by calling the respective setters at will, and
2890/// // execute the final call using `doit()`.
2891/// // Values shown here are possibly random and not representative !
2892/// let result = hub.methods().featured()
2893/// .searchfilter("Lorem")
2894/// .q("eos")
2895/// .pos("labore")
2896/// .media_filter("sed")
2897/// .locale("duo")
2898/// .limit(-80)
2899/// .country("no")
2900/// .contentfilter("Stet")
2901/// .component("kasd")
2902/// .collection("et")
2903/// .client_key("sed")
2904/// .ar_range("et")
2905/// .appversion("et")
2906/// .anon_id("vero")
2907/// .doit().await;
2908/// # }
2909/// ```
2910pub struct MethodFeaturedCall<'a, S>
2911 where S: 'a {
2912
2913 hub: &'a Tenor<S>,
2914 _searchfilter: Option<String>,
2915 _q: Option<String>,
2916 _pos: Option<String>,
2917 _media_filter: Option<String>,
2918 _locale: Option<String>,
2919 _limit: Option<i32>,
2920 _country: Option<String>,
2921 _contentfilter: Option<String>,
2922 _component: Option<String>,
2923 _collection: Option<String>,
2924 _client_key: Option<String>,
2925 _ar_range: Option<String>,
2926 _appversion: Option<String>,
2927 _anon_id: Option<String>,
2928 _delegate: Option<&'a mut dyn client::Delegate>,
2929 _additional_params: HashMap<String, String>,
2930}
2931
2932impl<'a, S> client::CallBuilder for MethodFeaturedCall<'a, S> {}
2933
2934impl<'a, S> MethodFeaturedCall<'a, S>
2935where
2936 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
2937 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
2938 S::Future: Send + Unpin + 'static,
2939 S::Error: Into<Box<dyn StdError + Send + Sync>>,
2940{
2941
2942
2943 /// Perform the operation you have build so far.
2944 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2FeaturedPostsResponse)> {
2945 use std::io::{Read, Seek};
2946 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
2947 use client::{ToParts, url::Params};
2948 use std::borrow::Cow;
2949
2950 let mut dd = client::DefaultDelegate;
2951 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
2952 dlg.begin(client::MethodInfo { id: "tenor.featured",
2953 http_method: hyper::Method::GET });
2954
2955 for &field in ["alt", "searchfilter", "q", "pos", "mediaFilter", "locale", "limit", "country", "contentfilter", "component", "collection", "clientKey", "arRange", "appversion", "anonId"].iter() {
2956 if self._additional_params.contains_key(field) {
2957 dlg.finished(false);
2958 return Err(client::Error::FieldClash(field));
2959 }
2960 }
2961
2962 let mut params = Params::with_capacity(16 + self._additional_params.len());
2963 if let Some(value) = self._searchfilter.as_ref() {
2964 params.push("searchfilter", value);
2965 }
2966 if let Some(value) = self._q.as_ref() {
2967 params.push("q", value);
2968 }
2969 if let Some(value) = self._pos.as_ref() {
2970 params.push("pos", value);
2971 }
2972 if let Some(value) = self._media_filter.as_ref() {
2973 params.push("mediaFilter", value);
2974 }
2975 if let Some(value) = self._locale.as_ref() {
2976 params.push("locale", value);
2977 }
2978 if let Some(value) = self._limit.as_ref() {
2979 params.push("limit", value.to_string());
2980 }
2981 if let Some(value) = self._country.as_ref() {
2982 params.push("country", value);
2983 }
2984 if let Some(value) = self._contentfilter.as_ref() {
2985 params.push("contentfilter", value);
2986 }
2987 if let Some(value) = self._component.as_ref() {
2988 params.push("component", value);
2989 }
2990 if let Some(value) = self._collection.as_ref() {
2991 params.push("collection", value);
2992 }
2993 if let Some(value) = self._client_key.as_ref() {
2994 params.push("clientKey", value);
2995 }
2996 if let Some(value) = self._ar_range.as_ref() {
2997 params.push("arRange", value);
2998 }
2999 if let Some(value) = self._appversion.as_ref() {
3000 params.push("appversion", value);
3001 }
3002 if let Some(value) = self._anon_id.as_ref() {
3003 params.push("anonId", value);
3004 }
3005
3006 params.extend(self._additional_params.iter());
3007
3008 params.push("alt", "json");
3009 let mut url = self.hub._base_url.clone() + "v2/featured";
3010
3011 match dlg.api_key() {
3012 Some(value) => params.push("key", value),
3013 None => {
3014 dlg.finished(false);
3015 return Err(client::Error::MissingAPIKey)
3016 }
3017 }
3018
3019
3020 let url = params.parse_with_url(&url);
3021
3022
3023
3024 loop {
3025 let mut req_result = {
3026 let client = &self.hub.client;
3027 dlg.pre_request();
3028 let mut req_builder = hyper::Request::builder()
3029 .method(hyper::Method::GET)
3030 .uri(url.as_str())
3031 .header(USER_AGENT, self.hub._user_agent.clone());
3032
3033
3034
3035 let request = req_builder
3036 .header(CONTENT_LENGTH, 0_u64)
3037 .body(hyper::body::Body::empty());
3038
3039 client.request(request.unwrap()).await
3040
3041 };
3042
3043 match req_result {
3044 Err(err) => {
3045 if let client::Retry::After(d) = dlg.http_error(&err) {
3046 sleep(d).await;
3047 continue;
3048 }
3049 dlg.finished(false);
3050 return Err(client::Error::HttpError(err))
3051 }
3052 Ok(mut res) => {
3053 if !res.status().is_success() {
3054 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3055 let (parts, _) = res.into_parts();
3056 let body = hyper::Body::from(res_body_string.clone());
3057 let restored_response = hyper::Response::from_parts(parts, body);
3058
3059 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
3060
3061 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
3062 sleep(d).await;
3063 continue;
3064 }
3065
3066 dlg.finished(false);
3067
3068 return match server_response {
3069 Some(error_value) => Err(client::Error::BadRequest(error_value)),
3070 None => Err(client::Error::Failure(restored_response)),
3071 }
3072 }
3073 let result_value = {
3074 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3075
3076 match json::from_str(&res_body_string) {
3077 Ok(decoded) => (res, decoded),
3078 Err(err) => {
3079 dlg.response_json_decode_error(&res_body_string, &err);
3080 return Err(client::Error::JsonDecodeError(res_body_string, err));
3081 }
3082 }
3083 };
3084
3085 dlg.finished(true);
3086 return Ok(result_value)
3087 }
3088 }
3089 }
3090 }
3091
3092
3093 /// 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.
3094 ///
3095 /// Sets the *searchfilter* query property to the given value.
3096 pub fn searchfilter(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3097 self._searchfilter = Some(new_value.to_string());
3098 self
3099 }
3100 /// Query string when retrieving from a collection.
3101 ///
3102 /// Sets the *q* query property to the given value.
3103 pub fn q(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3104 self._q = Some(new_value.to_string());
3105 self
3106 }
3107 /// 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.
3108 ///
3109 /// Sets the *pos* query property to the given value.
3110 pub fn pos(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3111 self._pos = Some(new_value.to_string());
3112 self
3113 }
3114 /// 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.
3115 ///
3116 /// Sets the *media filter* query property to the given value.
3117 pub fn media_filter(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3118 self._media_filter = Some(new_value.to_string());
3119 self
3120 }
3121 /// 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.
3122 ///
3123 /// Sets the *locale* query property to the given value.
3124 pub fn locale(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3125 self._locale = Some(new_value.to_string());
3126 self
3127 }
3128 /// The maximum number of results to be returned. The default is 20.
3129 ///
3130 /// Sets the *limit* query property to the given value.
3131 pub fn limit(mut self, new_value: i32) -> MethodFeaturedCall<'a, S> {
3132 self._limit = Some(new_value);
3133 self
3134 }
3135 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
3136 ///
3137 /// Sets the *country* query property to the given value.
3138 pub fn country(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3139 self._country = Some(new_value.to_string());
3140 self
3141 }
3142 /// The content filter level. The default is configurable per client.
3143 ///
3144 /// Sets the *contentfilter* query property to the given value.
3145 pub fn contentfilter(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3146 self._contentfilter = Some(new_value.to_string());
3147 self
3148 }
3149 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
3150 ///
3151 /// Sets the *component* query property to the given value.
3152 pub fn component(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3153 self._component = Some(new_value.to_string());
3154 self
3155 }
3156 /// 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.
3157 ///
3158 /// Sets the *collection* query property to the given value.
3159 pub fn collection(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3160 self._collection = Some(new_value.to_string());
3161 self
3162 }
3163 /// Client application identifier, e.g., "gboard".
3164 ///
3165 /// Sets the *client key* query property to the given value.
3166 pub fn client_key(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3167 self._client_key = Some(new_value.to_string());
3168 self
3169 }
3170 /// 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].
3171 ///
3172 /// Sets the *ar range* query property to the given value.
3173 pub fn ar_range(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3174 self._ar_range = Some(new_value.to_string());
3175 self
3176 }
3177 /// Client application version, e.g., "3.1".
3178 ///
3179 /// Sets the *appversion* query property to the given value.
3180 pub fn appversion(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3181 self._appversion = Some(new_value.to_string());
3182 self
3183 }
3184 /// Pseudonymous user id tied to the user.
3185 ///
3186 /// Sets the *anon id* query property to the given value.
3187 pub fn anon_id(mut self, new_value: &str) -> MethodFeaturedCall<'a, S> {
3188 self._anon_id = Some(new_value.to_string());
3189 self
3190 }
3191 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3192 /// while executing the actual API request.
3193 ///
3194 /// ````text
3195 /// It should be used to handle progress information, and to implement a certain level of resilience.
3196 /// ````
3197 ///
3198 /// Sets the *delegate* property to the given value.
3199 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodFeaturedCall<'a, S> {
3200 self._delegate = Some(new_value);
3201 self
3202 }
3203
3204 /// Set any additional parameter of the query string used in the request.
3205 /// It should be used to set parameters which are not yet available through their own
3206 /// setters.
3207 ///
3208 /// Please note that this method must not be used to set any of the known parameters
3209 /// which have their own setter method. If done anyway, the request will fail.
3210 ///
3211 /// # Additional Parameters
3212 ///
3213 /// * *$.xgafv* (query-string) - V1 error format.
3214 /// * *access_token* (query-string) - OAuth access token.
3215 /// * *alt* (query-string) - Data format for response.
3216 /// * *callback* (query-string) - JSONP
3217 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3218 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3219 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3220 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3221 /// * *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.
3222 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3223 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3224 pub fn param<T>(mut self, name: T, value: T) -> MethodFeaturedCall<'a, S>
3225 where T: AsRef<str> {
3226 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
3227 self
3228 }
3229
3230}
3231
3232
3233/// Register share.
3234///
3235/// A builder for the *registershare* method.
3236/// It is not used directly, but through a [`MethodMethods`] instance.
3237///
3238/// # Example
3239///
3240/// Instantiate a resource method builder
3241///
3242/// ```test_harness,no_run
3243/// # extern crate hyper;
3244/// # extern crate hyper_rustls;
3245/// # extern crate google_tenor2 as tenor2;
3246/// use tenor2::api::GoogleSearchTenorV2RegisterShareRequest;
3247/// # async fn dox() {
3248/// # use std::default::Default;
3249/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
3250/// #
3251/// # let secret: oauth2::ApplicationSecret = Default::default();
3252/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3253/// # secret,
3254/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3255/// # ).build().await.unwrap();
3256/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
3257/// // As the method needs a request, you would usually fill it with the desired information
3258/// // into the respective structure. Some of the parts shown here might not be applicable !
3259/// // Values shown here are possibly random and not representative !
3260/// let mut req = GoogleSearchTenorV2RegisterShareRequest::default();
3261///
3262/// // You can configure optional parameters by calling the respective setters at will, and
3263/// // execute the final call using `doit()`.
3264/// // Values shown here are possibly random and not representative !
3265/// let result = hub.methods().registershare(req)
3266/// .doit().await;
3267/// # }
3268/// ```
3269pub struct MethodRegistershareCall<'a, S>
3270 where S: 'a {
3271
3272 hub: &'a Tenor<S>,
3273 _request: GoogleSearchTenorV2RegisterShareRequest,
3274 _delegate: Option<&'a mut dyn client::Delegate>,
3275 _additional_params: HashMap<String, String>,
3276}
3277
3278impl<'a, S> client::CallBuilder for MethodRegistershareCall<'a, S> {}
3279
3280impl<'a, S> MethodRegistershareCall<'a, S>
3281where
3282 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
3283 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3284 S::Future: Send + Unpin + 'static,
3285 S::Error: Into<Box<dyn StdError + Send + Sync>>,
3286{
3287
3288
3289 /// Perform the operation you have build so far.
3290 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2RegisterShareResponse)> {
3291 use std::io::{Read, Seek};
3292 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
3293 use client::{ToParts, url::Params};
3294 use std::borrow::Cow;
3295
3296 let mut dd = client::DefaultDelegate;
3297 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
3298 dlg.begin(client::MethodInfo { id: "tenor.registershare",
3299 http_method: hyper::Method::POST });
3300
3301 for &field in ["alt"].iter() {
3302 if self._additional_params.contains_key(field) {
3303 dlg.finished(false);
3304 return Err(client::Error::FieldClash(field));
3305 }
3306 }
3307
3308 let mut params = Params::with_capacity(3 + self._additional_params.len());
3309
3310 params.extend(self._additional_params.iter());
3311
3312 params.push("alt", "json");
3313 let mut url = self.hub._base_url.clone() + "v2/registershare";
3314
3315 match dlg.api_key() {
3316 Some(value) => params.push("key", value),
3317 None => {
3318 dlg.finished(false);
3319 return Err(client::Error::MissingAPIKey)
3320 }
3321 }
3322
3323
3324 let url = params.parse_with_url(&url);
3325
3326 let mut json_mime_type = mime::APPLICATION_JSON;
3327 let mut request_value_reader =
3328 {
3329 let mut value = json::value::to_value(&self._request).expect("serde to work");
3330 client::remove_json_null_values(&mut value);
3331 let mut dst = io::Cursor::new(Vec::with_capacity(128));
3332 json::to_writer(&mut dst, &value).unwrap();
3333 dst
3334 };
3335 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
3336 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3337
3338
3339 loop {
3340 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3341 let mut req_result = {
3342 let client = &self.hub.client;
3343 dlg.pre_request();
3344 let mut req_builder = hyper::Request::builder()
3345 .method(hyper::Method::POST)
3346 .uri(url.as_str())
3347 .header(USER_AGENT, self.hub._user_agent.clone());
3348
3349
3350
3351 let request = req_builder
3352 .header(CONTENT_TYPE, json_mime_type.to_string())
3353 .header(CONTENT_LENGTH, request_size as u64)
3354 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
3355
3356 client.request(request.unwrap()).await
3357
3358 };
3359
3360 match req_result {
3361 Err(err) => {
3362 if let client::Retry::After(d) = dlg.http_error(&err) {
3363 sleep(d).await;
3364 continue;
3365 }
3366 dlg.finished(false);
3367 return Err(client::Error::HttpError(err))
3368 }
3369 Ok(mut res) => {
3370 if !res.status().is_success() {
3371 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3372 let (parts, _) = res.into_parts();
3373 let body = hyper::Body::from(res_body_string.clone());
3374 let restored_response = hyper::Response::from_parts(parts, body);
3375
3376 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
3377
3378 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
3379 sleep(d).await;
3380 continue;
3381 }
3382
3383 dlg.finished(false);
3384
3385 return match server_response {
3386 Some(error_value) => Err(client::Error::BadRequest(error_value)),
3387 None => Err(client::Error::Failure(restored_response)),
3388 }
3389 }
3390 let result_value = {
3391 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3392
3393 match json::from_str(&res_body_string) {
3394 Ok(decoded) => (res, decoded),
3395 Err(err) => {
3396 dlg.response_json_decode_error(&res_body_string, &err);
3397 return Err(client::Error::JsonDecodeError(res_body_string, err));
3398 }
3399 }
3400 };
3401
3402 dlg.finished(true);
3403 return Ok(result_value)
3404 }
3405 }
3406 }
3407 }
3408
3409
3410 ///
3411 /// Sets the *request* property to the given value.
3412 ///
3413 /// Even though the property as already been set when instantiating this call,
3414 /// we provide this method for API completeness.
3415 pub fn request(mut self, new_value: GoogleSearchTenorV2RegisterShareRequest) -> MethodRegistershareCall<'a, S> {
3416 self._request = new_value;
3417 self
3418 }
3419 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3420 /// while executing the actual API request.
3421 ///
3422 /// ````text
3423 /// It should be used to handle progress information, and to implement a certain level of resilience.
3424 /// ````
3425 ///
3426 /// Sets the *delegate* property to the given value.
3427 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodRegistershareCall<'a, S> {
3428 self._delegate = Some(new_value);
3429 self
3430 }
3431
3432 /// Set any additional parameter of the query string used in the request.
3433 /// It should be used to set parameters which are not yet available through their own
3434 /// setters.
3435 ///
3436 /// Please note that this method must not be used to set any of the known parameters
3437 /// which have their own setter method. If done anyway, the request will fail.
3438 ///
3439 /// # Additional Parameters
3440 ///
3441 /// * *$.xgafv* (query-string) - V1 error format.
3442 /// * *access_token* (query-string) - OAuth access token.
3443 /// * *alt* (query-string) - Data format for response.
3444 /// * *callback* (query-string) - JSONP
3445 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3446 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3447 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3448 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3449 /// * *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.
3450 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3451 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3452 pub fn param<T>(mut self, name: T, value: T) -> MethodRegistershareCall<'a, S>
3453 where T: AsRef<str> {
3454 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
3455 self
3456 }
3457
3458}
3459
3460
3461/// Get a post with the provided caption rendered.
3462///
3463/// A builder for the *render_caption* method.
3464/// It is not used directly, but through a [`MethodMethods`] instance.
3465///
3466/// # Example
3467///
3468/// Instantiate a resource method builder
3469///
3470/// ```test_harness,no_run
3471/// # extern crate hyper;
3472/// # extern crate hyper_rustls;
3473/// # extern crate google_tenor2 as tenor2;
3474/// # async fn dox() {
3475/// # use std::default::Default;
3476/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
3477/// #
3478/// # let secret: oauth2::ApplicationSecret = Default::default();
3479/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3480/// # secret,
3481/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3482/// # ).build().await.unwrap();
3483/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
3484/// // You can configure optional parameters by calling the respective setters at will, and
3485/// // execute the final call using `doit()`.
3486/// // Values shown here are possibly random and not representative !
3487/// let result = hub.methods().render_caption()
3488/// .width(-31)
3489/// .top_percent(0.06730027227364666)
3490/// .right_percent(0.5254434270373415)
3491/// .locale("et")
3492/// .left_percent(0.9697780726648698)
3493/// .id(99)
3494/// .height(-96)
3495/// .format("diam")
3496/// .country("dolor")
3497/// .component("et")
3498/// .client_key("et")
3499/// .caption("sadipscing")
3500/// .bottom_percent(0.6755988748158552)
3501/// .appversion("duo")
3502/// .anon_id("vero")
3503/// .doit().await;
3504/// # }
3505/// ```
3506pub struct MethodRenderCaptionCall<'a, S>
3507 where S: 'a {
3508
3509 hub: &'a Tenor<S>,
3510 _width: Option<i32>,
3511 _top_percent: Option<f32>,
3512 _right_percent: Option<f32>,
3513 _locale: Option<String>,
3514 _left_percent: Option<f32>,
3515 _id: Option<u64>,
3516 _height: Option<i32>,
3517 _format: Option<String>,
3518 _country: Option<String>,
3519 _component: Option<String>,
3520 _client_key: Option<String>,
3521 _caption: Option<String>,
3522 _bottom_percent: Option<f32>,
3523 _appversion: Option<String>,
3524 _anon_id: Option<String>,
3525 _delegate: Option<&'a mut dyn client::Delegate>,
3526 _additional_params: HashMap<String, String>,
3527}
3528
3529impl<'a, S> client::CallBuilder for MethodRenderCaptionCall<'a, S> {}
3530
3531impl<'a, S> MethodRenderCaptionCall<'a, S>
3532where
3533 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
3534 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3535 S::Future: Send + Unpin + 'static,
3536 S::Error: Into<Box<dyn StdError + Send + Sync>>,
3537{
3538
3539
3540 /// Perform the operation you have build so far.
3541 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleApiHttpBody)> {
3542 use std::io::{Read, Seek};
3543 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
3544 use client::{ToParts, url::Params};
3545 use std::borrow::Cow;
3546
3547 let mut dd = client::DefaultDelegate;
3548 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
3549 dlg.begin(client::MethodInfo { id: "tenor.render_caption",
3550 http_method: hyper::Method::GET });
3551
3552 for &field in ["alt", "width", "topPercent", "rightPercent", "locale", "leftPercent", "id", "height", "format", "country", "component", "clientKey", "caption", "bottomPercent", "appversion", "anonId"].iter() {
3553 if self._additional_params.contains_key(field) {
3554 dlg.finished(false);
3555 return Err(client::Error::FieldClash(field));
3556 }
3557 }
3558
3559 let mut params = Params::with_capacity(17 + self._additional_params.len());
3560 if let Some(value) = self._width.as_ref() {
3561 params.push("width", value.to_string());
3562 }
3563 if let Some(value) = self._top_percent.as_ref() {
3564 params.push("topPercent", value.to_string());
3565 }
3566 if let Some(value) = self._right_percent.as_ref() {
3567 params.push("rightPercent", value.to_string());
3568 }
3569 if let Some(value) = self._locale.as_ref() {
3570 params.push("locale", value);
3571 }
3572 if let Some(value) = self._left_percent.as_ref() {
3573 params.push("leftPercent", value.to_string());
3574 }
3575 if let Some(value) = self._id.as_ref() {
3576 params.push("id", value.to_string());
3577 }
3578 if let Some(value) = self._height.as_ref() {
3579 params.push("height", value.to_string());
3580 }
3581 if let Some(value) = self._format.as_ref() {
3582 params.push("format", value);
3583 }
3584 if let Some(value) = self._country.as_ref() {
3585 params.push("country", value);
3586 }
3587 if let Some(value) = self._component.as_ref() {
3588 params.push("component", value);
3589 }
3590 if let Some(value) = self._client_key.as_ref() {
3591 params.push("clientKey", value);
3592 }
3593 if let Some(value) = self._caption.as_ref() {
3594 params.push("caption", value);
3595 }
3596 if let Some(value) = self._bottom_percent.as_ref() {
3597 params.push("bottomPercent", value.to_string());
3598 }
3599 if let Some(value) = self._appversion.as_ref() {
3600 params.push("appversion", value);
3601 }
3602 if let Some(value) = self._anon_id.as_ref() {
3603 params.push("anonId", value);
3604 }
3605
3606 params.extend(self._additional_params.iter());
3607
3608 params.push("alt", "json");
3609 let mut url = self.hub._base_url.clone() + "v2/render_caption";
3610
3611 match dlg.api_key() {
3612 Some(value) => params.push("key", value),
3613 None => {
3614 dlg.finished(false);
3615 return Err(client::Error::MissingAPIKey)
3616 }
3617 }
3618
3619
3620 let url = params.parse_with_url(&url);
3621
3622
3623
3624 loop {
3625 let mut req_result = {
3626 let client = &self.hub.client;
3627 dlg.pre_request();
3628 let mut req_builder = hyper::Request::builder()
3629 .method(hyper::Method::GET)
3630 .uri(url.as_str())
3631 .header(USER_AGENT, self.hub._user_agent.clone());
3632
3633
3634
3635 let request = req_builder
3636 .header(CONTENT_LENGTH, 0_u64)
3637 .body(hyper::body::Body::empty());
3638
3639 client.request(request.unwrap()).await
3640
3641 };
3642
3643 match req_result {
3644 Err(err) => {
3645 if let client::Retry::After(d) = dlg.http_error(&err) {
3646 sleep(d).await;
3647 continue;
3648 }
3649 dlg.finished(false);
3650 return Err(client::Error::HttpError(err))
3651 }
3652 Ok(mut res) => {
3653 if !res.status().is_success() {
3654 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3655 let (parts, _) = res.into_parts();
3656 let body = hyper::Body::from(res_body_string.clone());
3657 let restored_response = hyper::Response::from_parts(parts, body);
3658
3659 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
3660
3661 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
3662 sleep(d).await;
3663 continue;
3664 }
3665
3666 dlg.finished(false);
3667
3668 return match server_response {
3669 Some(error_value) => Err(client::Error::BadRequest(error_value)),
3670 None => Err(client::Error::Failure(restored_response)),
3671 }
3672 }
3673 let result_value = {
3674 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3675
3676 match json::from_str(&res_body_string) {
3677 Ok(decoded) => (res, decoded),
3678 Err(err) => {
3679 dlg.response_json_decode_error(&res_body_string, &err);
3680 return Err(client::Error::JsonDecodeError(res_body_string, err));
3681 }
3682 }
3683 };
3684
3685 dlg.finished(true);
3686 return Ok(result_value)
3687 }
3688 }
3689 }
3690 }
3691
3692
3693 /// Requested width of the captioned media.
3694 ///
3695 /// Sets the *width* query property to the given value.
3696 pub fn width(mut self, new_value: i32) -> MethodRenderCaptionCall<'a, S> {
3697 self._width = Some(new_value);
3698 self
3699 }
3700 /// Percentage of top side of the bounding box.
3701 ///
3702 /// Sets the *top percent* query property to the given value.
3703 pub fn top_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
3704 self._top_percent = Some(new_value);
3705 self
3706 }
3707 /// Percentage of right side of the bounding box.
3708 ///
3709 /// Sets the *right percent* query property to the given value.
3710 pub fn right_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
3711 self._right_percent = Some(new_value);
3712 self
3713 }
3714 /// 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.
3715 ///
3716 /// Sets the *locale* query property to the given value.
3717 pub fn locale(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3718 self._locale = Some(new_value.to_string());
3719 self
3720 }
3721 /// 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.
3722 ///
3723 /// Sets the *left percent* query property to the given value.
3724 pub fn left_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
3725 self._left_percent = Some(new_value);
3726 self
3727 }
3728 /// ID of a post to use as the background media that is being captioned.
3729 ///
3730 /// Sets the *id* query property to the given value.
3731 pub fn id(mut self, new_value: u64) -> MethodRenderCaptionCall<'a, S> {
3732 self._id = Some(new_value);
3733 self
3734 }
3735 /// Requested height of the captioned media.
3736 ///
3737 /// Sets the *height* query property to the given value.
3738 pub fn height(mut self, new_value: i32) -> MethodRenderCaptionCall<'a, S> {
3739 self._height = Some(new_value);
3740 self
3741 }
3742 /// Requested output media format.
3743 ///
3744 /// Sets the *format* query property to the given value.
3745 pub fn format(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3746 self._format = Some(new_value.to_string());
3747 self
3748 }
3749 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
3750 ///
3751 /// Sets the *country* query property to the given value.
3752 pub fn country(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3753 self._country = Some(new_value.to_string());
3754 self
3755 }
3756 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
3757 ///
3758 /// Sets the *component* query property to the given value.
3759 pub fn component(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3760 self._component = Some(new_value.to_string());
3761 self
3762 }
3763 /// Client application identifier, e.g., "gboard".
3764 ///
3765 /// Sets the *client key* query property to the given value.
3766 pub fn client_key(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3767 self._client_key = Some(new_value.to_string());
3768 self
3769 }
3770 /// Caption text requested by the user.
3771 ///
3772 /// Sets the *caption* query property to the given value.
3773 pub fn caption(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3774 self._caption = Some(new_value.to_string());
3775 self
3776 }
3777 /// Percentage of bottom side of the bounding box.
3778 ///
3779 /// Sets the *bottom percent* query property to the given value.
3780 pub fn bottom_percent(mut self, new_value: f32) -> MethodRenderCaptionCall<'a, S> {
3781 self._bottom_percent = Some(new_value);
3782 self
3783 }
3784 /// Client application version, e.g., "3.1".
3785 ///
3786 /// Sets the *appversion* query property to the given value.
3787 pub fn appversion(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3788 self._appversion = Some(new_value.to_string());
3789 self
3790 }
3791 /// Pseudonymous user id tied to the user.
3792 ///
3793 /// Sets the *anon id* query property to the given value.
3794 pub fn anon_id(mut self, new_value: &str) -> MethodRenderCaptionCall<'a, S> {
3795 self._anon_id = Some(new_value.to_string());
3796 self
3797 }
3798 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3799 /// while executing the actual API request.
3800 ///
3801 /// ````text
3802 /// It should be used to handle progress information, and to implement a certain level of resilience.
3803 /// ````
3804 ///
3805 /// Sets the *delegate* property to the given value.
3806 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodRenderCaptionCall<'a, S> {
3807 self._delegate = Some(new_value);
3808 self
3809 }
3810
3811 /// Set any additional parameter of the query string used in the request.
3812 /// It should be used to set parameters which are not yet available through their own
3813 /// setters.
3814 ///
3815 /// Please note that this method must not be used to set any of the known parameters
3816 /// which have their own setter method. If done anyway, the request will fail.
3817 ///
3818 /// # Additional Parameters
3819 ///
3820 /// * *$.xgafv* (query-string) - V1 error format.
3821 /// * *access_token* (query-string) - OAuth access token.
3822 /// * *alt* (query-string) - Data format for response.
3823 /// * *callback* (query-string) - JSONP
3824 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3825 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3826 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3827 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3828 /// * *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.
3829 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3830 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3831 pub fn param<T>(mut self, name: T, value: T) -> MethodRenderCaptionCall<'a, S>
3832 where T: AsRef<str> {
3833 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
3834 self
3835 }
3836
3837}
3838
3839
3840/// Searches for posts (i.e., GIFs).
3841///
3842/// A builder for the *search* method.
3843/// It is not used directly, but through a [`MethodMethods`] instance.
3844///
3845/// # Example
3846///
3847/// Instantiate a resource method builder
3848///
3849/// ```test_harness,no_run
3850/// # extern crate hyper;
3851/// # extern crate hyper_rustls;
3852/// # extern crate google_tenor2 as tenor2;
3853/// # async fn dox() {
3854/// # use std::default::Default;
3855/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
3856/// #
3857/// # let secret: oauth2::ApplicationSecret = Default::default();
3858/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3859/// # secret,
3860/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3861/// # ).build().await.unwrap();
3862/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
3863/// // You can configure optional parameters by calling the respective setters at will, and
3864/// // execute the final call using `doit()`.
3865/// // Values shown here are possibly random and not representative !
3866/// let result = hub.methods().search()
3867/// .searchfilter("vero")
3868/// .random(false)
3869/// .q("Stet")
3870/// .pos("vero")
3871/// .media_filter("elitr")
3872/// .locale("Lorem")
3873/// .limit(-29)
3874/// .country("no")
3875/// .contentfilter("ipsum")
3876/// .component("accusam")
3877/// .client_key("takimata")
3878/// .ar_range("consetetur")
3879/// .appversion("voluptua.")
3880/// .anon_id("et")
3881/// .doit().await;
3882/// # }
3883/// ```
3884pub struct MethodSearchCall<'a, S>
3885 where S: 'a {
3886
3887 hub: &'a Tenor<S>,
3888 _searchfilter: Option<String>,
3889 _random: Option<bool>,
3890 _q: Option<String>,
3891 _pos: Option<String>,
3892 _media_filter: Option<String>,
3893 _locale: Option<String>,
3894 _limit: Option<i32>,
3895 _country: Option<String>,
3896 _contentfilter: Option<String>,
3897 _component: Option<String>,
3898 _client_key: Option<String>,
3899 _ar_range: Option<String>,
3900 _appversion: Option<String>,
3901 _anon_id: Option<String>,
3902 _delegate: Option<&'a mut dyn client::Delegate>,
3903 _additional_params: HashMap<String, String>,
3904}
3905
3906impl<'a, S> client::CallBuilder for MethodSearchCall<'a, S> {}
3907
3908impl<'a, S> MethodSearchCall<'a, S>
3909where
3910 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
3911 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3912 S::Future: Send + Unpin + 'static,
3913 S::Error: Into<Box<dyn StdError + Send + Sync>>,
3914{
3915
3916
3917 /// Perform the operation you have build so far.
3918 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2SearchPostsResponse)> {
3919 use std::io::{Read, Seek};
3920 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
3921 use client::{ToParts, url::Params};
3922 use std::borrow::Cow;
3923
3924 let mut dd = client::DefaultDelegate;
3925 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
3926 dlg.begin(client::MethodInfo { id: "tenor.search",
3927 http_method: hyper::Method::GET });
3928
3929 for &field in ["alt", "searchfilter", "random", "q", "pos", "mediaFilter", "locale", "limit", "country", "contentfilter", "component", "clientKey", "arRange", "appversion", "anonId"].iter() {
3930 if self._additional_params.contains_key(field) {
3931 dlg.finished(false);
3932 return Err(client::Error::FieldClash(field));
3933 }
3934 }
3935
3936 let mut params = Params::with_capacity(16 + self._additional_params.len());
3937 if let Some(value) = self._searchfilter.as_ref() {
3938 params.push("searchfilter", value);
3939 }
3940 if let Some(value) = self._random.as_ref() {
3941 params.push("random", value.to_string());
3942 }
3943 if let Some(value) = self._q.as_ref() {
3944 params.push("q", value);
3945 }
3946 if let Some(value) = self._pos.as_ref() {
3947 params.push("pos", value);
3948 }
3949 if let Some(value) = self._media_filter.as_ref() {
3950 params.push("mediaFilter", value);
3951 }
3952 if let Some(value) = self._locale.as_ref() {
3953 params.push("locale", value);
3954 }
3955 if let Some(value) = self._limit.as_ref() {
3956 params.push("limit", value.to_string());
3957 }
3958 if let Some(value) = self._country.as_ref() {
3959 params.push("country", value);
3960 }
3961 if let Some(value) = self._contentfilter.as_ref() {
3962 params.push("contentfilter", value);
3963 }
3964 if let Some(value) = self._component.as_ref() {
3965 params.push("component", value);
3966 }
3967 if let Some(value) = self._client_key.as_ref() {
3968 params.push("clientKey", value);
3969 }
3970 if let Some(value) = self._ar_range.as_ref() {
3971 params.push("arRange", value);
3972 }
3973 if let Some(value) = self._appversion.as_ref() {
3974 params.push("appversion", value);
3975 }
3976 if let Some(value) = self._anon_id.as_ref() {
3977 params.push("anonId", value);
3978 }
3979
3980 params.extend(self._additional_params.iter());
3981
3982 params.push("alt", "json");
3983 let mut url = self.hub._base_url.clone() + "v2/search";
3984
3985 match dlg.api_key() {
3986 Some(value) => params.push("key", value),
3987 None => {
3988 dlg.finished(false);
3989 return Err(client::Error::MissingAPIKey)
3990 }
3991 }
3992
3993
3994 let url = params.parse_with_url(&url);
3995
3996
3997
3998 loop {
3999 let mut req_result = {
4000 let client = &self.hub.client;
4001 dlg.pre_request();
4002 let mut req_builder = hyper::Request::builder()
4003 .method(hyper::Method::GET)
4004 .uri(url.as_str())
4005 .header(USER_AGENT, self.hub._user_agent.clone());
4006
4007
4008
4009 let request = req_builder
4010 .header(CONTENT_LENGTH, 0_u64)
4011 .body(hyper::body::Body::empty());
4012
4013 client.request(request.unwrap()).await
4014
4015 };
4016
4017 match req_result {
4018 Err(err) => {
4019 if let client::Retry::After(d) = dlg.http_error(&err) {
4020 sleep(d).await;
4021 continue;
4022 }
4023 dlg.finished(false);
4024 return Err(client::Error::HttpError(err))
4025 }
4026 Ok(mut res) => {
4027 if !res.status().is_success() {
4028 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4029 let (parts, _) = res.into_parts();
4030 let body = hyper::Body::from(res_body_string.clone());
4031 let restored_response = hyper::Response::from_parts(parts, body);
4032
4033 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
4034
4035 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
4036 sleep(d).await;
4037 continue;
4038 }
4039
4040 dlg.finished(false);
4041
4042 return match server_response {
4043 Some(error_value) => Err(client::Error::BadRequest(error_value)),
4044 None => Err(client::Error::Failure(restored_response)),
4045 }
4046 }
4047 let result_value = {
4048 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4049
4050 match json::from_str(&res_body_string) {
4051 Ok(decoded) => (res, decoded),
4052 Err(err) => {
4053 dlg.response_json_decode_error(&res_body_string, &err);
4054 return Err(client::Error::JsonDecodeError(res_body_string, err));
4055 }
4056 }
4057 };
4058
4059 dlg.finished(true);
4060 return Ok(result_value)
4061 }
4062 }
4063 }
4064 }
4065
4066
4067 /// 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.
4068 ///
4069 /// Sets the *searchfilter* query property to the given value.
4070 pub fn searchfilter(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4071 self._searchfilter = Some(new_value.to_string());
4072 self
4073 }
4074 /// Whether or not randomize the search results in the response.
4075 ///
4076 /// Sets the *random* query property to the given value.
4077 pub fn random(mut self, new_value: bool) -> MethodSearchCall<'a, S> {
4078 self._random = Some(new_value);
4079 self
4080 }
4081 /// Required. The search query.
4082 ///
4083 /// Sets the *q* query property to the given value.
4084 pub fn q(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4085 self._q = Some(new_value.to_string());
4086 self
4087 }
4088 /// 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.
4089 ///
4090 /// Sets the *pos* query property to the given value.
4091 pub fn pos(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4092 self._pos = Some(new_value.to_string());
4093 self
4094 }
4095 /// 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.
4096 ///
4097 /// Sets the *media filter* query property to the given value.
4098 pub fn media_filter(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4099 self._media_filter = Some(new_value.to_string());
4100 self
4101 }
4102 /// 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.
4103 ///
4104 /// Sets the *locale* query property to the given value.
4105 pub fn locale(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4106 self._locale = Some(new_value.to_string());
4107 self
4108 }
4109 /// The maximum number of results to be returned. The default is 20.
4110 ///
4111 /// Sets the *limit* query property to the given value.
4112 pub fn limit(mut self, new_value: i32) -> MethodSearchCall<'a, S> {
4113 self._limit = Some(new_value);
4114 self
4115 }
4116 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
4117 ///
4118 /// Sets the *country* query property to the given value.
4119 pub fn country(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4120 self._country = Some(new_value.to_string());
4121 self
4122 }
4123 /// The content filter level. The default is configurable per client.
4124 ///
4125 /// Sets the *contentfilter* query property to the given value.
4126 pub fn contentfilter(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4127 self._contentfilter = Some(new_value.to_string());
4128 self
4129 }
4130 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
4131 ///
4132 /// Sets the *component* query property to the given value.
4133 pub fn component(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4134 self._component = Some(new_value.to_string());
4135 self
4136 }
4137 /// Client application identifier, e.g., "gboard".
4138 ///
4139 /// Sets the *client key* query property to the given value.
4140 pub fn client_key(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4141 self._client_key = Some(new_value.to_string());
4142 self
4143 }
4144 /// 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].
4145 ///
4146 /// Sets the *ar range* query property to the given value.
4147 pub fn ar_range(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4148 self._ar_range = Some(new_value.to_string());
4149 self
4150 }
4151 /// Client application version, e.g., "3.1".
4152 ///
4153 /// Sets the *appversion* query property to the given value.
4154 pub fn appversion(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4155 self._appversion = Some(new_value.to_string());
4156 self
4157 }
4158 /// Pseudonymous user id tied to the user.
4159 ///
4160 /// Sets the *anon id* query property to the given value.
4161 pub fn anon_id(mut self, new_value: &str) -> MethodSearchCall<'a, S> {
4162 self._anon_id = Some(new_value.to_string());
4163 self
4164 }
4165 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4166 /// while executing the actual API request.
4167 ///
4168 /// ````text
4169 /// It should be used to handle progress information, and to implement a certain level of resilience.
4170 /// ````
4171 ///
4172 /// Sets the *delegate* property to the given value.
4173 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodSearchCall<'a, S> {
4174 self._delegate = Some(new_value);
4175 self
4176 }
4177
4178 /// Set any additional parameter of the query string used in the request.
4179 /// It should be used to set parameters which are not yet available through their own
4180 /// setters.
4181 ///
4182 /// Please note that this method must not be used to set any of the known parameters
4183 /// which have their own setter method. If done anyway, the request will fail.
4184 ///
4185 /// # Additional Parameters
4186 ///
4187 /// * *$.xgafv* (query-string) - V1 error format.
4188 /// * *access_token* (query-string) - OAuth access token.
4189 /// * *alt* (query-string) - Data format for response.
4190 /// * *callback* (query-string) - JSONP
4191 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4192 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4193 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4194 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4195 /// * *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.
4196 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4197 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4198 pub fn param<T>(mut self, name: T, value: T) -> MethodSearchCall<'a, S>
4199 where T: AsRef<str> {
4200 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
4201 self
4202 }
4203
4204}
4205
4206
4207/// Search Suggestions.
4208///
4209/// A builder for the *search_suggestions* method.
4210/// It is not used directly, but through a [`MethodMethods`] instance.
4211///
4212/// # Example
4213///
4214/// Instantiate a resource method builder
4215///
4216/// ```test_harness,no_run
4217/// # extern crate hyper;
4218/// # extern crate hyper_rustls;
4219/// # extern crate google_tenor2 as tenor2;
4220/// # async fn dox() {
4221/// # use std::default::Default;
4222/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
4223/// #
4224/// # let secret: oauth2::ApplicationSecret = Default::default();
4225/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4226/// # secret,
4227/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4228/// # ).build().await.unwrap();
4229/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
4230/// // You can configure optional parameters by calling the respective setters at will, and
4231/// // execute the final call using `doit()`.
4232/// // Values shown here are possibly random and not representative !
4233/// let result = hub.methods().search_suggestions()
4234/// .q("erat")
4235/// .locale("consetetur")
4236/// .limit(-2)
4237/// .country("sed")
4238/// .component("takimata")
4239/// .client_key("dolores")
4240/// .appversion("gubergren")
4241/// .anon_id("et")
4242/// .doit().await;
4243/// # }
4244/// ```
4245pub struct MethodSearchSuggestionCall<'a, S>
4246 where S: 'a {
4247
4248 hub: &'a Tenor<S>,
4249 _q: Option<String>,
4250 _locale: Option<String>,
4251 _limit: Option<i32>,
4252 _country: Option<String>,
4253 _component: Option<String>,
4254 _client_key: Option<String>,
4255 _appversion: Option<String>,
4256 _anon_id: Option<String>,
4257 _delegate: Option<&'a mut dyn client::Delegate>,
4258 _additional_params: HashMap<String, String>,
4259}
4260
4261impl<'a, S> client::CallBuilder for MethodSearchSuggestionCall<'a, S> {}
4262
4263impl<'a, S> MethodSearchSuggestionCall<'a, S>
4264where
4265 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
4266 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4267 S::Future: Send + Unpin + 'static,
4268 S::Error: Into<Box<dyn StdError + Send + Sync>>,
4269{
4270
4271
4272 /// Perform the operation you have build so far.
4273 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2SearchSuggestionsResponse)> {
4274 use std::io::{Read, Seek};
4275 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
4276 use client::{ToParts, url::Params};
4277 use std::borrow::Cow;
4278
4279 let mut dd = client::DefaultDelegate;
4280 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
4281 dlg.begin(client::MethodInfo { id: "tenor.search_suggestions",
4282 http_method: hyper::Method::GET });
4283
4284 for &field in ["alt", "q", "locale", "limit", "country", "component", "clientKey", "appversion", "anonId"].iter() {
4285 if self._additional_params.contains_key(field) {
4286 dlg.finished(false);
4287 return Err(client::Error::FieldClash(field));
4288 }
4289 }
4290
4291 let mut params = Params::with_capacity(10 + self._additional_params.len());
4292 if let Some(value) = self._q.as_ref() {
4293 params.push("q", value);
4294 }
4295 if let Some(value) = self._locale.as_ref() {
4296 params.push("locale", value);
4297 }
4298 if let Some(value) = self._limit.as_ref() {
4299 params.push("limit", value.to_string());
4300 }
4301 if let Some(value) = self._country.as_ref() {
4302 params.push("country", value);
4303 }
4304 if let Some(value) = self._component.as_ref() {
4305 params.push("component", value);
4306 }
4307 if let Some(value) = self._client_key.as_ref() {
4308 params.push("clientKey", value);
4309 }
4310 if let Some(value) = self._appversion.as_ref() {
4311 params.push("appversion", value);
4312 }
4313 if let Some(value) = self._anon_id.as_ref() {
4314 params.push("anonId", value);
4315 }
4316
4317 params.extend(self._additional_params.iter());
4318
4319 params.push("alt", "json");
4320 let mut url = self.hub._base_url.clone() + "v2/search_suggestions";
4321
4322 match dlg.api_key() {
4323 Some(value) => params.push("key", value),
4324 None => {
4325 dlg.finished(false);
4326 return Err(client::Error::MissingAPIKey)
4327 }
4328 }
4329
4330
4331 let url = params.parse_with_url(&url);
4332
4333
4334
4335 loop {
4336 let mut req_result = {
4337 let client = &self.hub.client;
4338 dlg.pre_request();
4339 let mut req_builder = hyper::Request::builder()
4340 .method(hyper::Method::GET)
4341 .uri(url.as_str())
4342 .header(USER_AGENT, self.hub._user_agent.clone());
4343
4344
4345
4346 let request = req_builder
4347 .header(CONTENT_LENGTH, 0_u64)
4348 .body(hyper::body::Body::empty());
4349
4350 client.request(request.unwrap()).await
4351
4352 };
4353
4354 match req_result {
4355 Err(err) => {
4356 if let client::Retry::After(d) = dlg.http_error(&err) {
4357 sleep(d).await;
4358 continue;
4359 }
4360 dlg.finished(false);
4361 return Err(client::Error::HttpError(err))
4362 }
4363 Ok(mut res) => {
4364 if !res.status().is_success() {
4365 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4366 let (parts, _) = res.into_parts();
4367 let body = hyper::Body::from(res_body_string.clone());
4368 let restored_response = hyper::Response::from_parts(parts, body);
4369
4370 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
4371
4372 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
4373 sleep(d).await;
4374 continue;
4375 }
4376
4377 dlg.finished(false);
4378
4379 return match server_response {
4380 Some(error_value) => Err(client::Error::BadRequest(error_value)),
4381 None => Err(client::Error::Failure(restored_response)),
4382 }
4383 }
4384 let result_value = {
4385 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4386
4387 match json::from_str(&res_body_string) {
4388 Ok(decoded) => (res, decoded),
4389 Err(err) => {
4390 dlg.response_json_decode_error(&res_body_string, &err);
4391 return Err(client::Error::JsonDecodeError(res_body_string, err));
4392 }
4393 }
4394 };
4395
4396 dlg.finished(true);
4397 return Ok(result_value)
4398 }
4399 }
4400 }
4401 }
4402
4403
4404 /// Required. The search query.
4405 ///
4406 /// Sets the *q* query property to the given value.
4407 pub fn q(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
4408 self._q = Some(new_value.to_string());
4409 self
4410 }
4411 /// 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.
4412 ///
4413 /// Sets the *locale* query property to the given value.
4414 pub fn locale(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
4415 self._locale = Some(new_value.to_string());
4416 self
4417 }
4418 /// The maximum number of results to be returned. The default is 8.
4419 ///
4420 /// Sets the *limit* query property to the given value.
4421 pub fn limit(mut self, new_value: i32) -> MethodSearchSuggestionCall<'a, S> {
4422 self._limit = Some(new_value);
4423 self
4424 }
4425 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
4426 ///
4427 /// Sets the *country* query property to the given value.
4428 pub fn country(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
4429 self._country = Some(new_value.to_string());
4430 self
4431 }
4432 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
4433 ///
4434 /// Sets the *component* query property to the given value.
4435 pub fn component(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
4436 self._component = Some(new_value.to_string());
4437 self
4438 }
4439 /// Client application identifier, e.g., "gboard".
4440 ///
4441 /// Sets the *client key* query property to the given value.
4442 pub fn client_key(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
4443 self._client_key = Some(new_value.to_string());
4444 self
4445 }
4446 /// Client application version, e.g., "3.1".
4447 ///
4448 /// Sets the *appversion* query property to the given value.
4449 pub fn appversion(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
4450 self._appversion = Some(new_value.to_string());
4451 self
4452 }
4453 /// Pseudonymous user id tied to the user.
4454 ///
4455 /// Sets the *anon id* query property to the given value.
4456 pub fn anon_id(mut self, new_value: &str) -> MethodSearchSuggestionCall<'a, S> {
4457 self._anon_id = Some(new_value.to_string());
4458 self
4459 }
4460 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4461 /// while executing the actual API request.
4462 ///
4463 /// ````text
4464 /// It should be used to handle progress information, and to implement a certain level of resilience.
4465 /// ````
4466 ///
4467 /// Sets the *delegate* property to the given value.
4468 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodSearchSuggestionCall<'a, S> {
4469 self._delegate = Some(new_value);
4470 self
4471 }
4472
4473 /// Set any additional parameter of the query string used in the request.
4474 /// It should be used to set parameters which are not yet available through their own
4475 /// setters.
4476 ///
4477 /// Please note that this method must not be used to set any of the known parameters
4478 /// which have their own setter method. If done anyway, the request will fail.
4479 ///
4480 /// # Additional Parameters
4481 ///
4482 /// * *$.xgafv* (query-string) - V1 error format.
4483 /// * *access_token* (query-string) - OAuth access token.
4484 /// * *alt* (query-string) - Data format for response.
4485 /// * *callback* (query-string) - JSONP
4486 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4487 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4488 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4489 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4490 /// * *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.
4491 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4492 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4493 pub fn param<T>(mut self, name: T, value: T) -> MethodSearchSuggestionCall<'a, S>
4494 where T: AsRef<str> {
4495 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
4496 self
4497 }
4498
4499}
4500
4501
4502/// Trending terms.
4503///
4504/// A builder for the *trending_terms* method.
4505/// It is not used directly, but through a [`MethodMethods`] instance.
4506///
4507/// # Example
4508///
4509/// Instantiate a resource method builder
4510///
4511/// ```test_harness,no_run
4512/// # extern crate hyper;
4513/// # extern crate hyper_rustls;
4514/// # extern crate google_tenor2 as tenor2;
4515/// # async fn dox() {
4516/// # use std::default::Default;
4517/// # use tenor2::{Tenor, oauth2, hyper, hyper_rustls, chrono, FieldMask};
4518/// #
4519/// # let secret: oauth2::ApplicationSecret = Default::default();
4520/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4521/// # secret,
4522/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4523/// # ).build().await.unwrap();
4524/// # let mut hub = Tenor::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
4525/// // You can configure optional parameters by calling the respective setters at will, and
4526/// // execute the final call using `doit()`.
4527/// // Values shown here are possibly random and not representative !
4528/// let result = hub.methods().trending_terms()
4529/// .locale("accusam")
4530/// .limit(-78)
4531/// .country("dolore")
4532/// .component("dolore")
4533/// .client_key("dolore")
4534/// .appversion("voluptua.")
4535/// .anon_id("amet.")
4536/// .doit().await;
4537/// # }
4538/// ```
4539pub struct MethodTrendingTermCall<'a, S>
4540 where S: 'a {
4541
4542 hub: &'a Tenor<S>,
4543 _locale: Option<String>,
4544 _limit: Option<i64>,
4545 _country: Option<String>,
4546 _component: Option<String>,
4547 _client_key: Option<String>,
4548 _appversion: Option<String>,
4549 _anon_id: Option<String>,
4550 _delegate: Option<&'a mut dyn client::Delegate>,
4551 _additional_params: HashMap<String, String>,
4552}
4553
4554impl<'a, S> client::CallBuilder for MethodTrendingTermCall<'a, S> {}
4555
4556impl<'a, S> MethodTrendingTermCall<'a, S>
4557where
4558 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
4559 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4560 S::Future: Send + Unpin + 'static,
4561 S::Error: Into<Box<dyn StdError + Send + Sync>>,
4562{
4563
4564
4565 /// Perform the operation you have build so far.
4566 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleSearchTenorV2TrendingTermsResponse)> {
4567 use std::io::{Read, Seek};
4568 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
4569 use client::{ToParts, url::Params};
4570 use std::borrow::Cow;
4571
4572 let mut dd = client::DefaultDelegate;
4573 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
4574 dlg.begin(client::MethodInfo { id: "tenor.trending_terms",
4575 http_method: hyper::Method::GET });
4576
4577 for &field in ["alt", "locale", "limit", "country", "component", "clientKey", "appversion", "anonId"].iter() {
4578 if self._additional_params.contains_key(field) {
4579 dlg.finished(false);
4580 return Err(client::Error::FieldClash(field));
4581 }
4582 }
4583
4584 let mut params = Params::with_capacity(9 + self._additional_params.len());
4585 if let Some(value) = self._locale.as_ref() {
4586 params.push("locale", value);
4587 }
4588 if let Some(value) = self._limit.as_ref() {
4589 params.push("limit", value.to_string());
4590 }
4591 if let Some(value) = self._country.as_ref() {
4592 params.push("country", value);
4593 }
4594 if let Some(value) = self._component.as_ref() {
4595 params.push("component", value);
4596 }
4597 if let Some(value) = self._client_key.as_ref() {
4598 params.push("clientKey", value);
4599 }
4600 if let Some(value) = self._appversion.as_ref() {
4601 params.push("appversion", value);
4602 }
4603 if let Some(value) = self._anon_id.as_ref() {
4604 params.push("anonId", value);
4605 }
4606
4607 params.extend(self._additional_params.iter());
4608
4609 params.push("alt", "json");
4610 let mut url = self.hub._base_url.clone() + "v2/trending_terms";
4611
4612 match dlg.api_key() {
4613 Some(value) => params.push("key", value),
4614 None => {
4615 dlg.finished(false);
4616 return Err(client::Error::MissingAPIKey)
4617 }
4618 }
4619
4620
4621 let url = params.parse_with_url(&url);
4622
4623
4624
4625 loop {
4626 let mut req_result = {
4627 let client = &self.hub.client;
4628 dlg.pre_request();
4629 let mut req_builder = hyper::Request::builder()
4630 .method(hyper::Method::GET)
4631 .uri(url.as_str())
4632 .header(USER_AGENT, self.hub._user_agent.clone());
4633
4634
4635
4636 let request = req_builder
4637 .header(CONTENT_LENGTH, 0_u64)
4638 .body(hyper::body::Body::empty());
4639
4640 client.request(request.unwrap()).await
4641
4642 };
4643
4644 match req_result {
4645 Err(err) => {
4646 if let client::Retry::After(d) = dlg.http_error(&err) {
4647 sleep(d).await;
4648 continue;
4649 }
4650 dlg.finished(false);
4651 return Err(client::Error::HttpError(err))
4652 }
4653 Ok(mut res) => {
4654 if !res.status().is_success() {
4655 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4656 let (parts, _) = res.into_parts();
4657 let body = hyper::Body::from(res_body_string.clone());
4658 let restored_response = hyper::Response::from_parts(parts, body);
4659
4660 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
4661
4662 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
4663 sleep(d).await;
4664 continue;
4665 }
4666
4667 dlg.finished(false);
4668
4669 return match server_response {
4670 Some(error_value) => Err(client::Error::BadRequest(error_value)),
4671 None => Err(client::Error::Failure(restored_response)),
4672 }
4673 }
4674 let result_value = {
4675 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4676
4677 match json::from_str(&res_body_string) {
4678 Ok(decoded) => (res, decoded),
4679 Err(err) => {
4680 dlg.response_json_decode_error(&res_body_string, &err);
4681 return Err(client::Error::JsonDecodeError(res_body_string, err));
4682 }
4683 }
4684 };
4685
4686 dlg.finished(true);
4687 return Ok(result_value)
4688 }
4689 }
4690 }
4691 }
4692
4693
4694 /// 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.
4695 ///
4696 /// Sets the *locale* query property to the given value.
4697 pub fn locale(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
4698 self._locale = Some(new_value.to_string());
4699 self
4700 }
4701 /// The number of terms desired. The default is 20 and the max is 50.
4702 ///
4703 /// Sets the *limit* query property to the given value.
4704 pub fn limit(mut self, new_value: i64) -> MethodTrendingTermCall<'a, S> {
4705 self._limit = Some(new_value);
4706 self
4707 }
4708 /// User's location in ISO 3166-1 alpha-2 code, e.g., "CA", "GB".
4709 ///
4710 /// Sets the *country* query property to the given value.
4711 pub fn country(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
4712 self._country = Some(new_value.to_string());
4713 self
4714 }
4715 /// UI component where the action was initiated, e.g., "trending". This string is client specific.
4716 ///
4717 /// Sets the *component* query property to the given value.
4718 pub fn component(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
4719 self._component = Some(new_value.to_string());
4720 self
4721 }
4722 /// Client application identifier, e.g., "gboard".
4723 ///
4724 /// Sets the *client key* query property to the given value.
4725 pub fn client_key(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
4726 self._client_key = Some(new_value.to_string());
4727 self
4728 }
4729 /// Client application version, e.g., "3.1".
4730 ///
4731 /// Sets the *appversion* query property to the given value.
4732 pub fn appversion(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
4733 self._appversion = Some(new_value.to_string());
4734 self
4735 }
4736 /// Pseudonymous user id tied to the user.
4737 ///
4738 /// Sets the *anon id* query property to the given value.
4739 pub fn anon_id(mut self, new_value: &str) -> MethodTrendingTermCall<'a, S> {
4740 self._anon_id = Some(new_value.to_string());
4741 self
4742 }
4743 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4744 /// while executing the actual API request.
4745 ///
4746 /// ````text
4747 /// It should be used to handle progress information, and to implement a certain level of resilience.
4748 /// ````
4749 ///
4750 /// Sets the *delegate* property to the given value.
4751 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodTrendingTermCall<'a, S> {
4752 self._delegate = Some(new_value);
4753 self
4754 }
4755
4756 /// Set any additional parameter of the query string used in the request.
4757 /// It should be used to set parameters which are not yet available through their own
4758 /// setters.
4759 ///
4760 /// Please note that this method must not be used to set any of the known parameters
4761 /// which have their own setter method. If done anyway, the request will fail.
4762 ///
4763 /// # Additional Parameters
4764 ///
4765 /// * *$.xgafv* (query-string) - V1 error format.
4766 /// * *access_token* (query-string) - OAuth access token.
4767 /// * *alt* (query-string) - Data format for response.
4768 /// * *callback* (query-string) - JSONP
4769 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4770 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4771 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4772 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4773 /// * *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.
4774 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4775 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4776 pub fn param<T>(mut self, name: T, value: T) -> MethodTrendingTermCall<'a, S>
4777 where T: AsRef<str> {
4778 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
4779 self
4780 }
4781
4782}
4783
4784