late 0.0.296

API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api
Documentation
/*
 * 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};

/// TargetingSpec : Normalized, platform-agnostic ad-targeting spec. Every field is optional, an empty object targets the platform's default broadest audience. Field names are camelCase and identical across `POST /v1/ads/create` (the `targeting` object), `POST /v1/ads/targeting/reach-estimate`, and `saved_targeting` audiences, so a spec resolved once can be reused verbatim.  Entity ids (`regions[].key`, `cities[].key`, `zips[].key`, `metros[].key`, `interests[].id`, `behaviors[].id`) are the platform's opaque identifiers resolved via `GET /v1/ads/targeting/search`. A spec is therefore meaningful only for the platform it was built against, except the portable fields (`countries`, `ageMin`/`ageMax`, `gender`, `incomeTier`, `languages`) which carry across platforms. Fields a platform cannot honour are rejected at create time with `INVALID_FIELD_VALUE` naming the offending field (not silently dropped).
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TargetingSpec {
    /// ISO 3166-1 alpha-2 country codes (e.g. ['US']).
    #[serde(rename = "countries", skip_serializing_if = "Option::is_none")]
    pub countries: Option<Vec<String>>,
    /// Region/state targeting. `key` is the platform location ID from /v1/ads/targeting/search?dimension=geo&geoType=region.
    #[serde(rename = "regions", skip_serializing_if = "Option::is_none")]
    pub regions: Option<Vec<models::CreateStandaloneAdRequestZipsInner>>,
    /// City targeting. Optional `radius` + `distanceUnit` extend beyond the city limits; both must be set together or both omitted. `radius` is only honoured on platforms whose capability map allows city radius (Meta).
    #[serde(rename = "cities", skip_serializing_if = "Option::is_none")]
    pub cities: Option<Vec<models::TargetingSpecCitiesInner>>,
    /// Postal/ZIP targeting. `key` is the platform's postal location ID (e.g. Meta `US:94304`). Supported on Meta, Google, TikTok, Pinterest, X.
    #[serde(rename = "zips", skip_serializing_if = "Option::is_none")]
    pub zips: Option<Vec<models::CreateStandaloneAdRequestZipsInner>>,
    /// DMA / metro-area targeting. `key` is the platform's metro ID (e.g. Meta `DMA:807`).
    #[serde(rename = "metros", skip_serializing_if = "Option::is_none")]
    pub metros: Option<Vec<models::CreateStandaloneAdRequestZipsInner>>,
    /// Point-radius (lat/lng) targeting (Meta custom_locations / Google proximity). Honoured only where the capability map allows radius (Meta).
    #[serde(rename = "customLocations", skip_serializing_if = "Option::is_none")]
    pub custom_locations: Option<Vec<models::TargetingSpecCustomLocationsInner>>,
    #[serde(rename = "excludedLocations", skip_serializing_if = "Option::is_none")]
    pub excluded_locations: Option<Box<models::TargetingSpecExcludedLocations>>,
    #[serde(rename = "ageMin", skip_serializing_if = "Option::is_none")]
    pub age_min: Option<i32>,
    #[serde(rename = "ageMax", skip_serializing_if = "Option::is_none")]
    pub age_max: Option<i32>,
    /// Restrict by gender. 'all' (default) targets everyone.
    #[serde(rename = "gender", skip_serializing_if = "Option::is_none")]
    pub gender: Option<Gender>,
    /// Normalized household-income tier (ZIP/percentile based). Meta and TikTok express all four. Google maps only `top_10` (its INCOME_RANGE_90_UP); other tiers on Google, and any income tier on LinkedIn / X / Pinterest, are rejected. On Meta, income/zip targeting requires the relevant `specialAdCategories` to be unset (housing/employment/credit ads cannot use it).
    #[serde(rename = "incomeTier", skip_serializing_if = "Option::is_none")]
    pub income_tier: Option<IncomeTier>,
    /// Language codes (e.g. ['en']).
    #[serde(rename = "languages", skip_serializing_if = "Option::is_none")]
    pub languages: Option<Vec<String>>,
    /// Interest entities from /v1/ads/targeting/search?dimension=interest. Each carries the platform's opaque id.
    #[serde(rename = "interests", skip_serializing_if = "Option::is_none")]
    pub interests: Option<Vec<models::CreateStandaloneAdRequestBehaviorsInner>>,
    /// Behaviour entities from /v1/ads/targeting/search?dimension=behavior. Supported on Meta and TikTok.
    #[serde(rename = "behaviors", skip_serializing_if = "Option::is_none")]
    pub behaviors: Option<Vec<models::CreateStandaloneAdRequestBehaviorsInner>>,
    /// LinkedIn B2B only. Industry URN id fragments.
    #[serde(rename = "industries", skip_serializing_if = "Option::is_none")]
    pub industries: Option<Vec<String>>,
    /// LinkedIn B2B only.
    #[serde(rename = "companySizes", skip_serializing_if = "Option::is_none")]
    pub company_sizes: Option<Vec<String>>,
    /// LinkedIn B2B only.
    #[serde(rename = "seniorities", skip_serializing_if = "Option::is_none")]
    pub seniorities: Option<Vec<String>>,
    /// LinkedIn B2B only.
    #[serde(rename = "jobFunctions", skip_serializing_if = "Option::is_none")]
    pub job_functions: Option<Vec<String>>,
    /// Platform audience IDs to include.
    #[serde(rename = "audienceInclude", skip_serializing_if = "Option::is_none")]
    pub audience_include: Option<Vec<String>>,
    /// Platform audience IDs to exclude.
    #[serde(rename = "audienceExclude", skip_serializing_if = "Option::is_none")]
    pub audience_exclude: Option<Vec<String>>,
}

impl TargetingSpec {
    /// Normalized, platform-agnostic ad-targeting spec. Every field is optional, an empty object targets the platform's default broadest audience. Field names are camelCase and identical across `POST /v1/ads/create` (the `targeting` object), `POST /v1/ads/targeting/reach-estimate`, and `saved_targeting` audiences, so a spec resolved once can be reused verbatim.  Entity ids (`regions[].key`, `cities[].key`, `zips[].key`, `metros[].key`, `interests[].id`, `behaviors[].id`) are the platform's opaque identifiers resolved via `GET /v1/ads/targeting/search`. A spec is therefore meaningful only for the platform it was built against, except the portable fields (`countries`, `ageMin`/`ageMax`, `gender`, `incomeTier`, `languages`) which carry across platforms. Fields a platform cannot honour are rejected at create time with `INVALID_FIELD_VALUE` naming the offending field (not silently dropped).
    pub fn new() -> TargetingSpec {
        TargetingSpec {
            countries: None,
            regions: None,
            cities: None,
            zips: None,
            metros: None,
            custom_locations: None,
            excluded_locations: None,
            age_min: None,
            age_max: None,
            gender: None,
            income_tier: None,
            languages: None,
            interests: None,
            behaviors: None,
            industries: None,
            company_sizes: None,
            seniorities: None,
            job_functions: None,
            audience_include: None,
            audience_exclude: None,
        }
    }
}
/// Restrict by gender. 'all' (default) targets everyone.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Gender {
    #[serde(rename = "all")]
    All,
    #[serde(rename = "male")]
    Male,
    #[serde(rename = "female")]
    Female,
}

impl Default for Gender {
    fn default() -> Gender {
        Self::All
    }
}
/// Normalized household-income tier (ZIP/percentile based). Meta and TikTok express all four. Google maps only `top_10` (its INCOME_RANGE_90_UP); other tiers on Google, and any income tier on LinkedIn / X / Pinterest, are rejected. On Meta, income/zip targeting requires the relevant `specialAdCategories` to be unset (housing/employment/credit ads cannot use it).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum IncomeTier {
    #[serde(rename = "top_5")]
    Top5,
    #[serde(rename = "top_10")]
    Top10,
    #[serde(rename = "top_10_25")]
    Top1025,
    #[serde(rename = "top_25_50")]
    Top2550,
}

impl Default for IncomeTier {
    fn default() -> IncomeTier {
        Self::Top5
    }
}