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