1#[derive(Clone, Debug)]
6#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
7pub struct IssuingToken {
8 pub card: stripe_types::Expandable<stripe_shared::IssuingCard>,
10 pub created: stripe_types::Timestamp,
12 pub device_fingerprint: Option<String>,
14 pub id: stripe_shared::IssuingTokenId,
16 pub last4: Option<String>,
18 pub livemode: bool,
20 pub network: IssuingTokenNetwork,
22 pub network_data: Option<stripe_shared::IssuingNetworkTokenNetworkData>,
23 pub network_updated_at: stripe_types::Timestamp,
26 pub status: stripe_shared::IssuingTokenStatus,
28 pub wallet_provider: Option<IssuingTokenWalletProvider>,
30}
31#[doc(hidden)]
32pub struct IssuingTokenBuilder {
33 card: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>,
34 created: Option<stripe_types::Timestamp>,
35 device_fingerprint: Option<Option<String>>,
36 id: Option<stripe_shared::IssuingTokenId>,
37 last4: Option<Option<String>>,
38 livemode: Option<bool>,
39 network: Option<IssuingTokenNetwork>,
40 network_data: Option<Option<stripe_shared::IssuingNetworkTokenNetworkData>>,
41 network_updated_at: Option<stripe_types::Timestamp>,
42 status: Option<stripe_shared::IssuingTokenStatus>,
43 wallet_provider: Option<Option<IssuingTokenWalletProvider>>,
44}
45
46#[allow(
47 unused_variables,
48 irrefutable_let_patterns,
49 clippy::let_unit_value,
50 clippy::match_single_binding,
51 clippy::single_match
52)]
53const _: () = {
54 use miniserde::de::{Map, Visitor};
55 use miniserde::json::Value;
56 use miniserde::{Deserialize, Result, make_place};
57 use stripe_types::miniserde_helpers::FromValueOpt;
58 use stripe_types::{MapBuilder, ObjectDeser};
59
60 make_place!(Place);
61
62 impl Deserialize for IssuingToken {
63 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
64 Place::new(out)
65 }
66 }
67
68 struct Builder<'a> {
69 out: &'a mut Option<IssuingToken>,
70 builder: IssuingTokenBuilder,
71 }
72
73 impl Visitor for Place<IssuingToken> {
74 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
75 Ok(Box::new(Builder {
76 out: &mut self.out,
77 builder: IssuingTokenBuilder::deser_default(),
78 }))
79 }
80 }
81
82 impl MapBuilder for IssuingTokenBuilder {
83 type Out = IssuingToken;
84 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
85 Ok(match k {
86 "card" => Deserialize::begin(&mut self.card),
87 "created" => Deserialize::begin(&mut self.created),
88 "device_fingerprint" => Deserialize::begin(&mut self.device_fingerprint),
89 "id" => Deserialize::begin(&mut self.id),
90 "last4" => Deserialize::begin(&mut self.last4),
91 "livemode" => Deserialize::begin(&mut self.livemode),
92 "network" => Deserialize::begin(&mut self.network),
93 "network_data" => Deserialize::begin(&mut self.network_data),
94 "network_updated_at" => Deserialize::begin(&mut self.network_updated_at),
95 "status" => Deserialize::begin(&mut self.status),
96 "wallet_provider" => Deserialize::begin(&mut self.wallet_provider),
97 _ => <dyn Visitor>::ignore(),
98 })
99 }
100
101 fn deser_default() -> Self {
102 Self {
103 card: Deserialize::default(),
104 created: Deserialize::default(),
105 device_fingerprint: Deserialize::default(),
106 id: Deserialize::default(),
107 last4: Deserialize::default(),
108 livemode: Deserialize::default(),
109 network: Deserialize::default(),
110 network_data: Deserialize::default(),
111 network_updated_at: Deserialize::default(),
112 status: Deserialize::default(),
113 wallet_provider: Deserialize::default(),
114 }
115 }
116
117 fn take_out(&mut self) -> Option<Self::Out> {
118 let (
119 Some(card),
120 Some(created),
121 Some(device_fingerprint),
122 Some(id),
123 Some(last4),
124 Some(livemode),
125 Some(network),
126 Some(network_data),
127 Some(network_updated_at),
128 Some(status),
129 Some(wallet_provider),
130 ) = (
131 self.card.take(),
132 self.created,
133 self.device_fingerprint.take(),
134 self.id.take(),
135 self.last4.take(),
136 self.livemode,
137 self.network.take(),
138 self.network_data.take(),
139 self.network_updated_at,
140 self.status.take(),
141 self.wallet_provider.take(),
142 )
143 else {
144 return None;
145 };
146 Some(Self::Out {
147 card,
148 created,
149 device_fingerprint,
150 id,
151 last4,
152 livemode,
153 network,
154 network_data,
155 network_updated_at,
156 status,
157 wallet_provider,
158 })
159 }
160 }
161
162 impl Map for Builder<'_> {
163 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
164 self.builder.key(k)
165 }
166
167 fn finish(&mut self) -> Result<()> {
168 *self.out = self.builder.take_out();
169 Ok(())
170 }
171 }
172
173 impl ObjectDeser for IssuingToken {
174 type Builder = IssuingTokenBuilder;
175 }
176
177 impl FromValueOpt for IssuingToken {
178 fn from_value(v: Value) -> Option<Self> {
179 let Value::Object(obj) = v else {
180 return None;
181 };
182 let mut b = IssuingTokenBuilder::deser_default();
183 for (k, v) in obj {
184 match k.as_str() {
185 "card" => b.card = FromValueOpt::from_value(v),
186 "created" => b.created = FromValueOpt::from_value(v),
187 "device_fingerprint" => b.device_fingerprint = FromValueOpt::from_value(v),
188 "id" => b.id = FromValueOpt::from_value(v),
189 "last4" => b.last4 = FromValueOpt::from_value(v),
190 "livemode" => b.livemode = FromValueOpt::from_value(v),
191 "network" => b.network = FromValueOpt::from_value(v),
192 "network_data" => b.network_data = FromValueOpt::from_value(v),
193 "network_updated_at" => b.network_updated_at = FromValueOpt::from_value(v),
194 "status" => b.status = FromValueOpt::from_value(v),
195 "wallet_provider" => b.wallet_provider = FromValueOpt::from_value(v),
196 _ => {}
197 }
198 }
199 b.take_out()
200 }
201 }
202};
203#[cfg(feature = "serialize")]
204impl serde::Serialize for IssuingToken {
205 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
206 use serde::ser::SerializeStruct;
207 let mut s = s.serialize_struct("IssuingToken", 12)?;
208 s.serialize_field("card", &self.card)?;
209 s.serialize_field("created", &self.created)?;
210 s.serialize_field("device_fingerprint", &self.device_fingerprint)?;
211 s.serialize_field("id", &self.id)?;
212 s.serialize_field("last4", &self.last4)?;
213 s.serialize_field("livemode", &self.livemode)?;
214 s.serialize_field("network", &self.network)?;
215 s.serialize_field("network_data", &self.network_data)?;
216 s.serialize_field("network_updated_at", &self.network_updated_at)?;
217 s.serialize_field("status", &self.status)?;
218 s.serialize_field("wallet_provider", &self.wallet_provider)?;
219
220 s.serialize_field("object", "issuing.token")?;
221 s.end()
222 }
223}
224#[derive(Clone, Eq, PartialEq)]
226#[non_exhaustive]
227pub enum IssuingTokenNetwork {
228 Mastercard,
229 Visa,
230 Unknown(String),
232}
233impl IssuingTokenNetwork {
234 pub fn as_str(&self) -> &str {
235 use IssuingTokenNetwork::*;
236 match self {
237 Mastercard => "mastercard",
238 Visa => "visa",
239 Unknown(v) => v,
240 }
241 }
242}
243
244impl std::str::FromStr for IssuingTokenNetwork {
245 type Err = std::convert::Infallible;
246 fn from_str(s: &str) -> Result<Self, Self::Err> {
247 use IssuingTokenNetwork::*;
248 match s {
249 "mastercard" => Ok(Mastercard),
250 "visa" => Ok(Visa),
251 v => {
252 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingTokenNetwork");
253 Ok(Unknown(v.to_owned()))
254 }
255 }
256 }
257}
258impl std::fmt::Display for IssuingTokenNetwork {
259 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
260 f.write_str(self.as_str())
261 }
262}
263
264impl std::fmt::Debug for IssuingTokenNetwork {
265 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
266 f.write_str(self.as_str())
267 }
268}
269#[cfg(feature = "serialize")]
270impl serde::Serialize for IssuingTokenNetwork {
271 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
272 where
273 S: serde::Serializer,
274 {
275 serializer.serialize_str(self.as_str())
276 }
277}
278impl miniserde::Deserialize for IssuingTokenNetwork {
279 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
280 crate::Place::new(out)
281 }
282}
283
284impl miniserde::de::Visitor for crate::Place<IssuingTokenNetwork> {
285 fn string(&mut self, s: &str) -> miniserde::Result<()> {
286 use std::str::FromStr;
287 self.out = Some(IssuingTokenNetwork::from_str(s).expect("infallible"));
288 Ok(())
289 }
290}
291
292stripe_types::impl_from_val_with_from_str!(IssuingTokenNetwork);
293#[cfg(feature = "deserialize")]
294impl<'de> serde::Deserialize<'de> for IssuingTokenNetwork {
295 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
296 use std::str::FromStr;
297 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
298 Ok(Self::from_str(&s).expect("infallible"))
299 }
300}
301#[derive(Clone, Eq, PartialEq)]
303#[non_exhaustive]
304pub enum IssuingTokenWalletProvider {
305 ApplePay,
306 GooglePay,
307 SamsungPay,
308 Unknown(String),
310}
311impl IssuingTokenWalletProvider {
312 pub fn as_str(&self) -> &str {
313 use IssuingTokenWalletProvider::*;
314 match self {
315 ApplePay => "apple_pay",
316 GooglePay => "google_pay",
317 SamsungPay => "samsung_pay",
318 Unknown(v) => v,
319 }
320 }
321}
322
323impl std::str::FromStr for IssuingTokenWalletProvider {
324 type Err = std::convert::Infallible;
325 fn from_str(s: &str) -> Result<Self, Self::Err> {
326 use IssuingTokenWalletProvider::*;
327 match s {
328 "apple_pay" => Ok(ApplePay),
329 "google_pay" => Ok(GooglePay),
330 "samsung_pay" => Ok(SamsungPay),
331 v => {
332 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingTokenWalletProvider");
333 Ok(Unknown(v.to_owned()))
334 }
335 }
336 }
337}
338impl std::fmt::Display for IssuingTokenWalletProvider {
339 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
340 f.write_str(self.as_str())
341 }
342}
343
344impl std::fmt::Debug for IssuingTokenWalletProvider {
345 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
346 f.write_str(self.as_str())
347 }
348}
349#[cfg(feature = "serialize")]
350impl serde::Serialize for IssuingTokenWalletProvider {
351 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
352 where
353 S: serde::Serializer,
354 {
355 serializer.serialize_str(self.as_str())
356 }
357}
358impl miniserde::Deserialize for IssuingTokenWalletProvider {
359 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
360 crate::Place::new(out)
361 }
362}
363
364impl miniserde::de::Visitor for crate::Place<IssuingTokenWalletProvider> {
365 fn string(&mut self, s: &str) -> miniserde::Result<()> {
366 use std::str::FromStr;
367 self.out = Some(IssuingTokenWalletProvider::from_str(s).expect("infallible"));
368 Ok(())
369 }
370}
371
372stripe_types::impl_from_val_with_from_str!(IssuingTokenWalletProvider);
373#[cfg(feature = "deserialize")]
374impl<'de> serde::Deserialize<'de> for IssuingTokenWalletProvider {
375 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
376 use std::str::FromStr;
377 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
378 Ok(Self::from_str(&s).expect("infallible"))
379 }
380}
381impl stripe_types::Object for IssuingToken {
382 type Id = stripe_shared::IssuingTokenId;
383 fn id(&self) -> &Self::Id {
384 &self.id
385 }
386
387 fn into_id(self) -> Self::Id {
388 self.id
389 }
390}
391stripe_types::def_id!(IssuingTokenId);
392#[derive(Clone, Eq, PartialEq)]
393#[non_exhaustive]
394pub enum IssuingTokenStatus {
395 Active,
396 Deleted,
397 Requested,
398 Suspended,
399 Unknown(String),
401}
402impl IssuingTokenStatus {
403 pub fn as_str(&self) -> &str {
404 use IssuingTokenStatus::*;
405 match self {
406 Active => "active",
407 Deleted => "deleted",
408 Requested => "requested",
409 Suspended => "suspended",
410 Unknown(v) => v,
411 }
412 }
413}
414
415impl std::str::FromStr for IssuingTokenStatus {
416 type Err = std::convert::Infallible;
417 fn from_str(s: &str) -> Result<Self, Self::Err> {
418 use IssuingTokenStatus::*;
419 match s {
420 "active" => Ok(Active),
421 "deleted" => Ok(Deleted),
422 "requested" => Ok(Requested),
423 "suspended" => Ok(Suspended),
424 v => {
425 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingTokenStatus");
426 Ok(Unknown(v.to_owned()))
427 }
428 }
429 }
430}
431impl std::fmt::Display for IssuingTokenStatus {
432 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
433 f.write_str(self.as_str())
434 }
435}
436
437impl std::fmt::Debug for IssuingTokenStatus {
438 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
439 f.write_str(self.as_str())
440 }
441}
442impl serde::Serialize for IssuingTokenStatus {
443 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
444 where
445 S: serde::Serializer,
446 {
447 serializer.serialize_str(self.as_str())
448 }
449}
450impl miniserde::Deserialize for IssuingTokenStatus {
451 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
452 crate::Place::new(out)
453 }
454}
455
456impl miniserde::de::Visitor for crate::Place<IssuingTokenStatus> {
457 fn string(&mut self, s: &str) -> miniserde::Result<()> {
458 use std::str::FromStr;
459 self.out = Some(IssuingTokenStatus::from_str(s).expect("infallible"));
460 Ok(())
461 }
462}
463
464stripe_types::impl_from_val_with_from_str!(IssuingTokenStatus);
465#[cfg(feature = "deserialize")]
466impl<'de> serde::Deserialize<'de> for IssuingTokenStatus {
467 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
468 use std::str::FromStr;
469 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
470 Ok(Self::from_str(&s).expect("infallible"))
471 }
472}