stripe_shared/
dispute_visa_compelling_evidence3_disputed_transaction.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct DisputeVisaCompellingEvidence3DisputedTransaction {
5    /// User Account ID used to log into business platform. Must be recognizable by the user.
6    pub customer_account_id: Option<String>,
7    /// Unique identifier of the cardholder’s device derived from a combination of at least two hardware and software attributes.
8    /// Must be at least 20 characters.
9    pub customer_device_fingerprint: Option<String>,
10    /// Unique identifier of the cardholder’s device such as a device serial number (e.g., International Mobile Equipment Identity [IMEI]).
11    /// Must be at least 15 characters.
12    pub customer_device_id: Option<String>,
13    /// The email address of the customer.
14    pub customer_email_address: Option<String>,
15    /// The IP address that the customer used when making the purchase.
16    pub customer_purchase_ip: Option<String>,
17    /// Categorization of disputed payment.
18    pub merchandise_or_services:
19        Option<DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices>,
20    /// A description of the product or service that was sold.
21    pub product_description: Option<String>,
22    /// The address to which a physical product was shipped.
23    /// All fields are required for Visa Compelling Evidence 3.0 evidence submission.
24    pub shipping_address: Option<stripe_shared::DisputeTransactionShippingAddress>,
25}
26#[doc(hidden)]
27pub struct DisputeVisaCompellingEvidence3DisputedTransactionBuilder {
28    customer_account_id: Option<Option<String>>,
29    customer_device_fingerprint: Option<Option<String>>,
30    customer_device_id: Option<Option<String>>,
31    customer_email_address: Option<Option<String>>,
32    customer_purchase_ip: Option<Option<String>>,
33    merchandise_or_services:
34        Option<Option<DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices>>,
35    product_description: Option<Option<String>>,
36    shipping_address: Option<Option<stripe_shared::DisputeTransactionShippingAddress>>,
37}
38
39#[allow(
40    unused_variables,
41    irrefutable_let_patterns,
42    clippy::let_unit_value,
43    clippy::match_single_binding,
44    clippy::single_match
45)]
46const _: () = {
47    use miniserde::de::{Map, Visitor};
48    use miniserde::json::Value;
49    use miniserde::{Deserialize, Result, make_place};
50    use stripe_types::miniserde_helpers::FromValueOpt;
51    use stripe_types::{MapBuilder, ObjectDeser};
52
53    make_place!(Place);
54
55    impl Deserialize for DisputeVisaCompellingEvidence3DisputedTransaction {
56        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
57            Place::new(out)
58        }
59    }
60
61    struct Builder<'a> {
62        out: &'a mut Option<DisputeVisaCompellingEvidence3DisputedTransaction>,
63        builder: DisputeVisaCompellingEvidence3DisputedTransactionBuilder,
64    }
65
66    impl Visitor for Place<DisputeVisaCompellingEvidence3DisputedTransaction> {
67        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
68            Ok(Box::new(Builder {
69                out: &mut self.out,
70                builder: DisputeVisaCompellingEvidence3DisputedTransactionBuilder::deser_default(),
71            }))
72        }
73    }
74
75    impl MapBuilder for DisputeVisaCompellingEvidence3DisputedTransactionBuilder {
76        type Out = DisputeVisaCompellingEvidence3DisputedTransaction;
77        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
78            Ok(match k {
79                "customer_account_id" => Deserialize::begin(&mut self.customer_account_id),
80                "customer_device_fingerprint" => {
81                    Deserialize::begin(&mut self.customer_device_fingerprint)
82                }
83                "customer_device_id" => Deserialize::begin(&mut self.customer_device_id),
84                "customer_email_address" => Deserialize::begin(&mut self.customer_email_address),
85                "customer_purchase_ip" => Deserialize::begin(&mut self.customer_purchase_ip),
86                "merchandise_or_services" => Deserialize::begin(&mut self.merchandise_or_services),
87                "product_description" => Deserialize::begin(&mut self.product_description),
88                "shipping_address" => Deserialize::begin(&mut self.shipping_address),
89                _ => <dyn Visitor>::ignore(),
90            })
91        }
92
93        fn deser_default() -> Self {
94            Self {
95                customer_account_id: Deserialize::default(),
96                customer_device_fingerprint: Deserialize::default(),
97                customer_device_id: Deserialize::default(),
98                customer_email_address: Deserialize::default(),
99                customer_purchase_ip: Deserialize::default(),
100                merchandise_or_services: Deserialize::default(),
101                product_description: Deserialize::default(),
102                shipping_address: Deserialize::default(),
103            }
104        }
105
106        fn take_out(&mut self) -> Option<Self::Out> {
107            let (
108                Some(customer_account_id),
109                Some(customer_device_fingerprint),
110                Some(customer_device_id),
111                Some(customer_email_address),
112                Some(customer_purchase_ip),
113                Some(merchandise_or_services),
114                Some(product_description),
115                Some(shipping_address),
116            ) = (
117                self.customer_account_id.take(),
118                self.customer_device_fingerprint.take(),
119                self.customer_device_id.take(),
120                self.customer_email_address.take(),
121                self.customer_purchase_ip.take(),
122                self.merchandise_or_services.take(),
123                self.product_description.take(),
124                self.shipping_address.take(),
125            )
126            else {
127                return None;
128            };
129            Some(Self::Out {
130                customer_account_id,
131                customer_device_fingerprint,
132                customer_device_id,
133                customer_email_address,
134                customer_purchase_ip,
135                merchandise_or_services,
136                product_description,
137                shipping_address,
138            })
139        }
140    }
141
142    impl Map for Builder<'_> {
143        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
144            self.builder.key(k)
145        }
146
147        fn finish(&mut self) -> Result<()> {
148            *self.out = self.builder.take_out();
149            Ok(())
150        }
151    }
152
153    impl ObjectDeser for DisputeVisaCompellingEvidence3DisputedTransaction {
154        type Builder = DisputeVisaCompellingEvidence3DisputedTransactionBuilder;
155    }
156
157    impl FromValueOpt for DisputeVisaCompellingEvidence3DisputedTransaction {
158        fn from_value(v: Value) -> Option<Self> {
159            let Value::Object(obj) = v else {
160                return None;
161            };
162            let mut b = DisputeVisaCompellingEvidence3DisputedTransactionBuilder::deser_default();
163            for (k, v) in obj {
164                match k.as_str() {
165                    "customer_account_id" => b.customer_account_id = FromValueOpt::from_value(v),
166                    "customer_device_fingerprint" => {
167                        b.customer_device_fingerprint = FromValueOpt::from_value(v)
168                    }
169                    "customer_device_id" => b.customer_device_id = FromValueOpt::from_value(v),
170                    "customer_email_address" => {
171                        b.customer_email_address = FromValueOpt::from_value(v)
172                    }
173                    "customer_purchase_ip" => b.customer_purchase_ip = FromValueOpt::from_value(v),
174                    "merchandise_or_services" => {
175                        b.merchandise_or_services = FromValueOpt::from_value(v)
176                    }
177                    "product_description" => b.product_description = FromValueOpt::from_value(v),
178                    "shipping_address" => b.shipping_address = FromValueOpt::from_value(v),
179                    _ => {}
180                }
181            }
182            b.take_out()
183        }
184    }
185};
186/// Categorization of disputed payment.
187#[derive(Clone, Eq, PartialEq)]
188#[non_exhaustive]
189pub enum DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices {
190    Merchandise,
191    Services,
192    /// An unrecognized value from Stripe. Should not be used as a request parameter.
193    Unknown(String),
194}
195impl DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices {
196    pub fn as_str(&self) -> &str {
197        use DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices::*;
198        match self {
199            Merchandise => "merchandise",
200            Services => "services",
201            Unknown(v) => v,
202        }
203    }
204}
205
206impl std::str::FromStr for DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices {
207    type Err = std::convert::Infallible;
208    fn from_str(s: &str) -> Result<Self, Self::Err> {
209        use DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices::*;
210        match s {
211            "merchandise" => Ok(Merchandise),
212            "services" => Ok(Services),
213            v => {
214                tracing::warn!(
215                    "Unknown value '{}' for enum '{}'",
216                    v,
217                    "DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices"
218                );
219                Ok(Unknown(v.to_owned()))
220            }
221        }
222    }
223}
224impl std::fmt::Display for DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices {
225    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
226        f.write_str(self.as_str())
227    }
228}
229
230impl std::fmt::Debug for DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices {
231    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
232        f.write_str(self.as_str())
233    }
234}
235#[cfg(feature = "serialize")]
236impl serde::Serialize for DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices {
237    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
238    where
239        S: serde::Serializer,
240    {
241        serializer.serialize_str(self.as_str())
242    }
243}
244impl miniserde::Deserialize
245    for DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices
246{
247    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
248        crate::Place::new(out)
249    }
250}
251
252impl miniserde::de::Visitor
253    for crate::Place<DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices>
254{
255    fn string(&mut self, s: &str) -> miniserde::Result<()> {
256        use std::str::FromStr;
257        self.out = Some(
258            DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices::from_str(s)
259                .expect("infallible"),
260        );
261        Ok(())
262    }
263}
264
265stripe_types::impl_from_val_with_from_str!(
266    DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices
267);
268#[cfg(feature = "deserialize")]
269impl<'de> serde::Deserialize<'de>
270    for DisputeVisaCompellingEvidence3DisputedTransactionMerchandiseOrServices
271{
272    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
273        use std::str::FromStr;
274        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
275        Ok(Self::from_str(&s).expect("infallible"))
276    }
277}