late 0.0.1138

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.
Documentation
/*
 * 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.228.0
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// WebhookPayloadMessageMetadataReferral : Click attribution forwarded verbatim from Meta. Populated only on the first inbound message Meta attaches it to, and absent on the other messages of the same conversation. That is not always the first message after the click: on Instagram Click-to-Direct Meta usually delivers the ad post itself first, as an attachment-only `share` / `ig_post` message with no referral, and attaches the referral to the message right after it. The first referral of a conversation is also stored on the conversation as `metadata.meta_ad_*` (`GET /v1/inbox/conversations/{conversationId}`), so read it there instead of matching webhooks. On Instagram and Messenger a RETURNING click also attaches it to the first message that follows, so read it on every `message.received` for per-click attribution; a click that opens an existing thread WITHOUT a message arrives as the separate `referral.received` event.  The populated subset identifies the source:   - `ctwa_clid` and `source_*` fields: WhatsApp CTWA     (Click-to-WhatsApp). Attribution window is 7 days from click.     Forward to Meta Conversions API for Business Messaging replay.   - `ad_id` and `ads_context_data`: Facebook Messenger CTM     (Click-to-Message) or Instagram CTD (Click-to-Direct). Use     `ad_id` to attribute the conversation to a specific ad.   - `ref` without `ad_id`: an ig.me / m.me link carrying a     `?ref=` parameter (`source` is `SHORTLINK`, `SHORTLINKS` or     `IGME-SOURCE-LINK` depending on surface - treat it as     opaque). Instagram delivers ig.me refs on new threads only     when the account has at least one Ice Breaker configured     (`PUT /v1/accounts/{accountId}/instagram-ice-breakers`).
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookPayloadMessageMetadataReferral {
    /// Meta's GCLID-equivalent click identifier.
    #[serde(rename = "ctwa_clid", skip_serializing_if = "Option::is_none")]
    pub ctwa_clid: Option<String>,
    #[serde(rename = "source_id", skip_serializing_if = "Option::is_none")]
    pub source_id: Option<String>,
    #[serde(rename = "source_type", skip_serializing_if = "Option::is_none")]
    pub source_type: Option<String>,
    #[serde(rename = "source_url", skip_serializing_if = "Option::is_none")]
    pub source_url: Option<String>,
    #[serde(rename = "headline", skip_serializing_if = "Option::is_none")]
    pub headline: Option<String>,
    #[serde(rename = "body", skip_serializing_if = "Option::is_none")]
    pub body: Option<String>,
    #[serde(rename = "media_type", skip_serializing_if = "Option::is_none")]
    pub media_type: Option<String>,
    #[serde(rename = "image_url", skip_serializing_if = "Option::is_none")]
    pub image_url: Option<String>,
    #[serde(rename = "video_url", skip_serializing_if = "Option::is_none")]
    pub video_url: Option<String>,
    #[serde(rename = "thumbnail_url", skip_serializing_if = "Option::is_none")]
    pub thumbnail_url: Option<String>,
    #[serde(rename = "welcome_message", skip_serializing_if = "Option::is_none")]
    pub welcome_message: Option<Box<models::WebhookPayloadMessageMetadataReferralWelcomeMessage>>,
    /// Facebook Messenger CTM / Instagram CTD only. The Meta ad ID the user clicked to start the conversation.
    #[serde(rename = "ad_id", skip_serializing_if = "Option::is_none")]
    pub ad_id: Option<String>,
    /// The `ref` parameter passed through from the Meta ad creative or from an ig.me / m.me link. Instagram / Facebook Messenger only.
    #[serde(rename = "ref", skip_serializing_if = "Option::is_none")]
    pub r#ref: Option<String>,
    /// Meta-supplied source identifier (`ADS` for ad clicks; `SHORTLINK`, `SHORTLINKS` or `IGME-SOURCE-LINK` for ref links). Instagram / Facebook Messenger only.
    #[serde(rename = "source", skip_serializing_if = "Option::is_none")]
    pub source: Option<String>,
    /// Meta-supplied referral type (e.g. `OPEN_THREAD`). Instagram / Facebook Messenger only.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,
    /// URI of the originating site, when Meta supplies one (m.me links opened from the web). Facebook Messenger only.
    #[serde(rename = "referer_uri", skip_serializing_if = "Option::is_none")]
    pub referer_uri: Option<String>,
    #[serde(rename = "ads_context_data", skip_serializing_if = "Option::is_none")]
    pub ads_context_data: Option<Box<models::WebhookPayloadMessageMetadataReferralAdsContextData>>,
}

impl WebhookPayloadMessageMetadataReferral {
    /// Click attribution forwarded verbatim from Meta. Populated only on the first inbound message Meta attaches it to, and absent on the other messages of the same conversation. That is not always the first message after the click: on Instagram Click-to-Direct Meta usually delivers the ad post itself first, as an attachment-only `share` / `ig_post` message with no referral, and attaches the referral to the message right after it. The first referral of a conversation is also stored on the conversation as `metadata.meta_ad_*` (`GET /v1/inbox/conversations/{conversationId}`), so read it there instead of matching webhooks. On Instagram and Messenger a RETURNING click also attaches it to the first message that follows, so read it on every `message.received` for per-click attribution; a click that opens an existing thread WITHOUT a message arrives as the separate `referral.received` event.  The populated subset identifies the source:   - `ctwa_clid` and `source_*` fields: WhatsApp CTWA     (Click-to-WhatsApp). Attribution window is 7 days from click.     Forward to Meta Conversions API for Business Messaging replay.   - `ad_id` and `ads_context_data`: Facebook Messenger CTM     (Click-to-Message) or Instagram CTD (Click-to-Direct). Use     `ad_id` to attribute the conversation to a specific ad.   - `ref` without `ad_id`: an ig.me / m.me link carrying a     `?ref=` parameter (`source` is `SHORTLINK`, `SHORTLINKS` or     `IGME-SOURCE-LINK` depending on surface - treat it as     opaque). Instagram delivers ig.me refs on new threads only     when the account has at least one Ice Breaker configured     (`PUT /v1/accounts/{accountId}/instagram-ice-breakers`).
    pub fn new() -> WebhookPayloadMessageMetadataReferral {
        WebhookPayloadMessageMetadataReferral {
            ctwa_clid: None,
            source_id: None,
            source_type: None,
            source_url: None,
            headline: None,
            body: None,
            media_type: None,
            image_url: None,
            video_url: None,
            thumbnail_url: None,
            welcome_message: None,
            ad_id: None,
            r#ref: None,
            source: None,
            r#type: None,
            referer_uri: None,
            ads_context_data: None,
        }
    }
}