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

/// WebhookPayloadExternalPost : Webhook payload for post.external.created / post.external.updated / post.external.deleted. Fired by Zernio's background sync when it detects a natively-authored post (e.g. a Google Business Profile localPost created in the Google UI), NOT a post published through Zernio. Poll-driven (~hourly), not real-time. On post.external.deleted, post.deletedAt is populated.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookPayloadExternalPost {
    /// Stable webhook event ID
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "event")]
    pub event: Event,
    #[serde(rename = "post")]
    pub post: Box<models::ExternalPostWebhookPost>,
    #[serde(rename = "account")]
    pub account: Box<models::WebhookPayloadReviewNewAccount>,
    #[serde(rename = "timestamp")]
    pub timestamp: String,
}

impl WebhookPayloadExternalPost {
    /// Webhook payload for post.external.created / post.external.updated / post.external.deleted. Fired by Zernio's background sync when it detects a natively-authored post (e.g. a Google Business Profile localPost created in the Google UI), NOT a post published through Zernio. Poll-driven (~hourly), not real-time. On post.external.deleted, post.deletedAt is populated.
    pub fn new(
        id: String,
        event: Event,
        post: models::ExternalPostWebhookPost,
        account: models::WebhookPayloadReviewNewAccount,
        timestamp: String,
    ) -> WebhookPayloadExternalPost {
        WebhookPayloadExternalPost {
            id,
            event,
            post: Box::new(post),
            account: Box::new(account),
            timestamp,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Event {
    #[serde(rename = "post.external.created")]
    PostExternalCreated,
    #[serde(rename = "post.external.updated")]
    PostExternalUpdated,
    #[serde(rename = "post.external.deleted")]
    PostExternalDeleted,
}

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