/*
* 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.610.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// WebhookPayloadAdUpdated : Webhook payload for the `ad.updated` event. Fires when an ad is edited through Zernio (API, MCP or dashboard), after the platform and Zernio both accepted the edit, or when the sync detects an edit made outside Zernio. It is sent once, to the owner of the edited ad. `source` is `zernio` for edits through Zernio, `platform` for edits the sync detected outside Zernio, up to one sync interval late. From the sync, `changes` covers only `name` and `status`. Budget, bid, schedule and targeting edits made outside Zernio are not announced on the ad. Never for history loaded when an account connects. Tracking tag edits are not announced, and an ad rule that changes an ad arrives as `ad_rule.triggered`. `platformId` can change when a LinkedIn creative is replaced, while `adId` stays stable. `changes` names the edited fields and never their values: read the ad with `GET /v1/ads/{adId}` for the current state. Ignore values you do not know, new ones can be added. Events are not deduplicated: every edit is announced. Use the event `id` to drop repeats.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookPayloadAdUpdated {
/// Stable webhook event ID: the dedupe key, also sent as the X-Zernio-Event-Id header and identical on every retry and redelivery.
#[serde(rename = "id")]
pub id: String,
/// The profiles this event belongs to, each with the externalId you set on it (null when none is set). Use it to route the event to your tenant without storing Zernio profile ids. Present on every event tied to a profile, absent on events that belong to none. Events spanning several profiles (a post published to accounts of different profiles) list each once.
#[serde(rename = "profiles", skip_serializing_if = "Option::is_none")]
pub profiles: Option<Vec<models::WebhookProfilesInner>>,
/// Always true when present: only a sample sent by POST /v1/webhooks/test with an event carries it. Real deliveries never do.
#[serde(rename = "test", skip_serializing_if = "Option::is_none")]
pub test: Option<bool>,
#[serde(rename = "event")]
pub event: Event,
#[serde(rename = "account")]
pub account: Box<models::WebhookAdsAccount>,
#[serde(rename = "adObject")]
pub ad_object: Box<models::WebhookPayloadAdCreatedAdObject>,
/// Fields edited by this request. `status` is the ad's own on/off switch. Ignore values you do not know.
#[serde(rename = "changes")]
pub changes: Vec<Changes>,
/// Where the edit was made. `zernio` for edits through Zernio, `platform` for edits the sync detected outside Zernio.
#[serde(rename = "source")]
pub source: Source,
/// UTC time at which Zernio generated this event.
#[serde(rename = "timestamp")]
pub timestamp: String,
}
impl WebhookPayloadAdUpdated {
/// Webhook payload for the `ad.updated` event. Fires when an ad is edited through Zernio (API, MCP or dashboard), after the platform and Zernio both accepted the edit, or when the sync detects an edit made outside Zernio. It is sent once, to the owner of the edited ad. `source` is `zernio` for edits through Zernio, `platform` for edits the sync detected outside Zernio, up to one sync interval late. From the sync, `changes` covers only `name` and `status`. Budget, bid, schedule and targeting edits made outside Zernio are not announced on the ad. Never for history loaded when an account connects. Tracking tag edits are not announced, and an ad rule that changes an ad arrives as `ad_rule.triggered`. `platformId` can change when a LinkedIn creative is replaced, while `adId` stays stable. `changes` names the edited fields and never their values: read the ad with `GET /v1/ads/{adId}` for the current state. Ignore values you do not know, new ones can be added. Events are not deduplicated: every edit is announced. Use the event `id` to drop repeats.
pub fn new(
id: String,
event: Event,
account: models::WebhookAdsAccount,
ad_object: models::WebhookPayloadAdCreatedAdObject,
changes: Vec<Changes>,
source: Source,
timestamp: String,
) -> WebhookPayloadAdUpdated {
WebhookPayloadAdUpdated {
id,
profiles: None,
test: None,
event,
account: Box::new(account),
ad_object: Box::new(ad_object),
changes,
source,
timestamp,
}
}
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Event {
#[serde(rename = "ad.updated")]
AdUpdated,
}
impl Default for Event {
fn default() -> Event {
Self::AdUpdated
}
}
/// Fields edited by this request. `status` is the ad's own on/off switch. Ignore values you do not know.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Changes {
#[serde(rename = "name")]
Name,
#[serde(rename = "status")]
Status,
#[serde(rename = "budget")]
Budget,
#[serde(rename = "bid")]
Bid,
#[serde(rename = "schedule")]
Schedule,
#[serde(rename = "targeting")]
Targeting,
#[serde(rename = "creative")]
Creative,
#[serde(rename = "settings")]
Settings,
}
impl Default for Changes {
fn default() -> Changes {
Self::Name
}
}
/// Where the edit was made. `zernio` for edits through Zernio, `platform` for edits the sync detected outside Zernio.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Source {
#[serde(rename = "zernio")]
Zernio,
#[serde(rename = "platform")]
Platform,
}
impl Default for Source {
fn default() -> Source {
Self::Zernio
}
}