/*
* 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.605.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// AdRuleActionOneOf6 : Exactly one of `percent` and `amount`.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AdRuleActionOneOf6 {
/// Move daily budget from the matched objects ranked worst by `metric` to those ranked best, keeping the total the same. Not with `lifecycle` or `groups`. Campaign or ad set rules where the budget sits at that level: objects whose budget sits at another level (Meta CBO and ad set budgets), Google shared budgets and lifetime budgets are left out. Changes are reserved all at once: when `maxChangesPerDay` would hold back any of them, none is made. A receiver is raised only after every giver's cut applied (else it fails with `reallocation_incomplete` and the move is tried again next run). Amounts move in the currency's smallest unit (whole units for JPY or KRW). Counts as raising live spend for the free ads allowance.
#[serde(rename = "type")]
pub r#type: Type,
/// What objects are ranked by: any condition metric except `day_of_month`, `working_day_of_month` and the Google impression shares, or a result metric (`result:<key>`) on campaign rules. Objects without a value are not ranked, except one that spent with no result on a metric where lower is best (a CPA with no conversions): it ranks worst and only gives.
#[serde(rename = "metric")]
pub metric: String,
/// The period the metric is read over, like a condition window.
#[serde(rename = "window")]
pub window: String,
/// Which end of the ranking is best. Defaults to `lowest` for `cpa`, `cpc`, `cpm`, `frequency` and result metrics whose formula has spend above the line (cost per sale, %CAC), `highest` otherwise.
#[serde(rename = "best", skip_serializing_if = "Option::is_none")]
pub best: Option<Best>,
#[serde(rename = "from")]
pub from: Box<models::AdRuleActionOneOf6From>,
#[serde(rename = "to")]
pub to: Box<models::AdRuleActionOneOf6To>,
/// The share of each giver's daily budget it gives.
#[serde(rename = "percent", skip_serializing_if = "Option::is_none")]
pub percent: Option<i32>,
/// The total to move each run, in the ad account currency, taken evenly from the givers.
#[serde(rename = "amount", skip_serializing_if = "Option::is_none")]
pub amount: Option<f64>,
/// A giver never goes below this daily budget. A giver also always keeps a tenth of its budget.
#[serde(rename = "minBudget", skip_serializing_if = "Option::is_none")]
pub min_budget: Option<f64>,
/// A receiver never goes above this daily budget; what receivers cannot take stays with the givers.
#[serde(rename = "maxBudget", skip_serializing_if = "Option::is_none")]
pub max_budget: Option<f64>,
/// At most this many objects changed in any 24 hours, across runs. Matches over the limit are skipped with `daily_limit_reached` and tried again later.
#[serde(rename = "maxChangesPerDay", skip_serializing_if = "Option::is_none")]
pub max_changes_per_day: Option<i32>,
/// At most this many changes to one object by this rule, counted over the last 400 days. An object at the limit is left alone like one in cooldown.
#[serde(
rename = "maxChangesPerObject",
skip_serializing_if = "Option::is_none"
)]
pub max_changes_per_object: Option<i32>,
}
impl AdRuleActionOneOf6 {
/// Exactly one of `percent` and `amount`.
pub fn new(
r#type: Type,
metric: String,
window: String,
from: models::AdRuleActionOneOf6From,
to: models::AdRuleActionOneOf6To,
) -> AdRuleActionOneOf6 {
AdRuleActionOneOf6 {
r#type,
metric,
window,
best: None,
from: Box::new(from),
to: Box::new(to),
percent: None,
amount: None,
min_budget: None,
max_budget: None,
max_changes_per_day: None,
max_changes_per_object: None,
}
}
}
/// Move daily budget from the matched objects ranked worst by `metric` to those ranked best, keeping the total the same. Not with `lifecycle` or `groups`. Campaign or ad set rules where the budget sits at that level: objects whose budget sits at another level (Meta CBO and ad set budgets), Google shared budgets and lifetime budgets are left out. Changes are reserved all at once: when `maxChangesPerDay` would hold back any of them, none is made. A receiver is raised only after every giver's cut applied (else it fails with `reallocation_incomplete` and the move is tried again next run). Amounts move in the currency's smallest unit (whole units for JPY or KRW). Counts as raising live spend for the free ads allowance.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "reallocate_budget")]
ReallocateBudget,
}
impl Default for Type {
fn default() -> Type {
Self::ReallocateBudget
}
}
/// Which end of the ranking is best. Defaults to `lowest` for `cpa`, `cpc`, `cpm`, `frequency` and result metrics whose formula has spend above the line (cost per sale, %CAC), `highest` otherwise.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Best {
#[serde(rename = "highest")]
Highest,
#[serde(rename = "lowest")]
Lowest,
}
impl Default for Best {
fn default() -> Best {
Self::Highest
}
}