payjp_core/event/
requests.rs1use payjp_client_core::{PayjpClient, BlockingClient, PayjpRequest, RequestBuilder, PayjpMethod};
2
3#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
4 struct ListEventBuilder {
5#[serde(skip_serializing_if = "Option::is_none")]
6 limit: Option<i64>,
7#[serde(skip_serializing_if = "Option::is_none")]
8 offset: Option<i64>,
9#[serde(skip_serializing_if = "Option::is_none")]
10 since: Option<i64>,
11#[serde(skip_serializing_if = "Option::is_none")]
12 until: Option<i64>,
13#[serde(skip_serializing_if = "Option::is_none")]
14 resource_id: Option<String>,
15#[serde(skip_serializing_if = "Option::is_none")]
16 object: Option<String>,
17#[serde(rename = "type")]
18#[serde(skip_serializing_if = "Option::is_none")]
19 type_: Option<String>,
20
21}
22impl ListEventBuilder {
23 fn new() -> Self {
24 Self {
25 limit: None,offset: None,since: None,until: None,resource_id: None,object: None,type_: None,
26 }
27}
28
29}
30 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
32pub struct ListEvent {
33 inner: ListEventBuilder,
34
35}
36impl ListEvent {
37 pub fn new() -> Self {
39 Self {
40 inner: ListEventBuilder::new()
41 }
42}
43 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
45 self.inner.limit = Some(limit.into());
46 self
47}
48 pub fn offset(mut self, offset: impl Into<i64>) -> Self {
50 self.inner.offset = Some(offset.into());
51 self
52}
53 pub fn since(mut self, since: impl Into<i64>) -> Self {
55 self.inner.since = Some(since.into());
56 self
57}
58 pub fn until(mut self, until: impl Into<i64>) -> Self {
60 self.inner.until = Some(until.into());
61 self
62}
63 pub fn resource_id(mut self, resource_id: impl Into<String>) -> Self {
65 self.inner.resource_id = Some(resource_id.into());
66 self
67}
68 pub fn object(mut self, object: impl Into<String>) -> Self {
71 self.inner.object = Some(object.into());
72 self
73}
74 pub fn type_(mut self, type_: impl Into<String>) -> Self {
76 self.inner.type_ = Some(type_.into());
77 self
78}
79
80}
81 impl Default for ListEvent {
82 fn default() -> Self {
83 Self::new()
84 }
85}impl ListEvent {
86 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
88 self.customize().send(client).await
89 }
90
91 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
93 self.customize().send_blocking(client)
94 }
95
96 pub fn paginate(&self) -> payjp_client_core::ListPaginator<payjp_types::List<payjp_shared::Event>> {
97
98 payjp_client_core::ListPaginator::new_list("/events", &self.inner)
99}
100
101}
102
103impl PayjpRequest for ListEvent {
104 type Output = payjp_types::List<payjp_shared::Event>;
105
106 fn build(&self) -> RequestBuilder {
107 RequestBuilder::new(PayjpMethod::Get, "/events").query(&self.inner)
108}
109
110}
111 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
113pub struct RetrieveEvent {
114 event: payjp_shared::EventId,
115
116}
117impl RetrieveEvent {
118 pub fn new(event:impl Into<payjp_shared::EventId>) -> Self {
120 Self {
121 event: event.into(),
122 }
123}
124
125}
126 impl RetrieveEvent {
127 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
129 self.customize().send(client).await
130 }
131
132 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
134 self.customize().send_blocking(client)
135 }
136
137
138}
139
140impl PayjpRequest for RetrieveEvent {
141 type Output = payjp_shared::Event;
142
143 fn build(&self) -> RequestBuilder {
144 let event = &self.event;
145RequestBuilder::new(PayjpMethod::Get, format!("/events/{event}"))
146}
147
148}
149