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
73 _ => <dyn Visitor>::ignore(),
74 })
75 }
76
77 fn deser_default() -> Self {
78 Self {
79 additional_documentation: Deserialize::default(),
80 expected_at: Deserialize::default(),
81 explanation: Deserialize::default(),
82 product_description: Deserialize::default(),
83 product_type: Deserialize::default(),
84 }
85 }
86
87 fn take_out(&mut self) -> Option<Self::Out> {
88 let (
89 Some(additional_documentation),
90 Some(expected_at),
91 Some(explanation),
92 Some(product_description),
93 Some(product_type),
94 ) = (
95 self.additional_documentation.take(),
96 self.expected_at,
97 self.explanation.take(),
98 self.product_description.take(),
99 self.product_type,
100 )
101 else {
102 return None;
103 };
104 Some(Self::Out {
105 additional_documentation,
106 expected_at,
107 explanation,
108 product_description,
109 product_type,
110 })
111 }
112 }
113
114 impl Map for Builder<'_> {
115 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
116 self.builder.key(k)
117 }
118
119 fn finish(&mut self) -> Result<()> {
120 *self.out = self.builder.take_out();
121 Ok(())
122 }
123 }
124
125 impl ObjectDeser for IssuingDisputeNotReceivedEvidence {
126 type Builder = IssuingDisputeNotReceivedEvidenceBuilder;
127 }
128
129 impl FromValueOpt for IssuingDisputeNotReceivedEvidence {
130 fn from_value(v: Value) -> Option<Self> {
131 let Value::Object(obj) = v else {
132 return None;
133 };
134 let mut b = IssuingDisputeNotReceivedEvidenceBuilder::deser_default();
135 for (k, v) in obj {
136 match k.as_str() {
137 "additional_documentation" => {
138 b.additional_documentation = FromValueOpt::from_value(v)
139 }
140 "expected_at" => b.expected_at = FromValueOpt::from_value(v),
141 "explanation" => b.explanation = FromValueOpt::from_value(v),
142 "product_description" => b.product_description = FromValueOpt::from_value(v),
143 "product_type" => b.product_type = FromValueOpt::from_value(v),
144
145 _ => {}
146 }
147 }
148 b.take_out()
149 }
150 }
151};
152#[derive(Copy, Clone, Eq, PartialEq)]
154pub enum IssuingDisputeNotReceivedEvidenceProductType {
155 Merchandise,
156 Service,
157}
158impl IssuingDisputeNotReceivedEvidenceProductType {
159 pub fn as_str(self) -> &'static str {
160 use IssuingDisputeNotReceivedEvidenceProductType::*;
161 match self {
162 Merchandise => "merchandise",
163 Service => "service",
164 }
165 }
166}
167
168impl std::str::FromStr for IssuingDisputeNotReceivedEvidenceProductType {
169 type Err = stripe_types::StripeParseError;
170 fn from_str(s: &str) -> Result<Self, Self::Err> {
171 use IssuingDisputeNotReceivedEvidenceProductType::*;
172 match s {
173 "merchandise" => Ok(Merchandise),
174 "service" => Ok(Service),
175 _ => Err(stripe_types::StripeParseError),
176 }
177 }
178}
179impl std::fmt::Display for IssuingDisputeNotReceivedEvidenceProductType {
180 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
181 f.write_str(self.as_str())
182 }
183}
184
185impl std::fmt::Debug for IssuingDisputeNotReceivedEvidenceProductType {
186 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
187 f.write_str(self.as_str())
188 }
189}
190#[cfg(feature = "serialize")]
191impl serde::Serialize for IssuingDisputeNotReceivedEvidenceProductType {
192 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
193 where
194 S: serde::Serializer,
195 {
196 serializer.serialize_str(self.as_str())
197 }
198}
199impl miniserde::Deserialize for IssuingDisputeNotReceivedEvidenceProductType {
200 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
201 crate::Place::new(out)
202 }
203}
204
205impl miniserde::de::Visitor for crate::Place<IssuingDisputeNotReceivedEvidenceProductType> {
206 fn string(&mut self, s: &str) -> miniserde::Result<()> {
207 use std::str::FromStr;
208 self.out = Some(
209 IssuingDisputeNotReceivedEvidenceProductType::from_str(s)
210 .map_err(|_| miniserde::Error)?,
211 );
212 Ok(())
213 }
214}
215
216stripe_types::impl_from_val_with_from_str!(IssuingDisputeNotReceivedEvidenceProductType);
217#[cfg(feature = "deserialize")]
218impl<'de> serde::Deserialize<'de> for IssuingDisputeNotReceivedEvidenceProductType {
219 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
220 use std::str::FromStr;
221 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
222 Self::from_str(&s).map_err(|_| {
223 serde::de::Error::custom(
224 "Unknown value for IssuingDisputeNotReceivedEvidenceProductType",
225 )
226 })
227 }
228}