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::{make_place, Deserialize, Result};
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
81 _ => <dyn Visitor>::ignore(),
82 })
83 }
84
85 fn deser_default() -> Self {
86 Self {
87 amount_remaining: Deserialize::default(),
88 currency: Deserialize::default(),
89 financial_addresses: Deserialize::default(),
90 hosted_instructions_url: Deserialize::default(),
91 reference: Deserialize::default(),
92 type_: Deserialize::default(),
93 }
94 }
95
96 fn take_out(&mut self) -> Option<Self::Out> {
97 let (
98 Some(amount_remaining),
99 Some(currency),
100 Some(financial_addresses),
101 Some(hosted_instructions_url),
102 Some(reference),
103 Some(type_),
104 ) = (
105 self.amount_remaining,
106 self.currency.take(),
107 self.financial_addresses.take(),
108 self.hosted_instructions_url.take(),
109 self.reference.take(),
110 self.type_,
111 )
112 else {
113 return None;
114 };
115 Some(Self::Out {
116 amount_remaining,
117 currency,
118 financial_addresses,
119 hosted_instructions_url,
120 reference,
121 type_,
122 })
123 }
124 }
125
126 impl Map for Builder<'_> {
127 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
128 self.builder.key(k)
129 }
130
131 fn finish(&mut self) -> Result<()> {
132 *self.out = self.builder.take_out();
133 Ok(())
134 }
135 }
136
137 impl ObjectDeser for PaymentIntentNextActionDisplayBankTransferInstructions {
138 type Builder = PaymentIntentNextActionDisplayBankTransferInstructionsBuilder;
139 }
140
141 impl FromValueOpt for PaymentIntentNextActionDisplayBankTransferInstructions {
142 fn from_value(v: Value) -> Option<Self> {
143 let Value::Object(obj) = v else {
144 return None;
145 };
146 let mut b =
147 PaymentIntentNextActionDisplayBankTransferInstructionsBuilder::deser_default();
148 for (k, v) in obj {
149 match k.as_str() {
150 "amount_remaining" => b.amount_remaining = FromValueOpt::from_value(v),
151 "currency" => b.currency = FromValueOpt::from_value(v),
152 "financial_addresses" => b.financial_addresses = FromValueOpt::from_value(v),
153 "hosted_instructions_url" => {
154 b.hosted_instructions_url = FromValueOpt::from_value(v)
155 }
156 "reference" => b.reference = FromValueOpt::from_value(v),
157 "type" => b.type_ = FromValueOpt::from_value(v),
158
159 _ => {}
160 }
161 }
162 b.take_out()
163 }
164 }
165};
166#[derive(Copy, Clone, Eq, PartialEq)]
168pub enum PaymentIntentNextActionDisplayBankTransferInstructionsType {
169 EuBankTransfer,
170 GbBankTransfer,
171 JpBankTransfer,
172 MxBankTransfer,
173 UsBankTransfer,
174}
175impl PaymentIntentNextActionDisplayBankTransferInstructionsType {
176 pub fn as_str(self) -> &'static str {
177 use PaymentIntentNextActionDisplayBankTransferInstructionsType::*;
178 match self {
179 EuBankTransfer => "eu_bank_transfer",
180 GbBankTransfer => "gb_bank_transfer",
181 JpBankTransfer => "jp_bank_transfer",
182 MxBankTransfer => "mx_bank_transfer",
183 UsBankTransfer => "us_bank_transfer",
184 }
185 }
186}
187
188impl std::str::FromStr for PaymentIntentNextActionDisplayBankTransferInstructionsType {
189 type Err = stripe_types::StripeParseError;
190 fn from_str(s: &str) -> Result<Self, Self::Err> {
191 use PaymentIntentNextActionDisplayBankTransferInstructionsType::*;
192 match s {
193 "eu_bank_transfer" => Ok(EuBankTransfer),
194 "gb_bank_transfer" => Ok(GbBankTransfer),
195 "jp_bank_transfer" => Ok(JpBankTransfer),
196 "mx_bank_transfer" => Ok(MxBankTransfer),
197 "us_bank_transfer" => Ok(UsBankTransfer),
198 _ => Err(stripe_types::StripeParseError),
199 }
200 }
201}
202impl std::fmt::Display for PaymentIntentNextActionDisplayBankTransferInstructionsType {
203 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
204 f.write_str(self.as_str())
205 }
206}
207
208impl std::fmt::Debug for PaymentIntentNextActionDisplayBankTransferInstructionsType {
209 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
210 f.write_str(self.as_str())
211 }
212}
213#[cfg(feature = "serialize")]
214impl serde::Serialize for PaymentIntentNextActionDisplayBankTransferInstructionsType {
215 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
216 where
217 S: serde::Serializer,
218 {
219 serializer.serialize_str(self.as_str())
220 }
221}
222impl miniserde::Deserialize for PaymentIntentNextActionDisplayBankTransferInstructionsType {
223 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
224 crate::Place::new(out)
225 }
226}
227
228impl miniserde::de::Visitor
229 for crate::Place<PaymentIntentNextActionDisplayBankTransferInstructionsType>
230{
231 fn string(&mut self, s: &str) -> miniserde::Result<()> {
232 use std::str::FromStr;
233 self.out = Some(
234 PaymentIntentNextActionDisplayBankTransferInstructionsType::from_str(s)
235 .map_err(|_| miniserde::Error)?,
236 );
237 Ok(())
238 }
239}
240
241stripe_types::impl_from_val_with_from_str!(
242 PaymentIntentNextActionDisplayBankTransferInstructionsType
243);
244#[cfg(feature = "deserialize")]
245impl<'de> serde::Deserialize<'de> for PaymentIntentNextActionDisplayBankTransferInstructionsType {
246 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
247 use std::str::FromStr;
248 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
249 Self::from_str(&s).map_err(|_| {
250 serde::de::Error::custom(
251 "Unknown value for PaymentIntentNextActionDisplayBankTransferInstructionsType",
252 )
253 })
254 }
255}