verifex 0.2.0

Official Rust SDK for the Verifex sanctions screening API
Documentation
/// Errors returned by the Verifex SDK.
#[derive(Debug, thiserror::Error)]
pub enum VerifexError {
    /// Authentication failed (HTTP 401). Check your API key.
    #[error("authentication failed: {message}")]
    Auth {
        message: String,
        request_id: String,
    },

    /// Rate limit exceeded (HTTP 429). Wait before retrying.
    #[error("rate limit exceeded: {message}")]
    RateLimit {
        message: String,
        retry_after: u64,
        request_id: String,
    },

    /// Monthly quota exceeded (HTTP 402). Upgrade your plan.
    #[error("quota exceeded: {message}")]
    QuotaExceeded {
        message: String,
        request_id: String,
    },

    /// Other API error.
    #[error("API error [{code}]: {message}")]
    Api {
        message: String,
        code: String,
        status: u16,
        request_id: String,
    },

    /// HTTP request failed (network error, timeout, etc.).
    #[error("request failed: {0}")]
    Request(#[from] reqwest::Error),
}

impl VerifexError {
    /// Returns `true` if this is an authentication error (401).
    pub fn is_auth(&self) -> bool {
        matches!(self, Self::Auth { .. })
    }

    /// Returns `true` if this is a rate limit error (429).
    pub fn is_rate_limit(&self) -> bool {
        matches!(self, Self::RateLimit { .. })
    }

    /// Returns `true` if this is a quota exceeded error (402).
    pub fn is_quota_exceeded(&self) -> bool {
        matches!(self, Self::QuotaExceeded { .. })
    }
}