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

/// Webhook : Individual webhook configuration for receiving real-time notifications
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Webhook {
    /// Unique webhook identifier
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    pub _id: Option<String>,
    /// Webhook name (for identification)
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Webhook endpoint URL
    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    /// Secret key for HMAC-SHA256 signature verification.
    #[serde(rename = "secret", skip_serializing_if = "Option::is_none")]
    pub secret: Option<String>,
    /// Events subscribed to
    #[serde(rename = "events", skip_serializing_if = "Option::is_none")]
    pub events: Option<Vec<Events>>,
    /// Whether webhook delivery is enabled
    #[serde(rename = "isActive", skip_serializing_if = "Option::is_none")]
    pub is_active: Option<bool>,
    /// Timestamp of last successful webhook delivery
    #[serde(rename = "lastFiredAt", skip_serializing_if = "Option::is_none")]
    pub last_fired_at: Option<String>,
    /// Consecutive delivery failures (resets on success, webhook disabled at 10)
    #[serde(rename = "failureCount", skip_serializing_if = "Option::is_none")]
    pub failure_count: Option<i32>,
    /// Custom headers included in webhook requests
    #[serde(rename = "customHeaders", skip_serializing_if = "Option::is_none")]
    pub custom_headers: Option<std::collections::HashMap<String, String>>,
}

impl Webhook {
    /// Individual webhook configuration for receiving real-time notifications
    pub fn new() -> Webhook {
        Webhook {
            _id: None,
            name: None,
            url: None,
            secret: None,
            events: None,
            is_active: None,
            last_fired_at: None,
            failure_count: None,
            custom_headers: None,
        }
    }
}
/// Events subscribed to
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Events {
    #[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,
    #[serde(rename = "post.platform.published")]
    PostPlatformPublished,
    #[serde(rename = "post.platform.failed")]
    PostPlatformFailed,
    #[serde(rename = "post.external.created")]
    PostExternalCreated,
    #[serde(rename = "post.external.updated")]
    PostExternalUpdated,
    #[serde(rename = "post.external.deleted")]
    PostExternalDeleted,
    #[serde(rename = "account.connected")]
    AccountConnected,
    #[serde(rename = "account.disconnected")]
    AccountDisconnected,
    #[serde(rename = "account.ads.initial_sync_completed")]
    AccountAdsInitialSyncCompleted,
    #[serde(rename = "message.received")]
    MessageReceived,
    #[serde(rename = "message.sent")]
    MessageSent,
    #[serde(rename = "message.edited")]
    MessageEdited,
    #[serde(rename = "message.deleted")]
    MessageDeleted,
    #[serde(rename = "message.delivered")]
    MessageDelivered,
    #[serde(rename = "message.read")]
    MessageRead,
    #[serde(rename = "message.failed")]
    MessageFailed,
    #[serde(rename = "reaction.received")]
    ReactionReceived,
    #[serde(rename = "comment.received")]
    CommentReceived,
    #[serde(rename = "review.new")]
    ReviewNew,
    #[serde(rename = "review.updated")]
    ReviewUpdated,
    #[serde(rename = "ad.status_changed")]
    AdStatusChanged,
    #[serde(rename = "whatsapp.template.status_updated")]
    WhatsappTemplateStatusUpdated,
    #[serde(rename = "whatsapp.number.activated")]
    WhatsappNumberActivated,
    #[serde(rename = "whatsapp.number.declined")]
    WhatsappNumberDeclined,
    #[serde(rename = "whatsapp.number.action_required")]
    WhatsappNumberActionRequired,
    #[serde(rename = "whatsapp.number.verification_required")]
    WhatsappNumberVerificationRequired,
    #[serde(rename = "whatsapp.number.suspended")]
    WhatsappNumberSuspended,
    #[serde(rename = "whatsapp.number.reactivated")]
    WhatsappNumberReactivated,
    #[serde(rename = "whatsapp.number.released")]
    WhatsappNumberReleased,
}

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