/*
* 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.587.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 AdRuleObjectEvaluationConditionsInner {
#[serde(rename = "metric")]
pub metric: Metric,
/// Days in the ad account's own timezone. `last_7d` is the 7 full days before today; only `today` and `this_month` read the day in progress. `this_month` runs from the 1st through today; `last_month` is the whole previous calendar month. `<from>_to_<to>_days_ago` is any range of full days, both ends included, such as `8_to_2_days_ago` to skip the 2 most recent days while their conversions still arrive. `from` is at least `to` and at most 90. `last_complete_hour`, `last_3h` and `today_so_far` read campaign totals hour by hour, on campaign rules for Meta and Google, and end at the latest hour whose numbers have settled, not at now. They take `spend`, `impressions`, `clicks`, `ctr`, `cpc` and `cpm`, and no `top` or `bottom`.
#[serde(rename = "window")]
pub window: Window,
/// `top` and `bottom` rank the rule's objects by the metric over the window, highest first for `top`, and match the first `value` (a whole number from 1 to 100). Objects with no value are not ranked; the run history shows each one's position.
#[serde(rename = "op")]
pub op: Op,
#[serde(rename = "value")]
pub value: f64,
/// Makes the condition relative: `value` becomes a ratio of the metric over `window` to the same metric over this window, such as `30_to_2_days_ago`. `previous_period` is the same number of days just before `window`. For `this_month` it is the same days of last month, and for `last_month` the month before. Spend, impressions, clicks, conversions and reach are compared per day, so windows of different lengths compare fairly; rates such as `cpc` compare as they are. A comparison window with no value never matches. `usual` compares with the median of the same window on the 4 previous weeks. For an hourly window that is the same hours on the 4 previous same weekdays, and for a window of up to 7 full days (not `today`) the same days moved back 1 to 4 weeks. `usual` needs at least 3 of those weeks with a value, and takes no reach, frequency, budget or calendar metric. On an hourly window, `compareTo` is `usual`, or for `ctr`, `cpc` and `cpm` a window of full days ending by yesterday and starting at most 35 days ago, read from the same hourly totals. For example, `cpc` over `last_complete_hour` `>=` 5 against `last_30d` means the last hour's clicks cost 5 times their 30-day price.
#[serde(rename = "compareTo", skip_serializing_if = "Option::is_none")]
pub compare_to: Option<String>,
/// Reads the usual value of the metric over `window` (as `compareTo: usual` defines it) instead of its current value, such as campaigns that usually get at least 50 impressions in the last 3 hours. Not combined with `compareTo`.
#[serde(rename = "of", skip_serializing_if = "Option::is_none")]
pub of: Option<Of>,
/// The object's value over the window. Null when it cannot be computed.
#[serde(rename = "actual", deserialize_with = "Option::deserialize")]
pub actual: Option<f64>,
#[serde(rename = "met")]
pub met: bool,
}
impl AdRuleObjectEvaluationConditionsInner {
pub fn new(
metric: Metric,
window: Window,
op: Op,
value: f64,
actual: Option<f64>,
met: bool,
) -> AdRuleObjectEvaluationConditionsInner {
AdRuleObjectEvaluationConditionsInner {
metric,
window,
op,
value,
compare_to: None,
of: None,
actual,
met,
}
}
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Metric {
#[serde(rename = "spend")]
Spend,
#[serde(rename = "impressions")]
Impressions,
#[serde(rename = "clicks")]
Clicks,
#[serde(rename = "conversions")]
Conversions,
#[serde(rename = "ctr")]
Ctr,
#[serde(rename = "cpc")]
Cpc,
#[serde(rename = "cpm")]
Cpm,
#[serde(rename = "cpa")]
Cpa,
#[serde(rename = "roas")]
Roas,
#[serde(rename = "reach")]
Reach,
#[serde(rename = "frequency")]
Frequency,
#[serde(rename = "daily_budget")]
DailyBudget,
#[serde(rename = "budget_used")]
BudgetUsed,
#[serde(rename = "day_of_month")]
DayOfMonth,
#[serde(rename = "working_day_of_month")]
WorkingDayOfMonth,
}
impl Default for Metric {
fn default() -> Metric {
Self::Spend
}
}
/// Days in the ad account's own timezone. `last_7d` is the 7 full days before today; only `today` and `this_month` read the day in progress. `this_month` runs from the 1st through today; `last_month` is the whole previous calendar month. `<from>_to_<to>_days_ago` is any range of full days, both ends included, such as `8_to_2_days_ago` to skip the 2 most recent days while their conversions still arrive. `from` is at least `to` and at most 90. `last_complete_hour`, `last_3h` and `today_so_far` read campaign totals hour by hour, on campaign rules for Meta and Google, and end at the latest hour whose numbers have settled, not at now. They take `spend`, `impressions`, `clicks`, `ctr`, `cpc` and `cpm`, and no `top` or `bottom`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Window {
#[serde(rename = "today")]
Today,
#[serde(rename = "yesterday")]
Yesterday,
#[serde(rename = "last_3d")]
Last3d,
#[serde(rename = "last_7d")]
Last7d,
#[serde(rename = "last_14d")]
Last14d,
#[serde(rename = "last_30d")]
Last30d,
#[serde(rename = "this_month")]
ThisMonth,
#[serde(rename = "last_month")]
LastMonth,
#[serde(rename = "last_complete_hour")]
LastCompleteHour,
#[serde(rename = "last_3h")]
Last3h,
#[serde(rename = "today_so_far")]
TodaySoFar,
}
impl Default for Window {
fn default() -> Window {
Self::Today
}
}
/// `top` and `bottom` rank the rule's objects by the metric over the window, highest first for `top`, and match the first `value` (a whole number from 1 to 100). Objects with no value are not ranked; the run history shows each one's position.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Op {
#[serde(rename = ">")]
GreaterThan,
#[serde(rename = ">=")]
GreaterThanEqual,
#[serde(rename = "<")]
LessThan,
#[serde(rename = "<=")]
LessThanEqual,
#[serde(rename = "top")]
Top,
#[serde(rename = "bottom")]
Bottom,
}
impl Default for Op {
fn default() -> Op {
Self::GreaterThan
}
}
/// Reads the usual value of the metric over `window` (as `compareTo: usual` defines it) instead of its current value, such as campaigns that usually get at least 50 impressions in the last 3 hours. Not combined with `compareTo`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Of {
#[serde(rename = "usual")]
Usual,
}
impl Default for Of {
fn default() -> Of {
Self::Usual
}
}