QuickBooks Types for Rust
The quickbooks-types crate provides strongly-typed Rust representations of QuickBooks Online (QBO) API entities, enabling seamless integration with QuickBooks accounting software. It is designed to work with the QuickBooks API and is ideal for building financial applications, integrations, and automation tools.
Features
- Complete Coverage: Supports all major QuickBooks entities, including:
- Accounts
- Invoices
- Customers
- Vendors
- Payments
- Sales Receipts
- Items
- Bills
- Estimates
- Attachments
- And more!
- Strong Typing: All entities are represented as Rust structs with proper types (e.g.,
NaiveDatefor dates,f64for monetary values). - Validation: Built-in validation for required fields and business rules.
- Serialization/Deserialization: Seamless integration with
serdefor JSON serialization and deserialization. - Builder Pattern: Optional builder pattern for easy object creation.
- Query Support: Helper methods for constructing SQL-like queries for QuickBooks entities.
- Error Handling: Comprehensive error types for API and validation errors.
- Async Support: Designed for use with async Rust and popular HTTP clients like
reqwest.
Installation
Add the crate to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic Example
use ;
use NaiveDate;
// Create a customer
let customer = Customer ;
// Create an invoice
let invoice = Invoice ;
// Serialize to JSON for API requests
let json = to_string.unwrap;
println!;
Querying Entities
use ;
// Query customers with a specific name
let query = query;
Builder Pattern (Optional)
Enable the builder feature in Cargo.toml:
[]
= { = "0.1.0", = ["builder"] }
Then use the builder pattern:
use ;
let invoice = default
.id
.customer_ref
.line
.build
.unwrap;
Supported Entities
The crate provides types for the following QuickBooks entities:
- Accounting:
- Account
- Budget
- Class
- Department
- TaxCode
- TaxRate
- Sales:
- Invoice
- Estimate
- SalesReceipt
- Payment
- CreditMemo
- Purchases:
- Bill
- VendorCredit
- PurchaseOrder
- Customers & Vendors:
- Customer
- Vendor
- Items:
- Item
- Inventory
- NonInventory
- Service
- Payroll:
- Employee
- TimeActivity
- Attachments:
- Attachable
- Reports:
- BalanceSheet
- ProfitAndLoss
- TrialBalance
Error Handling
The crate provides a comprehensive error type QBTypeError for handling validation and API errors:
Optional Features
- builder: Enables the builder pattern for entity creation.
- serde: Enables serialization and deserialization (enabled by default).
- chrono: Enables date/time support (enabled by default).
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or additional features.
License
This project is licensed under the MIT License. See LICENSE for details.
Documentation
For detailed documentation, visit docs.rs/quickbooks-types.