/*
* 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.522.1
* 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,
#[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.
#[serde(rename = "compareTo", skip_serializing_if = "Option::is_none")]
pub compare_to: Option<String>,
/// 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,
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
}
}
///
#[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,
}
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
}
}