stripe_shared/
payment_method_details_wechat_pay.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodDetailsWechatPay {
5    /// Uniquely identifies this particular WeChat Pay account.
6    /// You can use this attribute to check whether two WeChat accounts are the same.
7    pub fingerprint: Option<String>,
8    /// ID of the [location](https://stripe.com/docs/api/terminal/locations) that this transaction's reader is assigned to.
9    pub location: Option<String>,
10    /// ID of the [reader](https://stripe.com/docs/api/terminal/readers) this transaction was made on.
11    pub reader: Option<String>,
12    /// Transaction ID of this particular WeChat Pay transaction.
13    pub transaction_id: Option<String>,
14}
15#[doc(hidden)]
16pub struct PaymentMethodDetailsWechatPayBuilder {
17    fingerprint: Option<Option<String>>,
18    location: Option<Option<String>>,
19    reader: Option<Option<String>>,
20    transaction_id: Option<Option<String>>,
21}
22
23#[allow(
24    unused_variables,
25    irrefutable_let_patterns,
26    clippy::let_unit_value,
27    clippy::match_single_binding,
28    clippy::single_match
29)]
30const _: () = {
31    use miniserde::de::{Map, Visitor};
32    use miniserde::json::Value;
33    use miniserde::{make_place, Deserialize, Result};
34    use stripe_types::miniserde_helpers::FromValueOpt;
35    use stripe_types::{MapBuilder, ObjectDeser};
36
37    make_place!(Place);
38
39    impl Deserialize for PaymentMethodDetailsWechatPay {
40        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
41            Place::new(out)
42        }
43    }
44
45    struct Builder<'a> {
46        out: &'a mut Option<PaymentMethodDetailsWechatPay>,
47        builder: PaymentMethodDetailsWechatPayBuilder,
48    }
49
50    impl Visitor for Place<PaymentMethodDetailsWechatPay> {
51        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
52            Ok(Box::new(Builder {
53                out: &mut self.out,
54                builder: PaymentMethodDetailsWechatPayBuilder::deser_default(),
55            }))
56        }
57    }
58
59    impl MapBuilder for PaymentMethodDetailsWechatPayBuilder {
60        type Out = PaymentMethodDetailsWechatPay;
61        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
62            Ok(match k {
63                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
64                "location" => Deserialize::begin(&mut self.location),
65                "reader" => Deserialize::begin(&mut self.reader),
66                "transaction_id" => Deserialize::begin(&mut self.transaction_id),
67
68                _ => <dyn Visitor>::ignore(),
69            })
70        }
71
72        fn deser_default() -> Self {
73            Self {
74                fingerprint: Deserialize::default(),
75                location: Deserialize::default(),
76                reader: Deserialize::default(),
77                transaction_id: Deserialize::default(),
78            }
79        }
80
81        fn take_out(&mut self) -> Option<Self::Out> {
82            let (Some(fingerprint), Some(location), Some(reader), Some(transaction_id)) = (
83                self.fingerprint.take(),
84                self.location.take(),
85                self.reader.take(),
86                self.transaction_id.take(),
87            ) else {
88                return None;
89            };
90            Some(Self::Out { fingerprint, location, reader, transaction_id })
91        }
92    }
93
94    impl Map for Builder<'_> {
95        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
96            self.builder.key(k)
97        }
98
99        fn finish(&mut self) -> Result<()> {
100            *self.out = self.builder.take_out();
101            Ok(())
102        }
103    }
104
105    impl ObjectDeser for PaymentMethodDetailsWechatPay {
106        type Builder = PaymentMethodDetailsWechatPayBuilder;
107    }
108
109    impl FromValueOpt for PaymentMethodDetailsWechatPay {
110        fn from_value(v: Value) -> Option<Self> {
111            let Value::Object(obj) = v else {
112                return None;
113            };
114            let mut b = PaymentMethodDetailsWechatPayBuilder::deser_default();
115            for (k, v) in obj {
116                match k.as_str() {
117                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
118                    "location" => b.location = FromValueOpt::from_value(v),
119                    "reader" => b.reader = FromValueOpt::from_value(v),
120                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
121
122                    _ => {}
123                }
124            }
125            b.take_out()
126        }
127    }
128};