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