invoance 0.1.0

Official Rust SDK for the Invoance compliance API
Documentation
//! Events models.

use serde::{Deserialize, Serialize};

use super::{JsonObject, OrganizationPublic};

/// Parameters for [`EventsResource::ingest`](crate::resources::events::EventsResource::ingest).
#[derive(Debug, Clone, Default)]
pub struct IngestEventParams {
    /// Wire key `event_type`.
    pub event_type: String,
    /// Wire key `payload` (JSON object).
    pub payload: JsonObject,
    /// Wire key `event_time`.
    pub event_time: Option<String>,
    /// Per-call idempotency key.
    pub idempotency_key: Option<String>,
    /// Wire key `trace_id`.
    pub trace_id: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct IngestEventResponse {
    pub event_id: String,
    pub ingested_at: String,
}

/// Parameters for [`EventsResource::list`](crate::resources::events::EventsResource::list).
#[derive(Debug, Clone, Default)]
pub struct ListEventsParams {
    pub page: Option<u32>,
    pub limit: Option<u32>,
    pub date_from: Option<String>,
    pub date_to: Option<String>,
    pub event_type: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct EventListItem {
    pub event_id: String,
    pub event_type: String,
    pub payload_hash: String,
    pub event_hash: String,
    pub retention_policy: String,
    pub ingested_at: String,
    #[serde(default)]
    pub event_time: Option<String>,
    #[serde(default)]
    pub idempotency_key: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ListEventsResponse {
    pub events: Vec<EventListItem>,
    pub page: u32,
    pub limit: u32,
    pub total: u64,
    pub has_more: bool,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ComplianceEvent {
    pub event_id: String,
    pub tenant_id: String,
    pub event_type: String,
    pub payload: JsonObject,
    #[serde(default)]
    pub event_time: Option<String>,
    pub retention_policy: String,
    /// Storage tier. Not returned by every endpoint (e.g. the single-event GET
    /// omits it), so this is optional to stay forward-compatible.
    #[serde(default)]
    pub access_tier: Option<String>,
    /// Retention expiry timestamp, when the server includes it.
    #[serde(default)]
    pub expires_at: Option<String>,
    #[serde(default)]
    pub api_key_id: Option<String>,
    #[serde(default)]
    pub user_id: Option<String>,
    pub ingested_at: String,
    pub payload_hash: String,
    pub request_hash: String,
    pub event_hash: String,
    #[serde(default)]
    pub idempotency_key: Option<String>,
    #[serde(default)]
    pub organization: Option<OrganizationPublic>,
}

/// Parameters for [`EventsResource::verify`](crate::resources::events::EventsResource::verify).
///
/// Provide **either** `payload_hash` (hex SHA-256) **or** `payload` (raw JSON).
#[derive(Debug, Clone, Default)]
pub struct VerifyEventParams {
    pub payload_hash: Option<String>,
    pub payload: Option<JsonObject>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct VerifyEventResponse {
    pub event_id: String,
    pub match_result: bool,
    #[serde(default)]
    pub matched_field: Option<String>,
    pub anchored_hash: String,
    pub submitted_hash: String,
    pub anchored_at: String,
    pub method: String,
    #[serde(default)]
    pub organization: Option<OrganizationPublic>,
}