bachs-sdk 0.1.0

Unofficial Rust SDK for the Bachs API — payments and billing for internet businesses.
Documentation
//! Unofficial Rust SDK for the [Bachs API](https://docs.bachs.io) — payments
//! and billing for internet businesses.
//!
//! This is a community client, not published or endorsed by Bachs.
//!
//! # Quickstart
//!
//! ```no_run
//! use bachs_sdk::{Bachs, customers::CreateCustomerRequest};
//!
//! # async fn run() -> Result<(), bachs_sdk::BachsError> {
//! // Reads a sandbox (sk_sandbox_...) or live (sk_live_...) key and infers
//! // the right base URL from the prefix.
//! let bachs = Bachs::new(std::env::var("BACHS_API_KEY").unwrap())?;
//!
//! let customer = bachs
//!     .customers()
//!     .create(&CreateCustomerRequest::new("jane@example.com").name("Jane Doe"))
//!     .await?;
//!
//! println!("created {}", customer.customer_id);
//! # Ok(())
//! # }
//! ```
//!
//! # Conventions carried over from the API
//!
//! - **Money** is always a decimal string at the currency's precision (e.g.
//!   `"29.00"`), paired with an ISO 4217 currency code — never minor units.
//! - **Sandbox vs. production** are different hosts entirely
//!   (`sandbox-api.bachs.io` / `api.bachs.io`) with different key prefixes
//!   (`sk_sandbox_...` / `sk_live_...`). [`Bachs::new`] infers which one you
//!   mean from the key; going live is a key swap.
//! - **Webhooks are the source of truth** for fulfilment — see the
//!   [`webhooks`] module — not client-side checkout redirects.
//! - **Subscriptions** are created by completing a
//!   [checkout session](checkout_sessions::CheckoutSessions::create) against
//!   a recurring product. There's no direct create-subscription call.
//! - Resource IDs carry type prefixes (`cust_`, `prod_`, `sub_`, `chk_`,
//!   `inv_`, `ref_`, ...).
//!
//! # A note on coverage
//!
//! This SDK is built from Bachs' public documentation, not an internal
//! schema dump. The `customers` and `checkout_sessions` resources follow a
//! fully-specified OpenAPI schema and are typed strictly. Several other
//! resources (subscriptions, payments, refunds, transfers, connected
//! accounts, ...) are typed against the fields the docs and examples confirm,
//! with an `extra: FlexObject` catch-all on each response so additional
//! fields your API version returns are preserved rather than causing a
//! deserialization error. If you hit a mismatch, please open an issue.

pub mod client;
pub mod common;
pub mod error;
pub mod resources;
pub mod webhooks;

pub use client::{Bachs, BachsBuilder, Environment, RequestOptions};
pub use common::{Address, ListParams, ListResponse, Metadata, Money, Pagination, Timestamp};
pub use error::{ApiErrorBody, BachsError, BachsResult, FieldError};

// Flat re-exports so callers can write `bachs_sdk::customers::...` as shown
// in the README, matching the ergonomics of the Node SDK's `bachs.customers`.
pub use resources::accounts;
pub use resources::checkout_sessions;
pub use resources::connected_accounts;
pub use resources::customer_sessions;
pub use resources::customers;
pub use resources::media;
pub use resources::payment_rails;
pub use resources::payments;
pub use resources::products;
pub use resources::refunds;
pub use resources::subscriptions;
pub use resources::transfers;