stripe_shared/
payment_method_details_samsung_pay.rs

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