late 0.0.921

API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema).
Documentation
/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api  Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal.  Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema).
 *
 * 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};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Ad {
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    pub _id: Option<String>,
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    #[serde(rename = "platform", skip_serializing_if = "Option::is_none")]
    pub platform: Option<Platform>,
    /// Delivery status. Derived from the platform `effective_status`, so it inherits ancestor pauses (an ACTIVE ad under a PAUSED campaign reads `paused`). For the ad's own on/off toggle use `configuredStatus`; for the review state use `reviewStatus`.
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<models::AdStatus>,
    /// The ad's own on/off toggle as configured on the platform (Meta `configured_status`: ACTIVE / PAUSED), unaffected by ancestor (ad set / campaign) pauses. Distinct from `status`, which is the ancestor-cascaded delivery status. Only present for Meta ads synced after this field was added.
    #[serde(
        rename = "configuredStatus",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub configured_status: Option<Option<String>>,
    /// Platform review state of this ad, independent of delivery `status` / `configuredStatus`. Absent when the platform reports no review signal.
    #[serde(rename = "reviewStatus", skip_serializing_if = "Option::is_none")]
    pub review_status: Option<models::AdReviewStatus>,
    #[serde(rename = "adType", skip_serializing_if = "Option::is_none")]
    pub ad_type: Option<AdType>,
    /// Creative format, classified from the media the creative carries. `null` when the creative carries no media to classify. An unsynced creative and a genuine text-only ad are indistinguishable, so neither is guessed at. Returned by `GET /v1/ads`, `GET /v1/ads/{adId}` and the ad nodes of `GET /v1/ads/tree`.
    #[serde(
        rename = "creativeType",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub creative_type: Option<Option<CreativeType>>,
    /// Available goals vary by platform. Meta (Facebook/Instagram) supports all 10 (incl. `lead_conversion` = website pixel lead optimization, `catalog_sales` = Advantage+ catalog ads and `page_likes` = Page Likes conversion location under Engagement). TikTok supports engagement, traffic, awareness, video_views, lead_generation, conversions, app_promotion. LinkedIn supports all Meta goals except app_promotion / lead_conversion / catalog_sales / page_likes. X supports engagement, traffic, awareness, video_views, app_promotion. Pinterest supports only engagement, traffic, awareness, video_views. Google Ads supports only engagement, traffic, awareness (video_views is rejected at create with 422 FEATURE_NOT_AVAILABLE).
    #[serde(rename = "goal", skip_serializing_if = "Option::is_none")]
    pub goal: Option<Goal>,
    /// True for ads synced from platform ad managers
    #[serde(rename = "isExternal", skip_serializing_if = "Option::is_none")]
    pub is_external: Option<bool>,
    #[serde(rename = "budget", skip_serializing_if = "Option::is_none")]
    pub budget: Option<Box<models::AdBudget>>,
    #[serde(
        rename = "metrics",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub metrics: Option<Option<Box<models::AdMetrics>>>,
    #[serde(rename = "platformAdId", skip_serializing_if = "Option::is_none")]
    pub platform_ad_id: Option<String>,
    #[serde(
        rename = "platformAdAccountId",
        skip_serializing_if = "Option::is_none"
    )]
    pub platform_ad_account_id: Option<String>,
    #[serde(rename = "platformCampaignId", skip_serializing_if = "Option::is_none")]
    pub platform_campaign_id: Option<String>,
    #[serde(rename = "platformAdSetId", skip_serializing_if = "Option::is_none")]
    pub platform_ad_set_id: Option<String>,
    #[serde(rename = "campaignName", skip_serializing_if = "Option::is_none")]
    pub campaign_name: Option<String>,
    #[serde(rename = "adSetName", skip_serializing_if = "Option::is_none")]
    pub ad_set_name: Option<String>,
    /// Raw Meta campaign objective (e.g. OUTCOME_SALES, OUTCOME_LEADS, OUTCOME_TRAFFIC). Only present for Meta ads.
    #[serde(
        rename = "platformObjective",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub platform_objective: Option<Option<String>>,
    /// What the delivery system optimizes for, at ad-set level. The value space depends on `platform`:  - Meta: ad set `optimization_goal` (e.g. OFFSITE_CONVERSIONS, VALUE, LEAD_GENERATION, LINK_CLICKS). - LinkedIn: the campaign's EFFECTIVE `optimizationTargetType`, refreshed from LinkedIn on every   sync rather than echoing what was passed on create. `NONE` means manual bidding, and it is a   real value, not missing data. Auto-bid values are MAX_IMPRESSION / MAX_CLICK / MAX_CONVERSION /   MAX_VIDEO_VIEW / MAX_LEAD / MAX_REACH; target-cost values are TARGET_COST_PER_CLICK /   TARGET_COST_PER_IMPRESSION / TARGET_COST_PER_VIDEO_VIEW; cost-cap values are the   CAP_COST_AND_MAXIMIZE_* family.
    #[serde(
        rename = "optimizationGoal",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub optimization_goal: Option<Option<String>>,
    /// LinkedIn only. The campaign's EFFECTIVE cost model (billing event) as applied by LinkedIn, refreshed on every sync rather than echoing what was passed on create. One of `CPM` (cost per thousand impressions), `CPC` (cost per click) or `CPV` (cost per video view). On LinkedIn this is the axis that pairs with `bidAmount`; there is no `bidStrategy`. For campaign type SPONSORED_INMAILS, `CPM` bills as cost-per-send x 1000. `null` for non-LinkedIn ads.
    #[serde(
        rename = "costType",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub cost_type: Option<Option<String>>,
    /// LinkedIn only. Why the parent campaign is (or is not) delivering, verbatim from LinkedIn. A campaign can report `status: ACTIVE` and still serve nothing; this array is what says so.  - `[]` means no serving data: a non-LinkedIn ad, or a LinkedIn ad not yet re-synced. - `[\"RUNNABLE\"]` means the campaign is eligible to serve. - Anything else is a hold. Known values include ACCOUNT_SERVING_HOLD, ACCOUNT_TOTAL_BUDGET_HOLD,   ACCOUNT_END_DATE_HOLD, CAMPAIGN_START_DATE_HOLD, CAMPAIGN_END_DATE_HOLD,   CAMPAIGN_TOTAL_BUDGET_HOLD, CAMPAIGN_AUDIENCE_COUNT_HOLD, CAMPAIGN_GROUP_START_DATE_HOLD,   CAMPAIGN_GROUP_END_DATE_HOLD, CAMPAIGN_GROUP_TOTAL_BUDGET_HOLD, CAMPAIGN_GROUP_STATUS_HOLD and   STOPPED. The list is open on purpose, so treat unrecognized values as holds rather than errors.  The end-date and total-budget holds are terminal and surface as `status: completed`; the rest surface as `status: paused`. A hold is not the only cause of zero delivery: with manual, target-cost or cost-cap bidding, a `bidAmount` of 0 stops delivery while `servingStatuses` still reads `[\"RUNNABLE\"]`. Check `costType` / `bidAmount` / `optimizationGoal` as well.
    #[serde(rename = "servingStatuses", skip_serializing_if = "Option::is_none")]
    pub serving_statuses: Option<Vec<String>>,
    /// Human-readable advertiser/account name (Meta `AdAccount.name`, TikTok `advertiser_name`, LinkedIn / X / Pinterest equivalents). Refreshed every sync so platform-side renames propagate within one cycle. `null` when the platform doesn't return a name or the sync hasn't run yet.
    #[serde(
        rename = "platformAdAccountName",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub platform_ad_account_name: Option<Option<String>>,
    /// Platform-reported creation timestamp (Meta `created_time`, TikTok `create_time`). Distinct from `createdAt` which reflects when Zernio first synced the doc. To sort or filter by \"when the ad was actually created on the platform\", read this field. `null` for legacy ads synced before this field was added; aggregations fall back to `createdAt` in that case.
    #[serde(
        rename = "platformCreatedAt",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub platform_created_at: Option<Option<String>>,
    #[serde(
        rename = "bidStrategy",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub bid_strategy: Option<Option<models::BidStrategy>>,
    /// Bid amount in WHOLE currency units of the ad account (USD: 5 = $5.00; JPY: 100 = ¥100).  - Meta source: `bid_amount` on the ad set (smallest-denomination int, decoded here). Populated   when bidStrategy is `LOWEST_COST_WITH_BID_CAP` or `COST_CAP`; `null` for auto-bid   (`LOWEST_COST_WITHOUT_CAP`). - TikTok source: priority order `bid_price` -> `conversion_bid_price` -> `deep_cpa_bid`   (whichever is set on the ad group). TikTok stores all three in whole currency units. - LinkedIn source: the campaign's EFFECTIVE `unitCost`, refreshed on every sync rather than   echoing what was passed on create. Its meaning depends on the bidding mode implied by   `optimizationGoal`: bid amount (manual), target cost, or cost cap. It pairs with `costType`,   NOT with `bidStrategy`, which LinkedIn does not have. A value of `0` is a real, delivery-   stopping configuration and not \"unset\", so do not gate this field on `bidStrategy` for   LinkedIn ads.  Source: facebook-business-sdk-codegen api_specs/specs/AdSet.json (`bid_amount`).
    #[serde(
        rename = "bidAmount",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub bid_amount: Option<Option<f64>>,
    /// Minimum ROAS as a decimal multiplier (2.0 = 2.0x ROAS). Populated when bidStrategy is `LOWEST_COST_WITH_MIN_ROAS`.  - Meta source: decoded from `bid_constraints.roas_average_floor` (Meta stores as   fixed-point int × 10000; we return the decimal). - TikTok source: `roas_bid` on the ad group (already a decimal).  Source: facebook-business-sdk-codegen api_specs/specs/AdCampaignBidConstraint.json.
    #[serde(
        rename = "roasAverageFloor",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub roas_average_floor: Option<Option<f64>>,
    #[serde(rename = "promotedObject", skip_serializing_if = "Option::is_none")]
    pub promoted_object: Option<Box<models::AdPromotedObject>>,
    #[serde(rename = "creative", skip_serializing_if = "Option::is_none")]
    pub creative: Option<Box<models::AdCreative>>,
    /// The ad set's targeting (age, gender, geo, interests, placements, audience inclusions/exclusions). For ads created through Zernio this is the spec you supplied. For external ads (synced from Meta Ads Manager, `isExternal: true`) targeting lives at the ad set and isn't stored at ingest, so on the first `GET /v1/ads/{adId}` Zernio resolves it live from Meta and caches it on the ad; the value is then Meta's raw `targeting` shape (snake_case, e.g. `geo_locations`, `age_min`), the same object Ads Manager shows. May be absent if the ad set exposes no targeting or the lookup fails.
    #[serde(rename = "targeting", skip_serializing_if = "Option::is_none")]
    pub targeting: Option<serde_json::Value>,
    #[serde(rename = "schedule", skip_serializing_if = "Option::is_none")]
    pub schedule: Option<Box<models::AdSchedule>>,
    #[serde(rename = "rejectionReason", skip_serializing_if = "Option::is_none")]
    pub rejection_reason: Option<String>,
    #[serde(rename = "createdAt", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
    #[serde(rename = "updatedAt", skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<String>,
}

