1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct PaymentMethodCardWallet {
6 pub amex_express_checkout: Option<stripe_shared::PaymentMethodCardWalletAmexExpressCheckout>,
7 pub apple_pay: Option<stripe_shared::PaymentMethodCardWalletApplePay>,
8 pub dynamic_last4: Option<String>,
10 pub google_pay: Option<stripe_shared::PaymentMethodCardWalletGooglePay>,
11 pub link: Option<stripe_shared::PaymentMethodCardWalletLink>,
12 pub masterpass: Option<stripe_shared::PaymentMethodCardWalletMasterpass>,
13 pub samsung_pay: Option<stripe_shared::PaymentMethodCardWalletSamsungPay>,
14 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
18 pub type_: PaymentMethodCardWalletType,
19 pub visa_checkout: Option<stripe_shared::PaymentMethodCardWalletVisaCheckout>,
20}
21#[cfg(feature = "redact-generated-debug")]
22impl std::fmt::Debug for PaymentMethodCardWallet {
23 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24 f.debug_struct("PaymentMethodCardWallet").finish_non_exhaustive()
25 }
26}
27#[doc(hidden)]
28pub struct PaymentMethodCardWalletBuilder {
29 amex_express_checkout:
30 Option<Option<stripe_shared::PaymentMethodCardWalletAmexExpressCheckout>>,
31 apple_pay: Option<Option<stripe_shared::PaymentMethodCardWalletApplePay>>,
32 dynamic_last4: Option<Option<String>>,
33 google_pay: Option<Option<stripe_shared::PaymentMethodCardWalletGooglePay>>,
34 link: Option<Option<stripe_shared::PaymentMethodCardWalletLink>>,
35 masterpass: Option<Option<stripe_shared::PaymentMethodCardWalletMasterpass>>,
36 samsung_pay: Option<Option<stripe_shared::PaymentMethodCardWalletSamsungPay>>,
37 type_: Option<PaymentMethodCardWalletType>,
38 visa_checkout: Option<Option<stripe_shared::PaymentMethodCardWalletVisaCheckout>>,
39}
40
41#[allow(
42 unused_variables,
43 irrefutable_let_patterns,
44 clippy::let_unit_value,
45 clippy::match_single_binding,
46 clippy::single_match
47)]
48const _: () = {
49 use miniserde::de::{Map, Visitor};
50 use miniserde::json::Value;
51 use miniserde::{Deserialize, Result, make_place};
52 use stripe_types::miniserde_helpers::FromValueOpt;
53 use stripe_types::{MapBuilder, ObjectDeser};
54
55 make_place!(Place);
56
57 impl Deserialize for PaymentMethodCardWallet {
58 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
59 Place::new(out)
60 }
61 }
62
63 struct Builder<'a> {
64 out: &'a mut Option<PaymentMethodCardWallet>,
65 builder: PaymentMethodCardWalletBuilder,
66 }
67
68 impl Visitor for Place<PaymentMethodCardWallet> {
69 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
70 Ok(Box::new(Builder {
71 out: &mut self.out,
72 builder: PaymentMethodCardWalletBuilder::deser_default(),
73 }))
74 }
75 }
76
77 impl MapBuilder for PaymentMethodCardWalletBuilder {
78 type Out = PaymentMethodCardWallet;
79 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
80 Ok(match k {
81 "amex_express_checkout" => Deserialize::begin(&mut self.amex_express_checkout),
82 "apple_pay" => Deserialize::begin(&mut self.apple_pay),
83 "dynamic_last4" => Deserialize::begin(&mut self.dynamic_last4),
84 "google_pay" => Deserialize::begin(&mut self.google_pay),
85 "link" => Deserialize::begin(&mut self.link),
86 "masterpass" => Deserialize::begin(&mut self.masterpass),
87 "samsung_pay" => Deserialize::begin(&mut self.samsung_pay),
88 "type" => Deserialize::begin(&mut self.type_),
89 "visa_checkout" => Deserialize::begin(&mut self.visa_checkout),
90 _ => <dyn Visitor>::ignore(),
91 })
92 }
93
94 fn deser_default() -> Self {
95 Self {
96 amex_express_checkout: Some(None),
97 apple_pay: Some(None),
98 dynamic_last4: Some(None),
99 google_pay: Some(None),
100 link: Some(None),
101 masterpass: Some(None),
102 samsung_pay: Some(None),
103 type_: None,
104 visa_checkout: Some(None),
105 }
106 }
107
108 fn take_out(&mut self) -> Option<Self::Out> {
109 let (
110 Some(amex_express_checkout),
111 Some(apple_pay),
112 Some(dynamic_last4),
113 Some(google_pay),
114 Some(link),
115 Some(masterpass),
116 Some(samsung_pay),
117 Some(type_),
118 Some(visa_checkout),
119 ) = (
120 self.amex_express_checkout,
121 self.apple_pay,
122 self.dynamic_last4.take(),
123 self.google_pay,
124 self.link,
125 self.masterpass.take(),
126 self.samsung_pay,
127 self.type_.take(),
128 self.visa_checkout.take(),
129 )
130 else {
131 return None;
132 };
133 Some(Self::Out {
134 amex_express_checkout,
135 apple_pay,
136 dynamic_last4,
137 google_pay,
138 link,
139 masterpass,
140 samsung_pay,
141 type_,
142 visa_checkout,
143 })
144 }
145 }
146
147 impl Map for Builder<'_> {
148 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
149 self.builder.key(k)
150 }
151
152 fn finish(&mut self) -> Result<()> {
153 *self.out = self.builder.take_out();
154 Ok(())
155 }
156 }
157
158 impl ObjectDeser for PaymentMethodCardWallet {
159 type Builder = PaymentMethodCardWalletBuilder;
160 }
161
162 impl FromValueOpt for PaymentMethodCardWallet {
163 fn from_value(v: Value) -> Option<Self> {
164 let Value::Object(obj) = v else {
165 return None;
166 };
167 let mut b = PaymentMethodCardWalletBuilder::deser_default();
168 for (k, v) in obj {
169 match k.as_str() {
170 "amex_express_checkout" => {
171 b.amex_express_checkout = FromValueOpt::from_value(v)
172 }
173 "apple_pay" => b.apple_pay = FromValueOpt::from_value(v),
174 "dynamic_last4" => b.dynamic_last4 = FromValueOpt::from_value(v),
175 "google_pay" => b.google_pay = FromValueOpt::from_value(v),
176 "link" => b.link = FromValueOpt::from_value(v),
177 "masterpass" => b.masterpass = FromValueOpt::from_value(v),
178 "samsung_pay" => b.samsung_pay = FromValueOpt::from_value(v),
179 "type" => b.type_ = FromValueOpt::from_value(v),
180 "visa_checkout" => b.visa_checkout = FromValueOpt::from_value(v),
181 _ => {}
182 }
183 }
184 b.take_out()
185 }
186 }
187};
188#[derive(Clone, Eq, PartialEq)]
192#[non_exhaustive]
193pub enum PaymentMethodCardWalletType {
194 AmexExpressCheckout,
195 ApplePay,
196 GooglePay,
197 Link,
198 Masterpass,
199 SamsungPay,
200 VisaCheckout,
201 Unknown(String),
203}
204impl PaymentMethodCardWalletType {
205 pub fn as_str(&self) -> &str {
206 use PaymentMethodCardWalletType::*;
207 match self {
208 AmexExpressCheckout => "amex_express_checkout",
209 ApplePay => "apple_pay",
210 GooglePay => "google_pay",
211 Link => "link",
212 Masterpass => "masterpass",
213 SamsungPay => "samsung_pay",
214 VisaCheckout => "visa_checkout",
215 Unknown(v) => v,
216 }
217 }
218}
219
220impl std::str::FromStr for PaymentMethodCardWalletType {
221 type Err = std::convert::Infallible;
222 fn from_str(s: &str) -> Result<Self, Self::Err> {
223 use PaymentMethodCardWalletType::*;
224 match s {
225 "amex_express_checkout" => Ok(AmexExpressCheckout),
226 "apple_pay" => Ok(ApplePay),
227 "google_pay" => Ok(GooglePay),
228 "link" => Ok(Link),
229 "masterpass" => Ok(Masterpass),
230 "samsung_pay" => Ok(SamsungPay),
231 "visa_checkout" => Ok(VisaCheckout),
232 v => {
233 tracing::warn!(
234 "Unknown value '{}' for enum '{}'",
235 v,
236 "PaymentMethodCardWalletType"
237 );
238 Ok(Unknown(v.to_owned()))
239 }
240 }
241 }
242}
243impl std::fmt::Display for PaymentMethodCardWalletType {
244 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
245 f.write_str(self.as_str())
246 }
247}
248
249#[cfg(not(feature = "redact-generated-debug"))]
250impl std::fmt::Debug for PaymentMethodCardWalletType {
251 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
252 f.write_str(self.as_str())
253 }
254}
255#[cfg(feature = "redact-generated-debug")]
256impl std::fmt::Debug for PaymentMethodCardWalletType {
257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
258 f.debug_struct(stringify!(PaymentMethodCardWalletType)).finish_non_exhaustive()
259 }
260}
261#[cfg(feature = "serialize")]
262impl serde::Serialize for PaymentMethodCardWalletType {
263 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
264 where
265 S: serde::Serializer,
266 {
267 serializer.serialize_str(self.as_str())
268 }
269}
270impl miniserde::Deserialize for PaymentMethodCardWalletType {
271 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
272 crate::Place::new(out)
273 }
274}
275
276impl miniserde::de::Visitor for crate::Place<PaymentMethodCardWalletType> {
277 fn string(&mut self, s: &str) -> miniserde::Result<()> {
278 use std::str::FromStr;
279 self.out = Some(PaymentMethodCardWalletType::from_str(s).expect("infallible"));
280 Ok(())
281 }
282}
283
284stripe_types::impl_from_val_with_from_str!(PaymentMethodCardWalletType);
285#[cfg(feature = "deserialize")]
286impl<'de> serde::Deserialize<'de> for PaymentMethodCardWalletType {
287 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
288 use std::str::FromStr;
289 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
290 Ok(Self::from_str(&s).expect("infallible"))
291 }
292}