snippe 0.1.0

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

use snippe::{Client, Environment};

#[test]
fn defaults_to_production() {
    let c = Client::new("snp_t").unwrap();
    assert_eq!(c.base_url(), "https://api.snippe.sh");
}

#[test]
fn environment_picks_sandbox_url() {
    let c = Client::builder()
        .api_key("snp_t")
        .environment(Environment::Sandbox)
        .build()
        .unwrap();
    assert_eq!(c.base_url(), "https://sandbox.snippe.sh");
}

#[test]
fn explicit_base_url_overrides_environment() {
    let c = Client::builder()
        .api_key("snp_t")
        .environment(Environment::Production)
        .base_url("https://staging.snippe.sh")
        .build()
        .unwrap();
    assert_eq!(c.base_url(), "https://staging.snippe.sh");
}

#[test]
fn user_agent_suffix_is_validated() {
    // \n is invalid in a header value.
    let result = Client::builder()
        .api_key("snp_t")
        .user_agent_suffix("bad\nsuffix")
        .build();
    assert!(result.is_err());
}