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

/// TrackingTag : A platform measurement tag — the thing you create, install on a website, send events to, and target ads against. On Meta this is a Pixel (`kind: pixel`). The shape is platform-neutral so other platforms (Pinterest Tag, LinkedIn Insight Tag, etc.) can be added without changing the contract; platform-specific fields are simply absent where a platform has no equivalent. Returned by `listTrackingTags`, `createTrackingTag`, `getTrackingTag`, and `updateTrackingTag`.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TrackingTag {
    /// Platform-native tag id. Meta: numeric pixel id, as a string.
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "platform")]
    pub platform: Platform,
    /// Platform-native flavor of the tag (Meta: `pixel`).
    #[serde(rename = "kind")]
    pub kind: Kind,
    /// `inactive` when the platform reports the tag as broken/unavailable.
    #[serde(rename = "status")]
    pub status: Status,
    /// The base-code `<script>` snippet to install on the site. Meta only; populated by `getTrackingTag`, omitted from the list view.
    #[serde(rename = "code", skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,
    /// Unix seconds of the last event the tag received, or `null` if it never fired. The practical \"is it installed and working\" signal.
    #[serde(rename = "lastFiredTime", skip_serializing_if = "Option::is_none")]
    pub last_fired_time: Option<i32>,
    /// Whether the tag is in a broken/unavailable state (Meta `is_unavailable`).
    #[serde(rename = "isUnavailable", skip_serializing_if = "Option::is_none")]
    pub is_unavailable: Option<bool>,
    /// Convenience flag derived from `lastFiredTime` — has the tag ever fired.
    #[serde(rename = "installed", skip_serializing_if = "Option::is_none")]
    pub installed: Option<bool>,
    /// Unix seconds the tag was created.
    #[serde(rename = "creationTime", skip_serializing_if = "Option::is_none")]
    pub creation_time: Option<i32>,
    /// Business Manager id that owns the tag, or `null` when the tag lives on a personal (non-BM) ad account — such tags can't be shared with other ad accounts.
    #[serde(rename = "ownerBusinessId", skip_serializing_if = "Option::is_none")]
    pub owner_business_id: Option<String>,
    /// Ad account id (`act_...`) that owns the tag, when reported.
    #[serde(rename = "ownerAdAccountId", skip_serializing_if = "Option::is_none")]
    pub owner_ad_account_id: Option<String>,
}

impl TrackingTag {
    /// A platform measurement tag — the thing you create, install on a website, send events to, and target ads against. On Meta this is a Pixel (`kind: pixel`). The shape is platform-neutral so other platforms (Pinterest Tag, LinkedIn Insight Tag, etc.) can be added without changing the contract; platform-specific fields are simply absent where a platform has no equivalent. Returned by `listTrackingTags`, `createTrackingTag`, `getTrackingTag`, and `updateTrackingTag`.
    pub fn new(
        id: String,
        name: String,
        platform: Platform,
        kind: Kind,
        status: Status,
    ) -> TrackingTag {
        TrackingTag {
            id,
            name,
            platform,
            kind,
            status,
            code: None,
            last_fired_time: None,
            is_unavailable: None,
            installed: None,
            creation_time: None,
            owner_business_id: None,
            owner_ad_account_id: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Platform {
    #[serde(rename = "metaads")]
    Metaads,
}

impl Default for Platform {
    fn default() -> Platform {
        Self::Metaads
    }
}
/// Platform-native flavor of the tag (Meta: `pixel`).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Kind {
    #[serde(rename = "pixel")]
    Pixel,
    #[serde(rename = "tag")]
    Tag,
    #[serde(rename = "insight_tag")]
    InsightTag,
}

impl Default for Kind {
    fn default() -> Kind {
        Self::Pixel
    }
}
/// `inactive` when the platform reports the tag as broken/unavailable.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "active")]
    Active,
    #[serde(rename = "inactive")]
    Inactive,
}

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