late 0.0.1385

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.
Documentation
/*
 * 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};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookPayloadMessageSentMessage {
    /// Internal message ID
    #[serde(rename = "id")]
    pub id: String,
    /// Internal conversation ID
    #[serde(rename = "conversationId")]
    pub conversation_id: String,
    /// Every platform whose outgoing messages Zernio observes. sms is absent on purpose: its carrier receipts update delivery status and never raise message.sent.
    #[serde(rename = "platform")]
    pub platform: Platform,
    /// Platform's message ID
    #[serde(rename = "platformMessageId")]
    pub platform_message_id: String,
    #[serde(rename = "direction")]
    pub direction: Direction,
    /// Message text content
    #[serde(rename = "text", deserialize_with = "Option::deserialize")]
    pub text: Option<String>,
    #[serde(rename = "attachments")]
    pub attachments: Vec<models::WebhookPayloadMessageSentMessageAttachmentsInner>,
    #[serde(rename = "sender")]
    pub sender: Box<models::WebhookPayloadMessageSentMessageSender>,
    /// When the message was sent, as reported by the platform and passed through unmodified. Full ISO 8601 date-time: Instagram and Facebook carry millisecond precision; some platforms (for example WhatsApp and Telegram) report whole seconds.  Use it as the chronological ordering key. If two messages share the same value, fetch the conversation messages with sortOrder=desc for the deterministic order.
    #[serde(rename = "sentAt")]
    pub sent_at: String,
    #[serde(rename = "isRead")]
    pub is_read: bool,
    /// WhatsApp send origin. Absent on non-WhatsApp platforms.  - whatsapp_business_app: sent from the WhatsApp Business phone app on a Coexistence number. - cloud_api: sent through Zernio (dashboard, API, or broadcasts). - meta_business_agent: Meta Business Agent answered on the number.  Says where WhatsApp saw the send come from, not which Zernio surface produced it: read sentVia for that.
    #[serde(rename = "source", skip_serializing_if = "Option::is_none")]
    pub source: Option<Source>,
    /// Which Zernio surface produced this message. Same vocabulary as the `source` filter on the inbox analytics endpoints, and the same value a later GET on this message returns.  - `human`: an operator in the Zernio inbox - `api`: a call to this API - `broadcast` - `sequence` - `workflow` - `comment_automation` - `bulk-api`: POST /v1/whatsapp/bulk  Always present, and `null` whenever the lineage is unknown:  - any outgoing message not sent through Zernio (one typed in the platform's own app, a Meta automated reply such as an instant reply or away message, the echo of a click-to-message ad's greeting) - every message stored before this field shipped (2026-08)  Existing messages are NOT backfilled, so treat `null` as \"unknown\", never as \"sent by a human\".
    #[serde(
        rename = "sentVia",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub sent_via: Option<Option<SentVia>>,
    /// The comment automation that sent this DM (sentVia comment_automation). Null otherwise.
    #[serde(
        rename = "automationId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub automation_id: Option<Option<String>>,
    /// The workflow whose run sent this message (sentVia workflow). Null otherwise.
    #[serde(
        rename = "workflowId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub workflow_id: Option<Option<String>>,
    /// The workflow run (execution) that sent this message, as returned by the workflow executions endpoints. Null when workflowId is null.
    #[serde(
        rename = "executionId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_id: Option<Option<String>>,
    /// The broadcast that sent this message (sentVia broadcast). Null otherwise.
    #[serde(
        rename = "broadcastId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub broadcast_id: Option<Option<String>>,
    /// The sequence whose step sent this message (sentVia sequence). Null otherwise.
    #[serde(
        rename = "sequenceId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub sequence_id: Option<Option<String>>,
}

impl WebhookPayloadMessageSentMessage {
    pub fn new(
        id: String,
        conversation_id: String,
        platform: Platform,
        platform_message_id: String,
        direction: Direction,
        text: Option<String>,
        attachments: Vec<models::WebhookPayloadMessageSentMessageAttachmentsInner>,
        sender: models::WebhookPayloadMessageSentMessageSender,
        sent_at: String,
        is_read: bool,
    ) -> WebhookPayloadMessageSentMessage {
        WebhookPayloadMessageSentMessage {
            id,
            conversation_id,
            platform,
            platform_message_id,
            direction,
            text,
            attachments,
            sender: Box::new(sender),
            sent_at,
            is_read,
            source: None,
            sent_via: None,
            automation_id: None,
            workflow_id: None,
            execution_id: None,
            broadcast_id: None,
            sequence_id: None,
        }
    }
}
/// Every platform whose outgoing messages Zernio observes. sms is absent on purpose: its carrier receipts update delivery status and never raise message.sent.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Platform {
    #[serde(rename = "instagram")]
    Instagram,
    #[serde(rename = "facebook")]
    Facebook,
    #[serde(rename = "telegram")]
    Telegram,
    #[serde(rename = "whatsapp")]
    Whatsapp,
    #[serde(rename = "twitter")]
    Twitter,
    #[serde(rename = "reddit")]
    Reddit,
    #[serde(rename = "bluesky")]
    Bluesky,
    #[serde(rename = "slack")]
    Slack,
    #[serde(rename = "tiktok")]
    Tiktok,
    #[serde(rename = "imessage")]
    Imessage,
    #[serde(rename = "line")]
    Line,
    #[serde(rename = "wechat")]
    Wechat,
}

impl Default for Platform {
    fn default() -> Platform {
        Self::Instagram
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Direction {
    #[serde(rename = "incoming")]
    Incoming,
    #[serde(rename = "outgoing")]
    Outgoing,
}

impl Default for Direction {
    fn default() -> Direction {
        Self::Incoming
    }
}
/// WhatsApp send origin. Absent on non-WhatsApp platforms.  - whatsapp_business_app: sent from the WhatsApp Business phone app on a Coexistence number. - cloud_api: sent through Zernio (dashboard, API, or broadcasts). - meta_business_agent: Meta Business Agent answered on the number.  Says where WhatsApp saw the send come from, not which Zernio surface produced it: read sentVia for that.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Source {
    #[serde(rename = "whatsapp_business_app")]
    WhatsappBusinessApp,
    #[serde(rename = "cloud_api")]
    CloudApi,
    #[serde(rename = "meta_business_agent")]
    MetaBusinessAgent,
}

impl Default for Source {
    fn default() -> Source {
        Self::WhatsappBusinessApp
    }
}
/// Which Zernio surface produced this message. Same vocabulary as the `source` filter on the inbox analytics endpoints, and the same value a later GET on this message returns.  - `human`: an operator in the Zernio inbox - `api`: a call to this API - `broadcast` - `sequence` - `workflow` - `comment_automation` - `bulk-api`: POST /v1/whatsapp/bulk  Always present, and `null` whenever the lineage is unknown:  - any outgoing message not sent through Zernio (one typed in the platform's own app, a Meta automated reply such as an instant reply or away message, the echo of a click-to-message ad's greeting) - every message stored before this field shipped (2026-08)  Existing messages are NOT backfilled, so treat `null` as \"unknown\", never as \"sent by a human\".
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum SentVia {
    #[serde(rename = "human")]
    Human,
    #[serde(rename = "api")]
    Api,
    #[serde(rename = "broadcast")]
    Broadcast,
    #[serde(rename = "sequence")]
    Sequence,
    #[serde(rename = "workflow")]
    Workflow,
    #[serde(rename = "comment_automation")]
    CommentAutomation,
    #[serde(rename = "bulk-api")]
    BulkApi,
}

impl Default for SentVia {
    fn default() -> SentVia {
        Self::Human
    }
}