google_firebasedynamiclinks1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// View and administer all your Firebase data and settings
17    Firebase,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::Firebase => "https://www.googleapis.com/auth/firebase",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::Firebase
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all FirebaseDynamicLinks related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
49/// use firebasedynamiclinks1::api::GetIosPostInstallAttributionRequest;
50/// use firebasedynamiclinks1::{Result, Error};
51/// # async fn dox() {
52/// use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63///     secret,
64///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68///     hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71///     hyper_rustls::HttpsConnectorBuilder::new()
72///         .with_native_roots()
73///         .unwrap()
74///         .https_or_http()
75///         .enable_http1()
76///         .build()
77/// );
78/// let mut hub = FirebaseDynamicLinks::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = GetIosPostInstallAttributionRequest::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.methods().install_attribution(req)
88///              .doit().await;
89///
90/// match result {
91///     Err(e) => match e {
92///         // The Error enum provides details about what exactly happened.
93///         // You can also just use its `Debug`, `Display` or `Error` traits
94///          Error::HttpError(_)
95///         |Error::Io(_)
96///         |Error::MissingAPIKey
97///         |Error::MissingToken(_)
98///         |Error::Cancelled
99///         |Error::UploadSizeLimitExceeded(_, _)
100///         |Error::Failure(_)
101///         |Error::BadRequest(_)
102///         |Error::FieldClash(_)
103///         |Error::JsonDecodeError(_, _) => println!("{}", e),
104///     },
105///     Ok(res) => println!("Success: {:?}", res),
106/// }
107/// # }
108/// ```
109#[derive(Clone)]
110pub struct FirebaseDynamicLinks<C> {
111    pub client: common::Client<C>,
112    pub auth: Box<dyn common::GetToken>,
113    _user_agent: String,
114    _base_url: String,
115    _root_url: String,
116}
117
118impl<C> common::Hub for FirebaseDynamicLinks<C> {}
119
120impl<'a, C> FirebaseDynamicLinks<C> {
121    pub fn new<A: 'static + common::GetToken>(
122        client: common::Client<C>,
123        auth: A,
124    ) -> FirebaseDynamicLinks<C> {
125        FirebaseDynamicLinks {
126            client,
127            auth: Box::new(auth),
128            _user_agent: "google-api-rust-client/6.0.0".to_string(),
129            _base_url: "https://firebasedynamiclinks.googleapis.com/".to_string(),
130            _root_url: "https://firebasedynamiclinks.googleapis.com/".to_string(),
131        }
132    }
133
134    pub fn managed_short_links(&'a self) -> ManagedShortLinkMethods<'a, C> {
135        ManagedShortLinkMethods { hub: self }
136    }
137    pub fn methods(&'a self) -> MethodMethods<'a, C> {
138        MethodMethods { hub: self }
139    }
140    pub fn short_links(&'a self) -> ShortLinkMethods<'a, C> {
141        ShortLinkMethods { hub: self }
142    }
143
144    /// Set the user-agent header field to use in all requests to the server.
145    /// It defaults to `google-api-rust-client/6.0.0`.
146    ///
147    /// Returns the previously set user-agent.
148    pub fn user_agent(&mut self, agent_name: String) -> String {
149        std::mem::replace(&mut self._user_agent, agent_name)
150    }
151
152    /// Set the base url to use in all requests to the server.
153    /// It defaults to `https://firebasedynamiclinks.googleapis.com/`.
154    ///
155    /// Returns the previously set base url.
156    pub fn base_url(&mut self, new_base_url: String) -> String {
157        std::mem::replace(&mut self._base_url, new_base_url)
158    }
159
160    /// Set the root url to use in all requests to the server.
161    /// It defaults to `https://firebasedynamiclinks.googleapis.com/`.
162    ///
163    /// Returns the previously set root url.
164    pub fn root_url(&mut self, new_root_url: String) -> String {
165        std::mem::replace(&mut self._root_url, new_root_url)
166    }
167}
168
169// ############
170// SCHEMAS ###
171// ##########
172/// Tracking parameters supported by Dynamic Link.
173///
174/// This type is not used in any activity, and only used as *part* of another schema.
175///
176#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
177#[serde_with::serde_as]
178#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
179pub struct AnalyticsInfo {
180    /// Google Play Campaign Measurements.
181    #[serde(rename = "googlePlayAnalytics")]
182    pub google_play_analytics: Option<GooglePlayAnalytics>,
183    /// iTunes Connect App Analytics.
184    #[serde(rename = "itunesConnectAnalytics")]
185    pub itunes_connect_analytics: Option<ITunesConnectAnalytics>,
186}
187
188impl common::Part for AnalyticsInfo {}
189
190/// Android related attributes to the Dynamic Link.
191///
192/// This type is not used in any activity, and only used as *part* of another schema.
193///
194#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
195#[serde_with::serde_as]
196#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
197pub struct AndroidInfo {
198    /// Link to open on Android if the app is not installed.
199    #[serde(rename = "androidFallbackLink")]
200    pub android_fallback_link: Option<String>,
201    /// If specified, this overrides the ‘link’ parameter on Android.
202    #[serde(rename = "androidLink")]
203    pub android_link: Option<String>,
204    /// Minimum version code for the Android app. If the installed app’s version code is lower, then the user is taken to the Play Store.
205    #[serde(rename = "androidMinPackageVersionCode")]
206    pub android_min_package_version_code: Option<String>,
207    /// Android package name of the app.
208    #[serde(rename = "androidPackageName")]
209    pub android_package_name: Option<String>,
210}
211
212impl common::Part for AndroidInfo {}
213
214/// Request to create a managed Short Dynamic Link.
215///
216/// # Activities
217///
218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
220///
221/// * [create managed short links](ManagedShortLinkCreateCall) (request)
222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
223#[serde_with::serde_as]
224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
225pub struct CreateManagedShortLinkRequest {
226    /// Information about the Dynamic Link to be shortened. [Learn more](https://firebase.google.com/docs/reference/dynamic-links/link-shortener).
227    #[serde(rename = "dynamicLinkInfo")]
228    pub dynamic_link_info: Option<DynamicLinkInfo>,
229    /// Full long Dynamic Link URL with desired query parameters specified. For example, "https://sample.app.goo.gl/?link=http://www.google.com&apn=com.sample", [Learn more](https://firebase.google.com/docs/reference/dynamic-links/link-shortener).
230    #[serde(rename = "longDynamicLink")]
231    pub long_dynamic_link: Option<String>,
232    /// Link name to associate with the link. It's used for marketer to identify manually-created links in the Firebase console (https://console.firebase.google.com/). Links must be named to be tracked.
233    pub name: Option<String>,
234    /// Google SDK version. Version takes the form "$major.$minor.$patch"
235    #[serde(rename = "sdkVersion")]
236    pub sdk_version: Option<String>,
237    /// Short Dynamic Link suffix. Optional.
238    pub suffix: Option<Suffix>,
239}
240
241impl common::RequestValue for CreateManagedShortLinkRequest {}
242
243/// Response to create a short Dynamic Link.
244///
245/// # Activities
246///
247/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
248/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
249///
250/// * [create managed short links](ManagedShortLinkCreateCall) (response)
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct CreateManagedShortLinkResponse {
255    /// Short Dynamic Link value. e.g. https://abcd.app.goo.gl/wxyz
256    #[serde(rename = "managedShortLink")]
257    pub managed_short_link: Option<ManagedShortLink>,
258    /// Preview link to show the link flow chart. (debug info.)
259    #[serde(rename = "previewLink")]
260    pub preview_link: Option<String>,
261    /// Information about potential warnings on link creation.
262    pub warning: Option<Vec<DynamicLinkWarning>>,
263}
264
265impl common::ResponseResult for CreateManagedShortLinkResponse {}
266
267/// Request to create a short Dynamic Link.
268///
269/// # Activities
270///
271/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
272/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
273///
274/// * [create short links](ShortLinkCreateCall) (request)
275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
276#[serde_with::serde_as]
277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
278pub struct CreateShortDynamicLinkRequest {
279    /// Information about the Dynamic Link to be shortened. [Learn more](https://firebase.google.com/docs/reference/dynamic-links/link-shortener).
280    #[serde(rename = "dynamicLinkInfo")]
281    pub dynamic_link_info: Option<DynamicLinkInfo>,
282    /// Full long Dynamic Link URL with desired query parameters specified. For example, "https://sample.app.goo.gl/?link=http://www.google.com&apn=com.sample", [Learn more](https://firebase.google.com/docs/reference/dynamic-links/link-shortener).
283    #[serde(rename = "longDynamicLink")]
284    pub long_dynamic_link: Option<String>,
285    /// Google SDK version. Version takes the form "$major.$minor.$patch"
286    #[serde(rename = "sdkVersion")]
287    pub sdk_version: Option<String>,
288    /// Short Dynamic Link suffix. Optional.
289    pub suffix: Option<Suffix>,
290}
291
292impl common::RequestValue for CreateShortDynamicLinkRequest {}
293
294/// Response to create a short Dynamic Link.
295///
296/// # Activities
297///
298/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
299/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
300///
301/// * [create short links](ShortLinkCreateCall) (response)
302#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
303#[serde_with::serde_as]
304#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
305pub struct CreateShortDynamicLinkResponse {
306    /// Preview link to show the link flow chart. (debug info.)
307    #[serde(rename = "previewLink")]
308    pub preview_link: Option<String>,
309    /// Short Dynamic Link value. e.g. https://abcd.app.goo.gl/wxyz
310    #[serde(rename = "shortLink")]
311    pub short_link: Option<String>,
312    /// Information about potential warnings on link creation.
313    pub warning: Option<Vec<DynamicLinkWarning>>,
314}
315
316impl common::ResponseResult for CreateShortDynamicLinkResponse {}
317
318/// Desktop related attributes to the Dynamic Link.
319///
320/// This type is not used in any activity, and only used as *part* of another schema.
321///
322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
323#[serde_with::serde_as]
324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
325pub struct DesktopInfo {
326    /// Link to open on desktop.
327    #[serde(rename = "desktopFallbackLink")]
328    pub desktop_fallback_link: Option<String>,
329}
330
331impl common::Part for DesktopInfo {}
332
333/// Signals associated with the device making the request.
334///
335/// This type is not used in any activity, and only used as *part* of another schema.
336///
337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
338#[serde_with::serde_as]
339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
340pub struct DeviceInfo {
341    /// Device model name.
342    #[serde(rename = "deviceModelName")]
343    pub device_model_name: Option<String>,
344    /// Device language code setting.
345    #[serde(rename = "languageCode")]
346    pub language_code: Option<String>,
347    /// Device language code setting obtained by executing JavaScript code in WebView.
348    #[serde(rename = "languageCodeFromWebview")]
349    pub language_code_from_webview: Option<String>,
350    /// Device language code raw setting. iOS does returns language code in different format than iOS WebView. For example WebView returns en_US, but iOS returns en-US. Field below will return raw value returned by iOS.
351    #[serde(rename = "languageCodeRaw")]
352    pub language_code_raw: Option<String>,
353    /// Device display resolution height.
354    #[serde(rename = "screenResolutionHeight")]
355    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
356    pub screen_resolution_height: Option<i64>,
357    /// Device display resolution width.
358    #[serde(rename = "screenResolutionWidth")]
359    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
360    pub screen_resolution_width: Option<i64>,
361    /// Device timezone setting.
362    pub timezone: Option<String>,
363}
364
365impl common::Part for DeviceInfo {}
366
367/// Dynamic Link event stat.
368///
369/// This type is not used in any activity, and only used as *part* of another schema.
370///
371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
372#[serde_with::serde_as]
373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
374pub struct DynamicLinkEventStat {
375    /// The number of times this event occurred.
376    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
377    pub count: Option<i64>,
378    /// Link event.
379    pub event: Option<String>,
380    /// Requested platform.
381    pub platform: Option<String>,
382}
383
384impl common::Part for DynamicLinkEventStat {}
385
386/// Information about a Dynamic Link.
387///
388/// This type is not used in any activity, and only used as *part* of another schema.
389///
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct DynamicLinkInfo {
394    /// Parameters used for tracking. See all tracking parameters in the [documentation](https://firebase.google.com/docs/dynamic-links/create-manually).
395    #[serde(rename = "analyticsInfo")]
396    pub analytics_info: Option<AnalyticsInfo>,
397    /// Android related information. See Android related parameters in the [documentation](https://firebase.google.com/docs/dynamic-links/create-manually).
398    #[serde(rename = "androidInfo")]
399    pub android_info: Option<AndroidInfo>,
400    /// Desktop related information. See desktop related parameters in the [documentation](https://firebase.google.com/docs/dynamic-links/create-manually).
401    #[serde(rename = "desktopInfo")]
402    pub desktop_info: Option<DesktopInfo>,
403    /// E.g. https://maps.app.goo.gl, https://maps.page.link, https://g.co/maps More examples can be found in description of getNormalizedUriPrefix in j/c/g/firebase/dynamiclinks/uri/DdlDomain.java Will fallback to dynamic_link_domain is this field is missing
404    #[serde(rename = "domainUriPrefix")]
405    pub domain_uri_prefix: Option<String>,
406    /// Dynamic Links domain that the project owns, e.g. abcd.app.goo.gl [Learn more](https://firebase.google.com/docs/dynamic-links/android/receive) on how to set up Dynamic Link domain associated with your Firebase project. Required if missing domain_uri_prefix.
407    #[serde(rename = "dynamicLinkDomain")]
408    pub dynamic_link_domain: Option<String>,
409    /// iOS related information. See iOS related parameters in the [documentation](https://firebase.google.com/docs/dynamic-links/create-manually).
410    #[serde(rename = "iosInfo")]
411    pub ios_info: Option<IosInfo>,
412    /// The link your app will open, You can specify any URL your app can handle. This link must be a well-formatted URL, be properly URL-encoded, and use the HTTP or HTTPS scheme. See 'link' parameters in the [documentation](https://firebase.google.com/docs/dynamic-links/create-manually). Required.
413    pub link: Option<String>,
414    /// Information of navigation behavior of a Firebase Dynamic Links.
415    #[serde(rename = "navigationInfo")]
416    pub navigation_info: Option<NavigationInfo>,
417    /// Parameters for social meta tag params. Used to set meta tag data for link previews on social sites.
418    #[serde(rename = "socialMetaTagInfo")]
419    pub social_meta_tag_info: Option<SocialMetaTagInfo>,
420}
421
422impl common::Part for DynamicLinkInfo {}
423
424/// Analytics stats of a Dynamic Link for a given timeframe.
425///
426/// # Activities
427///
428/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
429/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
430///
431/// * [get link stats](MethodGetLinkStatCall) (response)
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct DynamicLinkStats {
436    /// Dynamic Link event stats.
437    #[serde(rename = "linkEventStats")]
438    pub link_event_stats: Option<Vec<DynamicLinkEventStat>>,
439}
440
441impl common::ResponseResult for DynamicLinkStats {}
442
443/// Dynamic Links warning messages.
444///
445/// This type is not used in any activity, and only used as *part* of another schema.
446///
447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
448#[serde_with::serde_as]
449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
450pub struct DynamicLinkWarning {
451    /// The warning code.
452    #[serde(rename = "warningCode")]
453    pub warning_code: Option<String>,
454    /// The document describing the warning, and helps resolve.
455    #[serde(rename = "warningDocumentLink")]
456    pub warning_document_link: Option<String>,
457    /// The warning message to help developers improve their requests.
458    #[serde(rename = "warningMessage")]
459    pub warning_message: Option<String>,
460}
461
462impl common::Part for DynamicLinkWarning {}
463
464/// Request for iSDK to execute strong match flow for post-install attribution. This is meant for iOS requests only. Requests from other platforms will not be honored.
465///
466/// # Activities
467///
468/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
469/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
470///
471/// * [install attribution](MethodInstallAttributionCall) (request)
472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
473#[serde_with::serde_as]
474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
475pub struct GetIosPostInstallAttributionRequest {
476    /// App installation epoch time (https://en.wikipedia.org/wiki/Unix_time). This is a client signal for a more accurate weak match.
477    #[serde(rename = "appInstallationTime")]
478    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
479    pub app_installation_time: Option<i64>,
480    /// APP bundle ID.
481    #[serde(rename = "bundleId")]
482    pub bundle_id: Option<String>,
483    /// Device information.
484    pub device: Option<DeviceInfo>,
485    /// iOS version, ie: 9.3.5. Consider adding "build".
486    #[serde(rename = "iosVersion")]
487    pub ios_version: Option<String>,
488    /// App post install attribution retrieval information. Disambiguates mechanism (iSDK or developer invoked) to retrieve payload from clicked link.
489    #[serde(rename = "retrievalMethod")]
490    pub retrieval_method: Option<String>,
491    /// Google SDK version. Version takes the form "$major.$minor.$patch"
492    #[serde(rename = "sdkVersion")]
493    pub sdk_version: Option<String>,
494    /// Possible unique matched link that server need to check before performing device heuristics match. If passed link is short server need to expand the link. If link is long server need to vslidate the link.
495    #[serde(rename = "uniqueMatchLinkToCheck")]
496    pub unique_match_link_to_check: Option<String>,
497    /// Strong match page information. Disambiguates between default UI and custom page to present when strong match succeeds/fails to find cookie.
498    #[serde(rename = "visualStyle")]
499    pub visual_style: Option<String>,
500}
501
502impl common::RequestValue for GetIosPostInstallAttributionRequest {}
503
504/// Response for iSDK to execute strong match flow for post-install attribution. Information of the resolved FDL link.
505///
506/// # Activities
507///
508/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
509/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
510///
511/// * [install attribution](MethodInstallAttributionCall) (response)
512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
513#[serde_with::serde_as]
514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
515pub struct GetIosPostInstallAttributionResponse {
516    /// The minimum version for app, specified by dev through ?imv= parameter. Return to iSDK to allow app to evaluate if current version meets this.
517    #[serde(rename = "appMinimumVersion")]
518    pub app_minimum_version: Option<String>,
519    /// The confidence of the returned attribution.
520    #[serde(rename = "attributionConfidence")]
521    pub attribution_confidence: Option<String>,
522    /// The deep-link attributed post-install via one of several techniques (device heuristics, copy unique).
523    #[serde(rename = "deepLink")]
524    pub deep_link: Option<String>,
525    /// User-agent specific custom-scheme URIs for iSDK to open. This will be set according to the user-agent tha the click was originally made in. There is no Safari-equivalent custom-scheme open URLs. ie: googlechrome://www.example.com ie: firefox://open-url?url=http://www.example.com ie: opera-http://example.com
526    #[serde(rename = "externalBrowserDestinationLink")]
527    pub external_browser_destination_link: Option<String>,
528    /// The link to navigate to update the app if min version is not met. This is either (in order): 1) fallback link (from ?ifl= parameter, if specified by developer) or 2) AppStore URL (from ?isi= parameter, if specified), or 3) the payload link (from required link= parameter).
529    #[serde(rename = "fallbackLink")]
530    pub fallback_link: Option<String>,
531    /// Invitation ID attributed post-install via one of several techniques (device heuristics, copy unique).
532    #[serde(rename = "invitationId")]
533    pub invitation_id: Option<String>,
534    /// Instruction for iSDK to attemmpt to perform strong match. For instance, if browser does not support/allow cookie or outside of support browsers, this will be false.
535    #[serde(rename = "isStrongMatchExecutable")]
536    pub is_strong_match_executable: Option<bool>,
537    /// Describes why match failed, ie: "discarded due to low confidence". This message will be publicly visible.
538    #[serde(rename = "matchMessage")]
539    pub match_message: Option<String>,
540    /// Which IP version the request was made from.
541    #[serde(rename = "requestIpVersion")]
542    pub request_ip_version: Option<String>,
543    /// Entire FDL (short or long) attributed post-install via one of several techniques (device heuristics, copy unique).
544    #[serde(rename = "requestedLink")]
545    pub requested_link: Option<String>,
546    /// The entire FDL, expanded from a short link. It is the same as the requested_link, if it is long. Parameters from this should not be used directly (ie: server can default utm_[campaign|medium|source] to a value when requested_link lack them, server determine the best fallback_link when requested_link specifies >1 fallback links).
547    #[serde(rename = "resolvedLink")]
548    pub resolved_link: Option<String>,
549    /// Scion campaign value to be propagated by iSDK to Scion at post-install.
550    #[serde(rename = "utmCampaign")]
551    pub utm_campaign: Option<String>,
552    /// Scion content value to be propagated by iSDK to Scion at app-reopen.
553    #[serde(rename = "utmContent")]
554    pub utm_content: Option<String>,
555    /// Scion medium value to be propagated by iSDK to Scion at post-install.
556    #[serde(rename = "utmMedium")]
557    pub utm_medium: Option<String>,
558    /// Scion source value to be propagated by iSDK to Scion at post-install.
559    #[serde(rename = "utmSource")]
560    pub utm_source: Option<String>,
561    /// Scion term value to be propagated by iSDK to Scion at app-reopen.
562    #[serde(rename = "utmTerm")]
563    pub utm_term: Option<String>,
564}
565
566impl common::ResponseResult for GetIosPostInstallAttributionResponse {}
567
568/// Request for iSDK to get reopen attribution for app universal link open deeplinking. This endpoint is meant for only iOS requests.
569///
570/// # Activities
571///
572/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
573/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
574///
575/// * [reopen attribution](MethodReopenAttributionCall) (request)
576#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
577#[serde_with::serde_as]
578#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
579pub struct GetIosReopenAttributionRequest {
580    /// APP bundle ID.
581    #[serde(rename = "bundleId")]
582    pub bundle_id: Option<String>,
583    /// FDL link to be verified from an app universal link open. The FDL link can be one of: 1) short FDL. e.g. .page.link/, or 2) long FDL. e.g. .page.link/?{query params}, or 3) Invite FDL. e.g. .page.link/i/
584    #[serde(rename = "requestedLink")]
585    pub requested_link: Option<String>,
586    /// Google SDK version. Version takes the form "$major.$minor.$patch"
587    #[serde(rename = "sdkVersion")]
588    pub sdk_version: Option<String>,
589}
590
591impl common::RequestValue for GetIosReopenAttributionRequest {}
592
593/// Response for iSDK to get reopen attribution for app universal link open deeplinking. This endpoint is meant for only iOS requests.
594///
595/// # Activities
596///
597/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
598/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
599///
600/// * [reopen attribution](MethodReopenAttributionCall) (response)
601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
602#[serde_with::serde_as]
603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
604pub struct GetIosReopenAttributionResponse {
605    /// The deep-link attributed the app universal link open. For both regular FDL links and invite FDL links.
606    #[serde(rename = "deepLink")]
607    pub deep_link: Option<String>,
608    /// Optional invitation ID, for only invite typed requested FDL links.
609    #[serde(rename = "invitationId")]
610    pub invitation_id: Option<String>,
611    /// FDL input value of the "&imv=" parameter, minimum app version to be returned to Google Firebase SDK running on iOS-9.
612    #[serde(rename = "iosMinAppVersion")]
613    pub ios_min_app_version: Option<String>,
614    /// The entire FDL, expanded from a short link. It is the same as the requested_link, if it is long.
615    #[serde(rename = "resolvedLink")]
616    pub resolved_link: Option<String>,
617    /// Scion campaign value to be propagated by iSDK to Scion at app-reopen.
618    #[serde(rename = "utmCampaign")]
619    pub utm_campaign: Option<String>,
620    /// Scion content value to be propagated by iSDK to Scion at app-reopen.
621    #[serde(rename = "utmContent")]
622    pub utm_content: Option<String>,
623    /// Scion medium value to be propagated by iSDK to Scion at app-reopen.
624    #[serde(rename = "utmMedium")]
625    pub utm_medium: Option<String>,
626    /// Scion source value to be propagated by iSDK to Scion at app-reopen.
627    #[serde(rename = "utmSource")]
628    pub utm_source: Option<String>,
629    /// Scion term value to be propagated by iSDK to Scion at app-reopen.
630    #[serde(rename = "utmTerm")]
631    pub utm_term: Option<String>,
632}
633
634impl common::ResponseResult for GetIosReopenAttributionResponse {}
635
636/// Parameters for Google Play Campaign Measurements. [Learn more](https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#campaign-params)
637///
638/// This type is not used in any activity, and only used as *part* of another schema.
639///
640#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
641#[serde_with::serde_as]
642#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
643pub struct GooglePlayAnalytics {
644    /// Deprecated; FDL SDK does not process nor log it.
645    pub gclid: Option<String>,
646    /// Campaign name; used for keyword analysis to identify a specific product promotion or strategic campaign.
647    #[serde(rename = "utmCampaign")]
648    pub utm_campaign: Option<String>,
649    /// Campaign content; used for A/B testing and content-targeted ads to differentiate ads or links that point to the same URL.
650    #[serde(rename = "utmContent")]
651    pub utm_content: Option<String>,
652    /// Campaign medium; used to identify a medium such as email or cost-per-click.
653    #[serde(rename = "utmMedium")]
654    pub utm_medium: Option<String>,
655    /// Campaign source; used to identify a search engine, newsletter, or other source.
656    #[serde(rename = "utmSource")]
657    pub utm_source: Option<String>,
658    /// Campaign term; used with paid search to supply the keywords for ads.
659    #[serde(rename = "utmTerm")]
660    pub utm_term: Option<String>,
661}
662
663impl common::Part for GooglePlayAnalytics {}
664
665/// Parameters for iTunes Connect App Analytics.
666///
667/// This type is not used in any activity, and only used as *part* of another schema.
668///
669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
670#[serde_with::serde_as]
671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
672pub struct ITunesConnectAnalytics {
673    /// Affiliate token used to create affiliate-coded links.
674    pub at: Option<String>,
675    /// Campaign text that developers can optionally add to any link in order to track sales from a specific marketing campaign.
676    pub ct: Option<String>,
677    /// iTune media types, including music, podcasts, audiobooks and so on.
678    pub mt: Option<String>,
679    /// Provider token that enables analytics for Dynamic Links from within iTunes Connect.
680    pub pt: Option<String>,
681}
682
683impl common::Part for ITunesConnectAnalytics {}
684
685/// iOS related attributes to the Dynamic Link..
686///
687/// This type is not used in any activity, and only used as *part* of another schema.
688///
689#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
690#[serde_with::serde_as]
691#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
692pub struct IosInfo {
693    /// iOS App Store ID.
694    #[serde(rename = "iosAppStoreId")]
695    pub ios_app_store_id: Option<String>,
696    /// iOS bundle ID of the app.
697    #[serde(rename = "iosBundleId")]
698    pub ios_bundle_id: Option<String>,
699    /// Custom (destination) scheme to use for iOS. By default, we’ll use the bundle ID as the custom scheme. Developer can override this behavior using this param.
700    #[serde(rename = "iosCustomScheme")]
701    pub ios_custom_scheme: Option<String>,
702    /// Link to open on iOS if the app is not installed.
703    #[serde(rename = "iosFallbackLink")]
704    pub ios_fallback_link: Option<String>,
705    /// iPad bundle ID of the app.
706    #[serde(rename = "iosIpadBundleId")]
707    pub ios_ipad_bundle_id: Option<String>,
708    /// If specified, this overrides the ios_fallback_link value on iPads.
709    #[serde(rename = "iosIpadFallbackLink")]
710    pub ios_ipad_fallback_link: Option<String>,
711    /// iOS minimum version.
712    #[serde(rename = "iosMinimumVersion")]
713    pub ios_minimum_version: Option<String>,
714}
715
716impl common::Part for IosInfo {}
717
718/// Managed Short Link.
719///
720/// # Activities
721///
722/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
723/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
724///
725/// * [create managed short links](ManagedShortLinkCreateCall) (none)
726#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
727#[serde_with::serde_as]
728#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
729pub struct ManagedShortLink {
730    /// Creation timestamp of the short link.
731    #[serde(rename = "creationTime")]
732    pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
733    /// Attributes that have been flagged about this short url.
734    #[serde(rename = "flaggedAttribute")]
735    pub flagged_attribute: Option<Vec<String>>,
736    /// Full Dyamic Link info
737    pub info: Option<DynamicLinkInfo>,
738    /// Short durable link url, for example, "https://sample.app.goo.gl/xyz123". Required.
739    pub link: Option<String>,
740    /// Link name defined by the creator. Required.
741    #[serde(rename = "linkName")]
742    pub link_name: Option<String>,
743    /// Visibility status of link.
744    pub visibility: Option<String>,
745}
746
747impl common::Resource for ManagedShortLink {}
748
749/// Information of navigation behavior.
750///
751/// This type is not used in any activity, and only used as *part* of another schema.
752///
753#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
754#[serde_with::serde_as]
755#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
756pub struct NavigationInfo {
757    /// If this option is on, FDL click will be forced to redirect rather than show an interstitial page.
758    #[serde(rename = "enableForcedRedirect")]
759    pub enable_forced_redirect: Option<bool>,
760}
761
762impl common::Part for NavigationInfo {}
763
764/// Parameters for social meta tag params. Used to set meta tag data for link previews on social sites.
765///
766/// This type is not used in any activity, and only used as *part* of another schema.
767///
768#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
769#[serde_with::serde_as]
770#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
771pub struct SocialMetaTagInfo {
772    /// A short description of the link. Optional.
773    #[serde(rename = "socialDescription")]
774    pub social_description: Option<String>,
775    /// An image url string. Optional.
776    #[serde(rename = "socialImageLink")]
777    pub social_image_link: Option<String>,
778    /// Title to be displayed. Optional.
779    #[serde(rename = "socialTitle")]
780    pub social_title: Option<String>,
781}
782
783impl common::Part for SocialMetaTagInfo {}
784
785/// Short Dynamic Link suffix.
786///
787/// This type is not used in any activity, and only used as *part* of another schema.
788///
789#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
790#[serde_with::serde_as]
791#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
792pub struct Suffix {
793    /// Only applies to Option.CUSTOM.
794    #[serde(rename = "customSuffix")]
795    pub custom_suffix: Option<String>,
796    /// Suffix option.
797    pub option: Option<String>,
798}
799
800impl common::Part for Suffix {}
801
802// ###################
803// MethodBuilders ###
804// #################
805
806/// A builder providing access to all methods supported on *managedShortLink* resources.
807/// It is not used directly, but through the [`FirebaseDynamicLinks`] hub.
808///
809/// # Example
810///
811/// Instantiate a resource builder
812///
813/// ```test_harness,no_run
814/// extern crate hyper;
815/// extern crate hyper_rustls;
816/// extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
817///
818/// # async fn dox() {
819/// use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
820///
821/// let secret: yup_oauth2::ApplicationSecret = Default::default();
822/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
823///     secret,
824///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
825/// ).build().await.unwrap();
826///
827/// let client = hyper_util::client::legacy::Client::builder(
828///     hyper_util::rt::TokioExecutor::new()
829/// )
830/// .build(
831///     hyper_rustls::HttpsConnectorBuilder::new()
832///         .with_native_roots()
833///         .unwrap()
834///         .https_or_http()
835///         .enable_http1()
836///         .build()
837/// );
838/// let mut hub = FirebaseDynamicLinks::new(client, auth);
839/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
840/// // like `create(...)`
841/// // to build up your call.
842/// let rb = hub.managed_short_links();
843/// # }
844/// ```
845pub struct ManagedShortLinkMethods<'a, C>
846where
847    C: 'a,
848{
849    hub: &'a FirebaseDynamicLinks<C>,
850}
851
852impl<'a, C> common::MethodsBuilder for ManagedShortLinkMethods<'a, C> {}
853
854impl<'a, C> ManagedShortLinkMethods<'a, C> {
855    /// Create a builder to help you perform the following task:
856    ///
857    /// Creates a managed short Dynamic Link given either a valid long Dynamic Link or details such as Dynamic Link domain, Android and iOS app information. The created short Dynamic Link will not expire. This differs from CreateShortDynamicLink in the following ways: - The request will also contain a name for the link (non unique name for the front end). - The response must be authenticated with an auth token (generated with the admin service account). - The link will appear in the FDL list of links in the console front end. The Dynamic Link domain in the request must be owned by requester's Firebase project.
858    ///
859    /// # Arguments
860    ///
861    /// * `request` - No description provided.
862    pub fn create(
863        &self,
864        request: CreateManagedShortLinkRequest,
865    ) -> ManagedShortLinkCreateCall<'a, C> {
866        ManagedShortLinkCreateCall {
867            hub: self.hub,
868            _request: request,
869            _delegate: Default::default(),
870            _additional_params: Default::default(),
871            _scopes: Default::default(),
872        }
873    }
874}
875
876/// A builder providing access to all methods supported on *shortLink* resources.
877/// It is not used directly, but through the [`FirebaseDynamicLinks`] hub.
878///
879/// # Example
880///
881/// Instantiate a resource builder
882///
883/// ```test_harness,no_run
884/// extern crate hyper;
885/// extern crate hyper_rustls;
886/// extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
887///
888/// # async fn dox() {
889/// use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
890///
891/// let secret: yup_oauth2::ApplicationSecret = Default::default();
892/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
893///     secret,
894///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
895/// ).build().await.unwrap();
896///
897/// let client = hyper_util::client::legacy::Client::builder(
898///     hyper_util::rt::TokioExecutor::new()
899/// )
900/// .build(
901///     hyper_rustls::HttpsConnectorBuilder::new()
902///         .with_native_roots()
903///         .unwrap()
904///         .https_or_http()
905///         .enable_http1()
906///         .build()
907/// );
908/// let mut hub = FirebaseDynamicLinks::new(client, auth);
909/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
910/// // like `create(...)`
911/// // to build up your call.
912/// let rb = hub.short_links();
913/// # }
914/// ```
915pub struct ShortLinkMethods<'a, C>
916where
917    C: 'a,
918{
919    hub: &'a FirebaseDynamicLinks<C>,
920}
921
922impl<'a, C> common::MethodsBuilder for ShortLinkMethods<'a, C> {}
923
924impl<'a, C> ShortLinkMethods<'a, C> {
925    /// Create a builder to help you perform the following task:
926    ///
927    /// Creates a short Dynamic Link given either a valid long Dynamic Link or details such as Dynamic Link domain, Android and iOS app information. The created short Dynamic Link will not expire. Repeated calls with the same long Dynamic Link or Dynamic Link information will produce the same short Dynamic Link. The Dynamic Link domain in the request must be owned by requester's Firebase project.
928    ///
929    /// # Arguments
930    ///
931    /// * `request` - No description provided.
932    pub fn create(&self, request: CreateShortDynamicLinkRequest) -> ShortLinkCreateCall<'a, C> {
933        ShortLinkCreateCall {
934            hub: self.hub,
935            _request: request,
936            _delegate: Default::default(),
937            _additional_params: Default::default(),
938            _scopes: Default::default(),
939        }
940    }
941}
942
943/// A builder providing access to all free methods, which are not associated with a particular resource.
944/// It is not used directly, but through the [`FirebaseDynamicLinks`] hub.
945///
946/// # Example
947///
948/// Instantiate a resource builder
949///
950/// ```test_harness,no_run
951/// extern crate hyper;
952/// extern crate hyper_rustls;
953/// extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
954///
955/// # async fn dox() {
956/// use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
957///
958/// let secret: yup_oauth2::ApplicationSecret = Default::default();
959/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
960///     secret,
961///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
962/// ).build().await.unwrap();
963///
964/// let client = hyper_util::client::legacy::Client::builder(
965///     hyper_util::rt::TokioExecutor::new()
966/// )
967/// .build(
968///     hyper_rustls::HttpsConnectorBuilder::new()
969///         .with_native_roots()
970///         .unwrap()
971///         .https_or_http()
972///         .enable_http1()
973///         .build()
974/// );
975/// let mut hub = FirebaseDynamicLinks::new(client, auth);
976/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
977/// // like `get_link_stats(...)`, `install_attribution(...)` and `reopen_attribution(...)`
978/// // to build up your call.
979/// let rb = hub.methods();
980/// # }
981/// ```
982pub struct MethodMethods<'a, C>
983where
984    C: 'a,
985{
986    hub: &'a FirebaseDynamicLinks<C>,
987}
988
989impl<'a, C> common::MethodsBuilder for MethodMethods<'a, C> {}
990
991impl<'a, C> MethodMethods<'a, C> {
992    /// Create a builder to help you perform the following task:
993    ///
994    /// Fetches analytics stats of a short Dynamic Link for a given duration. Metrics include number of clicks, redirects, installs, app first opens, and app reopens.
995    ///
996    /// # Arguments
997    ///
998    /// * `dynamicLink` - Dynamic Link URL. e.g. https://abcd.app.goo.gl/wxyz
999    pub fn get_link_stats(&self, dynamic_link: &str) -> MethodGetLinkStatCall<'a, C> {
1000        MethodGetLinkStatCall {
1001            hub: self.hub,
1002            _dynamic_link: dynamic_link.to_string(),
1003            _sdk_version: Default::default(),
1004            _duration_days: Default::default(),
1005            _delegate: Default::default(),
1006            _additional_params: Default::default(),
1007            _scopes: Default::default(),
1008        }
1009    }
1010
1011    /// Create a builder to help you perform the following task:
1012    ///
1013    /// Get iOS strong/weak-match info for post-install attribution.
1014    ///
1015    /// # Arguments
1016    ///
1017    /// * `request` - No description provided.
1018    pub fn install_attribution(
1019        &self,
1020        request: GetIosPostInstallAttributionRequest,
1021    ) -> MethodInstallAttributionCall<'a, C> {
1022        MethodInstallAttributionCall {
1023            hub: self.hub,
1024            _request: request,
1025            _delegate: Default::default(),
1026            _additional_params: Default::default(),
1027            _scopes: Default::default(),
1028        }
1029    }
1030
1031    /// Create a builder to help you perform the following task:
1032    ///
1033    /// Get iOS reopen attribution for app universal link open deeplinking.
1034    ///
1035    /// # Arguments
1036    ///
1037    /// * `request` - No description provided.
1038    pub fn reopen_attribution(
1039        &self,
1040        request: GetIosReopenAttributionRequest,
1041    ) -> MethodReopenAttributionCall<'a, C> {
1042        MethodReopenAttributionCall {
1043            hub: self.hub,
1044            _request: request,
1045            _delegate: Default::default(),
1046            _additional_params: Default::default(),
1047            _scopes: Default::default(),
1048        }
1049    }
1050}
1051
1052// ###################
1053// CallBuilders   ###
1054// #################
1055
1056/// Creates a managed short Dynamic Link given either a valid long Dynamic Link or details such as Dynamic Link domain, Android and iOS app information. The created short Dynamic Link will not expire. This differs from CreateShortDynamicLink in the following ways: - The request will also contain a name for the link (non unique name for the front end). - The response must be authenticated with an auth token (generated with the admin service account). - The link will appear in the FDL list of links in the console front end. The Dynamic Link domain in the request must be owned by requester's Firebase project.
1057///
1058/// A builder for the *create* method supported by a *managedShortLink* resource.
1059/// It is not used directly, but through a [`ManagedShortLinkMethods`] instance.
1060///
1061/// # Example
1062///
1063/// Instantiate a resource method builder
1064///
1065/// ```test_harness,no_run
1066/// # extern crate hyper;
1067/// # extern crate hyper_rustls;
1068/// # extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
1069/// use firebasedynamiclinks1::api::CreateManagedShortLinkRequest;
1070/// # async fn dox() {
1071/// # use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1072///
1073/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1074/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1075/// #     secret,
1076/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1077/// # ).build().await.unwrap();
1078///
1079/// # let client = hyper_util::client::legacy::Client::builder(
1080/// #     hyper_util::rt::TokioExecutor::new()
1081/// # )
1082/// # .build(
1083/// #     hyper_rustls::HttpsConnectorBuilder::new()
1084/// #         .with_native_roots()
1085/// #         .unwrap()
1086/// #         .https_or_http()
1087/// #         .enable_http1()
1088/// #         .build()
1089/// # );
1090/// # let mut hub = FirebaseDynamicLinks::new(client, auth);
1091/// // As the method needs a request, you would usually fill it with the desired information
1092/// // into the respective structure. Some of the parts shown here might not be applicable !
1093/// // Values shown here are possibly random and not representative !
1094/// let mut req = CreateManagedShortLinkRequest::default();
1095///
1096/// // You can configure optional parameters by calling the respective setters at will, and
1097/// // execute the final call using `doit()`.
1098/// // Values shown here are possibly random and not representative !
1099/// let result = hub.managed_short_links().create(req)
1100///              .doit().await;
1101/// # }
1102/// ```
1103pub struct ManagedShortLinkCreateCall<'a, C>
1104where
1105    C: 'a,
1106{
1107    hub: &'a FirebaseDynamicLinks<C>,
1108    _request: CreateManagedShortLinkRequest,
1109    _delegate: Option<&'a mut dyn common::Delegate>,
1110    _additional_params: HashMap<String, String>,
1111    _scopes: BTreeSet<String>,
1112}
1113
1114impl<'a, C> common::CallBuilder for ManagedShortLinkCreateCall<'a, C> {}
1115
1116impl<'a, C> ManagedShortLinkCreateCall<'a, C>
1117where
1118    C: common::Connector,
1119{
1120    /// Perform the operation you have build so far.
1121    pub async fn doit(
1122        mut self,
1123    ) -> common::Result<(common::Response, CreateManagedShortLinkResponse)> {
1124        use std::borrow::Cow;
1125        use std::io::{Read, Seek};
1126
1127        use common::{url::Params, ToParts};
1128        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1129
1130        let mut dd = common::DefaultDelegate;
1131        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1132        dlg.begin(common::MethodInfo {
1133            id: "firebasedynamiclinks.managedShortLinks.create",
1134            http_method: hyper::Method::POST,
1135        });
1136
1137        for &field in ["alt"].iter() {
1138            if self._additional_params.contains_key(field) {
1139                dlg.finished(false);
1140                return Err(common::Error::FieldClash(field));
1141            }
1142        }
1143
1144        let mut params = Params::with_capacity(3 + self._additional_params.len());
1145
1146        params.extend(self._additional_params.iter());
1147
1148        params.push("alt", "json");
1149        let mut url = self.hub._base_url.clone() + "v1/managedShortLinks:create";
1150        if self._scopes.is_empty() {
1151            self._scopes.insert(Scope::Firebase.as_ref().to_string());
1152        }
1153
1154        let url = params.parse_with_url(&url);
1155
1156        let mut json_mime_type = mime::APPLICATION_JSON;
1157        let mut request_value_reader = {
1158            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1159            common::remove_json_null_values(&mut value);
1160            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1161            serde_json::to_writer(&mut dst, &value).unwrap();
1162            dst
1163        };
1164        let request_size = request_value_reader
1165            .seek(std::io::SeekFrom::End(0))
1166            .unwrap();
1167        request_value_reader
1168            .seek(std::io::SeekFrom::Start(0))
1169            .unwrap();
1170
1171        loop {
1172            let token = match self
1173                .hub
1174                .auth
1175                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1176                .await
1177            {
1178                Ok(token) => token,
1179                Err(e) => match dlg.token(e) {
1180                    Ok(token) => token,
1181                    Err(e) => {
1182                        dlg.finished(false);
1183                        return Err(common::Error::MissingToken(e));
1184                    }
1185                },
1186            };
1187            request_value_reader
1188                .seek(std::io::SeekFrom::Start(0))
1189                .unwrap();
1190            let mut req_result = {
1191                let client = &self.hub.client;
1192                dlg.pre_request();
1193                let mut req_builder = hyper::Request::builder()
1194                    .method(hyper::Method::POST)
1195                    .uri(url.as_str())
1196                    .header(USER_AGENT, self.hub._user_agent.clone());
1197
1198                if let Some(token) = token.as_ref() {
1199                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1200                }
1201
1202                let request = req_builder
1203                    .header(CONTENT_TYPE, json_mime_type.to_string())
1204                    .header(CONTENT_LENGTH, request_size as u64)
1205                    .body(common::to_body(
1206                        request_value_reader.get_ref().clone().into(),
1207                    ));
1208
1209                client.request(request.unwrap()).await
1210            };
1211
1212            match req_result {
1213                Err(err) => {
1214                    if let common::Retry::After(d) = dlg.http_error(&err) {
1215                        sleep(d).await;
1216                        continue;
1217                    }
1218                    dlg.finished(false);
1219                    return Err(common::Error::HttpError(err));
1220                }
1221                Ok(res) => {
1222                    let (mut parts, body) = res.into_parts();
1223                    let mut body = common::Body::new(body);
1224                    if !parts.status.is_success() {
1225                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1226                        let error = serde_json::from_str(&common::to_string(&bytes));
1227                        let response = common::to_response(parts, bytes.into());
1228
1229                        if let common::Retry::After(d) =
1230                            dlg.http_failure(&response, error.as_ref().ok())
1231                        {
1232                            sleep(d).await;
1233                            continue;
1234                        }
1235
1236                        dlg.finished(false);
1237
1238                        return Err(match error {
1239                            Ok(value) => common::Error::BadRequest(value),
1240                            _ => common::Error::Failure(response),
1241                        });
1242                    }
1243                    let response = {
1244                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1245                        let encoded = common::to_string(&bytes);
1246                        match serde_json::from_str(&encoded) {
1247                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1248                            Err(error) => {
1249                                dlg.response_json_decode_error(&encoded, &error);
1250                                return Err(common::Error::JsonDecodeError(
1251                                    encoded.to_string(),
1252                                    error,
1253                                ));
1254                            }
1255                        }
1256                    };
1257
1258                    dlg.finished(true);
1259                    return Ok(response);
1260                }
1261            }
1262        }
1263    }
1264
1265    ///
1266    /// Sets the *request* property to the given value.
1267    ///
1268    /// Even though the property as already been set when instantiating this call,
1269    /// we provide this method for API completeness.
1270    pub fn request(
1271        mut self,
1272        new_value: CreateManagedShortLinkRequest,
1273    ) -> ManagedShortLinkCreateCall<'a, C> {
1274        self._request = new_value;
1275        self
1276    }
1277    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1278    /// while executing the actual API request.
1279    ///
1280    /// ````text
1281    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1282    /// ````
1283    ///
1284    /// Sets the *delegate* property to the given value.
1285    pub fn delegate(
1286        mut self,
1287        new_value: &'a mut dyn common::Delegate,
1288    ) -> ManagedShortLinkCreateCall<'a, C> {
1289        self._delegate = Some(new_value);
1290        self
1291    }
1292
1293    /// Set any additional parameter of the query string used in the request.
1294    /// It should be used to set parameters which are not yet available through their own
1295    /// setters.
1296    ///
1297    /// Please note that this method must not be used to set any of the known parameters
1298    /// which have their own setter method. If done anyway, the request will fail.
1299    ///
1300    /// # Additional Parameters
1301    ///
1302    /// * *$.xgafv* (query-string) - V1 error format.
1303    /// * *access_token* (query-string) - OAuth access token.
1304    /// * *alt* (query-string) - Data format for response.
1305    /// * *callback* (query-string) - JSONP
1306    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1307    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1308    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1309    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1310    /// * *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.
1311    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1312    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1313    pub fn param<T>(mut self, name: T, value: T) -> ManagedShortLinkCreateCall<'a, C>
1314    where
1315        T: AsRef<str>,
1316    {
1317        self._additional_params
1318            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1319        self
1320    }
1321
1322    /// Identifies the authorization scope for the method you are building.
1323    ///
1324    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1325    /// [`Scope::Firebase`].
1326    ///
1327    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1328    /// tokens for more than one scope.
1329    ///
1330    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1331    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1332    /// sufficient, a read-write scope will do as well.
1333    pub fn add_scope<St>(mut self, scope: St) -> ManagedShortLinkCreateCall<'a, C>
1334    where
1335        St: AsRef<str>,
1336    {
1337        self._scopes.insert(String::from(scope.as_ref()));
1338        self
1339    }
1340    /// Identifies the authorization scope(s) for the method you are building.
1341    ///
1342    /// See [`Self::add_scope()`] for details.
1343    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedShortLinkCreateCall<'a, C>
1344    where
1345        I: IntoIterator<Item = St>,
1346        St: AsRef<str>,
1347    {
1348        self._scopes
1349            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1350        self
1351    }
1352
1353    /// Removes all scopes, and no default scope will be used either.
1354    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1355    /// for details).
1356    pub fn clear_scopes(mut self) -> ManagedShortLinkCreateCall<'a, C> {
1357        self._scopes.clear();
1358        self
1359    }
1360}
1361
1362/// Creates a short Dynamic Link given either a valid long Dynamic Link or details such as Dynamic Link domain, Android and iOS app information. The created short Dynamic Link will not expire. Repeated calls with the same long Dynamic Link or Dynamic Link information will produce the same short Dynamic Link. The Dynamic Link domain in the request must be owned by requester's Firebase project.
1363///
1364/// A builder for the *create* method supported by a *shortLink* resource.
1365/// It is not used directly, but through a [`ShortLinkMethods`] instance.
1366///
1367/// # Example
1368///
1369/// Instantiate a resource method builder
1370///
1371/// ```test_harness,no_run
1372/// # extern crate hyper;
1373/// # extern crate hyper_rustls;
1374/// # extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
1375/// use firebasedynamiclinks1::api::CreateShortDynamicLinkRequest;
1376/// # async fn dox() {
1377/// # use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1378///
1379/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1380/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1381/// #     secret,
1382/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1383/// # ).build().await.unwrap();
1384///
1385/// # let client = hyper_util::client::legacy::Client::builder(
1386/// #     hyper_util::rt::TokioExecutor::new()
1387/// # )
1388/// # .build(
1389/// #     hyper_rustls::HttpsConnectorBuilder::new()
1390/// #         .with_native_roots()
1391/// #         .unwrap()
1392/// #         .https_or_http()
1393/// #         .enable_http1()
1394/// #         .build()
1395/// # );
1396/// # let mut hub = FirebaseDynamicLinks::new(client, auth);
1397/// // As the method needs a request, you would usually fill it with the desired information
1398/// // into the respective structure. Some of the parts shown here might not be applicable !
1399/// // Values shown here are possibly random and not representative !
1400/// let mut req = CreateShortDynamicLinkRequest::default();
1401///
1402/// // You can configure optional parameters by calling the respective setters at will, and
1403/// // execute the final call using `doit()`.
1404/// // Values shown here are possibly random and not representative !
1405/// let result = hub.short_links().create(req)
1406///              .doit().await;
1407/// # }
1408/// ```
1409pub struct ShortLinkCreateCall<'a, C>
1410where
1411    C: 'a,
1412{
1413    hub: &'a FirebaseDynamicLinks<C>,
1414    _request: CreateShortDynamicLinkRequest,
1415    _delegate: Option<&'a mut dyn common::Delegate>,
1416    _additional_params: HashMap<String, String>,
1417    _scopes: BTreeSet<String>,
1418}
1419
1420impl<'a, C> common::CallBuilder for ShortLinkCreateCall<'a, C> {}
1421
1422impl<'a, C> ShortLinkCreateCall<'a, C>
1423where
1424    C: common::Connector,
1425{
1426    /// Perform the operation you have build so far.
1427    pub async fn doit(
1428        mut self,
1429    ) -> common::Result<(common::Response, CreateShortDynamicLinkResponse)> {
1430        use std::borrow::Cow;
1431        use std::io::{Read, Seek};
1432
1433        use common::{url::Params, ToParts};
1434        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1435
1436        let mut dd = common::DefaultDelegate;
1437        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1438        dlg.begin(common::MethodInfo {
1439            id: "firebasedynamiclinks.shortLinks.create",
1440            http_method: hyper::Method::POST,
1441        });
1442
1443        for &field in ["alt"].iter() {
1444            if self._additional_params.contains_key(field) {
1445                dlg.finished(false);
1446                return Err(common::Error::FieldClash(field));
1447            }
1448        }
1449
1450        let mut params = Params::with_capacity(3 + self._additional_params.len());
1451
1452        params.extend(self._additional_params.iter());
1453
1454        params.push("alt", "json");
1455        let mut url = self.hub._base_url.clone() + "v1/shortLinks";
1456        if self._scopes.is_empty() {
1457            self._scopes.insert(Scope::Firebase.as_ref().to_string());
1458        }
1459
1460        let url = params.parse_with_url(&url);
1461
1462        let mut json_mime_type = mime::APPLICATION_JSON;
1463        let mut request_value_reader = {
1464            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1465            common::remove_json_null_values(&mut value);
1466            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1467            serde_json::to_writer(&mut dst, &value).unwrap();
1468            dst
1469        };
1470        let request_size = request_value_reader
1471            .seek(std::io::SeekFrom::End(0))
1472            .unwrap();
1473        request_value_reader
1474            .seek(std::io::SeekFrom::Start(0))
1475            .unwrap();
1476
1477        loop {
1478            let token = match self
1479                .hub
1480                .auth
1481                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1482                .await
1483            {
1484                Ok(token) => token,
1485                Err(e) => match dlg.token(e) {
1486                    Ok(token) => token,
1487                    Err(e) => {
1488                        dlg.finished(false);
1489                        return Err(common::Error::MissingToken(e));
1490                    }
1491                },
1492            };
1493            request_value_reader
1494                .seek(std::io::SeekFrom::Start(0))
1495                .unwrap();
1496            let mut req_result = {
1497                let client = &self.hub.client;
1498                dlg.pre_request();
1499                let mut req_builder = hyper::Request::builder()
1500                    .method(hyper::Method::POST)
1501                    .uri(url.as_str())
1502                    .header(USER_AGENT, self.hub._user_agent.clone());
1503
1504                if let Some(token) = token.as_ref() {
1505                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1506                }
1507
1508                let request = req_builder
1509                    .header(CONTENT_TYPE, json_mime_type.to_string())
1510                    .header(CONTENT_LENGTH, request_size as u64)
1511                    .body(common::to_body(
1512                        request_value_reader.get_ref().clone().into(),
1513                    ));
1514
1515                client.request(request.unwrap()).await
1516            };
1517
1518            match req_result {
1519                Err(err) => {
1520                    if let common::Retry::After(d) = dlg.http_error(&err) {
1521                        sleep(d).await;
1522                        continue;
1523                    }
1524                    dlg.finished(false);
1525                    return Err(common::Error::HttpError(err));
1526                }
1527                Ok(res) => {
1528                    let (mut parts, body) = res.into_parts();
1529                    let mut body = common::Body::new(body);
1530                    if !parts.status.is_success() {
1531                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1532                        let error = serde_json::from_str(&common::to_string(&bytes));
1533                        let response = common::to_response(parts, bytes.into());
1534
1535                        if let common::Retry::After(d) =
1536                            dlg.http_failure(&response, error.as_ref().ok())
1537                        {
1538                            sleep(d).await;
1539                            continue;
1540                        }
1541
1542                        dlg.finished(false);
1543
1544                        return Err(match error {
1545                            Ok(value) => common::Error::BadRequest(value),
1546                            _ => common::Error::Failure(response),
1547                        });
1548                    }
1549                    let response = {
1550                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1551                        let encoded = common::to_string(&bytes);
1552                        match serde_json::from_str(&encoded) {
1553                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1554                            Err(error) => {
1555                                dlg.response_json_decode_error(&encoded, &error);
1556                                return Err(common::Error::JsonDecodeError(
1557                                    encoded.to_string(),
1558                                    error,
1559                                ));
1560                            }
1561                        }
1562                    };
1563
1564                    dlg.finished(true);
1565                    return Ok(response);
1566                }
1567            }
1568        }
1569    }
1570
1571    ///
1572    /// Sets the *request* property to the given value.
1573    ///
1574    /// Even though the property as already been set when instantiating this call,
1575    /// we provide this method for API completeness.
1576    pub fn request(
1577        mut self,
1578        new_value: CreateShortDynamicLinkRequest,
1579    ) -> ShortLinkCreateCall<'a, C> {
1580        self._request = new_value;
1581        self
1582    }
1583    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1584    /// while executing the actual API request.
1585    ///
1586    /// ````text
1587    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1588    /// ````
1589    ///
1590    /// Sets the *delegate* property to the given value.
1591    pub fn delegate(
1592        mut self,
1593        new_value: &'a mut dyn common::Delegate,
1594    ) -> ShortLinkCreateCall<'a, C> {
1595        self._delegate = Some(new_value);
1596        self
1597    }
1598
1599    /// Set any additional parameter of the query string used in the request.
1600    /// It should be used to set parameters which are not yet available through their own
1601    /// setters.
1602    ///
1603    /// Please note that this method must not be used to set any of the known parameters
1604    /// which have their own setter method. If done anyway, the request will fail.
1605    ///
1606    /// # Additional Parameters
1607    ///
1608    /// * *$.xgafv* (query-string) - V1 error format.
1609    /// * *access_token* (query-string) - OAuth access token.
1610    /// * *alt* (query-string) - Data format for response.
1611    /// * *callback* (query-string) - JSONP
1612    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1613    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1614    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1615    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1616    /// * *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.
1617    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1618    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1619    pub fn param<T>(mut self, name: T, value: T) -> ShortLinkCreateCall<'a, C>
1620    where
1621        T: AsRef<str>,
1622    {
1623        self._additional_params
1624            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1625        self
1626    }
1627
1628    /// Identifies the authorization scope for the method you are building.
1629    ///
1630    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1631    /// [`Scope::Firebase`].
1632    ///
1633    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1634    /// tokens for more than one scope.
1635    ///
1636    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1637    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1638    /// sufficient, a read-write scope will do as well.
1639    pub fn add_scope<St>(mut self, scope: St) -> ShortLinkCreateCall<'a, C>
1640    where
1641        St: AsRef<str>,
1642    {
1643        self._scopes.insert(String::from(scope.as_ref()));
1644        self
1645    }
1646    /// Identifies the authorization scope(s) for the method you are building.
1647    ///
1648    /// See [`Self::add_scope()`] for details.
1649    pub fn add_scopes<I, St>(mut self, scopes: I) -> ShortLinkCreateCall<'a, C>
1650    where
1651        I: IntoIterator<Item = St>,
1652        St: AsRef<str>,
1653    {
1654        self._scopes
1655            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1656        self
1657    }
1658
1659    /// Removes all scopes, and no default scope will be used either.
1660    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1661    /// for details).
1662    pub fn clear_scopes(mut self) -> ShortLinkCreateCall<'a, C> {
1663        self._scopes.clear();
1664        self
1665    }
1666}
1667
1668/// Fetches analytics stats of a short Dynamic Link for a given duration. Metrics include number of clicks, redirects, installs, app first opens, and app reopens.
1669///
1670/// A builder for the *getLinkStats* method.
1671/// It is not used directly, but through a [`MethodMethods`] instance.
1672///
1673/// # Example
1674///
1675/// Instantiate a resource method builder
1676///
1677/// ```test_harness,no_run
1678/// # extern crate hyper;
1679/// # extern crate hyper_rustls;
1680/// # extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
1681/// # async fn dox() {
1682/// # use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1683///
1684/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1685/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1686/// #     secret,
1687/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1688/// # ).build().await.unwrap();
1689///
1690/// # let client = hyper_util::client::legacy::Client::builder(
1691/// #     hyper_util::rt::TokioExecutor::new()
1692/// # )
1693/// # .build(
1694/// #     hyper_rustls::HttpsConnectorBuilder::new()
1695/// #         .with_native_roots()
1696/// #         .unwrap()
1697/// #         .https_or_http()
1698/// #         .enable_http1()
1699/// #         .build()
1700/// # );
1701/// # let mut hub = FirebaseDynamicLinks::new(client, auth);
1702/// // You can configure optional parameters by calling the respective setters at will, and
1703/// // execute the final call using `doit()`.
1704/// // Values shown here are possibly random and not representative !
1705/// let result = hub.methods().get_link_stats("dynamicLink")
1706///              .sdk_version("magna")
1707///              .duration_days(-11)
1708///              .doit().await;
1709/// # }
1710/// ```
1711pub struct MethodGetLinkStatCall<'a, C>
1712where
1713    C: 'a,
1714{
1715    hub: &'a FirebaseDynamicLinks<C>,
1716    _dynamic_link: String,
1717    _sdk_version: Option<String>,
1718    _duration_days: Option<i64>,
1719    _delegate: Option<&'a mut dyn common::Delegate>,
1720    _additional_params: HashMap<String, String>,
1721    _scopes: BTreeSet<String>,
1722}
1723
1724impl<'a, C> common::CallBuilder for MethodGetLinkStatCall<'a, C> {}
1725
1726impl<'a, C> MethodGetLinkStatCall<'a, C>
1727where
1728    C: common::Connector,
1729{
1730    /// Perform the operation you have build so far.
1731    pub async fn doit(mut self) -> common::Result<(common::Response, DynamicLinkStats)> {
1732        use std::borrow::Cow;
1733        use std::io::{Read, Seek};
1734
1735        use common::{url::Params, ToParts};
1736        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1737
1738        let mut dd = common::DefaultDelegate;
1739        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1740        dlg.begin(common::MethodInfo {
1741            id: "firebasedynamiclinks.getLinkStats",
1742            http_method: hyper::Method::GET,
1743        });
1744
1745        for &field in ["alt", "dynamicLink", "sdkVersion", "durationDays"].iter() {
1746            if self._additional_params.contains_key(field) {
1747                dlg.finished(false);
1748                return Err(common::Error::FieldClash(field));
1749            }
1750        }
1751
1752        let mut params = Params::with_capacity(5 + self._additional_params.len());
1753        params.push("dynamicLink", self._dynamic_link);
1754        if let Some(value) = self._sdk_version.as_ref() {
1755            params.push("sdkVersion", value);
1756        }
1757        if let Some(value) = self._duration_days.as_ref() {
1758            params.push("durationDays", value.to_string());
1759        }
1760
1761        params.extend(self._additional_params.iter());
1762
1763        params.push("alt", "json");
1764        let mut url = self.hub._base_url.clone() + "v1/{dynamicLink}/linkStats";
1765        if self._scopes.is_empty() {
1766            self._scopes.insert(Scope::Firebase.as_ref().to_string());
1767        }
1768
1769        #[allow(clippy::single_element_loop)]
1770        for &(find_this, param_name) in [("{dynamicLink}", "dynamicLink")].iter() {
1771            url = params.uri_replacement(url, param_name, find_this, false);
1772        }
1773        {
1774            let to_remove = ["dynamicLink"];
1775            params.remove_params(&to_remove);
1776        }
1777
1778        let url = params.parse_with_url(&url);
1779
1780        loop {
1781            let token = match self
1782                .hub
1783                .auth
1784                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1785                .await
1786            {
1787                Ok(token) => token,
1788                Err(e) => match dlg.token(e) {
1789                    Ok(token) => token,
1790                    Err(e) => {
1791                        dlg.finished(false);
1792                        return Err(common::Error::MissingToken(e));
1793                    }
1794                },
1795            };
1796            let mut req_result = {
1797                let client = &self.hub.client;
1798                dlg.pre_request();
1799                let mut req_builder = hyper::Request::builder()
1800                    .method(hyper::Method::GET)
1801                    .uri(url.as_str())
1802                    .header(USER_AGENT, self.hub._user_agent.clone());
1803
1804                if let Some(token) = token.as_ref() {
1805                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1806                }
1807
1808                let request = req_builder
1809                    .header(CONTENT_LENGTH, 0_u64)
1810                    .body(common::to_body::<String>(None));
1811
1812                client.request(request.unwrap()).await
1813            };
1814
1815            match req_result {
1816                Err(err) => {
1817                    if let common::Retry::After(d) = dlg.http_error(&err) {
1818                        sleep(d).await;
1819                        continue;
1820                    }
1821                    dlg.finished(false);
1822                    return Err(common::Error::HttpError(err));
1823                }
1824                Ok(res) => {
1825                    let (mut parts, body) = res.into_parts();
1826                    let mut body = common::Body::new(body);
1827                    if !parts.status.is_success() {
1828                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1829                        let error = serde_json::from_str(&common::to_string(&bytes));
1830                        let response = common::to_response(parts, bytes.into());
1831
1832                        if let common::Retry::After(d) =
1833                            dlg.http_failure(&response, error.as_ref().ok())
1834                        {
1835                            sleep(d).await;
1836                            continue;
1837                        }
1838
1839                        dlg.finished(false);
1840
1841                        return Err(match error {
1842                            Ok(value) => common::Error::BadRequest(value),
1843                            _ => common::Error::Failure(response),
1844                        });
1845                    }
1846                    let response = {
1847                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1848                        let encoded = common::to_string(&bytes);
1849                        match serde_json::from_str(&encoded) {
1850                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1851                            Err(error) => {
1852                                dlg.response_json_decode_error(&encoded, &error);
1853                                return Err(common::Error::JsonDecodeError(
1854                                    encoded.to_string(),
1855                                    error,
1856                                ));
1857                            }
1858                        }
1859                    };
1860
1861                    dlg.finished(true);
1862                    return Ok(response);
1863                }
1864            }
1865        }
1866    }
1867
1868    /// Dynamic Link URL. e.g. https://abcd.app.goo.gl/wxyz
1869    ///
1870    /// Sets the *dynamic link* path property to the given value.
1871    ///
1872    /// Even though the property as already been set when instantiating this call,
1873    /// we provide this method for API completeness.
1874    pub fn dynamic_link(mut self, new_value: &str) -> MethodGetLinkStatCall<'a, C> {
1875        self._dynamic_link = new_value.to_string();
1876        self
1877    }
1878    /// Google SDK version. Version takes the form "$major.$minor.$patch"
1879    ///
1880    /// Sets the *sdk version* query property to the given value.
1881    pub fn sdk_version(mut self, new_value: &str) -> MethodGetLinkStatCall<'a, C> {
1882        self._sdk_version = Some(new_value.to_string());
1883        self
1884    }
1885    /// The span of time requested in days.
1886    ///
1887    /// Sets the *duration days* query property to the given value.
1888    pub fn duration_days(mut self, new_value: i64) -> MethodGetLinkStatCall<'a, C> {
1889        self._duration_days = Some(new_value);
1890        self
1891    }
1892    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1893    /// while executing the actual API request.
1894    ///
1895    /// ````text
1896    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1897    /// ````
1898    ///
1899    /// Sets the *delegate* property to the given value.
1900    pub fn delegate(
1901        mut self,
1902        new_value: &'a mut dyn common::Delegate,
1903    ) -> MethodGetLinkStatCall<'a, C> {
1904        self._delegate = Some(new_value);
1905        self
1906    }
1907
1908    /// Set any additional parameter of the query string used in the request.
1909    /// It should be used to set parameters which are not yet available through their own
1910    /// setters.
1911    ///
1912    /// Please note that this method must not be used to set any of the known parameters
1913    /// which have their own setter method. If done anyway, the request will fail.
1914    ///
1915    /// # Additional Parameters
1916    ///
1917    /// * *$.xgafv* (query-string) - V1 error format.
1918    /// * *access_token* (query-string) - OAuth access token.
1919    /// * *alt* (query-string) - Data format for response.
1920    /// * *callback* (query-string) - JSONP
1921    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1922    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1923    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1924    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1925    /// * *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.
1926    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1927    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1928    pub fn param<T>(mut self, name: T, value: T) -> MethodGetLinkStatCall<'a, C>
1929    where
1930        T: AsRef<str>,
1931    {
1932        self._additional_params
1933            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1934        self
1935    }
1936
1937    /// Identifies the authorization scope for the method you are building.
1938    ///
1939    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1940    /// [`Scope::Firebase`].
1941    ///
1942    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1943    /// tokens for more than one scope.
1944    ///
1945    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1946    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1947    /// sufficient, a read-write scope will do as well.
1948    pub fn add_scope<St>(mut self, scope: St) -> MethodGetLinkStatCall<'a, C>
1949    where
1950        St: AsRef<str>,
1951    {
1952        self._scopes.insert(String::from(scope.as_ref()));
1953        self
1954    }
1955    /// Identifies the authorization scope(s) for the method you are building.
1956    ///
1957    /// See [`Self::add_scope()`] for details.
1958    pub fn add_scopes<I, St>(mut self, scopes: I) -> MethodGetLinkStatCall<'a, C>
1959    where
1960        I: IntoIterator<Item = St>,
1961        St: AsRef<str>,
1962    {
1963        self._scopes
1964            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1965        self
1966    }
1967
1968    /// Removes all scopes, and no default scope will be used either.
1969    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1970    /// for details).
1971    pub fn clear_scopes(mut self) -> MethodGetLinkStatCall<'a, C> {
1972        self._scopes.clear();
1973        self
1974    }
1975}
1976
1977/// Get iOS strong/weak-match info for post-install attribution.
1978///
1979/// A builder for the *installAttribution* method.
1980/// It is not used directly, but through a [`MethodMethods`] instance.
1981///
1982/// # Example
1983///
1984/// Instantiate a resource method builder
1985///
1986/// ```test_harness,no_run
1987/// # extern crate hyper;
1988/// # extern crate hyper_rustls;
1989/// # extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
1990/// use firebasedynamiclinks1::api::GetIosPostInstallAttributionRequest;
1991/// # async fn dox() {
1992/// # use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1993///
1994/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1995/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1996/// #     secret,
1997/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1998/// # ).build().await.unwrap();
1999///
2000/// # let client = hyper_util::client::legacy::Client::builder(
2001/// #     hyper_util::rt::TokioExecutor::new()
2002/// # )
2003/// # .build(
2004/// #     hyper_rustls::HttpsConnectorBuilder::new()
2005/// #         .with_native_roots()
2006/// #         .unwrap()
2007/// #         .https_or_http()
2008/// #         .enable_http1()
2009/// #         .build()
2010/// # );
2011/// # let mut hub = FirebaseDynamicLinks::new(client, auth);
2012/// // As the method needs a request, you would usually fill it with the desired information
2013/// // into the respective structure. Some of the parts shown here might not be applicable !
2014/// // Values shown here are possibly random and not representative !
2015/// let mut req = GetIosPostInstallAttributionRequest::default();
2016///
2017/// // You can configure optional parameters by calling the respective setters at will, and
2018/// // execute the final call using `doit()`.
2019/// // Values shown here are possibly random and not representative !
2020/// let result = hub.methods().install_attribution(req)
2021///              .doit().await;
2022/// # }
2023/// ```
2024pub struct MethodInstallAttributionCall<'a, C>
2025where
2026    C: 'a,
2027{
2028    hub: &'a FirebaseDynamicLinks<C>,
2029    _request: GetIosPostInstallAttributionRequest,
2030    _delegate: Option<&'a mut dyn common::Delegate>,
2031    _additional_params: HashMap<String, String>,
2032    _scopes: BTreeSet<String>,
2033}
2034
2035impl<'a, C> common::CallBuilder for MethodInstallAttributionCall<'a, C> {}
2036
2037impl<'a, C> MethodInstallAttributionCall<'a, C>
2038where
2039    C: common::Connector,
2040{
2041    /// Perform the operation you have build so far.
2042    pub async fn doit(
2043        mut self,
2044    ) -> common::Result<(common::Response, GetIosPostInstallAttributionResponse)> {
2045        use std::borrow::Cow;
2046        use std::io::{Read, Seek};
2047
2048        use common::{url::Params, ToParts};
2049        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2050
2051        let mut dd = common::DefaultDelegate;
2052        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2053        dlg.begin(common::MethodInfo {
2054            id: "firebasedynamiclinks.installAttribution",
2055            http_method: hyper::Method::POST,
2056        });
2057
2058        for &field in ["alt"].iter() {
2059            if self._additional_params.contains_key(field) {
2060                dlg.finished(false);
2061                return Err(common::Error::FieldClash(field));
2062            }
2063        }
2064
2065        let mut params = Params::with_capacity(3 + self._additional_params.len());
2066
2067        params.extend(self._additional_params.iter());
2068
2069        params.push("alt", "json");
2070        let mut url = self.hub._base_url.clone() + "v1/installAttribution";
2071        if self._scopes.is_empty() {
2072            self._scopes.insert(Scope::Firebase.as_ref().to_string());
2073        }
2074
2075        let url = params.parse_with_url(&url);
2076
2077        let mut json_mime_type = mime::APPLICATION_JSON;
2078        let mut request_value_reader = {
2079            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2080            common::remove_json_null_values(&mut value);
2081            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2082            serde_json::to_writer(&mut dst, &value).unwrap();
2083            dst
2084        };
2085        let request_size = request_value_reader
2086            .seek(std::io::SeekFrom::End(0))
2087            .unwrap();
2088        request_value_reader
2089            .seek(std::io::SeekFrom::Start(0))
2090            .unwrap();
2091
2092        loop {
2093            let token = match self
2094                .hub
2095                .auth
2096                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2097                .await
2098            {
2099                Ok(token) => token,
2100                Err(e) => match dlg.token(e) {
2101                    Ok(token) => token,
2102                    Err(e) => {
2103                        dlg.finished(false);
2104                        return Err(common::Error::MissingToken(e));
2105                    }
2106                },
2107            };
2108            request_value_reader
2109                .seek(std::io::SeekFrom::Start(0))
2110                .unwrap();
2111            let mut req_result = {
2112                let client = &self.hub.client;
2113                dlg.pre_request();
2114                let mut req_builder = hyper::Request::builder()
2115                    .method(hyper::Method::POST)
2116                    .uri(url.as_str())
2117                    .header(USER_AGENT, self.hub._user_agent.clone());
2118
2119                if let Some(token) = token.as_ref() {
2120                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2121                }
2122
2123                let request = req_builder
2124                    .header(CONTENT_TYPE, json_mime_type.to_string())
2125                    .header(CONTENT_LENGTH, request_size as u64)
2126                    .body(common::to_body(
2127                        request_value_reader.get_ref().clone().into(),
2128                    ));
2129
2130                client.request(request.unwrap()).await
2131            };
2132
2133            match req_result {
2134                Err(err) => {
2135                    if let common::Retry::After(d) = dlg.http_error(&err) {
2136                        sleep(d).await;
2137                        continue;
2138                    }
2139                    dlg.finished(false);
2140                    return Err(common::Error::HttpError(err));
2141                }
2142                Ok(res) => {
2143                    let (mut parts, body) = res.into_parts();
2144                    let mut body = common::Body::new(body);
2145                    if !parts.status.is_success() {
2146                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2147                        let error = serde_json::from_str(&common::to_string(&bytes));
2148                        let response = common::to_response(parts, bytes.into());
2149
2150                        if let common::Retry::After(d) =
2151                            dlg.http_failure(&response, error.as_ref().ok())
2152                        {
2153                            sleep(d).await;
2154                            continue;
2155                        }
2156
2157                        dlg.finished(false);
2158
2159                        return Err(match error {
2160                            Ok(value) => common::Error::BadRequest(value),
2161                            _ => common::Error::Failure(response),
2162                        });
2163                    }
2164                    let response = {
2165                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2166                        let encoded = common::to_string(&bytes);
2167                        match serde_json::from_str(&encoded) {
2168                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2169                            Err(error) => {
2170                                dlg.response_json_decode_error(&encoded, &error);
2171                                return Err(common::Error::JsonDecodeError(
2172                                    encoded.to_string(),
2173                                    error,
2174                                ));
2175                            }
2176                        }
2177                    };
2178
2179                    dlg.finished(true);
2180                    return Ok(response);
2181                }
2182            }
2183        }
2184    }
2185
2186    ///
2187    /// Sets the *request* property to the given value.
2188    ///
2189    /// Even though the property as already been set when instantiating this call,
2190    /// we provide this method for API completeness.
2191    pub fn request(
2192        mut self,
2193        new_value: GetIosPostInstallAttributionRequest,
2194    ) -> MethodInstallAttributionCall<'a, C> {
2195        self._request = new_value;
2196        self
2197    }
2198    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2199    /// while executing the actual API request.
2200    ///
2201    /// ````text
2202    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2203    /// ````
2204    ///
2205    /// Sets the *delegate* property to the given value.
2206    pub fn delegate(
2207        mut self,
2208        new_value: &'a mut dyn common::Delegate,
2209    ) -> MethodInstallAttributionCall<'a, C> {
2210        self._delegate = Some(new_value);
2211        self
2212    }
2213
2214    /// Set any additional parameter of the query string used in the request.
2215    /// It should be used to set parameters which are not yet available through their own
2216    /// setters.
2217    ///
2218    /// Please note that this method must not be used to set any of the known parameters
2219    /// which have their own setter method. If done anyway, the request will fail.
2220    ///
2221    /// # Additional Parameters
2222    ///
2223    /// * *$.xgafv* (query-string) - V1 error format.
2224    /// * *access_token* (query-string) - OAuth access token.
2225    /// * *alt* (query-string) - Data format for response.
2226    /// * *callback* (query-string) - JSONP
2227    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2228    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2229    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2230    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2231    /// * *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.
2232    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2233    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2234    pub fn param<T>(mut self, name: T, value: T) -> MethodInstallAttributionCall<'a, C>
2235    where
2236        T: AsRef<str>,
2237    {
2238        self._additional_params
2239            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2240        self
2241    }
2242
2243    /// Identifies the authorization scope for the method you are building.
2244    ///
2245    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2246    /// [`Scope::Firebase`].
2247    ///
2248    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2249    /// tokens for more than one scope.
2250    ///
2251    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2252    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2253    /// sufficient, a read-write scope will do as well.
2254    pub fn add_scope<St>(mut self, scope: St) -> MethodInstallAttributionCall<'a, C>
2255    where
2256        St: AsRef<str>,
2257    {
2258        self._scopes.insert(String::from(scope.as_ref()));
2259        self
2260    }
2261    /// Identifies the authorization scope(s) for the method you are building.
2262    ///
2263    /// See [`Self::add_scope()`] for details.
2264    pub fn add_scopes<I, St>(mut self, scopes: I) -> MethodInstallAttributionCall<'a, C>
2265    where
2266        I: IntoIterator<Item = St>,
2267        St: AsRef<str>,
2268    {
2269        self._scopes
2270            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2271        self
2272    }
2273
2274    /// Removes all scopes, and no default scope will be used either.
2275    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2276    /// for details).
2277    pub fn clear_scopes(mut self) -> MethodInstallAttributionCall<'a, C> {
2278        self._scopes.clear();
2279        self
2280    }
2281}
2282
2283/// Get iOS reopen attribution for app universal link open deeplinking.
2284///
2285/// A builder for the *reopenAttribution* method.
2286/// It is not used directly, but through a [`MethodMethods`] instance.
2287///
2288/// # Example
2289///
2290/// Instantiate a resource method builder
2291///
2292/// ```test_harness,no_run
2293/// # extern crate hyper;
2294/// # extern crate hyper_rustls;
2295/// # extern crate google_firebasedynamiclinks1 as firebasedynamiclinks1;
2296/// use firebasedynamiclinks1::api::GetIosReopenAttributionRequest;
2297/// # async fn dox() {
2298/// # use firebasedynamiclinks1::{FirebaseDynamicLinks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2299///
2300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2302/// #     secret,
2303/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2304/// # ).build().await.unwrap();
2305///
2306/// # let client = hyper_util::client::legacy::Client::builder(
2307/// #     hyper_util::rt::TokioExecutor::new()
2308/// # )
2309/// # .build(
2310/// #     hyper_rustls::HttpsConnectorBuilder::new()
2311/// #         .with_native_roots()
2312/// #         .unwrap()
2313/// #         .https_or_http()
2314/// #         .enable_http1()
2315/// #         .build()
2316/// # );
2317/// # let mut hub = FirebaseDynamicLinks::new(client, auth);
2318/// // As the method needs a request, you would usually fill it with the desired information
2319/// // into the respective structure. Some of the parts shown here might not be applicable !
2320/// // Values shown here are possibly random and not representative !
2321/// let mut req = GetIosReopenAttributionRequest::default();
2322///
2323/// // You can configure optional parameters by calling the respective setters at will, and
2324/// // execute the final call using `doit()`.
2325/// // Values shown here are possibly random and not representative !
2326/// let result = hub.methods().reopen_attribution(req)
2327///              .doit().await;
2328/// # }
2329/// ```
2330pub struct MethodReopenAttributionCall<'a, C>
2331where
2332    C: 'a,
2333{
2334    hub: &'a FirebaseDynamicLinks<C>,
2335    _request: GetIosReopenAttributionRequest,
2336    _delegate: Option<&'a mut dyn common::Delegate>,
2337    _additional_params: HashMap<String, String>,
2338    _scopes: BTreeSet<String>,
2339}
2340
2341impl<'a, C> common::CallBuilder for MethodReopenAttributionCall<'a, C> {}
2342
2343impl<'a, C> MethodReopenAttributionCall<'a, C>
2344where
2345    C: common::Connector,
2346{
2347    /// Perform the operation you have build so far.
2348    pub async fn doit(
2349        mut self,
2350    ) -> common::Result<(common::Response, GetIosReopenAttributionResponse)> {
2351        use std::borrow::Cow;
2352        use std::io::{Read, Seek};
2353
2354        use common::{url::Params, ToParts};
2355        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2356
2357        let mut dd = common::DefaultDelegate;
2358        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2359        dlg.begin(common::MethodInfo {
2360            id: "firebasedynamiclinks.reopenAttribution",
2361            http_method: hyper::Method::POST,
2362        });
2363
2364        for &field in ["alt"].iter() {
2365            if self._additional_params.contains_key(field) {
2366                dlg.finished(false);
2367                return Err(common::Error::FieldClash(field));
2368            }
2369        }
2370
2371        let mut params = Params::with_capacity(3 + self._additional_params.len());
2372
2373        params.extend(self._additional_params.iter());
2374
2375        params.push("alt", "json");
2376        let mut url = self.hub._base_url.clone() + "v1/reopenAttribution";
2377        if self._scopes.is_empty() {
2378            self._scopes.insert(Scope::Firebase.as_ref().to_string());
2379        }
2380
2381        let url = params.parse_with_url(&url);
2382
2383        let mut json_mime_type = mime::APPLICATION_JSON;
2384        let mut request_value_reader = {
2385            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2386            common::remove_json_null_values(&mut value);
2387            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2388            serde_json::to_writer(&mut dst, &value).unwrap();
2389            dst
2390        };
2391        let request_size = request_value_reader
2392            .seek(std::io::SeekFrom::End(0))
2393            .unwrap();
2394        request_value_reader
2395            .seek(std::io::SeekFrom::Start(0))
2396            .unwrap();
2397
2398        loop {
2399            let token = match self
2400                .hub
2401                .auth
2402                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2403                .await
2404            {
2405                Ok(token) => token,
2406                Err(e) => match dlg.token(e) {
2407                    Ok(token) => token,
2408                    Err(e) => {
2409                        dlg.finished(false);
2410                        return Err(common::Error::MissingToken(e));
2411                    }
2412                },
2413            };
2414            request_value_reader
2415                .seek(std::io::SeekFrom::Start(0))
2416                .unwrap();
2417            let mut req_result = {
2418                let client = &self.hub.client;
2419                dlg.pre_request();
2420                let mut req_builder = hyper::Request::builder()
2421                    .method(hyper::Method::POST)
2422                    .uri(url.as_str())
2423                    .header(USER_AGENT, self.hub._user_agent.clone());
2424
2425                if let Some(token) = token.as_ref() {
2426                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2427                }
2428
2429                let request = req_builder
2430                    .header(CONTENT_TYPE, json_mime_type.to_string())
2431                    .header(CONTENT_LENGTH, request_size as u64)
2432                    .body(common::to_body(
2433                        request_value_reader.get_ref().clone().into(),
2434                    ));
2435
2436                client.request(request.unwrap()).await
2437            };
2438
2439            match req_result {
2440                Err(err) => {
2441                    if let common::Retry::After(d) = dlg.http_error(&err) {
2442                        sleep(d).await;
2443                        continue;
2444                    }
2445                    dlg.finished(false);
2446                    return Err(common::Error::HttpError(err));
2447                }
2448                Ok(res) => {
2449                    let (mut parts, body) = res.into_parts();
2450                    let mut body = common::Body::new(body);
2451                    if !parts.status.is_success() {
2452                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2453                        let error = serde_json::from_str(&common::to_string(&bytes));
2454                        let response = common::to_response(parts, bytes.into());
2455
2456                        if let common::Retry::After(d) =
2457                            dlg.http_failure(&response, error.as_ref().ok())
2458                        {
2459                            sleep(d).await;
2460                            continue;
2461                        }
2462
2463                        dlg.finished(false);
2464
2465                        return Err(match error {
2466                            Ok(value) => common::Error::BadRequest(value),
2467                            _ => common::Error::Failure(response),
2468                        });
2469                    }
2470                    let response = {
2471                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2472                        let encoded = common::to_string(&bytes);
2473                        match serde_json::from_str(&encoded) {
2474                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2475                            Err(error) => {
2476                                dlg.response_json_decode_error(&encoded, &error);
2477                                return Err(common::Error::JsonDecodeError(
2478                                    encoded.to_string(),
2479                                    error,
2480                                ));
2481                            }
2482                        }
2483                    };
2484
2485                    dlg.finished(true);
2486                    return Ok(response);
2487                }
2488            }
2489        }
2490    }
2491
2492    ///
2493    /// Sets the *request* property to the given value.
2494    ///
2495    /// Even though the property as already been set when instantiating this call,
2496    /// we provide this method for API completeness.
2497    pub fn request(
2498        mut self,
2499        new_value: GetIosReopenAttributionRequest,
2500    ) -> MethodReopenAttributionCall<'a, C> {
2501        self._request = new_value;
2502        self
2503    }
2504    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2505    /// while executing the actual API request.
2506    ///
2507    /// ````text
2508    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2509    /// ````
2510    ///
2511    /// Sets the *delegate* property to the given value.
2512    pub fn delegate(
2513        mut self,
2514        new_value: &'a mut dyn common::Delegate,
2515    ) -> MethodReopenAttributionCall<'a, C> {
2516        self._delegate = Some(new_value);
2517        self
2518    }
2519
2520    /// Set any additional parameter of the query string used in the request.
2521    /// It should be used to set parameters which are not yet available through their own
2522    /// setters.
2523    ///
2524    /// Please note that this method must not be used to set any of the known parameters
2525    /// which have their own setter method. If done anyway, the request will fail.
2526    ///
2527    /// # Additional Parameters
2528    ///
2529    /// * *$.xgafv* (query-string) - V1 error format.
2530    /// * *access_token* (query-string) - OAuth access token.
2531    /// * *alt* (query-string) - Data format for response.
2532    /// * *callback* (query-string) - JSONP
2533    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2534    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2535    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2536    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2537    /// * *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.
2538    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2539    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2540    pub fn param<T>(mut self, name: T, value: T) -> MethodReopenAttributionCall<'a, C>
2541    where
2542        T: AsRef<str>,
2543    {
2544        self._additional_params
2545            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2546        self
2547    }
2548
2549    /// Identifies the authorization scope for the method you are building.
2550    ///
2551    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2552    /// [`Scope::Firebase`].
2553    ///
2554    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2555    /// tokens for more than one scope.
2556    ///
2557    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2558    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2559    /// sufficient, a read-write scope will do as well.
2560    pub fn add_scope<St>(mut self, scope: St) -> MethodReopenAttributionCall<'a, C>
2561    where
2562        St: AsRef<str>,
2563    {
2564        self._scopes.insert(String::from(scope.as_ref()));
2565        self
2566    }
2567    /// Identifies the authorization scope(s) for the method you are building.
2568    ///
2569    /// See [`Self::add_scope()`] for details.
2570    pub fn add_scopes<I, St>(mut self, scopes: I) -> MethodReopenAttributionCall<'a, C>
2571    where
2572        I: IntoIterator<Item = St>,
2573        St: AsRef<str>,
2574    {
2575        self._scopes
2576            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2577        self
2578    }
2579
2580    /// Removes all scopes, and no default scope will be used either.
2581    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2582    /// for details).
2583    pub fn clear_scopes(mut self) -> MethodReopenAttributionCall<'a, C> {
2584        self._scopes.clear();
2585        self
2586    }
2587}