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

/// PostLog : Publishing log entry showing details of a post publishing attempt
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct PostLog {
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    pub _id: Option<String>,
    #[serde(rename = "postId", skip_serializing_if = "Option::is_none")]
    pub post_id: Option<Box<models::PostLogPostId>>,
    #[serde(rename = "userId", skip_serializing_if = "Option::is_none")]
    pub user_id: Option<String>,
    #[serde(rename = "profileId", skip_serializing_if = "Option::is_none")]
    pub profile_id: Option<String>,
    #[serde(rename = "platform", skip_serializing_if = "Option::is_none")]
    pub platform: Option<Platform>,
    #[serde(rename = "accountId", skip_serializing_if = "Option::is_none")]
    pub account_id: Option<String>,
    #[serde(rename = "accountUsername", skip_serializing_if = "Option::is_none")]
    pub account_username: Option<String>,
    /// Type of action logged: publish (initial attempt), retry (after failure), media_upload, rate_limit_pause, token_refresh, cancelled
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<Action>,
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<Status>,
    /// HTTP status code from platform API
    #[serde(rename = "statusCode", skip_serializing_if = "Option::is_none")]
    pub status_code: Option<i32>,
    /// Platform API endpoint called
    #[serde(rename = "endpoint", skip_serializing_if = "Option::is_none")]
    pub endpoint: Option<String>,
    #[serde(rename = "request", skip_serializing_if = "Option::is_none")]
    pub request: Option<Box<models::PostLogRequest>>,
    #[serde(rename = "response", skip_serializing_if = "Option::is_none")]
    pub response: Option<Box<models::PostLogResponse>>,
    /// How long the operation took in milliseconds
    #[serde(rename = "durationMs", skip_serializing_if = "Option::is_none")]
    pub duration_ms: Option<i32>,
    /// Attempt number (1 for first try, 2+ for retries)
    #[serde(rename = "attemptNumber", skip_serializing_if = "Option::is_none")]
    pub attempt_number: Option<i32>,
    #[serde(rename = "createdAt", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
}

impl PostLog {
    /// Publishing log entry showing details of a post publishing attempt
    pub fn new() -> PostLog {
        PostLog {
            _id: None,
            post_id: None,
            user_id: None,
            profile_id: None,
            platform: None,
            account_id: None,
            account_username: None,
            action: None,
            status: None,
            status_code: None,
            endpoint: None,
            request: None,
            response: None,
            duration_ms: None,
            attempt_number: None,
            created_at: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Platform {
    #[serde(rename = "tiktok")]
    Tiktok,
    #[serde(rename = "instagram")]
    Instagram,
    #[serde(rename = "facebook")]
    Facebook,
    #[serde(rename = "youtube")]
    Youtube,
    #[serde(rename = "linkedin")]
    Linkedin,
    #[serde(rename = "twitter")]
    Twitter,
    #[serde(rename = "threads")]
    Threads,
    #[serde(rename = "pinterest")]
    Pinterest,
    #[serde(rename = "reddit")]
    Reddit,
    #[serde(rename = "bluesky")]
    Bluesky,
    #[serde(rename = "googlebusiness")]
    Googlebusiness,
    #[serde(rename = "telegram")]
    Telegram,
    #[serde(rename = "snapchat")]
    Snapchat,
}

impl Default for Platform {
    fn default() -> Platform {
        Self::Tiktok
    }
}
/// Type of action logged: publish (initial attempt), retry (after failure), media_upload, rate_limit_pause, token_refresh, cancelled
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Action {
    #[serde(rename = "publish")]
    Publish,
    #[serde(rename = "retry")]
    Retry,
    #[serde(rename = "media_upload")]
    MediaUpload,
    #[serde(rename = "rate_limit_pause")]
    RateLimitPause,
    #[serde(rename = "token_refresh")]
    TokenRefresh,
    #[serde(rename = "cancelled")]
    Cancelled,
}

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

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