use crate::params::Timestamp;
use crate::resources::card::{CardBrand, CardType};
use serde_derive::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AccountHolderType {
Individual,
Company,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Address {
pub line1: Option<String>,
pub line2: Option<String>,
pub city: Option<String>,
pub state: Option<String>,
pub postal_code: Option<String>,
pub country: Option<String>,
pub town: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BillingDetails {
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CustomField {
pub name: String,
pub value: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Dob {
pub day: i64,
pub month: i64,
pub year: i64,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum FeeType {
ApplicationFee,
StripeFee,
Tax,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum FraudDetailsReport {
Fraudulent,
Safe,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingAuthorizationCheck {
Match,
Mismatch,
NotProvided,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingAuthorizationMethod {
KeyedIn,
Swipe,
Chip,
Contactless,
Online,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingAuthorizationReason {
AuthorizationControls,
CardActive,
CardInactive,
InsufficientFunds,
AccountComplianceDisabled,
AccountInactive,
SuspectedFraud,
WebhookApproved,
WebhookDeclined,
WebhookTimeout,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct PackageDimensions {
pub height: f64,
pub length: f64,
pub weight: f64,
pub width: f64,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct PaymentMethodCard {
#[serde(skip_serializing_if = "Option::is_none")]
pub brand: Option<CardBrand>,
pub country: String,
pub exp_month: i64,
pub exp_year: i64,
pub fingerprint: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub funding: Option<CardType>,
pub last4: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PaymentMethodDetails {
#[serde(skip_serializing_if = "Option::is_none")]
pub card: Option<PaymentMethodCard>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Period {
pub start: Timestamp,
pub end: Timestamp,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Shipping {
pub name: String,
pub address: Address,
#[serde(skip_serializing_if = "Option::is_none")]
pub carrier: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tracking_number: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ShippingParams {
pub address: Address,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SpendingLimit {
pub amount: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub categories: Option<Vec<String>>,
pub interval: SpendingLimitInterval,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum SpendingLimitInterval {
AllTime,
Daily,
Monthly,
PerAuthorization,
Weekly,
Yearly,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SubscriptionBillingThresholds {
#[serde(skip_serializing_if = "Option::is_none")]
pub amount_gte: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reset_billing_cycle_anchor: Option<bool>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SubscriptionItemBillingThresholds {
pub usage_gte: i64,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(untagged)]
pub enum DelayDays {
Days(u32),
Other(DelayDaysOther),
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum DelayDaysOther {
Minimum,
}
impl DelayDays {
pub fn days(n: u32) -> Self {
DelayDays::Days(n)
}
pub fn minimum() -> Self {
DelayDays::Other(DelayDaysOther::Minimum)
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(untagged)]
pub enum Scheduled {
Timestamp(Timestamp),
Other(ScheduledOther),
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum ScheduledOther {
Now,
}
impl Scheduled {
pub fn at(ts: Timestamp) -> Self {
Scheduled::Timestamp(ts)
}
pub fn now() -> Self {
Scheduled::Other(ScheduledOther::Now)
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(untagged)]
pub enum UpTo {
Max(u64),
Other(UpToOther),
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum UpToOther {
Inf,
}
impl UpTo {
pub fn max(n: u64) -> Self {
UpTo::Max(n)
}
pub fn now() -> Self {
UpTo::Other(UpToOther::Inf)
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum Weekday {
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
}