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