1#[derive(Clone, Eq, PartialEq)]
3#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct IssuingPhysicalBundle {
6 pub features: stripe_shared::IssuingPhysicalBundleFeatures,
7 pub id: stripe_shared::IssuingPhysicalBundleId,
9 pub livemode: bool,
12 pub name: String,
14 pub status: stripe_shared::IssuingPhysicalBundleStatus,
16 #[cfg_attr(feature = "deserialize", serde(rename = "type"))]
18 pub type_: stripe_shared::IssuingPhysicalBundleType,
19}
20#[cfg(feature = "redact-generated-debug")]
21impl std::fmt::Debug for IssuingPhysicalBundle {
22 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
23 f.debug_struct("IssuingPhysicalBundle").finish_non_exhaustive()
24 }
25}
26#[doc(hidden)]
27pub struct IssuingPhysicalBundleBuilder {
28 features: Option<stripe_shared::IssuingPhysicalBundleFeatures>,
29 id: Option<stripe_shared::IssuingPhysicalBundleId>,
30 livemode: Option<bool>,
31 name: Option<String>,
32 status: Option<stripe_shared::IssuingPhysicalBundleStatus>,
33 type_: Option<stripe_shared::IssuingPhysicalBundleType>,
34}
35
36#[allow(
37 unused_variables,
38 irrefutable_let_patterns,
39 clippy::let_unit_value,
40 clippy::match_single_binding,
41 clippy::single_match
42)]
43const _: () = {
44 use miniserde::de::{Map, Visitor};
45 use miniserde::json::Value;
46 use miniserde::{Deserialize, Result, make_place};
47 use stripe_types::miniserde_helpers::FromValueOpt;
48 use stripe_types::{MapBuilder, ObjectDeser};
49
50 make_place!(Place);
51
52 impl Deserialize for IssuingPhysicalBundle {
53 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
54 Place::new(out)
55 }
56 }
57
58 struct Builder<'a> {
59 out: &'a mut Option<IssuingPhysicalBundle>,
60 builder: IssuingPhysicalBundleBuilder,
61 }
62
63 impl Visitor for Place<IssuingPhysicalBundle> {
64 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
65 Ok(Box::new(Builder {
66 out: &mut self.out,
67 builder: IssuingPhysicalBundleBuilder::deser_default(),
68 }))
69 }
70 }
71
72 impl MapBuilder for IssuingPhysicalBundleBuilder {
73 type Out = IssuingPhysicalBundle;
74 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
75 Ok(match k {
76 "features" => Deserialize::begin(&mut self.features),
77 "id" => Deserialize::begin(&mut self.id),
78 "livemode" => Deserialize::begin(&mut self.livemode),
79 "name" => Deserialize::begin(&mut self.name),
80 "status" => Deserialize::begin(&mut self.status),
81 "type" => Deserialize::begin(&mut self.type_),
82 _ => <dyn Visitor>::ignore(),
83 })
84 }
85
86 fn deser_default() -> Self {
87 Self { features: None, id: None, livemode: None, name: None, status: None, type_: None }
88 }
89
90 fn take_out(&mut self) -> Option<Self::Out> {
91 let (Some(features), Some(id), Some(livemode), Some(name), Some(status), Some(type_)) = (
92 self.features.take(),
93 self.id.take(),
94 self.livemode,
95 self.name.take(),
96 self.status.take(),
97 self.type_.take(),
98 ) else {
99 return None;
100 };
101 Some(Self::Out { features, id, livemode, name, status, type_ })
102 }
103 }
104
105 impl Map for Builder<'_> {
106 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
107 self.builder.key(k)
108 }
109
110 fn finish(&mut self) -> Result<()> {
111 *self.out = self.builder.take_out();
112 Ok(())
113 }
114 }
115
116 impl ObjectDeser for IssuingPhysicalBundle {
117 type Builder = IssuingPhysicalBundleBuilder;
118 }
119
120 impl FromValueOpt for IssuingPhysicalBundle {
121 fn from_value(v: Value) -> Option<Self> {
122 let Value::Object(obj) = v else {
123 return None;
124 };
125 let mut b = IssuingPhysicalBundleBuilder::deser_default();
126 for (k, v) in obj {
127 match k.as_str() {
128 "features" => b.features = FromValueOpt::from_value(v),
129 "id" => b.id = FromValueOpt::from_value(v),
130 "livemode" => b.livemode = FromValueOpt::from_value(v),
131 "name" => b.name = FromValueOpt::from_value(v),
132 "status" => b.status = FromValueOpt::from_value(v),
133 "type" => b.type_ = FromValueOpt::from_value(v),
134 _ => {}
135 }
136 }
137 b.take_out()
138 }
139 }
140};
141#[cfg(feature = "serialize")]
142impl serde::Serialize for IssuingPhysicalBundle {
143 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
144 use serde::ser::SerializeStruct;
145 let mut s = s.serialize_struct("IssuingPhysicalBundle", 7)?;
146 s.serialize_field("features", &self.features)?;
147 s.serialize_field("id", &self.id)?;
148 s.serialize_field("livemode", &self.livemode)?;
149 s.serialize_field("name", &self.name)?;
150 s.serialize_field("status", &self.status)?;
151 s.serialize_field("type", &self.type_)?;
152
153 s.serialize_field("object", "issuing.physical_bundle")?;
154 s.end()
155 }
156}
157impl stripe_types::Object for IssuingPhysicalBundle {
158 type Id = stripe_shared::IssuingPhysicalBundleId;
159 fn id(&self) -> &Self::Id {
160 &self.id
161 }
162
163 fn into_id(self) -> Self::Id {
164 self.id
165 }
166}
167stripe_types::def_id!(IssuingPhysicalBundleId);
168#[derive(Clone, Eq, PartialEq)]
169#[non_exhaustive]
170pub enum IssuingPhysicalBundleStatus {
171 Active,
172 Inactive,
173 Review,
174 Unknown(String),
176}
177impl IssuingPhysicalBundleStatus {
178 pub fn as_str(&self) -> &str {
179 use IssuingPhysicalBundleStatus::*;
180 match self {
181 Active => "active",
182 Inactive => "inactive",
183 Review => "review",
184 Unknown(v) => v,
185 }
186 }
187}
188
189impl std::str::FromStr for IssuingPhysicalBundleStatus {
190 type Err = std::convert::Infallible;
191 fn from_str(s: &str) -> Result<Self, Self::Err> {
192 use IssuingPhysicalBundleStatus::*;
193 match s {
194 "active" => Ok(Active),
195 "inactive" => Ok(Inactive),
196 "review" => Ok(Review),
197 v => {
198 tracing::warn!(
199 "Unknown value '{}' for enum '{}'",
200 v,
201 "IssuingPhysicalBundleStatus"
202 );
203 Ok(Unknown(v.to_owned()))
204 }
205 }
206 }
207}
208impl std::fmt::Display for IssuingPhysicalBundleStatus {
209 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
210 f.write_str(self.as_str())
211 }
212}
213
214#[cfg(not(feature = "redact-generated-debug"))]
215impl std::fmt::Debug for IssuingPhysicalBundleStatus {
216 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
217 f.write_str(self.as_str())
218 }
219}
220#[cfg(feature = "redact-generated-debug")]
221impl std::fmt::Debug for IssuingPhysicalBundleStatus {
222 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
223 f.debug_struct(stringify!(IssuingPhysicalBundleStatus)).finish_non_exhaustive()
224 }
225}
226impl serde::Serialize for IssuingPhysicalBundleStatus {
227 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
228 where
229 S: serde::Serializer,
230 {
231 serializer.serialize_str(self.as_str())
232 }
233}
234impl miniserde::Deserialize for IssuingPhysicalBundleStatus {
235 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
236 crate::Place::new(out)
237 }
238}
239
240impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleStatus> {
241 fn string(&mut self, s: &str) -> miniserde::Result<()> {
242 use std::str::FromStr;
243 self.out = Some(IssuingPhysicalBundleStatus::from_str(s).expect("infallible"));
244 Ok(())
245 }
246}
247
248stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleStatus);
249#[cfg(feature = "deserialize")]
250impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleStatus {
251 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
252 use std::str::FromStr;
253 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
254 Ok(Self::from_str(&s).expect("infallible"))
255 }
256}
257#[derive(Clone, Eq, PartialEq)]
258#[non_exhaustive]
259pub enum IssuingPhysicalBundleType {
260 Custom,
261 Standard,
262 Unknown(String),
264}
265impl IssuingPhysicalBundleType {
266 pub fn as_str(&self) -> &str {
267 use IssuingPhysicalBundleType::*;
268 match self {
269 Custom => "custom",
270 Standard => "standard",
271 Unknown(v) => v,
272 }
273 }
274}
275
276impl std::str::FromStr for IssuingPhysicalBundleType {
277 type Err = std::convert::Infallible;
278 fn from_str(s: &str) -> Result<Self, Self::Err> {
279 use IssuingPhysicalBundleType::*;
280 match s {
281 "custom" => Ok(Custom),
282 "standard" => Ok(Standard),
283 v => {
284 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingPhysicalBundleType");
285 Ok(Unknown(v.to_owned()))
286 }
287 }
288 }
289}
290impl std::fmt::Display for IssuingPhysicalBundleType {
291 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
292 f.write_str(self.as_str())
293 }
294}
295
296#[cfg(not(feature = "redact-generated-debug"))]
297impl std::fmt::Debug for IssuingPhysicalBundleType {
298 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
299 f.write_str(self.as_str())
300 }
301}
302#[cfg(feature = "redact-generated-debug")]
303impl std::fmt::Debug for IssuingPhysicalBundleType {
304 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
305 f.debug_struct(stringify!(IssuingPhysicalBundleType)).finish_non_exhaustive()
306 }
307}
308impl serde::Serialize for IssuingPhysicalBundleType {
309 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
310 where
311 S: serde::Serializer,
312 {
313 serializer.serialize_str(self.as_str())
314 }
315}
316impl miniserde::Deserialize for IssuingPhysicalBundleType {
317 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
318 crate::Place::new(out)
319 }
320}
321
322impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleType> {
323 fn string(&mut self, s: &str) -> miniserde::Result<()> {
324 use std::str::FromStr;
325 self.out = Some(IssuingPhysicalBundleType::from_str(s).expect("infallible"));
326 Ok(())
327 }
328}
329
330stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleType);
331#[cfg(feature = "deserialize")]
332impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleType {
333 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
334 use std::str::FromStr;
335 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
336 Ok(Self::from_str(&s).expect("infallible"))
337 }
338}