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