wave-api 0.1.0

Typed Rust client for the Wave Accounting GraphQL API
Documentation
use serde::{Deserialize, Serialize};

/// Status of an invoice.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum InvoiceStatus {
    Draft,
    Saved,
    Sent,
    Viewed,
    Overdue,
    Partial,
    Paid,
}

/// Status used when creating or patching an invoice.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum InvoiceCreateStatus {
    Draft,
    Saved,
}

/// How an invoice was sent.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum InvoiceSendMethod {
    NotSent,
    WaveSend,
    ManualMarkSent,
    Skipped,
}

/// Type of discount applied to an invoice.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum InvoiceDiscountType {
    Fixed,
    Percentage,
}

/// Sort fields for invoices.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum InvoiceSort {
    CreatedAtAsc,
    CreatedAtDesc,
    ModifiedAtAsc,
    ModifiedAtDesc,
    InvoiceDateAsc,
    InvoiceDateDesc,
    InvoiceNumberAsc,
    InvoiceNumberDesc,
    DueDateAsc,
    DueDateDesc,
}

/// Sort fields for customers.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum CustomerSort {
    CreatedAtAsc,
    CreatedAtDesc,
    ModifiedAtAsc,
    ModifiedAtDesc,
    NameAsc,
    NameDesc,
}

/// Sort fields for products.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ProductSort {
    CreatedAtAsc,
    CreatedAtDesc,
    ModifiedAtAsc,
    ModifiedAtDesc,
    NameAsc,
    NameDesc,
}

/// Account type values.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum AccountTypeValue {
    Asset,
    Equity,
    Expense,
    Income,
    Liability,
}

/// Account normal balance type.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum AccountNormalBalanceType {
    Credit,
    Debit,
}

/// Account subtype values.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum AccountSubtypeValue {
    CashAndBank,
    CostOfGoodsSold,
    CreditCard,
    CustomerPrepaymentsAndCredits,
    DepreciationAndAmortization,
    Discounts,
    DueForPayroll,
    DueToYouAndOtherOwners,
    Expense,
    GainOnForeignExchange,
    Income,
    Inventory,
    Loans,
    LossOnForeignExchange,
    MoneyInTransit,
    NonRetainedEarnings,
    OtherCurrentAssets,
    OtherCurrentLiability,
    OtherIncome,
    OtherLongTermAssets,
    OtherLongTermLiability,
    Payable,
    PayableBills,
    PayableOther,
    PaymentProcessingFees,
    PayrollExpenses,
    PropertyPlantEquipment,
    Receivable,
    ReceivableInvoices,
    ReceivableOther,
    RetainedEarnings,
    SalesTax,
    SystemCustomerCredits,
    Transfers,
    UncategorizedExpense,
    UncategorizedIncome,
    UnknownAccount,
    VendorPrepaymentsAndCredits,
}

/// Direction of a transaction anchor.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum TransactionDirection {
    Deposit,
    Withdrawal,
}

/// Balance type for line items.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum BalanceType {
    Credit,
    Debit,
    Decrease,
    Increase,
}

/// Origin of a transaction.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum TransactionOrigin {
    Api,
}

/// Organizational type of a business.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum OrganizationalType {
    SoleProprietor,
    Partnership,
    Corporation,
    NonProfit,
}

/// Currency codes (ISO 4217). Common codes included; the full set is large.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CurrencyCode {
    USD,
    CAD,
    EUR,
    GBP,
    AUD,
    NZD,
    JPY,
    CNY,
    INR,
    BRL,
    MXN,
    CHF,
    SEK,
    NOK,
    DKK,
    ZAR,
    HKD,
    SGD,
    KRW,
    TWD,
    THB,
    PHP,
    IDR,
    MYR,
    VND,
    AED,
    SAR,
    ILS,
    TRY,
    PLN,
    CZK,
    HUF,
    RON,
    BGN,
    HRK,
    RUB,
    UAH,
    EGP,
    NGN,
    KES,
    GHS,
    COP,
    PEN,
    ARS,
    CLP,
    PKR,
    BDT,
    LKR,
    MMK,
    NPR,
    /// Catch-all for codes not listed above.
    #[serde(untagged)]
    Other(String),
}

impl std::fmt::Display for CurrencyCode {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            CurrencyCode::Other(s) => write!(f, "{s}"),
            other => write!(f, "{other:?}"),
        }
    }
}

/// Country codes (ISO 3166-1 alpha-2). Common codes included.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CountryCode {
    US,
    CA,
    GB,
    AU,
    NZ,
    IE,
    DE,
    FR,
    ES,
    IT,
    NL,
    BE,
    AT,
    CH,
    SE,
    NO,
    DK,
    FI,
    PT,
    JP,
    CN,
    IN,
    BR,
    MX,
    ZA,
    SG,
    HK,
    KR,
    TW,
    PH,
    MY,
    ID,
    TH,
    VN,
    AE,
    SA,
    IL,
    TR,
    PL,
    CZ,
    HU,
    RO,
    BG,
    HR,
    RU,
    UA,
    EG,
    NG,
    KE,
    GH,
    CO,
    PE,
    AR,
    CL,
    PK,
    BD,
    LK,
    NP,
    /// Catch-all for codes not listed above.
    #[serde(untagged)]
    Other(String),
}

impl std::fmt::Display for CountryCode {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            CountryCode::Other(s) => write!(f, "{s}"),
            other => write!(f, "{other:?}"),
        }
    }
}