late 0.0.1291

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). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
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).  Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
 *
 * The version of the OpenAPI document: 1.416.0
 * 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 AdRule {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "name")]
    pub name: String,
    /// The ads connection the rule acts through.
    #[serde(rename = "accountId")]
    pub account_id: String,
    /// Ad platform, for example `facebook` (Meta) or `google`.
    #[serde(rename = "platform")]
    pub platform: String,
    /// Platform ad account ID.
    #[serde(rename = "adAccountId")]
    pub ad_account_id: String,
    #[serde(rename = "level")]
    pub level: models::AdRuleLevel,
    /// Platform campaign IDs the rule is limited to. Null checks the whole ad account.
    #[serde(rename = "campaignIds", deserialize_with = "Option::deserialize")]
    pub campaign_ids: Option<Vec<String>>,
    #[serde(rename = "conditions")]
    pub conditions: Box<models::AdRuleConditions>,
    /// Each type at most once, and at most one of `pause`, `activate` and `adjust_budget`.
    #[serde(rename = "actions")]
    pub actions: Vec<models::AdRuleAction>,
    #[serde(rename = "schedule")]
    pub schedule: Box<models::AdRuleSchedule>,
    #[serde(rename = "cooldownMinutes")]
    pub cooldown_minutes: i32,
    #[serde(rename = "enabled")]
    pub enabled: bool,
    #[serde(rename = "lastRunAt", deserialize_with = "Option::deserialize")]
    pub last_run_at: Option<String>,
    /// Null while the rule is disabled.
    #[serde(rename = "nextRunAt", deserialize_with = "Option::deserialize")]
    pub next_run_at: Option<String>,
    #[serde(rename = "createdAt")]
    pub created_at: String,
    #[serde(rename = "updatedAt")]
    pub updated_at: String,
}

impl AdRule {
    pub fn new(
        id: String,
        name: String,
        account_id: String,
        platform: String,
        ad_account_id: String,
        level: models::AdRuleLevel,
        campaign_ids: Option<Vec<String>>,
        conditions: models::AdRuleConditions,
        actions: Vec<models::AdRuleAction>,
        schedule: models::AdRuleSchedule,
        cooldown_minutes: i32,
        enabled: bool,
        last_run_at: Option<String>,
        next_run_at: Option<String>,
        created_at: String,
        updated_at: String,
    ) -> AdRule {
        AdRule {
            id,
            name,
            account_id,
            platform,
            ad_account_id,
            level,
            campaign_ids,
            conditions: Box::new(conditions),
            actions,
            schedule: Box::new(schedule),
            cooldown_minutes,
            enabled,
            last_run_at,
            next_run_at,
            created_at,
            updated_at,
        }
    }
}