/*
 * 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.1
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// WebhookPayloadPost : Webhook payload for post events
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookPayloadPost {
    /// Stable webhook event ID
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "event")]
    pub event: Event,
    #[serde(rename = "post")]
    pub post: Box<models::WebhookPayloadPostPost>,
    #[serde(rename = "timestamp")]
    pub timestamp: String,
}

impl WebhookPayloadPost {
    /// Webhook payload for post events
    pub fn new(
        id: String,
        event: Event,
        post: models::WebhookPayloadPostPost,
        timestamp: String,
    ) -> WebhookPayloadPost {
        WebhookPayloadPost {
            id,
            event,
            post: Box::new(post),
            timestamp,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Event {
    #[serde(rename = "post.scheduled")]
    PostScheduled,
    #[serde(rename = "post.published")]
    PostPublished,
    #[serde(rename = "post.failed")]
    PostFailed,
    #[serde(rename = "post.partial")]
    PostPartial,
    #[serde(rename = "post.cancelled")]
    PostCancelled,
    #[serde(rename = "post.recycled")]
    PostRecycled,
}

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