impl Ad {
    pub fn new() -> Ad {
        Ad {
            _id: None,
            name: None,
            platform: None,
            status: None,
            configured_status: None,
            review_status: None,
            ad_type: None,
            creative_type: None,
            goal: None,
            is_external: None,
            budget: None,
            metrics: None,
            platform_ad_id: None,
            platform_ad_account_id: None,
            platform_campaign_id: None,
            platform_ad_set_id: None,
            campaign_name: None,
            ad_set_name: None,
            platform_objective: None,
            optimization_goal: None,
            cost_type: None,
            serving_statuses: None,
            platform_ad_account_name: None,
            platform_created_at: None,
            bid_strategy: None,
            bid_amount: None,
            roas_average_floor: None,
            promoted_object: None,
            creative: None,
            targeting: None,
            schedule: None,
            rejection_reason: None,
            created_at: None,
            updated_at: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Platform {
    #[serde(rename = "facebook")]
    Facebook,
    #[serde(rename = "instagram")]
    Instagram,
    #[serde(rename = "tiktok")]
    Tiktok,
    #[serde(rename = "linkedin")]
    Linkedin,
    #[serde(rename = "pinterest")]
    Pinterest,
    #[serde(rename = "google")]
    Google,
    #[serde(rename = "twitter")]
    Twitter,
    #[serde(rename = "openai")]
    Openai,
}

impl Default for Platform {
    fn default() -> Platform {
        Self::Facebook
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum AdType {
    #[serde(rename = "boost")]
    Boost,
    #[serde(rename = "standalone")]
    Standalone,
}

impl Default for AdType {
    fn default() -> AdType {
        Self::Boost
    }
}
/// Creative format, classified from the media the creative carries. `null` when the creative carries no media to classify. An unsynced creative and a genuine text-only ad are indistinguishable, so neither is guessed at. Returned by `GET /v1/ads`, `GET /v1/ads/{adId}` and the ad nodes of `GET /v1/ads/tree`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CreativeType {
    #[serde(rename = "carousel")]
    Carousel,
    #[serde(rename = "video")]
    Video,
    #[serde(rename = "document")]
    Document,
    #[serde(rename = "image")]
    Image,
}

impl Default for CreativeType {
    fn default() -> CreativeType {
        Self::Carousel
    }
}
/// Available goals vary by platform. Meta (Facebook/Instagram) supports all 10 (incl. `lead_conversion` = website pixel lead optimization, `catalog_sales` = Advantage+ catalog ads and `page_likes` = Page Likes conversion location under Engagement). TikTok supports engagement, traffic, awareness, video_views, lead_generation, conversions, app_promotion. LinkedIn supports all Meta goals except app_promotion / lead_conversion / catalog_sales / page_likes. X supports engagement, traffic, awareness, video_views, app_promotion. Pinterest supports only engagement, traffic, awareness, video_views. Google Ads supports only engagement, traffic, awareness (video_views is rejected at create with 422 FEATURE_NOT_AVAILABLE).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Goal {
    #[serde(rename = "engagement")]
    Engagement,
    #[serde(rename = "traffic")]
    Traffic,
    #[serde(rename = "awareness")]
    Awareness,
    #[serde(rename = "video_views")]
    VideoViews,
    #[serde(rename = "lead_generation")]
    LeadGeneration,
    #[serde(rename = "lead_conversion")]
    LeadConversion,
    #[serde(rename = "conversions")]
    Conversions,
    #[serde(rename = "app_promotion")]
    AppPromotion,
    #[serde(rename = "catalog_sales")]
    CatalogSales,
    #[serde(rename = "page_likes")]
    PageLikes,
    #[serde(rename = "job_applicants")]
    JobApplicants,
}

impl Default for Goal {
    fn default() -> Goal {
        Self::Engagement
    }
}