use stripe_client_core::{
RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
};
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct ListCustomerPaymentSourceBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
ending_before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
object: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
starting_after: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListCustomerPaymentSourceBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListCustomerPaymentSourceBuilder").finish_non_exhaustive()
}
}
impl ListCustomerPaymentSourceBuilder {
fn new() -> Self {
Self { ending_before: None, expand: None, limit: None, object: None, starting_after: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct ListCustomerPaymentSource {
inner: ListCustomerPaymentSourceBuilder,
customer: stripe_shared::CustomerId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListCustomerPaymentSource {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListCustomerPaymentSource").finish_non_exhaustive()
}
}
impl ListCustomerPaymentSource {
pub fn new(customer: impl Into<stripe_shared::CustomerId>) -> Self {
Self { customer: customer.into(), inner: ListCustomerPaymentSourceBuilder::new() }
}
pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
self.inner.ending_before = Some(ending_before.into());
self
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
pub fn limit(mut self, limit: impl Into<i64>) -> Self {
self.inner.limit = Some(limit.into());
self
}
pub fn object(mut self, object: impl Into<String>) -> Self {
self.inner.object = Some(object.into());
self
}
pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
self.inner.starting_after = Some(starting_after.into());
self
}
}
impl ListCustomerPaymentSource {
pub async fn send<C: StripeClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err> {
self.customize().send(client).await
}
pub fn send_blocking<C: StripeBlockingClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err> {
self.customize().send_blocking(client)
}
pub fn paginate(
&self,
) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::PaymentSource>> {
let customer = &self.customer;
stripe_client_core::ListPaginator::new_list(
format!("/customers/{customer}/sources"),
&self.inner,
)
}
}
impl StripeRequest for ListCustomerPaymentSource {
type Output = stripe_types::List<stripe_shared::PaymentSource>;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
RequestBuilder::new(StripeMethod::Get, format!("/customers/{customer}/sources"))
.query(&self.inner)
}
}
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct RetrievePaymentSourceBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrievePaymentSourceBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrievePaymentSourceBuilder").finish_non_exhaustive()
}
}
impl RetrievePaymentSourceBuilder {
fn new() -> Self {
Self { expand: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct RetrievePaymentSource {
inner: RetrievePaymentSourceBuilder,
customer: stripe_shared::CustomerId,
id: String,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrievePaymentSource {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrievePaymentSource").finish_non_exhaustive()
}
}
impl RetrievePaymentSource {
pub fn new(customer: impl Into<stripe_shared::CustomerId>, id: impl Into<String>) -> Self {
Self {
customer: customer.into(),
id: id.into(),
inner: RetrievePaymentSourceBuilder::new(),
}
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
}
impl RetrievePaymentSource {
pub async fn send<C: StripeClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err> {
self.customize().send(client).await
}
pub fn send_blocking<C: StripeBlockingClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err> {
self.customize().send_blocking(client)
}
}
impl StripeRequest for RetrievePaymentSource {
type Output = stripe_shared::PaymentSource;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
let id = &self.id;
RequestBuilder::new(StripeMethod::Get, format!("/customers/{customer}/sources/{id}"))
.query(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct CreateCustomerPaymentSourceBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<std::collections::HashMap<String, String>>,
source: String,
#[serde(skip_serializing_if = "Option::is_none")]
validate: Option<bool>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateCustomerPaymentSourceBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateCustomerPaymentSourceBuilder").finish_non_exhaustive()
}
}
impl CreateCustomerPaymentSourceBuilder {
fn new(source: impl Into<String>) -> Self {
Self { expand: None, metadata: None, source: source.into(), validate: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CreateCustomerPaymentSource {
inner: CreateCustomerPaymentSourceBuilder,
customer: stripe_shared::CustomerId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateCustomerPaymentSource {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateCustomerPaymentSource").finish_non_exhaustive()
}
}
impl CreateCustomerPaymentSource {
pub fn new(customer: impl Into<stripe_shared::CustomerId>, source: impl Into<String>) -> Self {
Self {
customer: customer.into(),
inner: CreateCustomerPaymentSourceBuilder::new(source.into()),
}
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.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 validate(mut self, validate: impl Into<bool>) -> Self {
self.inner.validate = Some(validate.into());
self
}
}
impl CreateCustomerPaymentSource {
pub async fn send<C: StripeClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err> {
self.customize().send(client).await
}
pub fn send_blocking<C: StripeBlockingClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err> {
self.customize().send_blocking(client)
}
}
impl StripeRequest for CreateCustomerPaymentSource {
type Output = stripe_shared::PaymentSource;
fn build(&self) -> RequestBuilder {
let customer = &self.customer;
RequestBuilder::new(StripeMethod::Post, format!("/customers/{customer}/sources"))
.form(&self.inner)
}
}