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