Skip to main content

stripe_shared/
setup_intent_next_action_pix_display_qr_code.rs

1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct SetupIntentNextActionPixDisplayQrCode {
6    /// The raw data string used to generate QR code, it should be used together with QR code library.
7    pub data: String,
8    /// The date (unix timestamp) when the PIX expires.
9    pub expires_at: stripe_types::Timestamp,
10    /// The URL to the hosted pix instructions page, which allows customers to view the pix QR code.
11    pub hosted_instructions_url: String,
12    /// The image_url_png string used to render png QR code
13    pub image_url_png: String,
14    /// The image_url_svg string used to render svg QR code
15    pub image_url_svg: String,
16}
17#[cfg(feature = "redact-generated-debug")]
18impl std::fmt::Debug for SetupIntentNextActionPixDisplayQrCode {
19    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
20        f.debug_struct("SetupIntentNextActionPixDisplayQrCode").finish_non_exhaustive()
21    }
22}
23#[doc(hidden)]
24pub struct SetupIntentNextActionPixDisplayQrCodeBuilder {
25    data: Option<String>,
26    expires_at: Option<stripe_types::Timestamp>,
27    hosted_instructions_url: Option<String>,
28    image_url_png: Option<String>,
29    image_url_svg: Option<String>,
30}
31
32#[allow(
33    unused_variables,
34    irrefutable_let_patterns,
35    clippy::let_unit_value,
36    clippy::match_single_binding,
37    clippy::single_match
38)]
39const _: () = {
40    use miniserde::de::{Map, Visitor};
41    use miniserde::json::Value;
42    use miniserde::{Deserialize, Result, make_place};
43    use stripe_types::miniserde_helpers::FromValueOpt;
44    use stripe_types::{MapBuilder, ObjectDeser};
45
46    make_place!(Place);
47
48    impl Deserialize for SetupIntentNextActionPixDisplayQrCode {
49        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
50            Place::new(out)
51        }
52    }
53
54    struct Builder<'a> {
55        out: &'a mut Option<SetupIntentNextActionPixDisplayQrCode>,
56        builder: SetupIntentNextActionPixDisplayQrCodeBuilder,
57    }
58
59    impl Visitor for Place<SetupIntentNextActionPixDisplayQrCode> {
60        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
61            Ok(Box::new(Builder {
62                out: &mut self.out,
63                builder: SetupIntentNextActionPixDisplayQrCodeBuilder::deser_default(),
64            }))
65        }
66    }
67
68    impl MapBuilder for SetupIntentNextActionPixDisplayQrCodeBuilder {
69        type Out = SetupIntentNextActionPixDisplayQrCode;
70        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
71            Ok(match k {
72                "data" => Deserialize::begin(&mut self.data),
73                "expires_at" => Deserialize::begin(&mut self.expires_at),
74                "hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url),
75                "image_url_png" => Deserialize::begin(&mut self.image_url_png),
76                "image_url_svg" => Deserialize::begin(&mut self.image_url_svg),
77                _ => <dyn Visitor>::ignore(),
78            })
79        }
80
81        fn deser_default() -> Self {
82            Self {
83                data: None,
84                expires_at: None,
85                hosted_instructions_url: None,
86                image_url_png: None,
87                image_url_svg: None,
88            }
89        }
90
91        fn take_out(&mut self) -> Option<Self::Out> {
92            let (
93                Some(data),
94                Some(expires_at),
95                Some(hosted_instructions_url),
96                Some(image_url_png),
97                Some(image_url_svg),
98            ) = (
99                self.data.take(),
100                self.expires_at,
101                self.hosted_instructions_url.take(),
102                self.image_url_png.take(),
103                self.image_url_svg.take(),
104            )
105            else {
106                return None;
107            };
108            Some(Self::Out {
109                data,
110                expires_at,
111                hosted_instructions_url,
112                image_url_png,
113                image_url_svg,
114            })
115        }
116    }
117
118    impl Map for Builder<'_> {
119        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
120            self.builder.key(k)
121        }
122
123        fn finish(&mut self) -> Result<()> {
124            *self.out = self.builder.take_out();
125            Ok(())
126        }
127    }
128
129    impl ObjectDeser for SetupIntentNextActionPixDisplayQrCode {
130        type Builder = SetupIntentNextActionPixDisplayQrCodeBuilder;
131    }
132
133    impl FromValueOpt for SetupIntentNextActionPixDisplayQrCode {
134        fn from_value(v: Value) -> Option<Self> {
135            let Value::Object(obj) = v else {
136                return None;
137            };
138            let mut b = SetupIntentNextActionPixDisplayQrCodeBuilder::deser_default();
139            for (k, v) in obj {
140                match k.as_str() {
141                    "data" => b.data = FromValueOpt::from_value(v),
142                    "expires_at" => b.expires_at = FromValueOpt::from_value(v),
143                    "hosted_instructions_url" => {
144                        b.hosted_instructions_url = FromValueOpt::from_value(v)
145                    }
146                    "image_url_png" => b.image_url_png = FromValueOpt::from_value(v),
147                    "image_url_svg" => b.image_url_svg = FromValueOpt::from_value(v),
148                    _ => {}
149                }
150            }
151            b.take_out()
152        }
153    }
154};