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