invoist 1.0.1

Official Rust client for the Invoist API: extract invoices, read a household's bills, verify webhooks.
Documentation
//! The official Rust client for the [Invoist API](https://invoi.st/docs):
//! turn invoices into structured data, read a household's bills, and verify
//! the webhooks Invoist sends.
//!
//! # A business workspace
//!
//! ```no_run
//! # async fn run() -> Result<(), invoist::Error> {
//! 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);
//! # Ok(())
//! # }
//! ```
//!
//! # A household
//!
//! ```no_run
//! # async fn run() -> Result<(), invoist::Error> {
//! 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);
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Errors, retries, cancellation
//!
//! Every failure is an [`Error`] with an HTTP [`status`](Error::status) (0 when
//! no response arrived), a stable [`code`](Error::code), and the response's
//! [`request_id`](Error::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.

#![cfg_attr(docsrs, feature(doc_cfg))]

mod macros;
pub(crate) use macros::string_enum;

mod bills;
mod client;
pub mod error;
mod files;
pub mod models;
mod month;
mod params;
mod retry;
pub mod webhooks;

#[cfg(feature = "blocking")]
#[cfg_attr(docsrs, doc(cfg(feature = "blocking")))]
pub mod blocking;

pub use bills::{Bills, HeldEmails};
pub use client::{
    Client, ClientBuilder, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT,
    ExtractedDocument,
};
pub use error::{Error, Result};
pub use files::{FileDownload, UploadFile};
pub use month::Month;
pub use params::{
    BillsStatsParams, BillsSummaryParams, CreateWebhookEndpoint, ExtractOptions, ListBillsParams,
    ListDocumentsParams, ListReviewQueueParams, ReviewResolution, WaitOptions,
};

/// The `bytes` crate, whose `Bytes` holds uploads and downloads.
pub use bytes;
/// The `reqwest` crate this client is built on, to build a custom
/// [`reqwest::Client`] for [`ClientBuilder::http_client`] with the same
/// version.
pub use reqwest;

/// The `User-Agent` every request sends.
pub const USER_AGENT: &str = client::USER_AGENT;

#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;