late 0.0.297

API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api
Documentation
/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api
 *
 * The version of the OpenAPI document: 1.0.4
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// SendWhatsAppConversionRequest : In addition to the `required` list, at least one of `conversationId` or `phoneE164` must be supplied (used to resolve the originating CTWA conversation). The route enforces this at the Zod boundary; OpenAPI's `required` cannot express OR-required cleanly.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct SendWhatsAppConversionRequest {
    /// WhatsApp SocialAccount ID.
    #[serde(rename = "accountId")]
    pub account_id: String,
    /// Live-verified allowlist of event names accepted by Meta's CAPI for Business Messaging (Graph API v25.0). Other standard pixel events including `Lead`, `CompleteRegistration`, `Subscribe`, `Schedule`, `Contact`, `StartTrial`, `AddPaymentInfo`, `Search`, and `SubmitApplication` are rejected with subcode 2804066 (\"Messaging Event Invalid Event Type\") on `action_source = business_messaging` events. Custom event names are also rejected.  Use `LeadSubmitted` (NOT `Lead`) for lead-style conversions.
    #[serde(rename = "eventName")]
    pub event_name: EventName,
    /// Unix seconds. Defaults to the time of the request when omitted. Meta's attribution window is 7 days from click; events older than that lose attribution.
    #[serde(rename = "eventTime", skip_serializing_if = "Option::is_none")]
    pub event_time: Option<f64>,
    /// Stable dedup key. Reuse to suppress duplicate events (Meta dedupes against pixel events with the same id).
    #[serde(rename = "eventId")]
    pub event_id: String,
    /// Zernio Conversation `_id` (preferred lookup). The conversation must have a captured `ctwa_clid` in metadata (set automatically by the WhatsApp webhook on the first inbound message after a CTWA ad click).
    #[serde(rename = "conversationId", skip_serializing_if = "Option::is_none")]
    pub conversation_id: Option<String>,
    /// Contact phone number, digits only with no '+'. When used in lieu of `conversationId`, the handler resolves to the most recent CTWA-attributed conversation for this phone on the supplied account.
    #[serde(rename = "phoneE164", skip_serializing_if = "Option::is_none")]
    pub phone_e164: Option<String>,
    /// Conversion value (e.g. order total).
    #[serde(rename = "value", skip_serializing_if = "Option::is_none")]
    pub value: Option<f64>,
    /// ISO 4217 currency code (e.g. `USD`).
    #[serde(rename = "currency", skip_serializing_if = "Option::is_none")]
    pub currency: Option<String>,
    /// Optional product / content identifiers.
    #[serde(rename = "contentIds", skip_serializing_if = "Option::is_none")]
    pub content_ids: Option<Vec<String>>,
    /// User email. Normalized + SHA-256 hashed before sending to Meta.
    #[serde(rename = "email", skip_serializing_if = "Option::is_none")]
    pub email: Option<String>,
    /// Stable customer identifier. Lowercased + SHA-256 hashed before sending to Meta.
    #[serde(rename = "externalId", skip_serializing_if = "Option::is_none")]
    pub external_id: Option<String>,
    /// Meta `test_event_code` passthrough. Routes the event to the Test Events tab in Events Manager instead of the production dataset, useful for development.
    #[serde(rename = "testCode", skip_serializing_if = "Option::is_none")]
    pub test_code: Option<String>,
}

impl SendWhatsAppConversionRequest {
    /// In addition to the `required` list, at least one of `conversationId` or `phoneE164` must be supplied (used to resolve the originating CTWA conversation). The route enforces this at the Zod boundary; OpenAPI's `required` cannot express OR-required cleanly.
    pub fn new(
        account_id: String,
        event_name: EventName,
        event_id: String,
    ) -> SendWhatsAppConversionRequest {
        SendWhatsAppConversionRequest {
            account_id,
            event_name,
            event_time: None,
            event_id,
            conversation_id: None,
            phone_e164: None,
            value: None,
            currency: None,
            content_ids: None,
            email: None,
            external_id: None,
            test_code: None,
        }
    }
}
/// Live-verified allowlist of event names accepted by Meta's CAPI for Business Messaging (Graph API v25.0). Other standard pixel events including `Lead`, `CompleteRegistration`, `Subscribe`, `Schedule`, `Contact`, `StartTrial`, `AddPaymentInfo`, `Search`, and `SubmitApplication` are rejected with subcode 2804066 (\"Messaging Event Invalid Event Type\") on `action_source = business_messaging` events. Custom event names are also rejected.  Use `LeadSubmitted` (NOT `Lead`) for lead-style conversions.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum EventName {
    #[serde(rename = "LeadSubmitted")]
    LeadSubmitted,
    #[serde(rename = "Purchase")]
    Purchase,
    #[serde(rename = "AddToCart")]
    AddToCart,
    #[serde(rename = "InitiateCheckout")]
    InitiateCheckout,
    #[serde(rename = "ViewContent")]
    ViewContent,
}

impl Default for EventName {
    fn default() -> EventName {
        Self::LeadSubmitted
    }
}