/*
* 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.531.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 CreateAdRuleRequest {
#[serde(rename = "name")]
pub name: String,
/// The ads connection (account ID from `GET /v1/accounts`).
#[serde(rename = "accountId")]
pub account_id: String,
/// Platform ad account ID, from `GET /v1/ads/accounts`.
#[serde(rename = "adAccountId")]
pub ad_account_id: String,
#[serde(rename = "level")]
pub level: models::AdRuleLevel,
/// Only check these platform campaign IDs (or their ad sets). Leave out to check the whole ad account.
#[serde(rename = "campaignIds", skip_serializing_if = "Option::is_none")]
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", skip_serializing_if = "Option::is_none")]
pub filters: Option<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",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub groups: Option<Option<Vec<models::AdRuleGroupsInner>>>,
#[serde(
rename = "lifecycle",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub lifecycle: Option<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>,
/// Leave it out to run every 60 minutes.
#[serde(rename = "schedule", skip_serializing_if = "Option::is_none")]
pub schedule: Option<Box<models::AdRuleSchedule>>,
/// How long the rule leaves an object alone after acting on it.
#[serde(rename = "cooldownMinutes", skip_serializing_if = "Option::is_none")]
pub cooldown_minutes: Option<i32>,
#[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
}
impl CreateAdRuleRequest {
pub fn new(
name: String,
account_id: String,
ad_account_id: String,
level: models::AdRuleLevel,
conditions: models::AdRuleConditions,
actions: Vec<models::AdRuleAction>,
) -> CreateAdRuleRequest {
CreateAdRuleRequest {
name,
account_id,
ad_account_id,
level,
campaign_ids: None,
filters: None,
groups: None,
lifecycle: None,
conditions: Box::new(conditions),
actions,
schedule: None,
cooldown_minutes: None,
enabled: None,
}
}
}