use crate::ids::{TreasuryInboundTransferId};
use crate::params::{Expandable, Metadata, Object, Timestamp};
use crate::resources::{Currency, TreasurySharedResourceBillingDetails, TreasuryTransaction};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryInboundTransfer {
pub id: TreasuryInboundTransferId,
pub amount: i64,
pub cancelable: bool,
pub created: Timestamp,
pub currency: Currency,
pub description: Option<String>,
pub failure_details: Option<TreasuryInboundTransfersResourceFailureDetails>,
pub financial_account: String,
pub hosted_regulatory_receipt_url: Option<String>,
pub linked_flows: TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows,
pub livemode: bool,
pub metadata: Metadata,
pub origin_payment_method: String,
pub origin_payment_method_details: Option<InboundTransfers>,
pub returned: Option<bool>,
pub statement_descriptor: String,
pub status: TreasuryInboundTransferStatus,
pub status_transitions: TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions,
pub transaction: Option<Expandable<TreasuryTransaction>>,
}
impl Object for TreasuryInboundTransfer {
type Id = TreasuryInboundTransferId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"treasury.inbound_transfer"
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct InboundTransfers {
pub billing_details: TreasurySharedResourceBillingDetails,
#[serde(rename = "type")]
pub type_: InboundTransfersType,
#[serde(skip_serializing_if = "Option::is_none")]
pub us_bank_account: Option<InboundTransfersPaymentMethodDetailsUsBankAccount>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct InboundTransfersPaymentMethodDetailsUsBankAccount {
pub account_holder_type: Option<InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType>,
pub account_type: Option<InboundTransfersPaymentMethodDetailsUsBankAccountAccountType>,
pub bank_name: Option<String>,
pub fingerprint: Option<String>,
pub last4: Option<String>,
pub network: InboundTransfersPaymentMethodDetailsUsBankAccountNetwork,
pub routing_number: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryInboundTransfersResourceFailureDetails {
pub code: TreasuryInboundTransfersResourceFailureDetailsCode,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows {
pub received_debit: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions {
#[serde(skip_serializing_if = "Option::is_none")]
pub canceled_at: Option<Timestamp>,
pub failed_at: Option<Timestamp>,
pub succeeded_at: Option<Timestamp>,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType {
Company,
Individual,
}
impl InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType {
pub fn as_str(self) -> &'static str {
match self {
InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType::Company => "company",
InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType::Individual => "individual",
}
}
}
impl AsRef<str> for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType {
fn default() -> Self {
Self::Company
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum InboundTransfersPaymentMethodDetailsUsBankAccountAccountType {
Checking,
Savings,
}
impl InboundTransfersPaymentMethodDetailsUsBankAccountAccountType {
pub fn as_str(self) -> &'static str {
match self {
InboundTransfersPaymentMethodDetailsUsBankAccountAccountType::Checking => "checking",
InboundTransfersPaymentMethodDetailsUsBankAccountAccountType::Savings => "savings",
}
}
}
impl AsRef<str> for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType {
fn default() -> Self {
Self::Checking
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum InboundTransfersPaymentMethodDetailsUsBankAccountNetwork {
Ach,
}
impl InboundTransfersPaymentMethodDetailsUsBankAccountNetwork {
pub fn as_str(self) -> &'static str {
match self {
InboundTransfersPaymentMethodDetailsUsBankAccountNetwork::Ach => "ach",
}
}
}
impl AsRef<str> for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork {
fn default() -> Self {
Self::Ach
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum InboundTransfersType {
UsBankAccount,
}
impl InboundTransfersType {
pub fn as_str(self) -> &'static str {
match self {
InboundTransfersType::UsBankAccount => "us_bank_account",
}
}
}
impl AsRef<str> for InboundTransfersType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for InboundTransfersType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for InboundTransfersType {
fn default() -> Self {
Self::UsBankAccount
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TreasuryInboundTransferStatus {
Canceled,
Failed,
Processing,
Succeeded,
}
impl TreasuryInboundTransferStatus {
pub fn as_str(self) -> &'static str {
match self {
TreasuryInboundTransferStatus::Canceled => "canceled",
TreasuryInboundTransferStatus::Failed => "failed",
TreasuryInboundTransferStatus::Processing => "processing",
TreasuryInboundTransferStatus::Succeeded => "succeeded",
}
}
}
impl AsRef<str> for TreasuryInboundTransferStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TreasuryInboundTransferStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TreasuryInboundTransferStatus {
fn default() -> Self {
Self::Canceled
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TreasuryInboundTransfersResourceFailureDetailsCode {
AccountClosed,
AccountFrozen,
BankAccountRestricted,
BankOwnershipChanged,
DebitNotAuthorized,
IncorrectAccountHolderAddress,
IncorrectAccountHolderName,
IncorrectAccountHolderTaxId,
InsufficientFunds,
InvalidAccountNumber,
InvalidCurrency,
NoAccount,
Other,
}
impl TreasuryInboundTransfersResourceFailureDetailsCode {
pub fn as_str(self) -> &'static str {
match self {
TreasuryInboundTransfersResourceFailureDetailsCode::AccountClosed => "account_closed",
TreasuryInboundTransfersResourceFailureDetailsCode::AccountFrozen => "account_frozen",
TreasuryInboundTransfersResourceFailureDetailsCode::BankAccountRestricted => "bank_account_restricted",
TreasuryInboundTransfersResourceFailureDetailsCode::BankOwnershipChanged => "bank_ownership_changed",
TreasuryInboundTransfersResourceFailureDetailsCode::DebitNotAuthorized => "debit_not_authorized",
TreasuryInboundTransfersResourceFailureDetailsCode::IncorrectAccountHolderAddress => "incorrect_account_holder_address",
TreasuryInboundTransfersResourceFailureDetailsCode::IncorrectAccountHolderName => "incorrect_account_holder_name",
TreasuryInboundTransfersResourceFailureDetailsCode::IncorrectAccountHolderTaxId => "incorrect_account_holder_tax_id",
TreasuryInboundTransfersResourceFailureDetailsCode::InsufficientFunds => "insufficient_funds",
TreasuryInboundTransfersResourceFailureDetailsCode::InvalidAccountNumber => "invalid_account_number",
TreasuryInboundTransfersResourceFailureDetailsCode::InvalidCurrency => "invalid_currency",
TreasuryInboundTransfersResourceFailureDetailsCode::NoAccount => "no_account",
TreasuryInboundTransfersResourceFailureDetailsCode::Other => "other",
}
}
}
impl AsRef<str> for TreasuryInboundTransfersResourceFailureDetailsCode {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TreasuryInboundTransfersResourceFailureDetailsCode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TreasuryInboundTransfersResourceFailureDetailsCode {
fn default() -> Self {
Self::AccountClosed
}
}