stripe_shared/
issuing_dispute_not_received_evidence.rs1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingDisputeNotReceivedEvidence {
5 pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>,
7 pub expected_at: Option<stripe_types::Timestamp>,
9 pub explanation: Option<String>,
11 pub product_description: Option<String>,
13 pub product_type: Option<IssuingDisputeNotReceivedEvidenceProductType>,
15}
16#[doc(hidden)]
17pub struct IssuingDisputeNotReceivedEvidenceBuilder {
18 additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>,
19 expected_at: Option<Option<stripe_types::Timestamp>>,
20 explanation: Option<Option<String>>,
21 product_description: Option<Option<String>>,
22 product_type: Option<Option<IssuingDisputeNotReceivedEvidenceProductType>>,
23}
24
25#[allow(
26 unused_variables,
27 irrefutable_let_patterns,
28 clippy::let_unit_value,
29 clippy::match_single_binding,
30 clippy::single_match
31)]
32const _: () = {
33 use miniserde::de::{Map, Visitor};
34 use miniserde::json::Value;
35 use miniserde::{Deserialize, Result, make_place};
36 use stripe_types::miniserde_helpers::FromValueOpt;
37 use stripe_types::{MapBuilder, ObjectDeser};
38
39 make_place!(Place);
40
41 impl Deserialize for IssuingDisputeNotReceivedEvidence {
42 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
43 Place::new(out)
44 }
45 }
46
47 struct Builder<'a> {
48 out: &'a mut Option<IssuingDisputeNotReceivedEvidence>,
49 builder: IssuingDisputeNotReceivedEvidenceBuilder,
50 }
51
52 impl Visitor for Place<IssuingDisputeNotReceivedEvidence> {
53 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
54 Ok(Box::new(Builder {
55 out: &mut self.out,
56 builder: IssuingDisputeNotReceivedEvidenceBuilder::deser_default(),
57 }))
58 }
59 }
60
61 impl MapBuilder for IssuingDisputeNotReceivedEvidenceBuilder {
62 type Out = IssuingDisputeNotReceivedEvidence;
63 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
64 Ok(match k {
65 "additional_documentation" => {
66 Deserialize::begin(&mut self.additional_documentation)
67 }
68 "expected_at" => Deserialize::begin(&mut self.expected_at),
69 "explanation" => Deserialize::begin(&mut self.explanation),
70 "product_description" => Deserialize::begin(&mut self.product_description),
71 "product_type" => Deserialize::begin(&mut self.product_type),
72 _ => <dyn Visitor>::ignore(),
73 })
74 }
75
76 fn deser_default() -> Self {
77 Self {
78 additional_documentation: Deserialize::default(),
79 expected_at: Deserialize::default(),
80 explanation: Deserialize::default(),
81 product_description: Deserialize::default(),
82 product_type: Deserialize::default(),
83 }
84 }
85
86 fn take_out(&mut self) -> Option<Self::Out> {
87 let (
88 Some(additional_documentation),
89 Some(expected_at),
90 Some(explanation),
91 Some(product_description),
92 Some(product_type),
93 ) = (
94 self.additional_documentation.take(),
95 self.expected_at,
96 self.explanation.take(),
97 self.product_description.take(),
98 self.product_type,
99 )
100 else {
101 return None;
102 };
103 Some(Self::Out {
104 additional_documentation,
105 expected_at,
106 explanation,
107 product_description,
108 product_type,
109 })
110 }
111 }
112
113 impl Map for Builder<'_> {
114 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
115 self.builder.key(k)
116 }
117
118 fn finish(&mut self) -> Result<()> {
119 *self.out = self.builder.take_out();
120 Ok(())
121 }
122 }
123
124 impl ObjectDeser for IssuingDisputeNotReceivedEvidence {
125 type Builder = IssuingDisputeNotReceivedEvidenceBuilder;
126 }
127
128 impl FromValueOpt for IssuingDisputeNotReceivedEvidence {
129 fn from_value(v: Value) -> Option<Self> {
130 let Value::Object(obj) = v else {
131 return None;
132 };
133 let mut b = IssuingDisputeNotReceivedEvidenceBuilder::deser_default();
134 for (k, v) in obj {
135 match k.as_str() {
136 "additional_documentation" => {
137 b.additional_documentation = FromValueOpt::from_value(v)
138 }
139 "expected_at" => b.expected_at = FromValueOpt::from_value(v),
140 "explanation" => b.explanation = FromValueOpt::from_value(v),
141 "product_description" => b.product_description = FromValueOpt::from_value(v),
142 "product_type" => b.product_type = FromValueOpt::from_value(v),
143 _ => {}
144 }
145 }
146 b.take_out()
147 }
148 }
149};
150#[derive(Copy, Clone, Eq, PartialEq)]
152pub enum IssuingDisputeNotReceivedEvidenceProductType {
153 Merchandise,
154 Service,
155}
156impl IssuingDisputeNotReceivedEvidenceProductType {
157 pub fn as_str(self) -> &'static str {
158 use IssuingDisputeNotReceivedEvidenceProductType::*;
159 match self {
160 Merchandise => "merchandise",
161 Service => "service",
162 }
163 }
164}
165
166impl std::str::FromStr for IssuingDisputeNotReceivedEvidenceProductType {
167 type Err = stripe_types::StripeParseError;
168 fn from_str(s: &str) -> Result<Self, Self::Err> {
169 use IssuingDisputeNotReceivedEvidenceProductType::*;
170 match s {
171 "merchandise" => Ok(Merchandise),
172 "service" => Ok(Service),
173 _ => Err(stripe_types::StripeParseError),
174 }
175 }
176}
177impl std::fmt::Display for IssuingDisputeNotReceivedEvidenceProductType {
178 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
179 f.write_str(self.as_str())
180 }
181}
182
183impl std::fmt::Debug for IssuingDisputeNotReceivedEvidenceProductType {
184 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
185 f.write_str(self.as_str())
186 }
187}
188#[cfg(feature = "serialize")]
189impl serde::Serialize for IssuingDisputeNotReceivedEvidenceProductType {
190 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
191 where
192 S: serde::Serializer,
193 {
194 serializer.serialize_str(self.as_str())
195 }
196}
197impl miniserde::Deserialize for IssuingDisputeNotReceivedEvidenceProductType {
198 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
199 crate::Place::new(out)
200 }
201}
202
203impl miniserde::de::Visitor for crate::Place<IssuingDisputeNotReceivedEvidenceProductType> {
204 fn string(&mut self, s: &str) -> miniserde::Result<()> {
205 use std::str::FromStr;
206 self.out = Some(
207 IssuingDisputeNotReceivedEvidenceProductType::from_str(s)
208 .map_err(|_| miniserde::Error)?,
209 );
210 Ok(())
211 }
212}
213
214stripe_types::impl_from_val_with_from_str!(IssuingDisputeNotReceivedEvidenceProductType);
215#[cfg(feature = "deserialize")]
216impl<'de> serde::Deserialize<'de> for IssuingDisputeNotReceivedEvidenceProductType {
217 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
218 use std::str::FromStr;
219 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
220 Self::from_str(&s).map_err(|_| {
221 serde::de::Error::custom(
222 "Unknown value for IssuingDisputeNotReceivedEvidenceProductType",
223 )
224 })
225 }
226}