stripe_shared/
dispute_enhanced_evidence_visa_compelling_evidence3.rs

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