late 0.0.1097

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

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

/// WebhookPayloadWhatsAppContactIdentityChanged : Webhook payload for the `whatsapp.contact.identity_changed` event. Fired when Meta reports that a WhatsApp user is now known by a different identifier: a `system` message of type `user_changed_number`, `user_changed_user_id` or `user_identity_changed`, or a `user_id_update` webhook (BSUID regenerated). Zernio re-keys the inbox conversation and contact channel before firing.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookPayloadWhatsAppContactIdentityChanged {
    /// Stable webhook event ID: the dedupe key, also sent as the X-Zernio-Event-Id header and identical on every retry and redelivery. It identifies the event only, never an account or other resource.
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "event")]
    pub event: Event,
    #[serde(rename = "account")]
    pub account: Box<models::WebhookPayloadWhatsAppContactIdentityChangedAccount>,
    /// Which Meta signal reported the change. `user_changed_number`: new phone number. `user_changed_user_id` and `user_id_update`: new BSUID.
    #[serde(rename = "reason")]
    pub reason: Reason,
    #[serde(rename = "previous")]
    pub previous: Box<models::WhatsAppContactIdentity>,
    #[serde(rename = "current")]
    pub current: Box<models::WhatsAppContactIdentity>,
    /// Zernio contact id matched on the new identity, null when none exists yet.
    #[serde(rename = "contactId", deserialize_with = "Option::deserialize")]
    pub contact_id: Option<String>,
    /// Zernio inbox conversation that was re-keyed, null when there was none.
    #[serde(rename = "conversationId", deserialize_with = "Option::deserialize")]
    pub conversation_id: Option<String>,
    /// When Meta reported the change.
    #[serde(rename = "changedAt")]
    pub changed_at: String,
    /// UTC time at which Zernio generated this event (set once when the event payload is built, before delivery is queued). Retries and redeliveries keep the original value, so it reflects the event, not the delivery attempt.
    #[serde(rename = "timestamp")]
    pub timestamp: String,
}

impl WebhookPayloadWhatsAppContactIdentityChanged {
    /// Webhook payload for the `whatsapp.contact.identity_changed` event. Fired when Meta reports that a WhatsApp user is now known by a different identifier: a `system` message of type `user_changed_number`, `user_changed_user_id` or `user_identity_changed`, or a `user_id_update` webhook (BSUID regenerated). Zernio re-keys the inbox conversation and contact channel before firing.
    pub fn new(
        id: String,
        event: Event,
        account: models::WebhookPayloadWhatsAppContactIdentityChangedAccount,
        reason: Reason,
        previous: models::WhatsAppContactIdentity,
        current: models::WhatsAppContactIdentity,
        contact_id: Option<String>,
        conversation_id: Option<String>,
        changed_at: String,
        timestamp: String,
    ) -> WebhookPayloadWhatsAppContactIdentityChanged {
        WebhookPayloadWhatsAppContactIdentityChanged {
            id,
            event,
            account: Box::new(account),
            reason,
            previous: Box::new(previous),
            current: Box::new(current),
            contact_id,
            conversation_id,
            changed_at,
            timestamp,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Event {
    #[serde(rename = "whatsapp.contact.identity_changed")]
    WhatsappContactIdentityChanged,
}

impl Default for Event {
    fn default() -> Event {
        Self::WhatsappContactIdentityChanged
    }
}
/// Which Meta signal reported the change. `user_changed_number`: new phone number. `user_changed_user_id` and `user_id_update`: new BSUID.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Reason {
    #[serde(rename = "user_changed_number")]
    UserChangedNumber,
    #[serde(rename = "user_changed_user_id")]
    UserChangedUserId,
    #[serde(rename = "user_identity_changed")]
    UserIdentityChanged,
    #[serde(rename = "user_id_update")]
    UserIdUpdate,
}

impl Default for Reason {
    fn default() -> Reason {
        Self::UserChangedNumber
    }
}