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

/// ConnectionLog : Connection event log showing account connection/disconnection history
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ConnectionLog {
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    pub _id: Option<String>,
    /// User who owns the connection (may be null for early OAuth failures)
    #[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>,
    /// The social account ID (present on successful connections and disconnects)
    #[serde(rename = "accountId", skip_serializing_if = "Option::is_none")]
    pub account_id: Option<String>,
    #[serde(rename = "platform", skip_serializing_if = "Option::is_none")]
    pub platform: Option<Platform>,
    /// Type of connection event: connect_success, connect_failed, disconnect, reconnect_success, reconnect_failed
    #[serde(rename = "eventType", skip_serializing_if = "Option::is_none")]
    pub event_type: Option<EventType>,
    /// How the connection was initiated
    #[serde(rename = "connectionMethod", skip_serializing_if = "Option::is_none")]
    pub connection_method: Option<ConnectionMethod>,
    #[serde(rename = "error", skip_serializing_if = "Option::is_none")]
    pub error: Option<Box<models::ConnectionLogError>>,
    #[serde(rename = "success", skip_serializing_if = "Option::is_none")]
    pub success: Option<Box<models::ConnectionLogSuccess>>,
    #[serde(rename = "context", skip_serializing_if = "Option::is_none")]
    pub context: Option<Box<models::ConnectionLogContext>>,
    /// How long the operation took in milliseconds
    #[serde(rename = "durationMs", skip_serializing_if = "Option::is_none")]
    pub duration_ms: Option<i32>,
    /// Additional metadata
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<serde_json::Value>,
    #[serde(rename = "createdAt", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
}

impl ConnectionLog {
    /// Connection event log showing account connection/disconnection history
    pub fn new() -> ConnectionLog {
        ConnectionLog {
            _id: None,
            user_id: None,
            profile_id: None,
            account_id: None,
            platform: None,
            event_type: None,
            connection_method: None,
            error: None,
            success: None,
            context: None,
            duration_ms: None,
            metadata: 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 connection event: connect_success, connect_failed, disconnect, reconnect_success, reconnect_failed
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum EventType {
    #[serde(rename = "connect_success")]
    ConnectSuccess,
    #[serde(rename = "connect_failed")]
    ConnectFailed,
    #[serde(rename = "disconnect")]
    Disconnect,
    #[serde(rename = "reconnect_success")]
    ReconnectSuccess,
    #[serde(rename = "reconnect_failed")]
    ReconnectFailed,
}

impl Default for EventType {
    fn default() -> EventType {
        Self::ConnectSuccess
    }
}
/// How the connection was initiated
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ConnectionMethod {
    #[serde(rename = "oauth")]
    Oauth,
    #[serde(rename = "credentials")]
    Credentials,
    #[serde(rename = "invitation")]
    Invitation,
}

impl Default for ConnectionMethod {
    fn default() -> ConnectionMethod {
        Self::Oauth
    }
}
