stripe_shared/
payment_intent_next_action_konbini.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentNextActionKonbini {
5    /// The timestamp at which the pending Konbini payment expires.
6    pub expires_at: stripe_types::Timestamp,
7    /// The URL for the Konbini payment instructions page, which allows customers to view and print a Konbini voucher.
8    pub hosted_voucher_url: Option<String>,
9    pub stores: stripe_shared::PaymentIntentNextActionKonbiniStores,
10}
11#[doc(hidden)]
12pub struct PaymentIntentNextActionKonbiniBuilder {
13    expires_at: Option<stripe_types::Timestamp>,
14    hosted_voucher_url: Option<Option<String>>,
15    stores: Option<stripe_shared::PaymentIntentNextActionKonbiniStores>,
16}
17
18#[allow(
19    unused_variables,
20    irrefutable_let_patterns,
21    clippy::let_unit_value,
22    clippy::match_single_binding,
23    clippy::single_match
24)]
25const _: () = {
26    use miniserde::de::{Map, Visitor};
27    use miniserde::json::Value;
28    use miniserde::{make_place, Deserialize, Result};
29    use stripe_types::miniserde_helpers::FromValueOpt;
30    use stripe_types::{MapBuilder, ObjectDeser};
31
32    make_place!(Place);
33
34    impl Deserialize for PaymentIntentNextActionKonbini {
35        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
36            Place::new(out)
37        }
38    }
39
40    struct Builder<'a> {
41        out: &'a mut Option<PaymentIntentNextActionKonbini>,
42        builder: PaymentIntentNextActionKonbiniBuilder,
43    }
44
45    impl Visitor for Place<PaymentIntentNextActionKonbini> {
46        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
47            Ok(Box::new(Builder {
48                out: &mut self.out,
49                builder: PaymentIntentNextActionKonbiniBuilder::deser_default(),
50            }))
51        }
52    }
53
54    impl MapBuilder for PaymentIntentNextActionKonbiniBuilder {
55        type Out = PaymentIntentNextActionKonbini;
56        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
57            Ok(match k {
58                "expires_at" => Deserialize::begin(&mut self.expires_at),
59                "hosted_voucher_url" => Deserialize::begin(&mut self.hosted_voucher_url),
60                "stores" => Deserialize::begin(&mut self.stores),
61
62                _ => <dyn Visitor>::ignore(),
63            })
64        }
65
66        fn deser_default() -> Self {
67            Self {
68                expires_at: Deserialize::default(),
69                hosted_voucher_url: Deserialize::default(),
70                stores: Deserialize::default(),
71            }
72        }
73
74        fn take_out(&mut self) -> Option<Self::Out> {
75            let (Some(expires_at), Some(hosted_voucher_url), Some(stores)) =
76                (self.expires_at, self.hosted_voucher_url.take(), self.stores.take())
77            else {
78                return None;
79            };
80            Some(Self::Out { expires_at, hosted_voucher_url, stores })
81        }
82    }
83
84    impl Map for Builder<'_> {
85        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
86            self.builder.key(k)
87        }
88
89        fn finish(&mut self) -> Result<()> {
90            *self.out = self.builder.take_out();
91            Ok(())
92        }
93    }
94
95    impl ObjectDeser for PaymentIntentNextActionKonbini {
96        type Builder = PaymentIntentNextActionKonbiniBuilder;
97    }
98
99    impl FromValueOpt for PaymentIntentNextActionKonbini {
100        fn from_value(v: Value) -> Option<Self> {
101            let Value::Object(obj) = v else {
102                return None;
103            };
104            let mut b = PaymentIntentNextActionKonbiniBuilder::deser_default();
105            for (k, v) in obj {
106                match k.as_str() {
107                    "expires_at" => b.expires_at = FromValueOpt::from_value(v),
108                    "hosted_voucher_url" => b.hosted_voucher_url = FromValueOpt::from_value(v),
109                    "stores" => b.stores = FromValueOpt::from_value(v),
110
111                    _ => {}
112                }
113            }
114            b.take_out()
115        }
116    }
117};