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 ListPayoutBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
arrival_date: Option<stripe_types::RangeQueryTs>,
#[serde(skip_serializing_if = "Option::is_none")]
created: Option<stripe_types::RangeQueryTs>,
#[serde(skip_serializing_if = "Option::is_none")]
destination: Option<String>,
#[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")]
starting_after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
status: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListPayoutBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListPayoutBuilder").finish_non_exhaustive()
}
}
impl ListPayoutBuilder {
fn new() -> Self {
Self {
arrival_date: None,
created: None,
destination: None,
ending_before: None,
expand: None,
limit: None,
starting_after: None,
status: None,
}
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct ListPayout {
inner: ListPayoutBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListPayout {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListPayout").finish_non_exhaustive()
}
}
impl ListPayout {
pub fn new() -> Self {
Self { inner: ListPayoutBuilder::new() }
}
pub fn arrival_date(mut self, arrival_date: impl Into<stripe_types::RangeQueryTs>) -> Self {
self.inner.arrival_date = Some(arrival_date.into());
self
}
pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
self.inner.created = Some(created.into());
self
}
pub fn destination(mut self, destination: impl Into<String>) -> Self {
self.inner.destination = Some(destination.into());
self
}
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 starting_after(mut self, starting_after: impl Into<String>) -> Self {
self.inner.starting_after = Some(starting_after.into());
self
}
pub fn status(mut self, status: impl Into<String>) -> Self {
self.inner.status = Some(status.into());
self
}
}
impl Default for ListPayout {
fn default() -> Self {
Self::new()
}
}
impl ListPayout {
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::Payout>> {
stripe_client_core::ListPaginator::new_list("/payouts", &self.inner)
}
}
impl StripeRequest for ListPayout {
type Output = stripe_types::List<stripe_shared::Payout>;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(StripeMethod::Get, "/payouts").query(&self.inner)
}
}
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct RetrievePayoutBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrievePayoutBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrievePayoutBuilder").finish_non_exhaustive()
}
}
impl RetrievePayoutBuilder {
fn new() -> Self {
Self { expand: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct RetrievePayout {
inner: RetrievePayoutBuilder,
payout: stripe_shared::PayoutId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrievePayout {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrievePayout").finish_non_exhaustive()
}
}
impl RetrievePayout {
pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
Self { payout: payout.into(), inner: RetrievePayoutBuilder::new() }
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
}
impl RetrievePayout {
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 RetrievePayout {
type Output = stripe_shared::Payout;
fn build(&self) -> RequestBuilder {
let payout = &self.payout;
RequestBuilder::new(StripeMethod::Get, format!("/payouts/{payout}")).query(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct CreatePayoutBuilder {
amount: i64,
currency: stripe_types::Currency,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
destination: Option<String>,
#[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>>,
#[serde(skip_serializing_if = "Option::is_none")]
method: Option<CreatePayoutMethod>,
#[serde(skip_serializing_if = "Option::is_none")]
payout_method: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
source_type: Option<CreatePayoutSourceType>,
#[serde(skip_serializing_if = "Option::is_none")]
statement_descriptor: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreatePayoutBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreatePayoutBuilder").finish_non_exhaustive()
}
}
impl CreatePayoutBuilder {
fn new(amount: impl Into<i64>, currency: impl Into<stripe_types::Currency>) -> Self {
Self {
amount: amount.into(),
currency: currency.into(),
description: None,
destination: None,
expand: None,
metadata: None,
method: None,
payout_method: None,
source_type: None,
statement_descriptor: None,
}
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CreatePayoutMethod {
Instant,
Standard,
Unknown(String),
}
impl CreatePayoutMethod {
pub fn as_str(&self) -> &str {
use CreatePayoutMethod::*;
match self {
Instant => "instant",
Standard => "standard",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CreatePayoutMethod {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CreatePayoutMethod::*;
match s {
"instant" => Ok(Instant),
"standard" => Ok(Standard),
v => {
tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreatePayoutMethod");
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CreatePayoutMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for CreatePayoutMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreatePayoutMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CreatePayoutMethod)).finish_non_exhaustive()
}
}
impl serde::Serialize for CreatePayoutMethod {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CreatePayoutMethod {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CreatePayoutSourceType {
BankAccount,
Card,
Fpx,
Unknown(String),
}
impl CreatePayoutSourceType {
pub fn as_str(&self) -> &str {
use CreatePayoutSourceType::*;
match self {
BankAccount => "bank_account",
Card => "card",
Fpx => "fpx",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CreatePayoutSourceType {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CreatePayoutSourceType::*;
match s {
"bank_account" => Ok(BankAccount),
"card" => Ok(Card),
"fpx" => Ok(Fpx),
v => {
tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreatePayoutSourceType");
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CreatePayoutSourceType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for CreatePayoutSourceType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreatePayoutSourceType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CreatePayoutSourceType)).finish_non_exhaustive()
}
}
impl serde::Serialize for CreatePayoutSourceType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CreatePayoutSourceType {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CreatePayout {
inner: CreatePayoutBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreatePayout {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreatePayout").finish_non_exhaustive()
}
}
impl CreatePayout {
pub fn new(amount: impl Into<i64>, currency: impl Into<stripe_types::Currency>) -> Self {
Self { inner: CreatePayoutBuilder::new(amount.into(), currency.into()) }
}
pub fn description(mut self, description: impl Into<String>) -> Self {
self.inner.description = Some(description.into());
self
}
pub fn destination(mut self, destination: impl Into<String>) -> Self {
self.inner.destination = Some(destination.into());
self
}
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 method(mut self, method: impl Into<CreatePayoutMethod>) -> Self {
self.inner.method = Some(method.into());
self
}
pub fn payout_method(mut self, payout_method: impl Into<String>) -> Self {
self.inner.payout_method = Some(payout_method.into());
self
}
pub fn source_type(mut self, source_type: impl Into<CreatePayoutSourceType>) -> Self {
self.inner.source_type = Some(source_type.into());
self
}
pub fn statement_descriptor(mut self, statement_descriptor: impl Into<String>) -> Self {
self.inner.statement_descriptor = Some(statement_descriptor.into());
self
}
}
impl CreatePayout {
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 CreatePayout {
type Output = stripe_shared::Payout;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(StripeMethod::Post, "/payouts").form(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct UpdatePayoutBuilder {
#[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>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdatePayoutBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("UpdatePayoutBuilder").finish_non_exhaustive()
}
}
impl UpdatePayoutBuilder {
fn new() -> Self {
Self { expand: None, metadata: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct UpdatePayout {
inner: UpdatePayoutBuilder,
payout: stripe_shared::PayoutId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdatePayout {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("UpdatePayout").finish_non_exhaustive()
}
}
impl UpdatePayout {
pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
Self { payout: payout.into(), inner: UpdatePayoutBuilder::new() }
}
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
}
}
impl UpdatePayout {
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 UpdatePayout {
type Output = stripe_shared::Payout;
fn build(&self) -> RequestBuilder {
let payout = &self.payout;
RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}")).form(&self.inner)
}
}
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct CancelPayoutBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CancelPayoutBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CancelPayoutBuilder").finish_non_exhaustive()
}
}
impl CancelPayoutBuilder {
fn new() -> Self {
Self { expand: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CancelPayout {
inner: CancelPayoutBuilder,
payout: stripe_shared::PayoutId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CancelPayout {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CancelPayout").finish_non_exhaustive()
}
}
impl CancelPayout {
pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
Self { payout: payout.into(), inner: CancelPayoutBuilder::new() }
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
}
impl CancelPayout {
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 CancelPayout {
type Output = stripe_shared::Payout;
fn build(&self) -> RequestBuilder {
let payout = &self.payout;
RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}/cancel"))
.form(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct ReversePayoutBuilder {
#[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>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ReversePayoutBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ReversePayoutBuilder").finish_non_exhaustive()
}
}
impl ReversePayoutBuilder {
fn new() -> Self {
Self { expand: None, metadata: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct ReversePayout {
inner: ReversePayoutBuilder,
payout: stripe_shared::PayoutId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ReversePayout {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ReversePayout").finish_non_exhaustive()
}
}
impl ReversePayout {
pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
Self { payout: payout.into(), inner: ReversePayoutBuilder::new() }
}
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
}
}
impl ReversePayout {
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 ReversePayout {
type Output = stripe_shared::Payout;
fn build(&self) -> RequestBuilder {
let payout = &self.payout;
RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}/reverse"))
.form(&self.inner)
}
}