late 0.0.802

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

#[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, while some platforms (for example WhatsApp and Telegram) report whole seconds. Use this field 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. whatsapp_business_app when sent from the WhatsApp Business phone app on a Coexistence number; cloud_api when sent through Zernio (dashboard, API, or broadcasts). Absent on non-WhatsApp platforms. 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: `human` (an operator in the Zernio inbox), `api` (a call to this API), `broadcast`, `sequence`, `workflow`, `comment_automation`, or `bulk-api` (POST /v1/whatsapp/bulk). Same vocabulary as the `source` filter on the inbox analytics endpoints, and the same value a later GET on this message returns.  Always present, and `null` whenever the lineage is unknown: a message sent from the platform's own app, and 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>>,
}

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,
        }
    }
}
/// 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,
}

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. whatsapp_business_app when sent from the WhatsApp Business phone app on a Coexistence number; cloud_api when sent through Zernio (dashboard, API, or broadcasts). Absent on non-WhatsApp platforms. 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,
}

impl Default for Source {
    fn default() -> Source {
        Self::WhatsappBusinessApp
    }
}
/// Which Zernio surface produced this message: `human` (an operator in the Zernio inbox), `api` (a call to this API), `broadcast`, `sequence`, `workflow`, `comment_automation`, or `bulk-api` (POST /v1/whatsapp/bulk). Same vocabulary as the `source` filter on the inbox analytics endpoints, and the same value a later GET on this message returns.  Always present, and `null` whenever the lineage is unknown: a message sent from the platform's own app, and 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
    }
}