use payjp_client_core::{PayjpClient, BlockingClient, PayjpRequest, RequestBuilder, PayjpMethod};
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
struct ListEventBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
offset: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
since: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
until: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
resource_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
object: Option<String>,
#[serde(rename = "type")]
#[serde(skip_serializing_if = "Option::is_none")]
type_: Option<String>,
}
impl ListEventBuilder {
fn new() -> Self {
Self {
limit: None,offset: None,since: None,until: None,resource_id: None,object: None,type_: None,
}
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct ListEvent {
inner: ListEventBuilder,
}
impl ListEvent {
pub fn new() -> Self {
Self {
inner: ListEventBuilder::new()
}
}
pub fn limit(mut self, limit: impl Into<i64>) -> Self {
self.inner.limit = Some(limit.into());
self
}
pub fn offset(mut self, offset: impl Into<i64>) -> Self {
self.inner.offset = Some(offset.into());
self
}
pub fn since(mut self, since: impl Into<i64>) -> Self {
self.inner.since = Some(since.into());
self
}
pub fn until(mut self, until: impl Into<i64>) -> Self {
self.inner.until = Some(until.into());
self
}
pub fn resource_id(mut self, resource_id: impl Into<String>) -> Self {
self.inner.resource_id = Some(resource_id.into());
self
}
pub fn object(mut self, object: impl Into<String>) -> Self {
self.inner.object = Some(object.into());
self
}
pub fn type_(mut self, type_: impl Into<String>) -> Self {
self.inner.type_ = Some(type_.into());
self
}
}
impl Default for ListEvent {
fn default() -> Self {
Self::new()
}
}impl ListEvent {
pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
self.customize().send(client).await
}
pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
self.customize().send_blocking(client)
}
pub fn paginate(&self) -> payjp_client_core::ListPaginator<payjp_types::List<payjp_shared::Event>> {
payjp_client_core::ListPaginator::new_list("/events", &self.inner)
}
}
impl PayjpRequest for ListEvent {
type Output = payjp_types::List<payjp_shared::Event>;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(PayjpMethod::Get, "/events").query(&self.inner)
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct RetrieveEvent {
event: payjp_shared::EventId,
}
impl RetrieveEvent {
pub fn new(event:impl Into<payjp_shared::EventId>) -> Self {
Self {
event: event.into(),
}
}
}
impl RetrieveEvent {
pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
self.customize().send(client).await
}
pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
self.customize().send_blocking(client)
}
}
impl PayjpRequest for RetrieveEvent {
type Output = payjp_shared::Event;
fn build(&self) -> RequestBuilder {
let event = &self.event;
RequestBuilder::new(PayjpMethod::Get, format!("/events/{event}"))
}
}