use payjp_client_core::{PayjpClient, BlockingClient, PayjpRequest, RequestBuilder, PayjpMethod};
#[derive(Copy,Clone,Debug,)]#[derive(serde::Serialize)]
struct ListCustomerBuilder {
#[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>,
}
impl ListCustomerBuilder {
fn new() -> Self {
Self {
limit: None,offset: None,since: None,until: None,
}
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct ListCustomer {
inner: ListCustomerBuilder,
}
impl ListCustomer {
pub fn new() -> Self {
Self {
inner: ListCustomerBuilder::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
}
}
impl Default for ListCustomer {
fn default() -> Self {
Self::new()
}
}impl ListCustomer {
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_core::Customer>> {
payjp_client_core::ListPaginator::new_list("/customers", &self.inner)
}
}
impl PayjpRequest for ListCustomer {
type Output = payjp_types::List<payjp_core::Customer>;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(PayjpMethod::Get, "/customers").query(&self.inner)
}
}
#[derive(Clone,Debug,serde::Serialize)]
struct CreateCustomerBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
card: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<std::collections::HashMap<String, String>>,
}
impl CreateCustomerBuilder {
fn new() -> Self {
Self {
card: None,description: None,email: None,id: None,metadata: None,
}
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct CreateCustomer {
inner: CreateCustomerBuilder,
}
impl CreateCustomer {
pub fn new() -> Self {
Self {
inner: CreateCustomerBuilder::new()
}
}
pub fn card(mut self, card: impl Into<String>) -> Self {
self.inner.card = Some(card.into());
self
}
pub fn description(mut self, description: impl Into<String>) -> Self {
self.inner.description = Some(description.into());
self
}
pub fn email(mut self, email: impl Into<String>) -> Self {
self.inner.email = Some(email.into());
self
}
pub fn id(mut self, id: impl Into<String>) -> Self {
self.inner.id = Some(id.into());
self
}
pub fn metadata(mut self,
metadata: impl Into<std::collections::HashMap<String, String>>
) -> Self {
self.inner.metadata = Some(metadata.into());
self
}
}
impl Default for CreateCustomer {
fn default() -> Self {
Self::new()
}
}impl CreateCustomer {
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 CreateCustomer {
type Output = payjp_core::Customer;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(PayjpMethod::Post, "/customers").form(&self.inner)
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct RetrieveCustomer {
customer: payjp_core::CustomerId,
}
impl RetrieveCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
Self {
customer: customer.into(),
}
}
}
impl RetrieveCustomer {
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 RetrieveCustomer {
type Output = payjp_core::Customer;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
RequestBuilder::new(PayjpMethod::Get, format!("/customers/{customer}"))
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
struct UpdateCustomerBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
card: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
default_card: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<std::collections::HashMap<String, String>>,
}
impl UpdateCustomerBuilder {
fn new() -> Self {
Self {
card: None,default_card: None,description: None,email: None,metadata: None,
}
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct UpdateCustomer {
inner: UpdateCustomerBuilder,
customer: payjp_core::CustomerId,
}
impl UpdateCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
Self {
customer: customer.into(),inner: UpdateCustomerBuilder::new()
}
}
pub fn card(mut self, card: impl Into<String>) -> Self {
self.inner.card = Some(card.into());
self
}
pub fn default_card(mut self, default_card: impl Into<String>) -> Self {
self.inner.default_card = Some(default_card.into());
self
}
pub fn description(mut self, description: impl Into<String>) -> Self {
self.inner.description = Some(description.into());
self
}
pub fn email(mut self, email: impl Into<String>) -> Self {
self.inner.email = Some(email.into());
self
}
pub fn metadata(mut self,
metadata: impl Into<std::collections::HashMap<String, String>>
) -> Self {
self.inner.metadata = Some(metadata.into());
self
}
}
impl UpdateCustomer {
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 UpdateCustomer {
type Output = payjp_core::Customer;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
RequestBuilder::new(PayjpMethod::Post, format!("/customers/{customer}")).form(&self.inner)
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct DeleteCustomer {
customer: payjp_core::CustomerId,
}
impl DeleteCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
Self {
customer: customer.into(),
}
}
}
impl DeleteCustomer {
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 DeleteCustomer {
type Output = payjp_shared::DeleteResponse;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
RequestBuilder::new(PayjpMethod::Delete, format!("/customers/{customer}"))
}
}
#[derive(Copy,Clone,Debug,)]#[derive(serde::Serialize)]
struct ListCardCustomerBuilder {
#[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>,
}
impl ListCardCustomerBuilder {
fn new() -> Self {
Self {
limit: None,offset: None,since: None,until: None,
}
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct ListCardCustomer {
inner: ListCardCustomerBuilder,
customer: payjp_core::CustomerId,
}
impl ListCardCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
Self {
customer: customer.into(),inner: ListCardCustomerBuilder::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
}
}
impl ListCardCustomer {
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_core::Card>> {
let customer = &self.customer;
payjp_client_core::ListPaginator::new_list(format!("/customers/{customer}/cards"), &self.inner)
}
}
impl PayjpRequest for ListCardCustomer {
type Output = payjp_types::List<payjp_core::Card>;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
RequestBuilder::new(PayjpMethod::Get, format!("/customers/{customer}/cards")).query(&self.inner)
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
struct CreateCardCustomerBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
card: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
default: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<std::collections::HashMap<String, String>>,
}
impl CreateCardCustomerBuilder {
fn new() -> Self {
Self {
card: None,default: None,metadata: None,
}
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct CreateCardCustomer {
inner: CreateCardCustomerBuilder,
customer: payjp_core::CustomerId,
}
impl CreateCardCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
Self {
customer: customer.into(),inner: CreateCardCustomerBuilder::new()
}
}
pub fn card(mut self, card: impl Into<String>) -> Self {
self.inner.card = Some(card.into());
self
}
pub fn default(mut self, default: impl Into<bool>) -> Self {
self.inner.default = Some(default.into());
self
}
pub fn metadata(mut self,
metadata: impl Into<std::collections::HashMap<String, String>>,
) -> Self {
self.inner.metadata = Some(metadata.into());
self
}
}
impl CreateCardCustomer {
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 CreateCardCustomer {
type Output = payjp_core::Card;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
RequestBuilder::new(PayjpMethod::Post, format!("/customers/{customer}/cards")).form(&self.inner)
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct RetrieveCardCustomer {
customer: payjp_core::CustomerId,
card: String,
}
impl RetrieveCardCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>,card:impl Into<String>) -> Self {
Self {
customer: customer.into(),card: card.into(),
}
}
}
impl RetrieveCardCustomer {
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 RetrieveCardCustomer {
type Output = payjp_core::Card;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
let card = &self.card;
RequestBuilder::new(PayjpMethod::Get, format!("/customers/{customer}/cards/{card}"))
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
struct UpdateCardCustomerBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
address_city: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
address_line1: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
address_line2: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
address_state: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
address_zip: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
country: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<std::collections::HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
phone: Option<String>,
}
impl UpdateCardCustomerBuilder {
fn new() -> Self {
Self {
address_city: None,address_line1: None,address_line2: None,address_state: None,address_zip: None,country: None,email: None,metadata: None,name: None,phone: None,
}
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct UpdateCardCustomer {
inner: UpdateCardCustomerBuilder,
customer: payjp_core::CustomerId,
card: String,
}
impl UpdateCardCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>,card:impl Into<String>) -> Self {
Self {
customer: customer.into(),card: card.into(),inner: UpdateCardCustomerBuilder::new()
}
}
pub fn address_city(mut self, address_city: impl Into<String>) -> Self {
self.inner.address_city = Some(address_city.into());
self
}
pub fn address_line1(mut self, address_line1: impl Into<String>) -> Self {
self.inner.address_line1 = Some(address_line1.into());
self
}
pub fn address_line2(mut self, address_line2: impl Into<String>) -> Self {
self.inner.address_line2 = Some(address_line2.into());
self
}
pub fn address_state(mut self, address_state: impl Into<String>) -> Self {
self.inner.address_state = Some(address_state.into());
self
}
pub fn address_zip(mut self, address_zip: impl Into<String>) -> Self {
self.inner.address_zip = Some(address_zip.into());
self
}
pub fn country(mut self, country: impl Into<String>) -> Self {
self.inner.country = Some(country.into());
self
}
pub fn email(mut self, email: impl Into<String>) -> Self {
self.inner.email = Some(email.into());
self
}
pub fn metadata(mut self,
metadata: impl Into<std::collections::HashMap<String, String>>,
) -> Self {
self.inner.metadata = Some(metadata.into());
self
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.inner.name = Some(name.into());
self
}
pub fn phone(mut self, phone: impl Into<String>) -> Self {
self.inner.phone = Some(phone.into());
self
}
}
impl UpdateCardCustomer {
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 UpdateCardCustomer {
type Output = payjp_core::Card;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
let card = &self.card;
RequestBuilder::new(PayjpMethod::Post, format!("/customers/{customer}/cards/{card}")).form(&self.inner)
}
}
#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
pub struct DeleteCardCustomer {
customer: payjp_core::CustomerId,
card: String,
}
impl DeleteCardCustomer {
pub fn new(customer:impl Into<payjp_core::CustomerId>,card:impl Into<String>) -> Self {
Self {
customer: customer.into(),card: card.into(),
}
}
}
impl DeleteCardCustomer {
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 DeleteCardCustomer {
type Output = payjp_shared::DeleteResponse;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
let card = &self.card;
RequestBuilder::new(PayjpMethod::Delete, format!("/customers/{customer}/cards/{card}"))
}
}