/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.605.0
* 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,
/// Event names accepted by Meta's CAPI for Business Messaging. 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`) when a lead comes in and `QualifiedLead` once your team qualifies it. `OrderCreated`, `OrderCanceled` and `OrderReturned` track an order placed in the chat; send `value` and `currency` with them (and with `Purchase`) to report the order amount.
#[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, sent at the request root (a root-level `test_event_code` is accepted as an alias). The event shows in Events Manager's Test Events tab for the dataset whose current test code matches. Meta still processes it like any other event, so remove it in production.
#[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,
}
}
}
/// Event names accepted by Meta's CAPI for Business Messaging. 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`) when a lead comes in and `QualifiedLead` once your team qualifies it. `OrderCreated`, `OrderCanceled` and `OrderReturned` track an order placed in the chat; send `value` and `currency` with them (and with `Purchase`) to report the order amount.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum EventName {
#[serde(rename = "LeadSubmitted")]
LeadSubmitted,
#[serde(rename = "QualifiedLead")]
QualifiedLead,
#[serde(rename = "Purchase")]
Purchase,
#[serde(rename = "AddToCart")]
AddToCart,
#[serde(rename = "InitiateCheckout")]
InitiateCheckout,
#[serde(rename = "ViewContent")]
ViewContent,
#[serde(rename = "OrderCreated")]
OrderCreated,
#[serde(rename = "OrderCanceled")]
OrderCanceled,
#[serde(rename = "OrderReturned")]
OrderReturned,
}
impl Default for EventName {
fn default() -> EventName {
Self::LeadSubmitted
}
}