stripe_core/event/
requests.rs1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListEventBuilder {
7 #[serde(skip_serializing_if = "Option::is_none")]
8 created: Option<stripe_types::RangeQueryTs>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 delivery_success: Option<bool>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 ending_before: Option<String>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 expand: Option<Vec<String>>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 limit: Option<i64>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 starting_after: Option<String>,
19 #[serde(rename = "type")]
20 #[serde(skip_serializing_if = "Option::is_none")]
21 type_: Option<String>,
22 #[serde(skip_serializing_if = "Option::is_none")]
23 types: Option<Vec<String>>,
24}
25impl ListEventBuilder {
26 fn new() -> Self {
27 Self {
28 created: None,
29 delivery_success: None,
30 ending_before: None,
31 expand: None,
32 limit: None,
33 starting_after: None,
34 type_: None,
35 types: None,
36 }
37 }
38}
39#[derive(Clone, Debug, serde::Serialize)]
42pub struct ListEvent {
43 inner: ListEventBuilder,
44}
45impl ListEvent {
46 pub fn new() -> Self {
48 Self { inner: ListEventBuilder::new() }
49 }
50 pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
52 self.inner.created = Some(created.into());
53 self
54 }
55 pub fn delivery_success(mut self, delivery_success: impl Into<bool>) -> Self {
58 self.inner.delivery_success = Some(delivery_success.into());
59 self
60 }
61 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
65 self.inner.ending_before = Some(ending_before.into());
66 self
67 }
68 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
70 self.inner.expand = Some(expand.into());
71 self
72 }
73 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
76 self.inner.limit = Some(limit.into());
77 self
78 }
79 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
83 self.inner.starting_after = Some(starting_after.into());
84 self
85 }
86 pub fn type_(mut self, type_: impl Into<String>) -> Self {
89 self.inner.type_ = Some(type_.into());
90 self
91 }
92 pub fn types(mut self, types: impl Into<Vec<String>>) -> Self {
96 self.inner.types = Some(types.into());
97 self
98 }
99}
100impl Default for ListEvent {
101 fn default() -> Self {
102 Self::new()
103 }
104}
105impl ListEvent {
106 pub async fn send<C: StripeClient>(
108 &self,
109 client: &C,
110 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
111 self.customize().send(client).await
112 }
113
114 pub fn send_blocking<C: StripeBlockingClient>(
116 &self,
117 client: &C,
118 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
119 self.customize().send_blocking(client)
120 }
121
122 pub fn paginate(
123 &self,
124 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::Event>> {
125 stripe_client_core::ListPaginator::new_list("/events", &self.inner)
126 }
127}
128
129impl StripeRequest for ListEvent {
130 type Output = stripe_types::List<stripe_shared::Event>;
131
132 fn build(&self) -> RequestBuilder {
133 RequestBuilder::new(StripeMethod::Get, "/events").query(&self.inner)
134 }
135}
136#[derive(Clone, Debug, serde::Serialize)]
137struct RetrieveEventBuilder {
138 #[serde(skip_serializing_if = "Option::is_none")]
139 expand: Option<Vec<String>>,
140}
141impl RetrieveEventBuilder {
142 fn new() -> Self {
143 Self { expand: None }
144 }
145}
146#[derive(Clone, Debug, serde::Serialize)]
149pub struct RetrieveEvent {
150 inner: RetrieveEventBuilder,
151 id: stripe_shared::EventId,
152}
153impl RetrieveEvent {
154 pub fn new(id: impl Into<stripe_shared::EventId>) -> Self {
156 Self { id: id.into(), inner: RetrieveEventBuilder::new() }
157 }
158 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
160 self.inner.expand = Some(expand.into());
161 self
162 }
163}
164impl RetrieveEvent {
165 pub async fn send<C: StripeClient>(
167 &self,
168 client: &C,
169 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
170 self.customize().send(client).await
171 }
172
173 pub fn send_blocking<C: StripeBlockingClient>(
175 &self,
176 client: &C,
177 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
178 self.customize().send_blocking(client)
179 }
180}
181
182impl StripeRequest for RetrieveEvent {
183 type Output = stripe_shared::Event;
184
185 fn build(&self) -> RequestBuilder {
186 let id = &self.id;
187 RequestBuilder::new(StripeMethod::Get, format!("/events/{id}")).query(&self.inner)
188 }
189}