late 0.0.1344

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.526.1
 * 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 WebhookPayloadMessageMessage {
    /// Internal message ID
    #[serde(rename = "id")]
    pub id: String,
    /// Internal conversation ID
    #[serde(rename = "conversationId")]
    pub conversation_id: String,
    #[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::WebhookPayloadMessageMessageAttachmentsInner>,
    #[serde(rename = "sender")]
    pub sender: Box<models::WebhookPayloadMessageMessageSender>,
    /// 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 (e.g. WhatsApp and Telegram) report whole seconds.  Use it as the chronological ordering key. If two messages share a 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,
    /// Which Zernio surface produced the message. Always present and always `null` on this event, since nobody on our side produced an inbound message; it is only informative on `message.sent`, which documents the vocabulary.
    #[serde(
        rename = "sentVia",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub sent_via: Option<Option<SentVia>>,
    /// Always null on this event; see message.sent.
    #[serde(
        rename = "automationId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub automation_id: Option<Option<String>>,
    /// Always null on this event; see message.sent.
    #[serde(
        rename = "workflowId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub workflow_id: Option<Option<String>>,
    /// Always null on this event; see message.sent.
    #[serde(
        rename = "executionId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_id: Option<Option<String>>,
    /// Always null on this event; see message.sent.
    #[serde(
        rename = "broadcastId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub broadcast_id: Option<Option<String>>,
    /// Always null on this event; see message.sent.
    #[serde(
        rename = "sequenceId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub sequence_id: Option<Option<String>>,
}

impl WebhookPayloadMessageMessage {
    pub fn new(
        id: String,
        conversation_id: String,
        platform: Platform,
        platform_message_id: String,
        direction: Direction,
        text: Option<String>,
        attachments: Vec<models::WebhookPayloadMessageMessageAttachmentsInner>,
        sender: models::WebhookPayloadMessageMessageSender,
        sent_at: String,
        is_read: bool,
    ) -> WebhookPayloadMessageMessage {
        WebhookPayloadMessageMessage {
            id,
            conversation_id,
            platform,
            platform_message_id,
            direction,
            text,
            attachments,
            sender: Box::new(sender),
            sent_at,
            is_read,
            sent_via: None,
            automation_id: None,
            workflow_id: None,
            execution_id: None,
            broadcast_id: None,
            sequence_id: None,
        }
    }
}
///
#[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 = "sms")]
    Sms,
    #[serde(rename = "rcs")]
    Rcs,
    #[serde(rename = "twitter")]
    Twitter,
    #[serde(rename = "bluesky")]
    Bluesky,
    #[serde(rename = "reddit")]
    Reddit,
    #[serde(rename = "slack")]
    Slack,
    #[serde(rename = "tiktok")]
    Tiktok,
    #[serde(rename = "imessage")]
    Imessage,
}

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
    }
}
/// Which Zernio surface produced the message. Always present and always `null` on this event, since nobody on our side produced an inbound message; it is only informative on `message.sent`, which documents the vocabulary.
#[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
    }
}