stripe_shared/
payment_intent_next_action_konbini_ministop.rs

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