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