snippe 0.1.0

Async Rust client for the Snippe payments API (Tanzania) — collections, hosted checkout sessions, disbursements, and verified webhooks.
Documentation
//! Client configuration constants and the [`Environment`] enum.

use std::time::Duration;

/// Production base URL (`https://api.snippe.sh`).
pub const PRODUCTION_BASE_URL: &str = "https://api.snippe.sh";

/// Sandbox base URL. The Snippe documentation only references the production
/// base URL — `sandbox.snippe.sh` is the conventional name. If your dashboard
/// documents a different sandbox host, override it via
/// [`crate::ClientBuilder::base_url`].
pub const SANDBOX_BASE_URL: &str = "https://sandbox.snippe.sh";

/// Default request timeout — 30 seconds.
pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);

/// Default Snippe API version targeted by this SDK.
pub const DEFAULT_API_VERSION: &str = "2026-01-25";

/// `User-Agent` value sent on every request.
pub const USER_AGENT: &str = concat!("snippe-rust/", env!("CARGO_PKG_VERSION"));

/// Which Snippe environment the client targets.
///
/// Convenience wrapper around the base URL — equivalent to passing the
/// matching string to [`crate::ClientBuilder::base_url`].
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)]
pub enum Environment {
    /// Sandbox — development and integration testing.
    Sandbox,
    /// Production — live customer traffic.
    #[default]
    Production,
}

impl Environment {
    /// Base URL for this environment.
    pub const fn base_url(self) -> &'static str {
        match self {
            Self::Sandbox => SANDBOX_BASE_URL,
            Self::Production => PRODUCTION_BASE_URL,
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn environment_base_urls() {
        assert_eq!(Environment::Production.base_url(), PRODUCTION_BASE_URL);
        assert_eq!(Environment::Sandbox.base_url(), SANDBOX_BASE_URL);
    }

    #[test]
    fn default_environment_is_production() {
        assert_eq!(Environment::default(), Environment::Production);
    }
}