// This file is auto-generated from JSON Schema.
// Do not edit this file by hand. Regenerate via the CLI.

#![allow(clippy::all)]
#![allow(dead_code)]

use serde::{Deserialize, Serialize};


#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RecordKind {
    #[serde(rename = "entity")]
    Entity,
    #[serde(rename = "relationship")]
    Relationship,
    #[serde(rename = "exchange")]
    Exchange,
    #[serde(rename = "p3tag")]
    P3tag,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum StatusCode {
    #[serde(rename = "ACTIVE")]
    Active,
    #[serde(rename = "INACTIVE")]
    Inactive,
    #[serde(rename = "DEPRECATED")]
    Deprecated,
    #[serde(rename = "PENDING")]
    Pending,
}

/// Lifecycle status of the record.

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StatusEnvelope {

    #[serde(rename = "statusCode")]
    pub status_code: StatusCode,

    #[serde(rename = "statusReason")]
    pub status_reason: Option<String>,

    #[serde(rename = "statusEffectiveDate")]
    pub status_effective_date: String,
}

/// Shared timestamps for record lifecycle and validity.

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Timestamps {

    #[serde(rename = "firstSeenAt")]
    pub first_seen_at: String,

    #[serde(rename = "lastUpdatedAt")]
    pub last_updated_at: String,

    #[serde(rename = "validFrom")]
    pub valid_from: String,

    #[serde(rename = "validTo")]
    pub valid_to: Option<String>,
}

/// Evidence about who asserted these facts and how.

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Attestation {

    #[serde(rename = "attestationTimestamp")]
    pub attestation_timestamp: String,

    #[serde(rename = "attestorId")]
    pub attestor_id: String,

    #[serde(rename = "verificationMethodUri")]
    pub verification_method_uri: String,

    #[serde(rename = "proofType")]
    pub proof_type: String,

    #[serde(rename = "proofPurpose")]
    pub proof_purpose: String,

    #[serde(rename = "proofValue")]
    pub proof_value: Option<String>,

    #[serde(rename = "sourceSystem")]
    pub source_system: Option<String>,

    #[serde(rename = "sourceReference")]
    pub source_reference: Option<String>,
}

/// The entity from which value flows (payer, grantor, transferor). For procurement, this typically aligns with OCDS 'buyer'. For grants, this is the grantor or pass-through entity. For campaign finance, this may be the donor or committee.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Sourceentity {
    #[serde(rename = "entityId")]
    pub entity_id: String,
    #[serde(rename = "roleUri")]
    pub role_uri: Option<String>,
    #[serde(rename = "accountIdentifier")]
    pub account_identifier: Option<String>,
}

/// The entity to which value flows (payee, grantee, transferee). For procurement this aligns with OCDS 'supplier'; for grants and education finance, the grantee, subrecipient, or school; for campaign finance, the recipient committee or vendor.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Recipiententity {
    #[serde(rename = "entityId")]
    pub entity_id: String,
    #[serde(rename = "roleUri")]
    pub role_uri: Option<String>,
    #[serde(rename = "accountIdentifier")]
    pub account_identifier: Option<String>,
}

/// The quantified value being exchanged. For monetary flows, this aligns with OCDS 'implementation.transactions.amount', Schema.org MonetaryAmount / MonetaryGrant, and XBRL monetary elements.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Value {
    pub amount: f64,
    #[serde(rename = "currencyCode")]
    pub currency_code: Option<String>,
    #[serde(rename = "valueTypeUri")]
    pub value_type_uri: Option<String>,
    #[serde(rename = "inKindDescription")]
    pub in_kind_description: Option<String>,
}

/// Lifecycle/settlement status of the exchange event.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Exchangestatus {
    #[serde(rename = "statusCode")]
    pub status_code: String,
    #[serde(rename = "statusEffectiveTimestamp")]
    pub status_effective_timestamp: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Intermediaryentitiesitem {
    #[serde(rename = "entityId")]
    pub entity_id: String,
    #[serde(rename = "roleUri")]
    pub role_uri: Option<String>,
}

/// Traces the compositional flow of funds or value through the civic graph. Conceptually, this is a Category Theory morphism path and aligns with W3C PROV 'wasDerivedFrom' across exchanges.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Provenancechain {
    #[serde(rename = "fundingChainTag")]
    pub funding_chain_tag: Option<String>,
    #[serde(rename = "ultimateSourceEntityId")]
    pub ultimate_source_entity_id: Option<String>,
    #[serde(rename = "intermediaryEntities")]
    pub intermediary_entities: Option<Vec<Intermediaryentitiesitem>>,
    #[serde(rename = "parentExchangeId")]
    pub parent_exchange_id: Option<String>,
}

/// Standardized categorization codes for reporting and analysis. This block is the main bridge to domain specific reporting frameworks such as federal assistance listings, NAICS, GTAS, and local chart-of-accounts.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Categorization {
    #[serde(rename = "cfdaNumber")]
    pub cfda_number: Option<String>,
    #[serde(rename = "naicsCode")]
    pub naics_code: Option<String>,
    #[serde(rename = "gtasAccountCode")]
    pub gtas_account_code: Option<String>,
    #[serde(rename = "localCategoryCode")]
    pub local_category_code: Option<String>,
    #[serde(rename = "localCategoryLabel")]
    pub local_category_label: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Sourcereferencesitem {
    #[serde(rename = "sourceSystemUri")]
    pub source_system_uri: String,
    #[serde(rename = "sourceRecordId")]
    pub source_record_id: String,
    #[serde(rename = "sourceUrl")]
    pub source_url: Option<String>,
}

/// Defines a verifiable value exchange (financial, in-kind, or informational) between entities within an established relationship. This is the atomic unit of civic transparency. CEP Exchanges are designed to interoperate with Open Contracting Data Standard (OCDS) transactions, Schema.org MonetaryGrant/Payment, XBRL financial taxonomies, and campaign finance / education finance datasets via exchangeTypeUri, value, categorization, and sourceReferences.

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExchangeRecord {

    #[serde(rename = "recordKind")]
    pub record_kind: RecordKind,

    #[serde(rename = "recordSchemaUri")]
    pub record_schema_uri: String,

    #[serde(rename = "schemaVersion")]
    pub schema_version: String,

    #[serde(rename = "revisionNumber")]
    pub revision_number: i64,

    #[serde(rename = "verifiableId")]
    pub verifiable_id: String,

    #[serde(rename = "recordTypeUri")]
    pub record_type_uri: String,

    pub status: StatusEnvelope,

    pub timestamps: Timestamps,

    pub attestations: Vec<Attestation>,

    pub ctags: Option<Vec<serde_json::Value>>,

    #[serde(rename = "relationshipId")]
    pub relationship_id: String,

    #[serde(rename = "exchangeTypeUri")]
    pub exchange_type_uri: String,

    #[serde(rename = "sourceEntity")]
    pub source_entity: Sourceentity,

    #[serde(rename = "recipientEntity")]
    pub recipient_entity: Recipiententity,

    pub value: Value,

    #[serde(rename = "occurredTimestamp")]
    pub occurred_timestamp: String,

    #[serde(rename = "exchangeStatus")]
    pub exchange_status: Exchangestatus,

    #[serde(rename = "provenanceChain")]
    pub provenance_chain: Option<Provenancechain>,

    pub categorization: Option<Categorization>,

    #[serde(rename = "sourceReferences")]
    pub source_references: Option<Vec<Sourcereferencesitem>>,

    pub attestation: Attestation,

    #[serde(rename = "previousRecordHash")]
    pub previous_record_hash: Option<String>,
}
