capacitor_bindings 0.14.0

Capacitor bindings to help you build android and ios apps with rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
#[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
use crate::{extern_functions::*, prelude::*};
use serde::{Deserialize, Serialize};
use serde_repr::*;
use typed_builder::TypedBuilder;

/// For details, https://github.com/capacitor-community/admob
pub struct Admob {}

impl Admob {
    /// Initialize AdMob with AdMobInitializationOptions
    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn initialize(options: impl Into<AdMobInitializationOptions>) -> Result<(), Error> {
        run_value_unit(options, admob_initialize).await
    }

    /// Confirm requestTrackingAuthorization status (iOS >14)
    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn tracking_authorization_status(
    ) -> Result<TrackingAuthorizationStatusInterface, Error> {
        run_unit_value(admob_tracking_authorization_status).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// request requestTrackingAuthorization (iOS >14). This is deprecated method. We recommend UMP Consent.
    #[deprecated]
    pub async fn request_tracking_authorization() -> Result<(), Error> {
        run_unit_unit(admob_request_tracking_authorization).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Report application mute state to AdMob SDK
    pub async fn set_application_muted(
        options: impl Into<ApplicationMutedOptions>,
    ) -> Result<(), Error> {
        run_value_unit(options, admob_set_application_muted).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Report application volume to AdMob SDK
    pub async fn set_application_volume(
        options: impl Into<ApplicationVolumeOptions>,
    ) -> Result<(), Error> {
        run_value_unit(options, admob_set_application_volume).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Show a banner Ad
    pub async fn show_banner(options: impl Into<BannerAdOptions>) -> Result<(), Error> {
        run_value_unit(options, admob_show_banner).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Hide the banner, remove it from screen, but can show it later
    pub async fn hide_banner() -> Result<(), Error> {
        run_unit_unit(admob_hide_banner).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Resume the banner, show it after hide
    pub async fn resume_banner() -> Result<(), Error> {
        run_unit_unit(admob_resume_banner).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn add_banner_ad_sized_changed_listener<F: Fn(AdMobBannerSize) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "bannerAdSizeChanged", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn add_banner_ad_loaded_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "bannerAdLoaded", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn add_banner_failed_to_load_listener<F: Fn(AdMobError) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "bannerAdFailedToLoad", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn add_banner_opened_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "bannerAdOpened", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn add_banner_closed_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "bannerAdClosed", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    pub async fn add_banner_ad_impression_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "bannerAdImpression", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Request user consent information
    pub async fn request_consent_info(
        options: impl Into<AdmobConsentRequestOptions>,
    ) -> Result<AdmobConsentInfo, Error> {
        run_value_value(options, admob_request_consent_info).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Shows a google user consent form (rendered from your GDPR message config).
    pub async fn show_consent_form() -> Result<AdmobConsentInfo, Error> {
        run_unit_value(admob_show_consent_form).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Resets the UMP SDK state. Call requestConsentInfo function again to allow user modify their consent
    pub async fn reset_consent_info() -> Result<(), Error> {
        run_unit_unit(admob_reset_consent_info).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Prepare interstitial banner
    pub async fn prepare_interstitial(options: impl Into<AdOptions>) -> Result<AdLoadInfo, Error> {
        run_value_value(options, admob_prepare_interstitial).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Show interstitial ad when it’s ready
    pub async fn show_interstitial() -> Result<(), Error> {
        run_unit_unit(admob_show_interstitial).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits after trying to prepare an Interstitial, when it is loaded and ready to be show
    pub async fn add_interstitial_ad_loaded_listener<F: Fn(AdLoadInfo) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "interstitialAdLoaded", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits after trying to prepare and Interstitial, when it could not be loaded
    pub async fn add_interstitial_failed_to_load_listener<F: Fn(AdMobError) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "interstitialAdFailedToLoad", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits when the Interstitial ad is visible to the user
    pub async fn add_interstitial_showed_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "interstitialAdShowed", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits when the Interstitial ad is failed to show
    pub async fn add_interstitial_failed_to_show_listener<F: Fn(AdMobError) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "interstitialAdFailedToShow", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits when the Interstitial ad is not visible to the user anymore.
    pub async fn add_interstitial_ad_dismissed_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "interstitialAdDismissed", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Prepare a reward video ad
    pub async fn prepare_reward_video_ad(
        options: impl Into<RewardAdOptions>,
    ) -> Result<AdLoadInfo, Error> {
        run_value_value(options, admob_prepare_reward_video_ad).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Show a reward video ad
    pub async fn show_reward_video_ad() -> Result<AdMobRewardItem, Error> {
        run_unit_value(admob_show_reward_video_ad).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits after trying to prepare a RewardAd when it could not be loaded
    pub async fn add_reward_failed_to_load_listener<F: Fn(AdMobError) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "onRewardedVideoAdFailedToLoad", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits after trying to prepare a RewardAd and the Video is loaded and ready to be show
    pub async fn add_reward_ad_loaded_listener<F: Fn(AdLoadInfo) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "onRewardedVideoAdLoaded", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits when user get rewarded from AdReward
    pub async fn add_reward_ad_rewarded_listener<F: Fn(AdMobRewardItem) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "onRewardedVideoAdReward", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits when the AdReward video is not visible to the user anymore. Important: This has nothing to do with the reward it self. This event will emits in this two cases: 1. The user starts the video ad but close it before the reward emit. 2. The user start the video and see it until end, then gets the reward and after that the ad is closed.
    pub async fn add_reward_ad_dismissed_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "onRewardedVideoAdDismissed", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits when the AdReward video is failed to show
    pub async fn add_reward_ad_failed_to_show_listener<F: Fn(AdMobError) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "onRewardedVideoAdFailedToShow", admob_add_listener).await
    }

    #[cfg(all(feature = "admob_plugin", any(feature = "ios", feature = "android")))]
    /// Emits when the AdReward video is visible to the user
    pub async fn add_reward_showed_listener<F: Fn(()) + 'static>(
        func: F,
    ) -> Result<PluginListenerHandle, Error> {
        listen_async(func, "onRewardedVideoAdShowed", admob_add_listener).await
    }
}

#[derive(Clone, Debug, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct AdMobInitializationOptions {
    ///An Array of devices IDs that will be marked as tested devices if `AdMobInitializationOptions.initializeForTesting` is true (Real Ads will be served to Testing devices, but they will not count as 'real').
    #[builder(setter(into))]
    #[serde(rename = "testingDevices")]
    pub testing_devices: Vec<String>,

    /// If set to true, the devices on `AdMobInitializationOptions.testingDevices` will be registered to receive test production ads.
    #[builder(setter(into))]
    #[serde(rename = "initializeForTesting")]
    pub initialize_for_testing: bool,

    /// For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called tagForChildDirectedTreatment.
    #[builder(setter(into))]
    #[serde(rename = "tagForChildDirectedTreatment")]
    pub tag_for_child_directed_treatment: bool,

    /// When using this feature, a Tag For Users under the Age of Consent in Europe (TFUA) parameter will be included in all future ad requests.
    #[builder(setter(into))]
    #[serde(rename = "tagForUnderAgeOfConsent")]
    pub tag_for_under_age_of_consent: bool,

    /// As an app developer, you can indicate whether you want Google to treat your content as child-directed when you make an ad request.
    #[builder(setter(into))]
    #[serde(rename = "maxAdContentRating")]
    pub max_ad_content_rating: MaxAdContentRating,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub enum MaxAdContentRating {
    /// Content suitable for general audiences, including families.
    General,
    /// Content suitable for most audiences with parental guidance.
    ParentalGuidance,
    /// Content suitable for teen and older audiences.
    Teen,
    /// Content suitable only for mature audiences.
    MatureAudience,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TrackingAuthorizationStatusInterface {
    pub status: TrackingAuthorizationStatus,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum TrackingAuthorizationStatus {
    Authorized,
    Denied,
    NotDetermined,
    Restricted,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplicationMutedOptions {
    /// To inform the SDK that the app volume has been muted. Note: Video ads that are ineligible to be shown with muted audio are not returned for ad requests made, when the app volume is reported as muted or set to a value of 0. This may restrict a subset of the broader video ads pool from serving.
    pub muted: bool,
}

impl From<bool> for ApplicationMutedOptions {
    fn from(value: bool) -> Self {
        Self { muted: value }
    }
}

#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplicationVolumeOptions {
    /// If your app has its own volume controls (such as custom music or sound effect volumes), disclosing app volume to the Google Mobile Ads SDK allows video ads to respect app volume settings. enable set 0.0 - 1.0, any float allowed.
    pub volume: f32,
}

impl From<f32> for ApplicationVolumeOptions {
    fn from(value: f32) -> Self {
        Self {
            volume: value.clamp(0.0, 1.0),
        }
    }
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
/// When notice listener of OnAdLoaded, you can get banner size.
pub struct AdMobBannerSize {
    pub width: f32,
    pub height: f32,
}

/// For more information https://developers.google.com/android/reference/com/google/android/gms/ads/AdError
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdMobError {
    /// Gets the error's code.
    pub code: u32,
    /// Gets the message describing the error.
    pub message: String,
}

impl std::fmt::Display for AdMobError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.message)
    }
}

impl std::error::Error for AdMobError {}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct AdmobConsentInfo {
    /// The consent status of the user.
    pub status: AdmobConsentStatus,
    #[serde(default)]
    /// If `true` a consent form is available and vice versa.
    pub is_consent_form_available: bool,
}

#[derive(Clone, Debug, PartialEq, Serialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct AdmobConsentRequestOptions {
    /// Sets the debug geography to test the consent locally.
    pub debug_geography: AdmobConsentDebugGeography,
    /// An array of test device IDs to allow. Note: On iOS, the ID may renew if you uninstall and reinstall the app.
    pub test_device_identifiers: Vec<String>,
    /// Set to true to provide the option for the user to accept being shown personalized ads.
    pub tag_for_under_age_of_consent: bool,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct AdLoadInfo {
    pub ad_unit_id: String,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct AdOptions {
    /// The ad unit ID that you want to request
    pub ad_id: String,
    /// You can use test mode of ad.
    pub is_testing: bool,
    /// Margin Banner. Default is 0px; If position is BOTTOM_CENTER, margin is be margin-bottom. If position is TOP_CENTER, margin is be margin-top.
    pub margin: f32,
    /// The default behavior of the Google Mobile Ads SDK is to serve personalized ads. Set this to true to request Non-Personalized Ads
    pub npa: bool,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TypedBuilder)]

pub struct AdMobRewardItem {
    /// Rewarded type user got
    #[serde(rename = "type")]
    pub reward_type: String,
    /// Rewarded amount user got
    #[serde(rename = "amount")]
    pub amount: u32,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum AdmobConsentStatus {
    /// User consent not required.
    NotRequired,
    /// User consent already obtained.
    Obtained,
    /// User consent required but not yet obtained.
    Required,
    /// Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it.
    Unknown,
}

#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone, Copy)]
#[repr(u8)]
pub enum AdmobConsentDebugGeography {
    /// Debug geography disabled.
    Disabled = 0,
    /// Geography appears as in EEA for debug devices.
    EEA = 1,
    /// Geography appears as not in EEA for debug devices.
    NotEea = 2,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]

pub enum InterstitialAdPluginEvents {
    /// Emits after trying to prepare and Interstitial, when it is loaded and ready to be show
    #[serde(rename = "interstitialAdLoaded")]
    Loaded,
    /// Emits after trying to prepare and Interstitial, when it could not be loaded
    #[serde(rename = "interstitialAdFailedToLoad")]
    FailedToLoad,
    /// Emits when the Interstitial ad is visible to the user
    #[serde(rename = "interstitialAdShowed")]
    Showed,
    /// Emits when the Interstitial ad is failed to show
    #[serde(rename = "interstitialAdFailedToShow")]
    FailedToShow,
    /// Emits when the Interstitial ad is not visible to the user anymore.
    #[serde(rename = "interstitialAdDismissed")]
    Dismissed,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum RewardAdPluginEvents {
    /// Emits after trying to prepare a RewardAd and the Video is loaded and ready to be show
    #[serde(rename = "onRewardedVideoAdLoaded")]
    Loaded,
    /// Emits after trying to prepare a RewardAd when it could not be loaded
    #[serde(rename = "onRewardedVideoAdFailedToLoad")]
    FailedToLoad,
    /// Emits when the AdReward video is visible to the user
    #[serde(rename = "onRewardedVideoAdShowed")]
    Showed,
    /// Emits when the AdReward video is failed to show
    #[serde(rename = "onRewardedVideoAdFailedToShow")]
    FailedToShow,
    /// Emits when the AdReward video is not visible to the user anymore. Important: This has nothing to do with the reward it self. This event will emits in this two cases: 1. The user starts the video ad but close it before the reward emit. 2. The user start the video and see it until end, then gets the reward and after that the ad is closed.
    #[serde(rename = "onRewardedVideoAdDismissed")]
    Dismissed,
    /// Emits when user get rewarded from AdReward
    #[serde(rename = "onRewardedVideoAdReward")]
    Rewarded,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum BannerAdSize {
    /// Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).
    Banner,
    /// Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).
    FullBanner,
    /// Large banner ad size (320x100 density-independent pixels).
    LargeBanner,
    /// Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).
    MediumRectangle,
    /// Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).
    Leaderboard,
    /// A dynamically sized banner that is full-width and auto-height.
    AdaptiveBanner,
    SmartBanner,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum BannerAdPosition {
    /// Banner position be top-center
    TopCenter,
    /// Banner position be center
    Center,
    /// Banner position be bottom-center(default)
    BottomCenter,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum BannerAdPluginEvents {
    SizeChanged,
    Loaded,
    FailedToLoad,
    /// Open "Adsense" Event after user click banner
    Opened,
    /// Close "Adsense" Event after user click banner
    Closed,
    /// Similarly, this method should be called when an impression is recorded for the ad by the mediated SDK.
    AdImpression,
}

/// If you have enabled SSV in your AdMob Application. You can provide customData or a userId be passed to your callback to do further processing on. Important You HAVE to define one of them.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct RewardAdSSV {
    pub user_id: Option<String>,
    pub custom_data: Option<String>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct RewardAdOptions {
    /// If you have enabled SSV in your AdMob Application. You can provide customData or a userId be passed to your callback to do further processing on. Important You HAVE to define one of them.
    pub ssv: Option<RewardAdSSV>,

    /// The ad unit ID that you want to request
    pub ad_id: String,
    /// You can use test mode of ad.
    pub is_testing: bool,
    /// Margin Banner. Default is 0px; If position is BOTTOM_CENTER, margin is be margin-bottom. If position is TOP_CENTER, margin is be margin-top.
    pub margin: f32,
    /// The default behavior of the Google Mobile Ads SDK is to serve personalized ads. Set this to true to request Non-Personalized Ads
    pub npa: bool,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase")]
pub struct BannerAdOptions {
    pub ad_size: BannerAdSize,
    pub position: BannerAdPosition,

    /// The ad unit ID that you want to request
    pub ad_id: String,
    /// You can use test mode of ad.
    pub is_testing: bool,
    /// Margin Banner. Default is 0px; If position is BOTTOM_CENTER, margin is margin-bottom. If position is TOP_CENTER, margin is margin-top.
    pub margin: f32,
    /// The default behavior of the Google Mobile Ads SDK is to serve personalized ads. Set this to true to request Non-Personalized Ads
    pub npa: bool,
}