1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingCardShippingAddressValidation {
5 pub mode: IssuingCardShippingAddressValidationMode,
7 pub normalized_address: Option<stripe_shared::Address>,
9 pub result: Option<IssuingCardShippingAddressValidationResult>,
11}
12#[doc(hidden)]
13pub struct IssuingCardShippingAddressValidationBuilder {
14 mode: Option<IssuingCardShippingAddressValidationMode>,
15 normalized_address: Option<Option<stripe_shared::Address>>,
16 result: Option<Option<IssuingCardShippingAddressValidationResult>>,
17}
18
19#[allow(
20 unused_variables,
21 irrefutable_let_patterns,
22 clippy::let_unit_value,
23 clippy::match_single_binding,
24 clippy::single_match
25)]
26const _: () = {
27 use miniserde::de::{Map, Visitor};
28 use miniserde::json::Value;
29 use miniserde::{Deserialize, Result, make_place};
30 use stripe_types::miniserde_helpers::FromValueOpt;
31 use stripe_types::{MapBuilder, ObjectDeser};
32
33 make_place!(Place);
34
35 impl Deserialize for IssuingCardShippingAddressValidation {
36 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
37 Place::new(out)
38 }
39 }
40
41 struct Builder<'a> {
42 out: &'a mut Option<IssuingCardShippingAddressValidation>,
43 builder: IssuingCardShippingAddressValidationBuilder,
44 }
45
46 impl Visitor for Place<IssuingCardShippingAddressValidation> {
47 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
48 Ok(Box::new(Builder {
49 out: &mut self.out,
50 builder: IssuingCardShippingAddressValidationBuilder::deser_default(),
51 }))
52 }
53 }
54
55 impl MapBuilder for IssuingCardShippingAddressValidationBuilder {
56 type Out = IssuingCardShippingAddressValidation;
57 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
58 Ok(match k {
59 "mode" => Deserialize::begin(&mut self.mode),
60 "normalized_address" => Deserialize::begin(&mut self.normalized_address),
61 "result" => Deserialize::begin(&mut self.result),
62 _ => <dyn Visitor>::ignore(),
63 })
64 }
65
66 fn deser_default() -> Self {
67 Self {
68 mode: Deserialize::default(),
69 normalized_address: Deserialize::default(),
70 result: Deserialize::default(),
71 }
72 }
73
74 fn take_out(&mut self) -> Option<Self::Out> {
75 let (Some(mode), Some(normalized_address), Some(result)) =
76 (self.mode.take(), self.normalized_address.take(), self.result.take())
77 else {
78 return None;
79 };
80 Some(Self::Out { mode, normalized_address, result })
81 }
82 }
83
84 impl Map for Builder<'_> {
85 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
86 self.builder.key(k)
87 }
88
89 fn finish(&mut self) -> Result<()> {
90 *self.out = self.builder.take_out();
91 Ok(())
92 }
93 }
94
95 impl ObjectDeser for IssuingCardShippingAddressValidation {
96 type Builder = IssuingCardShippingAddressValidationBuilder;
97 }
98
99 impl FromValueOpt for IssuingCardShippingAddressValidation {
100 fn from_value(v: Value) -> Option<Self> {
101 let Value::Object(obj) = v else {
102 return None;
103 };
104 let mut b = IssuingCardShippingAddressValidationBuilder::deser_default();
105 for (k, v) in obj {
106 match k.as_str() {
107 "mode" => b.mode = FromValueOpt::from_value(v),
108 "normalized_address" => b.normalized_address = FromValueOpt::from_value(v),
109 "result" => b.result = FromValueOpt::from_value(v),
110 _ => {}
111 }
112 }
113 b.take_out()
114 }
115 }
116};
117#[derive(Clone, Eq, PartialEq)]
119#[non_exhaustive]
120pub enum IssuingCardShippingAddressValidationMode {
121 Disabled,
122 NormalizationOnly,
123 ValidationAndNormalization,
124 Unknown(String),
126}
127impl IssuingCardShippingAddressValidationMode {
128 pub fn as_str(&self) -> &str {
129 use IssuingCardShippingAddressValidationMode::*;
130 match self {
131 Disabled => "disabled",
132 NormalizationOnly => "normalization_only",
133 ValidationAndNormalization => "validation_and_normalization",
134 Unknown(v) => v,
135 }
136 }
137}
138
139impl std::str::FromStr for IssuingCardShippingAddressValidationMode {
140 type Err = std::convert::Infallible;
141 fn from_str(s: &str) -> Result<Self, Self::Err> {
142 use IssuingCardShippingAddressValidationMode::*;
143 match s {
144 "disabled" => Ok(Disabled),
145 "normalization_only" => Ok(NormalizationOnly),
146 "validation_and_normalization" => Ok(ValidationAndNormalization),
147 v => {
148 tracing::warn!(
149 "Unknown value '{}' for enum '{}'",
150 v,
151 "IssuingCardShippingAddressValidationMode"
152 );
153 Ok(Unknown(v.to_owned()))
154 }
155 }
156 }
157}
158impl std::fmt::Display for IssuingCardShippingAddressValidationMode {
159 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
160 f.write_str(self.as_str())
161 }
162}
163
164impl std::fmt::Debug for IssuingCardShippingAddressValidationMode {
165 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
166 f.write_str(self.as_str())
167 }
168}
169#[cfg(feature = "serialize")]
170impl serde::Serialize for IssuingCardShippingAddressValidationMode {
171 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
172 where
173 S: serde::Serializer,
174 {
175 serializer.serialize_str(self.as_str())
176 }
177}
178impl miniserde::Deserialize for IssuingCardShippingAddressValidationMode {
179 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
180 crate::Place::new(out)
181 }
182}
183
184impl miniserde::de::Visitor for crate::Place<IssuingCardShippingAddressValidationMode> {
185 fn string(&mut self, s: &str) -> miniserde::Result<()> {
186 use std::str::FromStr;
187 self.out = Some(IssuingCardShippingAddressValidationMode::from_str(s).expect("infallible"));
188 Ok(())
189 }
190}
191
192stripe_types::impl_from_val_with_from_str!(IssuingCardShippingAddressValidationMode);
193#[cfg(feature = "deserialize")]
194impl<'de> serde::Deserialize<'de> for IssuingCardShippingAddressValidationMode {
195 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
196 use std::str::FromStr;
197 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
198 Ok(Self::from_str(&s).expect("infallible"))
199 }
200}
201#[derive(Clone, Eq, PartialEq)]
203#[non_exhaustive]
204pub enum IssuingCardShippingAddressValidationResult {
205 Indeterminate,
206 LikelyDeliverable,
207 LikelyUndeliverable,
208 Unknown(String),
210}
211impl IssuingCardShippingAddressValidationResult {
212 pub fn as_str(&self) -> &str {
213 use IssuingCardShippingAddressValidationResult::*;
214 match self {
215 Indeterminate => "indeterminate",
216 LikelyDeliverable => "likely_deliverable",
217 LikelyUndeliverable => "likely_undeliverable",
218 Unknown(v) => v,
219 }
220 }
221}
222
223impl std::str::FromStr for IssuingCardShippingAddressValidationResult {
224 type Err = std::convert::Infallible;
225 fn from_str(s: &str) -> Result<Self, Self::Err> {
226 use IssuingCardShippingAddressValidationResult::*;
227 match s {
228 "indeterminate" => Ok(Indeterminate),
229 "likely_deliverable" => Ok(LikelyDeliverable),
230 "likely_undeliverable" => Ok(LikelyUndeliverable),
231 v => {
232 tracing::warn!(
233 "Unknown value '{}' for enum '{}'",
234 v,
235 "IssuingCardShippingAddressValidationResult"
236 );
237 Ok(Unknown(v.to_owned()))
238 }
239 }
240 }
241}
242impl std::fmt::Display for IssuingCardShippingAddressValidationResult {
243 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
244 f.write_str(self.as_str())
245 }
246}
247
248impl std::fmt::Debug for IssuingCardShippingAddressValidationResult {
249 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
250 f.write_str(self.as_str())
251 }
252}
253#[cfg(feature = "serialize")]
254impl serde::Serialize for IssuingCardShippingAddressValidationResult {
255 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
256 where
257 S: serde::Serializer,
258 {
259 serializer.serialize_str(self.as_str())
260 }
261}
262impl miniserde::Deserialize for IssuingCardShippingAddressValidationResult {
263 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
264 crate::Place::new(out)
265 }
266}
267
268impl miniserde::de::Visitor for crate::Place<IssuingCardShippingAddressValidationResult> {
269 fn string(&mut self, s: &str) -> miniserde::Result<()> {
270 use std::str::FromStr;
271 self.out =
272 Some(IssuingCardShippingAddressValidationResult::from_str(s).expect("infallible"));
273 Ok(())
274 }
275}
276
277stripe_types::impl_from_val_with_from_str!(IssuingCardShippingAddressValidationResult);
278#[cfg(feature = "deserialize")]
279impl<'de> serde::Deserialize<'de> for IssuingCardShippingAddressValidationResult {
280 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
281 use std::str::FromStr;
282 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
283 Ok(Self::from_str(&s).expect("infallible"))
284 }
285}