#![deny(missing_docs)]

//! tenbin-sdk
//!
//! Official asynchronous Rust SDK for interacting with the Tenbin platform.
//!
//! ## Overview
//!
//! This crate provides a unified client for:
//! - REST-based request/response APIs (health checks, order submission, quotes)
//! - WebSocket-based streaming and event APIs (real-time order updates)
//!
//! The primary entry point is [`TenbinClient`], which exposes REST functionality
//! immediately and allows WebSocket connections to be established explicitly.
//!
//! ## Quick Start
//!
//! ```no_run
//! use tenbin_sdk::{ClientConfig, TenbinClient};
//! use url::Url;
//!
//! # async fn example() -> Result<(), tenbin_sdk::ClientError> {
//! // 1. Configure and create the client
//! let http_url = Url::parse("https://api.tenbin.io").unwrap();
//! let ws_url = Url::parse("wss://api.tenbin.io/stream").unwrap();
//! let config = ClientConfig::new(http_url, ws_url);
//! let client = TenbinClient::new(config)?;
//!
//! // 2. Use REST endpoints (unauthenticated)
//! let healthy = client.rest.health_check().await?;
//! let deployment = client.rest.get_deployment().await?;
//!
//! // 3. Submit an order (see types module for Order construction)
//! // let order_id = client.rest.submit_order(&order).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Authentication
//!
//! Several endpoints require signature-based authentication. The SDK never
//! handles private keys directly. Instead, you implement the [`signing::signer::PayloadSigner`]
//! trait to provide signing capabilities from your key management solution.
//!
//! For REST authentication, use [`signing::rest_auth::generate_auth_credentials`]
//! to create the required headers. For WebSocket authentication, the SDK handles
//! the challenge-response flow automatically via [`TenbinClient::ws_subscribe`].
//!
//! ## Design Principles
//!
//! - **Explicit over implicit**: No hidden background tasks or automatic reconnection
//! - **User-controlled signing**: The SDK constructs payloads; you sign them
//! - **Testability**: All transports are abstracted via traits for easy mocking
//! - **Clear error handling**: All errors are represented by [`ClientError`]
//!
//! ## Stability
//!
//! This crate is currently **0.x**. The API shape is intended to remain stable,
//! but lower-level modules may evolve. Prefer interacting through [`TenbinClient`]
//! unless you have advanced requirements.

/// High-level client entry point.
///
/// This module contains [`TenbinClient`], the primary type through which users
/// interact with the Tenbin platform.
pub mod client;

/// Client configuration types.
///
/// Defines the configuration required to construct a [`TenbinClient`],
/// including endpoint URLs and timeouts.
pub mod config;

/// Error types returned by this crate.
///
/// All fallible operations in this SDK return [`ClientError`].
pub mod error;

/// Signing payload construction utilities.
///
/// This module provides deterministic helpers for constructing the exact
/// payloads and digests that must be signed for authentication challenges
/// (EIP-191) and order submission (EIP-712).
///
/// The SDK never performs signing itself and never handles private keys.
/// Users are responsible only for signing the provided payloads using an
/// Ethereum-compatible signer.
pub mod signing;

/// Domain and protocol types.
///
/// Contains core domain types such as orders and statuses that are shared
/// across REST and WebSocket APIs.
pub mod types;

/// REST API client implementation.
///
/// This module provides lower-level access to Tenbin's REST endpoints.
/// Most users should access REST functionality via [`TenbinClient`].
pub mod rest;

/// WebSocket protocol and client implementation.
///
/// This module contains the WebSocket protocol definitions and client-side
/// session handling used for streaming and event-based APIs.
pub mod ws;

/// Internal transport abstractions.
///
/// This module contains HTTP and WebSocket transport implementations.
/// It is an implementation detail and not part of the public API contract.
pub(crate) mod transport;

/// Test fixtures and helpers.
///
/// This module is only available when running tests.
#[cfg(test)]
pub mod fixtures;

/// Contract bindings generated from Solidity ABIs
#[rustfmt::skip]
#[allow(missing_docs)]
#[allow(clippy::all)]
#[allow(dead_code)]
#[allow(warnings)]
pub mod bindings;

pub use client::TenbinClient;
pub use config::ClientConfig;
pub use error::ClientError;
