Skip to main content

Crate invoist

Crate invoist 

Source
Expand description

The official Rust client for the Invoist API: turn invoices into structured data, read a household’s bills, and verify the webhooks Invoist sends.

§A business workspace

use invoist::{Client, UploadFile, WaitOptions};

let client = Client::from_env()?; // INVOIST_API_KEY
let file = UploadFile::from_path_async("invoice.pdf").await.expect("readable file");
let done = client.extract_and_wait(file, WaitOptions::default()).await?;
println!("{:?} owes {:?} cents", done.extraction.vendor_name, done.extraction.total_cents);

§A household

use invoist::{Client, ListBillsParams};

let client = Client::from_env()?;
let unpaid = client
    .bills()
    .list(ListBillsParams { paid: Some(false), ..Default::default() })
    .await?;
for bill in unpaid {
    println!("{:?}: {:?} due {:?}", bill.vendor_name, bill.total_cents, bill.due_date);
}

§Errors, retries, cancellation

Every failure is an Error with an HTTP status (0 when no response arrived), a stable code, and the response’s request_id. Failures worth retrying (no response, 429, 5xx) are retried up to twice, honouring Retry-After (a wait above 60 seconds fails at once instead), otherwise backing off from 500ms with jitter. Dropping a call’s future cancels it.

§Features

  • rustls-tls (default): TLS through rustls. No OpenSSL.
  • native-tls: TLS through the platform’s library instead.
  • http2: HTTP/2 when the server offers it.
  • blocking: blocking::Client, for code without an async runtime.

Money is always an i64 in minor units (cents), never a float.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use bytes;
pub use reqwest;

Modules§

blockingblocking
A synchronous client, for programs without an async runtime.
error
The one error type every call returns.
models
Request and response types, generated from the API’s OpenAPI document.
webhooks
Verifying the webhooks Invoist sends.

Structs§

Bills
A household’s bills (Invoist Personal), from Client::bills.
BillsStatsParams
Options for Bills::stats.
BillsSummaryParams
Options for Bills::summary.
Client
The Invoist API client.
ClientBuilder
Configures a Client. Start with Client::builder.
CreateWebhookEndpoint
A webhook endpoint to register with Client::create_webhook_endpoint.
ExtractOptions
Options for Client::extract.
ExtractedDocument
A document and its finished extraction, from Client::extract_and_wait.
FileDownload
A downloaded file: its bytes exactly as uploaded, and its media type.
HeldEmails
Emails forwarded to a household that wait for approval, from Client::held_emails.
ListBillsParams
Filters for Bills::list.
ListDocumentsParams
Filters for Client::list_documents.
ListReviewQueueParams
Filters for Client::list_review_queue.
Month
A calendar month, sent to the API as YYYY-MM.
UploadFile
A file to upload: its bytes, a filename, and optionally a media type.
WaitOptions
How long Client::wait_for_extraction waits, and how often it asks.

Enums§

ReviewResolution
How Client::resolve_review_item closes an item.

Constants§

DEFAULT_BASE_URL
The production API.
DEFAULT_MAX_RETRIES
How many times a retryable failure is retried (so at most three attempts).
DEFAULT_TIMEOUT
How long one attempt may take before it fails with code timeout.
USER_AGENT
The User-Agent every request sends.