/*
* 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.565.5
* 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>>,
/// Narrows the objects the rule checks. Every filter must hold. A campaign rule reads `name`, `campaign_id`, `goal`, `days_live` and `budget_level`; an ad set rule also `campaign_name` and `adset_id`; an ad rule also `adset_name` and `ad_id`.
#[serde(rename = "filters")]
pub filters: Vec<models::AdRuleFiltersInner>,
/// Campaigns judged together, campaign rules only. Each group's numbers and your results are added up across its campaigns, and rates and formulas are computed on the totals: a group's `result:cac_percent` is its total spend over its total revenue. The conditions are judged once per group, and a matching group acts on each of its campaigns, each with its own cooldown and daily cap. Paused campaigns count toward a group's totals; only the ones the rule may act on are changed. A group with no filters holds every campaign the rule checks: the whole ad account. A campaign in several groups is acted on once per run, by the first matching group. Reach and frequency cannot be added up across campaigns, so a rule with groups cannot use them. A campaign with no results sent for the window adds its spend and no results to its group. A result sent as a rate (kind `percent` or `ratio`, no formula) reads as unknown for a group; define it as a formula over counts.
#[serde(rename = "groups", deserialize_with = "Option::deserialize")]
pub groups: Option<Vec<models::AdRuleGroupsInner>>,
#[serde(rename = "lifecycle", deserialize_with = "Option::deserialize")]
pub lifecycle: Option<Box<models::AdRuleLifecycle>>,
#[serde(rename = "conditions")]
pub conditions: Box<models::AdRuleConditions>,
/// Each type at most once, and at most one of `pause`, `activate`, `adjust_budget`, `adjust_bid`, `adjust_target`, `reallocate_budget`, `duplicate` and `edit_name`.
#[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>>,
filters: Vec<models::AdRuleFiltersInner>,
groups: Option<Vec<models::AdRuleGroupsInner>>,
lifecycle: Option<models::AdRuleLifecycle>,
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,
filters,
groups,
lifecycle: if let Some(x) = lifecycle {
Some(Box::new(x))
} else {
None
},
conditions: Box::new(conditions),
actions,
schedule: Box::new(schedule),
cooldown_minutes,
enabled,
last_run_at,
next_run_at,
created_at,
updated_at,
}
}
}