/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api
 *
 * 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 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")]
    pub text: String,
    #[serde(rename = "attachments")]
    pub attachments: Vec<models::InboxWebhookMessageAttachmentsInner>,
    #[serde(rename = "sender")]
    pub sender: Box<models::WebhookPayloadMessageMessageSender>,
    #[serde(rename = "sentAt")]
    pub sent_at: String,
    #[serde(rename = "isRead")]
    pub is_read: bool,
}

impl WebhookPayloadMessageMessage {
    pub fn new(
        id: String,
        conversation_id: String,
        platform: Platform,
        platform_message_id: String,
        direction: Direction,
        text: String,
        attachments: Vec<models::InboxWebhookMessageAttachmentsInner>,
        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,
        }
    }
}
///
#[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,
}

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