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

/// WebhookPayloadMessage : Webhook payload for message received events
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookPayloadMessage {
    /// Stable webhook event ID
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "event")]
    pub event: Event,
    #[serde(rename = "message")]
    pub message: Box<models::WebhookPayloadMessageMessage>,
    #[serde(rename = "conversation")]
    pub conversation: Box<models::InboxWebhookConversation>,
    #[serde(rename = "account")]
    pub account: Box<models::InboxWebhookAccount>,
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<Box<models::WebhookPayloadMessageMetadata>>,
    #[serde(rename = "timestamp")]
    pub timestamp: String,
}

impl WebhookPayloadMessage {
    /// Webhook payload for message received events
    pub fn new(
        id: String,
        event: Event,
        message: models::WebhookPayloadMessageMessage,
        conversation: models::InboxWebhookConversation,
        account: models::InboxWebhookAccount,
        timestamp: String,
    ) -> WebhookPayloadMessage {
        WebhookPayloadMessage {
            id,
            event,
            message: Box::new(message),
            conversation: Box::new(conversation),
            account: Box::new(account),
            metadata: None,
            timestamp,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Event {
    #[serde(rename = "message.received")]
    MessageReceived,
}

impl Default for Event {
    fn default() -> Event {
        Self::MessageReceived
    }
}
