use crate::ids::{TreasuryTransactionEntryId};
use crate::params::{Expandable, Object, Timestamp};
use crate::resources::{Currency, TreasuryTransaction, TreasuryTransactionsResourceBalanceImpact, TreasuryTransactionsResourceFlowDetails};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryTransactionEntry {
pub id: TreasuryTransactionEntryId,
pub balance_impact: TreasuryTransactionsResourceBalanceImpact,
pub created: Timestamp,
pub currency: Currency,
pub effective_at: Timestamp,
pub financial_account: String,
pub flow: Option<String>,
pub flow_details: Option<TreasuryTransactionsResourceFlowDetails>,
pub flow_type: TreasuryTransactionEntryFlowType,
pub livemode: bool,
pub transaction: Expandable<TreasuryTransaction>,
#[serde(rename = "type")]
pub type_: TreasuryTransactionEntryType,
}
impl Object for TreasuryTransactionEntry {
type Id = TreasuryTransactionEntryId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"treasury.transaction_entry"
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TreasuryTransactionEntryFlowType {
CreditReversal,
DebitReversal,
InboundTransfer,
IssuingAuthorization,
Other,
OutboundPayment,
OutboundTransfer,
ReceivedCredit,
ReceivedDebit,
}
impl TreasuryTransactionEntryFlowType {
pub fn as_str(self) -> &'static str {
match self {
TreasuryTransactionEntryFlowType::CreditReversal => "credit_reversal",
TreasuryTransactionEntryFlowType::DebitReversal => "debit_reversal",
TreasuryTransactionEntryFlowType::InboundTransfer => "inbound_transfer",
TreasuryTransactionEntryFlowType::IssuingAuthorization => "issuing_authorization",
TreasuryTransactionEntryFlowType::Other => "other",
TreasuryTransactionEntryFlowType::OutboundPayment => "outbound_payment",
TreasuryTransactionEntryFlowType::OutboundTransfer => "outbound_transfer",
TreasuryTransactionEntryFlowType::ReceivedCredit => "received_credit",
TreasuryTransactionEntryFlowType::ReceivedDebit => "received_debit",
}
}
}
impl AsRef<str> for TreasuryTransactionEntryFlowType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TreasuryTransactionEntryFlowType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TreasuryTransactionEntryFlowType {
fn default() -> Self {
Self::CreditReversal
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TreasuryTransactionEntryType {
CreditReversal,
CreditReversalPosting,
DebitReversal,
InboundTransfer,
InboundTransferReturn,
IssuingAuthorizationHold,
IssuingAuthorizationRelease,
Other,
OutboundPayment,
OutboundPaymentCancellation,
OutboundPaymentFailure,
OutboundPaymentPosting,
OutboundPaymentReturn,
OutboundTransfer,
OutboundTransferCancellation,
OutboundTransferFailure,
OutboundTransferPosting,
OutboundTransferReturn,
ReceivedCredit,
ReceivedDebit,
}
impl TreasuryTransactionEntryType {
pub fn as_str(self) -> &'static str {
match self {
TreasuryTransactionEntryType::CreditReversal => "credit_reversal",
TreasuryTransactionEntryType::CreditReversalPosting => "credit_reversal_posting",
TreasuryTransactionEntryType::DebitReversal => "debit_reversal",
TreasuryTransactionEntryType::InboundTransfer => "inbound_transfer",
TreasuryTransactionEntryType::InboundTransferReturn => "inbound_transfer_return",
TreasuryTransactionEntryType::IssuingAuthorizationHold => "issuing_authorization_hold",
TreasuryTransactionEntryType::IssuingAuthorizationRelease => "issuing_authorization_release",
TreasuryTransactionEntryType::Other => "other",
TreasuryTransactionEntryType::OutboundPayment => "outbound_payment",
TreasuryTransactionEntryType::OutboundPaymentCancellation => "outbound_payment_cancellation",
TreasuryTransactionEntryType::OutboundPaymentFailure => "outbound_payment_failure",
TreasuryTransactionEntryType::OutboundPaymentPosting => "outbound_payment_posting",
TreasuryTransactionEntryType::OutboundPaymentReturn => "outbound_payment_return",
TreasuryTransactionEntryType::OutboundTransfer => "outbound_transfer",
TreasuryTransactionEntryType::OutboundTransferCancellation => "outbound_transfer_cancellation",
TreasuryTransactionEntryType::OutboundTransferFailure => "outbound_transfer_failure",
TreasuryTransactionEntryType::OutboundTransferPosting => "outbound_transfer_posting",
TreasuryTransactionEntryType::OutboundTransferReturn => "outbound_transfer_return",
TreasuryTransactionEntryType::ReceivedCredit => "received_credit",
TreasuryTransactionEntryType::ReceivedDebit => "received_debit",
}
}
}
impl AsRef<str> for TreasuryTransactionEntryType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TreasuryTransactionEntryType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TreasuryTransactionEntryType {
fn default() -> Self {
Self::CreditReversal
}
}