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 ListRefundBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
charge: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
created: Option<stripe_types::RangeQueryTs>,
#[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")]
payment_intent: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
starting_after: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListRefundBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListRefundBuilder").finish_non_exhaustive()
}
}
impl ListRefundBuilder {
fn new() -> Self {
Self {
charge: None,
created: None,
ending_before: None,
expand: None,
limit: None,
payment_intent: None,
starting_after: None,
}
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct ListRefund {
inner: ListRefundBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListRefund {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListRefund").finish_non_exhaustive()
}
}
impl ListRefund {
pub fn new() -> Self {
Self { inner: ListRefundBuilder::new() }
}
pub fn charge(mut self, charge: impl Into<String>) -> Self {
self.inner.charge = Some(charge.into());
self
}
pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
self.inner.created = Some(created.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 payment_intent(mut self, payment_intent: impl Into<String>) -> Self {
self.inner.payment_intent = Some(payment_intent.into());
self
}
pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
self.inner.starting_after = Some(starting_after.into());
self
}
}
impl Default for ListRefund {
fn default() -> Self {
Self::new()
}
}
impl ListRefund {
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::Refund>> {
stripe_client_core::ListPaginator::new_list("/refunds", &self.inner)
}
}
impl StripeRequest for ListRefund {
type Output = stripe_types::List<stripe_shared::Refund>;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(StripeMethod::Get, "/refunds").query(&self.inner)
}
}
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct RetrieveRefundBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrieveRefundBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrieveRefundBuilder").finish_non_exhaustive()
}
}
impl RetrieveRefundBuilder {
fn new() -> Self {
Self { expand: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct RetrieveRefund {
inner: RetrieveRefundBuilder,
refund: stripe_shared::RefundId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrieveRefund {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrieveRefund").finish_non_exhaustive()
}
}
impl RetrieveRefund {
pub fn new(refund: impl Into<stripe_shared::RefundId>) -> Self {
Self { refund: refund.into(), inner: RetrieveRefundBuilder::new() }
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
}
impl RetrieveRefund {
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 RetrieveRefund {
type Output = stripe_shared::Refund;
fn build(&self) -> RequestBuilder {
let refund = &self.refund;
RequestBuilder::new(StripeMethod::Get, format!("/refunds/{refund}")).query(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct CreateRefundBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
amount: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
charge: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
currency: Option<stripe_types::Currency>,
#[serde(skip_serializing_if = "Option::is_none")]
customer: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
instructions_email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<std::collections::HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
origin: Option<CreateRefundOrigin>,
#[serde(skip_serializing_if = "Option::is_none")]
payment_intent: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
reason: Option<CreateRefundReason>,
#[serde(skip_serializing_if = "Option::is_none")]
refund_application_fee: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
reverse_transfer: Option<bool>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateRefundBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateRefundBuilder").finish_non_exhaustive()
}
}
impl CreateRefundBuilder {
fn new() -> Self {
Self {
amount: None,
charge: None,
currency: None,
customer: None,
expand: None,
instructions_email: None,
metadata: None,
origin: None,
payment_intent: None,
reason: None,
refund_application_fee: None,
reverse_transfer: None,
}
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CreateRefundOrigin {
CustomerBalance,
Unknown(String),
}
impl CreateRefundOrigin {
pub fn as_str(&self) -> &str {
use CreateRefundOrigin::*;
match self {
CustomerBalance => "customer_balance",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CreateRefundOrigin {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CreateRefundOrigin::*;
match s {
"customer_balance" => Ok(CustomerBalance),
v => {
tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreateRefundOrigin");
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CreateRefundOrigin {
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 CreateRefundOrigin {
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 CreateRefundOrigin {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CreateRefundOrigin)).finish_non_exhaustive()
}
}
impl serde::Serialize for CreateRefundOrigin {
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 CreateRefundOrigin {
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 CreateRefundReason {
Duplicate,
Fraudulent,
RequestedByCustomer,
Unknown(String),
}
impl CreateRefundReason {
pub fn as_str(&self) -> &str {
use CreateRefundReason::*;
match self {
Duplicate => "duplicate",
Fraudulent => "fraudulent",
RequestedByCustomer => "requested_by_customer",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CreateRefundReason {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CreateRefundReason::*;
match s {
"duplicate" => Ok(Duplicate),
"fraudulent" => Ok(Fraudulent),
"requested_by_customer" => Ok(RequestedByCustomer),
v => {
tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreateRefundReason");
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CreateRefundReason {
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 CreateRefundReason {
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 CreateRefundReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CreateRefundReason)).finish_non_exhaustive()
}
}
impl serde::Serialize for CreateRefundReason {
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 CreateRefundReason {
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 CreateRefund {
inner: CreateRefundBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateRefund {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateRefund").finish_non_exhaustive()
}
}
impl CreateRefund {
pub fn new() -> Self {
Self { inner: CreateRefundBuilder::new() }
}
pub fn amount(mut self, amount: impl Into<i64>) -> Self {
self.inner.amount = Some(amount.into());
self
}
pub fn charge(mut self, charge: impl Into<String>) -> Self {
self.inner.charge = Some(charge.into());
self
}
pub fn currency(mut self, currency: impl Into<stripe_types::Currency>) -> Self {
self.inner.currency = Some(currency.into());
self
}
pub fn customer(mut self, customer: impl Into<String>) -> Self {
self.inner.customer = Some(customer.into());
self
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
pub fn instructions_email(mut self, instructions_email: impl Into<String>) -> Self {
self.inner.instructions_email = Some(instructions_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 origin(mut self, origin: impl Into<CreateRefundOrigin>) -> Self {
self.inner.origin = Some(origin.into());
self
}
pub fn payment_intent(mut self, payment_intent: impl Into<String>) -> Self {
self.inner.payment_intent = Some(payment_intent.into());
self
}
pub fn reason(mut self, reason: impl Into<CreateRefundReason>) -> Self {
self.inner.reason = Some(reason.into());
self
}
pub fn refund_application_fee(mut self, refund_application_fee: impl Into<bool>) -> Self {
self.inner.refund_application_fee = Some(refund_application_fee.into());
self
}
pub fn reverse_transfer(mut self, reverse_transfer: impl Into<bool>) -> Self {
self.inner.reverse_transfer = Some(reverse_transfer.into());
self
}
}
impl Default for CreateRefund {
fn default() -> Self {
Self::new()
}
}
impl CreateRefund {
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 CreateRefund {
type Output = stripe_shared::Refund;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(StripeMethod::Post, "/refunds").form(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct UpdateRefundBuilder {
#[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 UpdateRefundBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("UpdateRefundBuilder").finish_non_exhaustive()
}
}
impl UpdateRefundBuilder {
fn new() -> Self {
Self { expand: None, metadata: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct UpdateRefund {
inner: UpdateRefundBuilder,
refund: stripe_shared::RefundId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateRefund {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("UpdateRefund").finish_non_exhaustive()
}
}
impl UpdateRefund {
pub fn new(refund: impl Into<stripe_shared::RefundId>) -> Self {
Self { refund: refund.into(), inner: UpdateRefundBuilder::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 UpdateRefund {
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 UpdateRefund {
type Output = stripe_shared::Refund;
fn build(&self) -> RequestBuilder {
let refund = &self.refund;
RequestBuilder::new(StripeMethod::Post, format!("/refunds/{refund}")).form(&self.inner)
}
}
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct CancelRefundBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CancelRefundBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CancelRefundBuilder").finish_non_exhaustive()
}
}
impl CancelRefundBuilder {
fn new() -> Self {
Self { expand: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CancelRefund {
inner: CancelRefundBuilder,
refund: stripe_shared::RefundId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CancelRefund {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CancelRefund").finish_non_exhaustive()
}
}
impl CancelRefund {
pub fn new(refund: impl Into<stripe_shared::RefundId>) -> Self {
Self { refund: refund.into(), inner: CancelRefundBuilder::new() }
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
}
impl CancelRefund {
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 CancelRefund {
type Output = stripe_shared::Refund;
fn build(&self) -> RequestBuilder {
let refund = &self.refund;
RequestBuilder::new(StripeMethod::Post, format!("/refunds/{refund}/cancel"))
.form(&self.inner)
}
}
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct ExpireRefundBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ExpireRefundBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ExpireRefundBuilder").finish_non_exhaustive()
}
}
impl ExpireRefundBuilder {
fn new() -> Self {
Self { expand: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct ExpireRefund {
inner: ExpireRefundBuilder,
refund: String,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ExpireRefund {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ExpireRefund").finish_non_exhaustive()
}
}
impl ExpireRefund {
pub fn new(refund: impl Into<String>) -> Self {
Self { refund: refund.into(), inner: ExpireRefundBuilder::new() }
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
}
impl ExpireRefund {
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 ExpireRefund {
type Output = stripe_shared::Refund;
fn build(&self) -> RequestBuilder {
let refund = &self.refund;
RequestBuilder::new(StripeMethod::Post, format!("/test_helpers/refunds/{refund}/expire"))
.form(&self.inner)
}
}