stripe_shared/
payment_method_details_cashapp.rs

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