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

/// WebhookLog : Webhook delivery log entry
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookLog {
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    pub _id: Option<String>,
    /// ID of the webhook that was triggered
    #[serde(rename = "webhookId", skip_serializing_if = "Option::is_none")]
    pub webhook_id: Option<String>,
    /// Name of the webhook that was triggered
    #[serde(rename = "webhookName", skip_serializing_if = "Option::is_none")]
    pub webhook_name: Option<String>,
    #[serde(rename = "event", skip_serializing_if = "Option::is_none")]
    pub event: Option<Event>,
    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<Status>,
    /// HTTP status code from webhook endpoint
    #[serde(rename = "statusCode", skip_serializing_if = "Option::is_none")]
    pub status_code: Option<i32>,
    /// Payload sent to webhook endpoint
    #[serde(rename = "requestPayload", skip_serializing_if = "Option::is_none")]
    pub request_payload: Option<serde_json::Value>,
    /// Response body from webhook endpoint (truncated to 10KB)
    #[serde(rename = "responseBody", skip_serializing_if = "Option::is_none")]
    pub response_body: Option<String>,
    /// Error message if delivery failed
    #[serde(rename = "errorMessage", skip_serializing_if = "Option::is_none")]
    pub error_message: Option<String>,
    /// Delivery attempt number (max 7 attempts)
    #[serde(rename = "attemptNumber", skip_serializing_if = "Option::is_none")]
    pub attempt_number: Option<i32>,
    /// Response time in milliseconds
    #[serde(rename = "responseTime", skip_serializing_if = "Option::is_none")]
    pub response_time: Option<i32>,
    #[serde(rename = "createdAt", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
}

impl WebhookLog {
    /// Webhook delivery log entry
    pub fn new() -> WebhookLog {
        WebhookLog {
            _id: None,
            webhook_id: None,
            webhook_name: None,
            event: None,
            url: None,
            status: None,
            status_code: None,
            request_payload: None,
            response_body: None,
            error_message: None,
            attempt_number: None,
            response_time: None,
            created_at: None,
        }
    }
}
///
#[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,
    #[serde(rename = "account.connected")]
    AccountConnected,
    #[serde(rename = "account.disconnected")]
    AccountDisconnected,
    #[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 = "comment.received")]
    CommentReceived,
    #[serde(rename = "webhook.test")]
    WebhookTest,
}

impl Default for Event {
    fn default() -> Event {
        Self::PostScheduled
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "success")]
    Success,
    #[serde(rename = "failed")]
    Failed,
}

impl Default for Status {
    fn default() -> Status {
        Self::Success
    }
}
