Skip to main content

stripe_shared/
payment_method_details_payment_record_alma.rs

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 PaymentMethodDetailsPaymentRecordAlma {
6pub installments: Option<stripe_shared::PaymentsPrimitivesPaymentRecordsResourcePaymentMethodAlmaDetailsResourceInstallments>,
7    /// The Alma transaction ID associated with this payment.
8pub transaction_id: Option<String>,
9
10}
11#[cfg(feature = "redact-generated-debug")]
12impl std::fmt::Debug for PaymentMethodDetailsPaymentRecordAlma {
13    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
14        f.debug_struct("PaymentMethodDetailsPaymentRecordAlma").finish_non_exhaustive()
15    }
16}
17#[doc(hidden)]
18pub struct PaymentMethodDetailsPaymentRecordAlmaBuilder {
19    installments: Option<Option<stripe_shared::PaymentsPrimitivesPaymentRecordsResourcePaymentMethodAlmaDetailsResourceInstallments>>,
20transaction_id: Option<Option<String>>,
21
22}
23
24#[allow(
25    unused_variables,
26    irrefutable_let_patterns,
27    clippy::let_unit_value,
28    clippy::match_single_binding,
29    clippy::single_match
30)]
31const _: () = {
32    use miniserde::de::{Map, Visitor};
33    use miniserde::json::Value;
34    use miniserde::{Deserialize, Result, make_place};
35    use stripe_types::miniserde_helpers::FromValueOpt;
36    use stripe_types::{MapBuilder, ObjectDeser};
37
38    make_place!(Place);
39
40    impl Deserialize for PaymentMethodDetailsPaymentRecordAlma {
41        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
42            Place::new(out)
43        }
44    }
45
46    struct Builder<'a> {
47        out: &'a mut Option<PaymentMethodDetailsPaymentRecordAlma>,
48        builder: PaymentMethodDetailsPaymentRecordAlmaBuilder,
49    }
50
51    impl Visitor for Place<PaymentMethodDetailsPaymentRecordAlma> {
52        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
53            Ok(Box::new(Builder {
54                out: &mut self.out,
55                builder: PaymentMethodDetailsPaymentRecordAlmaBuilder::deser_default(),
56            }))
57        }
58    }
59
60    impl MapBuilder for PaymentMethodDetailsPaymentRecordAlmaBuilder {
61        type Out = PaymentMethodDetailsPaymentRecordAlma;
62        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
63            Ok(match k {
64                "installments" => Deserialize::begin(&mut self.installments),
65                "transaction_id" => Deserialize::begin(&mut self.transaction_id),
66                _ => <dyn Visitor>::ignore(),
67            })
68        }
69
70        fn deser_default() -> Self {
71            Self { installments: Some(None), transaction_id: Some(None) }
72        }
73
74        fn take_out(&mut self) -> Option<Self::Out> {
75            let (Some(installments), Some(transaction_id)) =
76                (self.installments, self.transaction_id.take())
77            else {
78                return None;
79            };
80            Some(Self::Out { installments, transaction_id })
81        }
82    }
83
84    impl Map for Builder<'_> {
85        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
86            self.builder.key(k)
87        }
88
89        fn finish(&mut self) -> Result<()> {
90            *self.out = self.builder.take_out();
91            Ok(())
92        }
93    }
94
95    impl ObjectDeser for PaymentMethodDetailsPaymentRecordAlma {
96        type Builder = PaymentMethodDetailsPaymentRecordAlmaBuilder;
97    }
98
99    impl FromValueOpt for PaymentMethodDetailsPaymentRecordAlma {
100        fn from_value(v: Value) -> Option<Self> {
101            let Value::Object(obj) = v else {
102                return None;
103            };
104            let mut b = PaymentMethodDetailsPaymentRecordAlmaBuilder::deser_default();
105            for (k, v) in obj {
106                match k.as_str() {
107                    "installments" => b.installments = FromValueOpt::from_value(v),
108                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
109                    _ => {}
110                }
111            }
112            b.take_out()
113        }
114    }
115};