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 RetrieveTaxTransactionBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrieveTaxTransactionBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrieveTaxTransactionBuilder").finish_non_exhaustive()
}
}
impl RetrieveTaxTransactionBuilder {
fn new() -> Self {
Self { expand: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct RetrieveTaxTransaction {
inner: RetrieveTaxTransactionBuilder,
transaction: stripe_misc::TaxTransactionId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrieveTaxTransaction {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RetrieveTaxTransaction").finish_non_exhaustive()
}
}
impl RetrieveTaxTransaction {
pub fn new(transaction: impl Into<stripe_misc::TaxTransactionId>) -> Self {
Self { transaction: transaction.into(), inner: RetrieveTaxTransactionBuilder::new() }
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
}
impl RetrieveTaxTransaction {
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 RetrieveTaxTransaction {
type Output = stripe_misc::TaxTransaction;
fn build(&self) -> RequestBuilder {
let transaction = &self.transaction;
RequestBuilder::new(StripeMethod::Get, format!("/tax/transactions/{transaction}"))
.query(&self.inner)
}
}
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct ListLineItemsTaxTransactionBuilder {
#[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>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListLineItemsTaxTransactionBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListLineItemsTaxTransactionBuilder").finish_non_exhaustive()
}
}
impl ListLineItemsTaxTransactionBuilder {
fn new() -> Self {
Self { ending_before: None, expand: None, limit: None, starting_after: None }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct ListLineItemsTaxTransaction {
inner: ListLineItemsTaxTransactionBuilder,
transaction: stripe_misc::TaxTransactionId,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for ListLineItemsTaxTransaction {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("ListLineItemsTaxTransaction").finish_non_exhaustive()
}
}
impl ListLineItemsTaxTransaction {
pub fn new(transaction: impl Into<stripe_misc::TaxTransactionId>) -> Self {
Self { transaction: transaction.into(), inner: ListLineItemsTaxTransactionBuilder::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 starting_after(mut self, starting_after: impl Into<String>) -> Self {
self.inner.starting_after = Some(starting_after.into());
self
}
}
impl ListLineItemsTaxTransaction {
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_misc::TaxTransactionLineItem>>
{
let transaction = &self.transaction;
stripe_client_core::ListPaginator::new_list(
format!("/tax/transactions/{transaction}/line_items"),
&self.inner,
)
}
}
impl StripeRequest for ListLineItemsTaxTransaction {
type Output = stripe_types::List<stripe_misc::TaxTransactionLineItem>;
fn build(&self) -> RequestBuilder {
let transaction = &self.transaction;
RequestBuilder::new(
StripeMethod::Get,
format!("/tax/transactions/{transaction}/line_items"),
)
.query(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct CreateFromCalculationTaxTransactionBuilder {
calculation: 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")]
posted_at: Option<stripe_types::Timestamp>,
reference: String,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateFromCalculationTaxTransactionBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateFromCalculationTaxTransactionBuilder").finish_non_exhaustive()
}
}
impl CreateFromCalculationTaxTransactionBuilder {
fn new(calculation: impl Into<String>, reference: impl Into<String>) -> Self {
Self {
calculation: calculation.into(),
expand: None,
metadata: None,
posted_at: None,
reference: reference.into(),
}
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CreateFromCalculationTaxTransaction {
inner: CreateFromCalculationTaxTransactionBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateFromCalculationTaxTransaction {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateFromCalculationTaxTransaction").finish_non_exhaustive()
}
}
impl CreateFromCalculationTaxTransaction {
pub fn new(calculation: impl Into<String>, reference: impl Into<String>) -> Self {
Self {
inner: CreateFromCalculationTaxTransactionBuilder::new(
calculation.into(),
reference.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 posted_at(mut self, posted_at: impl Into<stripe_types::Timestamp>) -> Self {
self.inner.posted_at = Some(posted_at.into());
self
}
}
impl CreateFromCalculationTaxTransaction {
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 CreateFromCalculationTaxTransaction {
type Output = stripe_misc::TaxTransaction;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(StripeMethod::Post, "/tax/transactions/create_from_calculation")
.form(&self.inner)
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct CreateReversalTaxTransactionBuilder {
#[serde(skip_serializing_if = "Option::is_none")]
expand: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
flat_amount: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
line_items: Option<Vec<CreateReversalTaxTransactionLineItems>>,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<std::collections::HashMap<String, String>>,
mode: CreateReversalTaxTransactionMode,
original_transaction: String,
reference: String,
#[serde(skip_serializing_if = "Option::is_none")]
shipping_cost: Option<CreateReversalTaxTransactionShippingCost>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateReversalTaxTransactionBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateReversalTaxTransactionBuilder").finish_non_exhaustive()
}
}
impl CreateReversalTaxTransactionBuilder {
fn new(
mode: impl Into<CreateReversalTaxTransactionMode>,
original_transaction: impl Into<String>,
reference: impl Into<String>,
) -> Self {
Self {
expand: None,
flat_amount: None,
line_items: None,
metadata: None,
mode: mode.into(),
original_transaction: original_transaction.into(),
reference: reference.into(),
shipping_cost: None,
}
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CreateReversalTaxTransactionLineItems {
pub amount: i64,
pub amount_tax: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::HashMap<String, String>>,
pub original_line_item: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity: Option<u64>,
pub reference: String,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateReversalTaxTransactionLineItems {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateReversalTaxTransactionLineItems").finish_non_exhaustive()
}
}
impl CreateReversalTaxTransactionLineItems {
pub fn new(
amount: impl Into<i64>,
amount_tax: impl Into<i64>,
original_line_item: impl Into<String>,
reference: impl Into<String>,
) -> Self {
Self {
amount: amount.into(),
amount_tax: amount_tax.into(),
metadata: None,
original_line_item: original_line_item.into(),
quantity: None,
reference: reference.into(),
}
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CreateReversalTaxTransactionMode {
Full,
Partial,
Unknown(String),
}
impl CreateReversalTaxTransactionMode {
pub fn as_str(&self) -> &str {
use CreateReversalTaxTransactionMode::*;
match self {
Full => "full",
Partial => "partial",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CreateReversalTaxTransactionMode {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CreateReversalTaxTransactionMode::*;
match s {
"full" => Ok(Full),
"partial" => Ok(Partial),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"CreateReversalTaxTransactionMode"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CreateReversalTaxTransactionMode {
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 CreateReversalTaxTransactionMode {
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 CreateReversalTaxTransactionMode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CreateReversalTaxTransactionMode)).finish_non_exhaustive()
}
}
impl serde::Serialize for CreateReversalTaxTransactionMode {
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 CreateReversalTaxTransactionMode {
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(Copy, Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CreateReversalTaxTransactionShippingCost {
pub amount: i64,
pub amount_tax: i64,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateReversalTaxTransactionShippingCost {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateReversalTaxTransactionShippingCost").finish_non_exhaustive()
}
}
impl CreateReversalTaxTransactionShippingCost {
pub fn new(amount: impl Into<i64>, amount_tax: impl Into<i64>) -> Self {
Self { amount: amount.into(), amount_tax: amount_tax.into() }
}
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct CreateReversalTaxTransaction {
inner: CreateReversalTaxTransactionBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CreateReversalTaxTransaction {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CreateReversalTaxTransaction").finish_non_exhaustive()
}
}
impl CreateReversalTaxTransaction {
pub fn new(
mode: impl Into<CreateReversalTaxTransactionMode>,
original_transaction: impl Into<String>,
reference: impl Into<String>,
) -> Self {
Self {
inner: CreateReversalTaxTransactionBuilder::new(
mode.into(),
original_transaction.into(),
reference.into(),
),
}
}
pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
self.inner.expand = Some(expand.into());
self
}
pub fn flat_amount(mut self, flat_amount: impl Into<i64>) -> Self {
self.inner.flat_amount = Some(flat_amount.into());
self
}
pub fn line_items(
mut self,
line_items: impl Into<Vec<CreateReversalTaxTransactionLineItems>>,
) -> Self {
self.inner.line_items = Some(line_items.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 shipping_cost(
mut self,
shipping_cost: impl Into<CreateReversalTaxTransactionShippingCost>,
) -> Self {
self.inner.shipping_cost = Some(shipping_cost.into());
self
}
}
impl CreateReversalTaxTransaction {
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 CreateReversalTaxTransaction {
type Output = stripe_misc::TaxTransaction;
fn build(&self) -> RequestBuilder {
RequestBuilder::new(StripeMethod::Post, "/tax/transactions/create_reversal")
.form(&self.inner)
}
}