/*
* 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.104.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// ValueRule : One bid-adjustment rule. Rules are evaluated in ARRAY ORDER and only the first matching rule adjusts the bid for an overlapping audience, so the order is semantic.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ValueRule {
/// Platform rule id. Echo it on `PUT` to KEEP this rule, omit it to CREATE a new one. A rule left out of the array entirely is DELETED.
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name")]
pub name: String,
/// Direction of the adjustment. There is no signed value field.
#[serde(rename = "adjustSign")]
pub adjust_sign: AdjustSign,
/// Unsigned percentage magnitude. `INCREASE` accepts 1-1000, `DECREASE` accepts 1-90. 0 is out of range on both.
#[serde(rename = "adjustValue")]
pub adjust_value: i32,
/// Meta returns `ACTIVE` here but documents no enum for the field. Treat it as a passthrough: echo whatever the `GET` returned, and do not synthesize values.
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
/// All criteria on a rule must match for the rule to fire.
#[serde(rename = "criteria")]
pub criteria: Vec<models::ValueRuleCriterion>,
}
impl ValueRule {
/// One bid-adjustment rule. Rules are evaluated in ARRAY ORDER and only the first matching rule adjusts the bid for an overlapping audience, so the order is semantic.
pub fn new(
name: String,
adjust_sign: AdjustSign,
adjust_value: i32,
criteria: Vec<models::ValueRuleCriterion>,
) -> ValueRule {
ValueRule {
id: None,
name,
adjust_sign,
adjust_value,
status: None,
criteria,
}
}
}
/// Direction of the adjustment. There is no signed value field.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum AdjustSign {
#[serde(rename = "INCREASE")]
Increase,
#[serde(rename = "DECREASE")]
Decrease,
}
impl Default for AdjustSign {
fn default() -> AdjustSign {
Self::Increase
}
}