stripe_shared/
issuing_card_wallets.rs1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingCardWallets {
5 pub apple_pay: stripe_shared::IssuingCardApplePay,
6 pub google_pay: stripe_shared::IssuingCardGooglePay,
7 pub primary_account_identifier: Option<String>,
9}
10#[doc(hidden)]
11pub struct IssuingCardWalletsBuilder {
12 apple_pay: Option<stripe_shared::IssuingCardApplePay>,
13 google_pay: Option<stripe_shared::IssuingCardGooglePay>,
14 primary_account_identifier: Option<Option<String>>,
15}
16
17#[allow(
18 unused_variables,
19 irrefutable_let_patterns,
20 clippy::let_unit_value,
21 clippy::match_single_binding,
22 clippy::single_match
23)]
24const _: () = {
25 use miniserde::de::{Map, Visitor};
26 use miniserde::json::Value;
27 use miniserde::{Deserialize, Result, make_place};
28 use stripe_types::miniserde_helpers::FromValueOpt;
29 use stripe_types::{MapBuilder, ObjectDeser};
30
31 make_place!(Place);
32
33 impl Deserialize for IssuingCardWallets {
34 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
35 Place::new(out)
36 }
37 }
38
39 struct Builder<'a> {
40 out: &'a mut Option<IssuingCardWallets>,
41 builder: IssuingCardWalletsBuilder,
42 }
43
44 impl Visitor for Place<IssuingCardWallets> {
45 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
46 Ok(Box::new(Builder {
47 out: &mut self.out,
48 builder: IssuingCardWalletsBuilder::deser_default(),
49 }))
50 }
51 }
52
53 impl MapBuilder for IssuingCardWalletsBuilder {
54 type Out = IssuingCardWallets;
55 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56 Ok(match k {
57 "apple_pay" => Deserialize::begin(&mut self.apple_pay),
58 "google_pay" => Deserialize::begin(&mut self.google_pay),
59 "primary_account_identifier" => {
60 Deserialize::begin(&mut self.primary_account_identifier)
61 }
62 _ => <dyn Visitor>::ignore(),
63 })
64 }
65
66 fn deser_default() -> Self {
67 Self {
68 apple_pay: Deserialize::default(),
69 google_pay: Deserialize::default(),
70 primary_account_identifier: Deserialize::default(),
71 }
72 }
73
74 fn take_out(&mut self) -> Option<Self::Out> {
75 let (Some(apple_pay), Some(google_pay), Some(primary_account_identifier)) = (
76 self.apple_pay.take(),
77 self.google_pay.take(),
78 self.primary_account_identifier.take(),
79 ) else {
80 return None;
81 };
82 Some(Self::Out { apple_pay, google_pay, primary_account_identifier })
83 }
84 }
85
86 impl Map for Builder<'_> {
87 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
88 self.builder.key(k)
89 }
90
91 fn finish(&mut self) -> Result<()> {
92 *self.out = self.builder.take_out();
93 Ok(())
94 }
95 }
96
97 impl ObjectDeser for IssuingCardWallets {
98 type Builder = IssuingCardWalletsBuilder;
99 }
100
101 impl FromValueOpt for IssuingCardWallets {
102 fn from_value(v: Value) -> Option<Self> {
103 let Value::Object(obj) = v else {
104 return None;
105 };
106 let mut b = IssuingCardWalletsBuilder::deser_default();
107 for (k, v) in obj {
108 match k.as_str() {
109 "apple_pay" => b.apple_pay = FromValueOpt::from_value(v),
110 "google_pay" => b.google_pay = FromValueOpt::from_value(v),
111 "primary_account_identifier" => {
112 b.primary_account_identifier = FromValueOpt::from_value(v)
113 }
114 _ => {}
115 }
116 }
117 b.take_out()
118 }
119 }
120};