use serde::{Deserialize, Serialize};
use crate::ids::IssuingDisputeId;
use crate::params::{Expandable, Metadata, Object, Timestamp};
use crate::resources::{
BalanceTransaction, Currency, File, IssuingDisputeStatus, IssuingTransaction,
};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDispute {
pub id: IssuingDisputeId,
pub amount: i64,
pub balance_transactions: Option<Vec<BalanceTransaction>>,
pub created: Timestamp,
pub currency: Currency,
pub evidence: IssuingDisputeEvidence,
pub livemode: bool,
pub metadata: Metadata,
pub status: IssuingDisputeStatus,
pub transaction: Expandable<IssuingTransaction>,
#[serde(skip_serializing_if = "Option::is_none")]
pub treasury: Option<IssuingDisputeTreasury>,
}
impl Object for IssuingDispute {
type Id = IssuingDisputeId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"issuing.dispute"
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeEvidence {
#[serde(skip_serializing_if = "Option::is_none")]
pub canceled: Option<IssuingDisputeCanceledEvidence>,
#[serde(skip_serializing_if = "Option::is_none")]
pub duplicate: Option<IssuingDisputeDuplicateEvidence>,
#[serde(skip_serializing_if = "Option::is_none")]
pub fraudulent: Option<IssuingDisputeFraudulentEvidence>,
#[serde(skip_serializing_if = "Option::is_none")]
pub merchandise_not_as_described: Option<IssuingDisputeMerchandiseNotAsDescribedEvidence>,
#[serde(skip_serializing_if = "Option::is_none")]
pub not_received: Option<IssuingDisputeNotReceivedEvidence>,
#[serde(skip_serializing_if = "Option::is_none")]
pub other: Option<IssuingDisputeOtherEvidence>,
pub reason: IssuingDisputeEvidenceReason,
#[serde(skip_serializing_if = "Option::is_none")]
pub service_not_as_described: Option<IssuingDisputeServiceNotAsDescribedEvidence>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeCanceledEvidence {
pub additional_documentation: Option<Expandable<File>>,
pub canceled_at: Option<Timestamp>,
pub cancellation_policy_provided: Option<bool>,
pub cancellation_reason: Option<String>,
pub expected_at: Option<Timestamp>,
pub explanation: Option<String>,
pub product_description: Option<String>,
pub product_type: Option<IssuingDisputeCanceledEvidenceProductType>,
pub return_status: Option<IssuingDisputeCanceledEvidenceReturnStatus>,
pub returned_at: Option<Timestamp>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeDuplicateEvidence {
pub additional_documentation: Option<Expandable<File>>,
pub card_statement: Option<Expandable<File>>,
pub cash_receipt: Option<Expandable<File>>,
pub check_image: Option<Expandable<File>>,
pub explanation: Option<String>,
pub original_transaction: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeFraudulentEvidence {
pub additional_documentation: Option<Expandable<File>>,
pub explanation: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeMerchandiseNotAsDescribedEvidence {
pub additional_documentation: Option<Expandable<File>>,
pub explanation: Option<String>,
pub received_at: Option<Timestamp>,
pub return_description: Option<String>,
pub return_status: Option<IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus>,
pub returned_at: Option<Timestamp>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeNotReceivedEvidence {
pub additional_documentation: Option<Expandable<File>>,
pub expected_at: Option<Timestamp>,
pub explanation: Option<String>,
pub product_description: Option<String>,
pub product_type: Option<IssuingDisputeNotReceivedEvidenceProductType>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeOtherEvidence {
pub additional_documentation: Option<Expandable<File>>,
pub explanation: Option<String>,
pub product_description: Option<String>,
pub product_type: Option<IssuingDisputeOtherEvidenceProductType>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeServiceNotAsDescribedEvidence {
pub additional_documentation: Option<Expandable<File>>,
pub canceled_at: Option<Timestamp>,
pub cancellation_reason: Option<String>,
pub explanation: Option<String>,
pub received_at: Option<Timestamp>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IssuingDisputeTreasury {
pub debit_reversal: Option<String>,
pub received_debit: String,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingDisputeCanceledEvidenceProductType {
Merchandise,
Service,
}
impl IssuingDisputeCanceledEvidenceProductType {
pub fn as_str(self) -> &'static str {
match self {
IssuingDisputeCanceledEvidenceProductType::Merchandise => "merchandise",
IssuingDisputeCanceledEvidenceProductType::Service => "service",
}
}
}
impl AsRef<str> for IssuingDisputeCanceledEvidenceProductType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IssuingDisputeCanceledEvidenceProductType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IssuingDisputeCanceledEvidenceProductType {
fn default() -> Self {
Self::Merchandise
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingDisputeCanceledEvidenceReturnStatus {
MerchantRejected,
Successful,
}
impl IssuingDisputeCanceledEvidenceReturnStatus {
pub fn as_str(self) -> &'static str {
match self {
IssuingDisputeCanceledEvidenceReturnStatus::MerchantRejected => "merchant_rejected",
IssuingDisputeCanceledEvidenceReturnStatus::Successful => "successful",
}
}
}
impl AsRef<str> for IssuingDisputeCanceledEvidenceReturnStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IssuingDisputeCanceledEvidenceReturnStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IssuingDisputeCanceledEvidenceReturnStatus {
fn default() -> Self {
Self::MerchantRejected
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingDisputeEvidenceReason {
Canceled,
Duplicate,
Fraudulent,
MerchandiseNotAsDescribed,
NotReceived,
Other,
ServiceNotAsDescribed,
}
impl IssuingDisputeEvidenceReason {
pub fn as_str(self) -> &'static str {
match self {
IssuingDisputeEvidenceReason::Canceled => "canceled",
IssuingDisputeEvidenceReason::Duplicate => "duplicate",
IssuingDisputeEvidenceReason::Fraudulent => "fraudulent",
IssuingDisputeEvidenceReason::MerchandiseNotAsDescribed => {
"merchandise_not_as_described"
}
IssuingDisputeEvidenceReason::NotReceived => "not_received",
IssuingDisputeEvidenceReason::Other => "other",
IssuingDisputeEvidenceReason::ServiceNotAsDescribed => "service_not_as_described",
}
}
}
impl AsRef<str> for IssuingDisputeEvidenceReason {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IssuingDisputeEvidenceReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IssuingDisputeEvidenceReason {
fn default() -> Self {
Self::Canceled
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus {
MerchantRejected,
Successful,
}
impl IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus {
pub fn as_str(self) -> &'static str {
match self {
IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus::MerchantRejected => {
"merchant_rejected"
}
IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus::Successful => "successful",
}
}
}
impl AsRef<str> for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus {
fn default() -> Self {
Self::MerchantRejected
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingDisputeNotReceivedEvidenceProductType {
Merchandise,
Service,
}
impl IssuingDisputeNotReceivedEvidenceProductType {
pub fn as_str(self) -> &'static str {
match self {
IssuingDisputeNotReceivedEvidenceProductType::Merchandise => "merchandise",
IssuingDisputeNotReceivedEvidenceProductType::Service => "service",
}
}
}
impl AsRef<str> for IssuingDisputeNotReceivedEvidenceProductType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IssuingDisputeNotReceivedEvidenceProductType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IssuingDisputeNotReceivedEvidenceProductType {
fn default() -> Self {
Self::Merchandise
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingDisputeOtherEvidenceProductType {
Merchandise,
Service,
}
impl IssuingDisputeOtherEvidenceProductType {
pub fn as_str(self) -> &'static str {
match self {
IssuingDisputeOtherEvidenceProductType::Merchandise => "merchandise",
IssuingDisputeOtherEvidenceProductType::Service => "service",
}
}
}
impl AsRef<str> for IssuingDisputeOtherEvidenceProductType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IssuingDisputeOtherEvidenceProductType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IssuingDisputeOtherEvidenceProductType {
fn default() -> Self {
Self::Merchandise
}
}