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    /// Transaction ID of this particular WeChat Pay transaction.
9    pub transaction_id: Option<String>,
10}
11#[doc(hidden)]
12pub struct PaymentMethodDetailsWechatPayBuilder {
13    fingerprint: Option<Option<String>>,
14    transaction_id: 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::{make_place, Deserialize, Result};
28    use stripe_types::miniserde_helpers::FromValueOpt;
29    use stripe_types::{MapBuilder, ObjectDeser};
30
31    make_place!(Place);
32
33    impl Deserialize for PaymentMethodDetailsWechatPay {
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<PaymentMethodDetailsWechatPay>,
41        builder: PaymentMethodDetailsWechatPayBuilder,
42    }
43
44    impl Visitor for Place<PaymentMethodDetailsWechatPay> {
45        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
46            Ok(Box::new(Builder {
47                out: &mut self.out,
48                builder: PaymentMethodDetailsWechatPayBuilder::deser_default(),
49            }))
50        }
51    }
52
53    impl MapBuilder for PaymentMethodDetailsWechatPayBuilder {
54        type Out = PaymentMethodDetailsWechatPay;
55        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56            Ok(match k {
57                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
58                "transaction_id" => Deserialize::begin(&mut self.transaction_id),
59
60                _ => <dyn Visitor>::ignore(),
61            })
62        }
63
64        fn deser_default() -> Self {
65            Self { fingerprint: Deserialize::default(), transaction_id: Deserialize::default() }
66        }
67
68        fn take_out(&mut self) -> Option<Self::Out> {
69            let (Some(fingerprint), Some(transaction_id)) =
70                (self.fingerprint.take(), self.transaction_id.take())
71            else {
72                return None;
73            };
74            Some(Self::Out { fingerprint, transaction_id })
75        }
76    }
77
78    impl<'a> Map for Builder<'a> {
79        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
80            self.builder.key(k)
81        }
82
83        fn finish(&mut self) -> Result<()> {
84            *self.out = self.builder.take_out();
85            Ok(())
86        }
87    }
88
89    impl ObjectDeser for PaymentMethodDetailsWechatPay {
90        type Builder = PaymentMethodDetailsWechatPayBuilder;
91    }
92
93    impl FromValueOpt for PaymentMethodDetailsWechatPay {
94        fn from_value(v: Value) -> Option<Self> {
95            let Value::Object(obj) = v else {
96                return None;
97            };
98            let mut b = PaymentMethodDetailsWechatPayBuilder::deser_default();
99            for (k, v) in obj {
100                match k.as_str() {
101                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
102                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
103
104                    _ => {}
105                }
106            }
107            b.take_out()
108        }
109    }
110};