/*
* 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.34.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 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, 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,
/// 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>>,
}
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,
}
}
}
///
#[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 = "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
}
}