hatang 0.3.0

Official Rust client for the Ha Tang (Hạ Tầng) API: transactional email, live chat and support CRM, VietQR payments, AI chatbot knowledge and webhook verification. Async (Tokio) and blocking.
Documentation
//! The official Rust client for the [Ha Tang](https://hatang.dev) (Hạ Tầng) API: transactional email, live chat
//! and support CRM, plans and purchases on the customer's profile, the AI chatbot's knowledge, VietQR payments and
//! webhook verification. Async (Tokio) and blocking.
//!
//! ```no_run
//! use hatang::{Hatang, Platform, SubscriptionUpsert};
//!
//! # async fn run() -> hatang::Result<()> {
//! let hatang = Hatang::from_env()?; // reads HATANG_API_KEY; or Hatang::new("ht_…")
//!
//! // What a customer pays for, from your backend (web sales included).
//! hatang.chat.subscriptions.upsert(Platform::Web, "sub_123", &SubscriptionUpsert {
//!     status: "active".into(),
//!     sku: Some("PRO-1M".into()),                  // finds the product in your catalog
//!     external_user_id: Some("user-42".into()),    // the id you pass to identify() in the chat
//!     current_period_end: Some("2026-12-01T00:00:00Z".into()),
//!     amount: Some(99000.0),
//!     currency: Some("VND".into()),
//!     ..Default::default()
//! }).await?;
//! # Ok(()) }
//! ```
//!
//! - [`Hatang`] is async (any runtime that drives `reqwest`, Tokio in practice). With the `blocking` feature,
//!   `blocking::Hatang` has the same methods and returns results directly.
//! - Bodies take `impl Serialize`: the typed structs in this crate, or `serde_json::json!` for anything else.
//!   Responses are `serde_json::Value`, as the API sends them.
//! - Errors are [`Error`]; [`Error::retryable`] tells what can succeed later (unreachable, rate limits, a
//!   request still running with the same idempotency key, 5xx) from mistakes, with [`Error::retry_after`];
//!   [`Error::is_quota_exceeded`] flags the daily email quota.
//! - [`verify_webhook`] and [`verify_ipn`] check what Ha Tang sends to your endpoints.
#![doc(
    html_logo_url = "https://hatang.dev/logo-mark.svg",
    html_favicon_url = "https://hatang.dev/logo-mark.svg"
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_debug_implementations)]

mod client;
mod error;
mod helpers;
pub mod resources;
mod transport;
pub mod types;
pub mod webhooks;

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

pub use client::{Client, Hatang, HatangBuilder, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, VERSION};
pub use error::{Error, Result};
pub use helpers::{identity_hash, purchase_token};
pub use resources::Contact;
#[cfg(feature = "blocking")]
pub use transport::Blocking;
#[doc(hidden)]
pub use transport::Req;
pub use transport::{Async, BoxFuture, Executor};
pub use types::*;
pub use webhooks::{
    construct_ipn_event, construct_webhook_event, verify_ipn, verify_webhook, Headers,
};

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