/*
* 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.1
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// ConversionEvent : A single conversion event to relay to the ad platform. All PII fields (email, phone, names) are hashed with SHA-256 server-side using each platform's normalization rules before they leave Zernio. Callers send plaintext.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ConversionEvent {
/// Standard event name (Purchase, Lead, CompleteRegistration, AddToCart, InitiateCheckout, AddPaymentInfo, Subscribe, StartTrial, ViewContent, Search, Contact, SubmitApplication, Schedule) or a custom string (only supported on platforms that accept custom events — Meta). Per-platform behavior: - Meta: free-form; standard names match Meta's built-ins. - Google: ignored — the conversion action's category determines the type. - LinkedIn: ignored — the conversion rule's `type` is locked to the destination.
#[serde(rename = "eventName")]
pub event_name: String,
/// When the conversion happened, in unix seconds.
#[serde(rename = "eventTime")]
pub event_time: i32,
/// Unique dedup key. The same eventId must be used on pixel + CAPI to prevent double-counting. Mapped to event_id on Meta, transactionId on Google, eventId on LinkedIn (LinkedIn deduplicates against Insight Tag events with the same eventId; the Insight Tag event wins when both arrive).
#[serde(rename = "eventId")]
pub event_id: String,
/// Conversion value in the specified currency.
#[serde(rename = "value", skip_serializing_if = "Option::is_none")]
pub value: Option<f64>,
/// ISO 4217 currency code.
#[serde(rename = "currency", skip_serializing_if = "Option::is_none")]
pub currency: Option<String>,
#[serde(rename = "user")]
pub user: Box<models::ConversionEventUser>,
/// Item-level detail for ecommerce events.
#[serde(rename = "items", skip_serializing_if = "Option::is_none")]
pub items: Option<Vec<models::ConversionEventItemsInner>>,
/// URL where the conversion originated (used by Meta).
#[serde(rename = "sourceUrl", skip_serializing_if = "Option::is_none")]
pub source_url: Option<String>,
/// Where the conversion happened. Used by Meta; Google ignores.
#[serde(rename = "actionSource", skip_serializing_if = "Option::is_none")]
pub action_source: Option<ActionSource>,
/// Escape hatch for platform-specific fields we haven't normalized. Forwarded as-is.
#[serde(rename = "platformData", skip_serializing_if = "Option::is_none")]
pub platform_data: Option<std::collections::HashMap<String, serde_json::Value>>,
}
impl ConversionEvent {
/// A single conversion event to relay to the ad platform. All PII fields (email, phone, names) are hashed with SHA-256 server-side using each platform's normalization rules before they leave Zernio. Callers send plaintext.
pub fn new(
event_name: String,
event_time: i32,
event_id: String,
user: models::ConversionEventUser,
) -> ConversionEvent {
ConversionEvent {
event_name,
event_time,
event_id,
value: None,
currency: None,
user: Box::new(user),
items: None,
source_url: None,
action_source: None,
platform_data: None,
}
}
}
/// Where the conversion happened. Used by Meta; Google ignores.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ActionSource {
#[serde(rename = "web")]
Web,
#[serde(rename = "app")]
App,
#[serde(rename = "offline")]
Offline,
#[serde(rename = "crm")]
Crm,
#[serde(rename = "phone_call")]
PhoneCall,
#[serde(rename = "system_generated")]
SystemGenerated,
}
impl Default for ActionSource {
fn default() -> ActionSource {
Self::Web
}
}