stripe_shared/
notification_event_request.rs1#[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 NotificationEventRequest {
6 pub id: Option<String>,
10 pub idempotency_key: Option<String>,
13}
14#[cfg(feature = "redact-generated-debug")]
15impl std::fmt::Debug for NotificationEventRequest {
16 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
17 f.debug_struct("NotificationEventRequest").finish_non_exhaustive()
18 }
19}
20#[doc(hidden)]
21pub struct NotificationEventRequestBuilder {
22 id: Option<Option<String>>,
23 idempotency_key: Option<Option<String>>,
24}
25
26#[allow(
27 unused_variables,
28 irrefutable_let_patterns,
29 clippy::let_unit_value,
30 clippy::match_single_binding,
31 clippy::single_match
32)]
33const _: () = {
34 use miniserde::de::{Map, Visitor};
35 use miniserde::json::Value;
36 use miniserde::{Deserialize, Result, make_place};
37 use stripe_types::miniserde_helpers::FromValueOpt;
38 use stripe_types::{MapBuilder, ObjectDeser};
39
40 make_place!(Place);
41
42 impl Deserialize for NotificationEventRequest {
43 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
44 Place::new(out)
45 }
46 }
47
48 struct Builder<'a> {
49 out: &'a mut Option<NotificationEventRequest>,
50 builder: NotificationEventRequestBuilder,
51 }
52
53 impl Visitor for Place<NotificationEventRequest> {
54 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
55 Ok(Box::new(Builder {
56 out: &mut self.out,
57 builder: NotificationEventRequestBuilder::deser_default(),
58 }))
59 }
60 }
61
62 impl MapBuilder for NotificationEventRequestBuilder {
63 type Out = NotificationEventRequest;
64 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
65 Ok(match k {
66 "id" => Deserialize::begin(&mut self.id),
67 "idempotency_key" => Deserialize::begin(&mut self.idempotency_key),
68 _ => <dyn Visitor>::ignore(),
69 })
70 }
71
72 fn deser_default() -> Self {
73 Self { id: Deserialize::default(), idempotency_key: Deserialize::default() }
74 }
75
76 fn take_out(&mut self) -> Option<Self::Out> {
77 let (Some(id), Some(idempotency_key)) = (self.id.take(), self.idempotency_key.take())
78 else {
79 return None;
80 };
81 Some(Self::Out { id, idempotency_key })
82 }
83 }
84
85 impl Map for Builder<'_> {
86 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
87 self.builder.key(k)
88 }
89
90 fn finish(&mut self) -> Result<()> {
91 *self.out = self.builder.take_out();
92 Ok(())
93 }
94 }
95
96 impl ObjectDeser for NotificationEventRequest {
97 type Builder = NotificationEventRequestBuilder;
98 }
99
100 impl FromValueOpt for NotificationEventRequest {
101 fn from_value(v: Value) -> Option<Self> {
102 let Value::Object(obj) = v else {
103 return None;
104 };
105 let mut b = NotificationEventRequestBuilder::deser_default();
106 for (k, v) in obj {
107 match k.as_str() {
108 "id" => b.id = FromValueOpt::from_value(v),
109 "idempotency_key" => b.idempotency_key = FromValueOpt::from_value(v),
110 _ => {}
111 }
112 }
113 b.take_out()
114 }
115 }
116};