hatang 0.1.0

Official Rust SDK for Ha Tang (Hạ Tầng): support CRM and live chat, plans and purchases, the AI assistant's knowledge, email, VietQR payments and webhooks.
Documentation
//! The official Rust SDK for [Ha Tang](https://hatang.dev) (Hạ Tầng): customer support CRM and live chat, plans
//! and purchases on the customer's profile, the AI assistant's knowledge, email, VietQR payments and webhooks.
//!
//! ```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 outages (unreachable, 429, 5xx) from mistakes.
//! - [`verify_webhook`] and [`verify_ipn`] check what Ha Tang sends to your endpoints.
#![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;