stripe_shared/
dispute_payment_method_details_paypal.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct DisputePaymentMethodDetailsPaypal {
5    /// The ID of the dispute in PayPal.
6    pub case_id: Option<String>,
7    /// The reason for the dispute as defined by PayPal
8    pub reason_code: Option<String>,
9}
10#[doc(hidden)]
11pub struct DisputePaymentMethodDetailsPaypalBuilder {
12    case_id: Option<Option<String>>,
13    reason_code: 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 DisputePaymentMethodDetailsPaypal {
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<DisputePaymentMethodDetailsPaypal>,
40        builder: DisputePaymentMethodDetailsPaypalBuilder,
41    }
42
43    impl Visitor for Place<DisputePaymentMethodDetailsPaypal> {
44        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
45            Ok(Box::new(Builder {
46                out: &mut self.out,
47                builder: DisputePaymentMethodDetailsPaypalBuilder::deser_default(),
48            }))
49        }
50    }
51
52    impl MapBuilder for DisputePaymentMethodDetailsPaypalBuilder {
53        type Out = DisputePaymentMethodDetailsPaypal;
54        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
55            Ok(match k {
56                "case_id" => Deserialize::begin(&mut self.case_id),
57                "reason_code" => Deserialize::begin(&mut self.reason_code),
58                _ => <dyn Visitor>::ignore(),
59            })
60        }
61
62        fn deser_default() -> Self {
63            Self { case_id: Deserialize::default(), reason_code: Deserialize::default() }
64        }
65
66        fn take_out(&mut self) -> Option<Self::Out> {
67            let (Some(case_id), Some(reason_code)) = (self.case_id.take(), self.reason_code.take())
68            else {
69                return None;
70            };
71            Some(Self::Out { case_id, reason_code })
72        }
73    }
74
75    impl Map for Builder<'_> {
76        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
77            self.builder.key(k)
78        }
79
80        fn finish(&mut self) -> Result<()> {
81            *self.out = self.builder.take_out();
82            Ok(())
83        }
84    }
85
86    impl ObjectDeser for DisputePaymentMethodDetailsPaypal {
87        type Builder = DisputePaymentMethodDetailsPaypalBuilder;
88    }
89
90    impl FromValueOpt for DisputePaymentMethodDetailsPaypal {
91        fn from_value(v: Value) -> Option<Self> {
92            let Value::Object(obj) = v else {
93                return None;
94            };
95            let mut b = DisputePaymentMethodDetailsPaypalBuilder::deser_default();
96            for (k, v) in obj {
97                match k.as_str() {
98                    "case_id" => b.case_id = FromValueOpt::from_value(v),
99                    "reason_code" => b.reason_code = FromValueOpt::from_value(v),
100                    _ => {}
101                }
102            }
103            b.take_out()
104        }
105    }
106};