late 0.0.1072

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

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

/// Webhook : Individual webhook configuration for receiving real-time notifications
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Webhook {
    /// Unique webhook identifier
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    pub _id: Option<String>,
    /// Webhook name (for identification)
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Webhook endpoint URL
    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    /// Secret key for HMAC-SHA256 signature verification.
    #[serde(rename = "secret", skip_serializing_if = "Option::is_none")]
    pub secret: Option<String>,
    /// Events subscribed to
    #[serde(rename = "events", skip_serializing_if = "Option::is_none")]
    pub events: Option<Vec<Events>>,
    /// Whether webhook delivery is enabled
    #[serde(rename = "isActive", skip_serializing_if = "Option::is_none")]
    pub is_active: Option<bool>,
    /// Timestamp of last successful webhook delivery
    #[serde(rename = "lastFiredAt", skip_serializing_if = "Option::is_none")]
    pub last_fired_at: Option<String>,
    /// Consecutive terminal delivery failures (resets to 0 on any successful delivery). Auto-disable only triggers when the endpoint has had no successful delivery within a 3-day window AND either reaches 20 consecutive terminal failures or has been failing continuously for 3 days; any success within that window keeps the endpoint enabled regardless of the count.
    #[serde(rename = "failureCount", skip_serializing_if = "Option::is_none")]
    pub failure_count: Option<i32>,
    /// Custom headers included in webhook requests
    #[serde(rename = "customHeaders", skip_serializing_if = "Option::is_none")]
    pub custom_headers: Option<std::collections::HashMap<String, String>>,
    /// Resource groups this subscription does not receive (opt-out denylist, same vocabulary and same semantics as the field on API keys). Absent or empty means the subscription receives every event listed in `events`, which is how every subscription created before this field existed behaves. An event whose group is listed here is dropped before delivery even when it is still present in `events`, and the same check runs on every replay path (test fire, redelivery, dead-letter requeue). Editing the denylist applies to every event emitted afterwards; events already queued when the edit landed can still be delivered for up to five minutes after they were enqueued.
    #[serde(
        rename = "disabledResourceGroups",
        skip_serializing_if = "Option::is_none"
    )]
    pub disabled_resource_groups: Option<Vec<DisabledResourceGroups>>,
    /// Profiles this subscription receives events for (allowlist). Absent or empty means every profile, which is how every subscription created before this field existed behaves. A scoped subscription is only sent events attributable to a listed profile. An aggregate `post.*` event is attributed to the profile of every account the post targets, so a post spanning two scoped endpoints' profiles reaches both. Events with no profile behind them (`verification.*`, `phone_number.*`, a legacy post whose accounts were deleted) are not delivered to it. Applied when the event is emitted: a redelivery replays a delivery already made to this endpoint, and a test fire ignores the list.
    #[serde(rename = "profileIds", skip_serializing_if = "Option::is_none")]
    pub profile_ids: Option<Vec<String>>,
    /// Connected accounts this subscription receives events for (allowlist). Absent or empty means every account. Same semantics as `profileIds`, keyed on the account: an aggregate `post.*` event is attributed to every account the post targets. Events that name no connected account (`verification.*`, `phone_number.*`, and `whatsapp.number.*`, which carry the phone number) are not delivered to an account-scoped subscription. A subscription with both lists must be satisfied on both. Applied when the event is emitted; a redelivery replays a delivery already made to this endpoint and a test fire ignores the list.
    #[serde(rename = "accountIds", skip_serializing_if = "Option::is_none")]
    pub account_ids: Option<Vec<String>>,
}

impl Webhook {
    /// Individual webhook configuration for receiving real-time notifications
    pub fn new() -> Webhook {
        Webhook {
            _id: None,
            name: None,
            url: None,
            secret: None,
            events: None,
            is_active: None,
            last_fired_at: None,
            failure_count: None,
            custom_headers: None,
            disabled_resource_groups: None,
            profile_ids: None,
            account_ids: None,
        }
    }
}
/// Events subscribed to
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Events {
    #[serde(rename = "post.scheduled")]
    PostScheduled,
    #[serde(rename = "post.published")]
    PostPublished,
    #[serde(rename = "post.failed")]
    PostFailed,
    #[serde(rename = "post.partial")]
    PostPartial,
    #[serde(rename = "post.cancelled")]
    PostCancelled,
    #[serde(rename = "post.recycled")]
    PostRecycled,
    #[serde(rename = "post.platform.published")]
    PostPlatformPublished,
    #[serde(rename = "post.platform.failed")]
    PostPlatformFailed,
    #[serde(rename = "post.platform.deleted")]
    PostPlatformDeleted,
    #[serde(rename = "post.tiktok.url_resolved")]
    PostTiktokUrlResolved,
    #[serde(rename = "post.external.created")]
    PostExternalCreated,
    #[serde(rename = "post.external.updated")]
    PostExternalUpdated,
    #[serde(rename = "post.external.deleted")]
    PostExternalDeleted,
    #[serde(rename = "account.connected")]
    AccountConnected,
    #[serde(rename = "account.disconnected")]
    AccountDisconnected,
    #[serde(rename = "account.ads.initial_sync_completed")]
    AccountAdsInitialSyncCompleted,
    #[serde(rename = "analytics.synced")]
    AnalyticsSynced,
    #[serde(rename = "message.received")]
    MessageReceived,
    #[serde(rename = "conversation.started")]
    ConversationStarted,
    #[serde(rename = "conversation.control_changed")]
    ConversationControlChanged,
    #[serde(rename = "call.received")]
    CallReceived,
    #[serde(rename = "call.ended")]
    CallEnded,
    #[serde(rename = "call.failed")]
    CallFailed,
    #[serde(rename = "call.permission_request")]
    CallPermissionRequest,
    #[serde(rename = "message.sent")]
    MessageSent,
    #[serde(rename = "message.edited")]
    MessageEdited,
    #[serde(rename = "message.deleted")]
    MessageDeleted,
    #[serde(rename = "message.delivered")]
    MessageDelivered,
    #[serde(rename = "message.read")]
    MessageRead,
    #[serde(rename = "message.failed")]
    MessageFailed,
    #[serde(rename = "reaction.received")]
    ReactionReceived,
    #[serde(rename = "referral.received")]
    ReferralReceived,
    #[serde(rename = "comment.received")]
    CommentReceived,
    #[serde(rename = "review.new")]
    ReviewNew,
    #[serde(rename = "review.updated")]
    ReviewUpdated,
    #[serde(rename = "lead.received")]
    LeadReceived,
    #[serde(rename = "ad.status_changed")]
    AdStatusChanged,
    #[serde(rename = "whatsapp.template.status_updated")]
    WhatsappTemplateStatusUpdated,
    #[serde(rename = "whatsapp.template.category_updated")]
    WhatsappTemplateCategoryUpdated,
    #[serde(rename = "whatsapp.account.name_status_updated")]
    WhatsappAccountNameStatusUpdated,
    #[serde(rename = "whatsapp.automatic_event")]
    WhatsappAutomaticEvent,
    #[serde(rename = "whatsapp.number.activated")]
    WhatsappNumberActivated,
    #[serde(rename = "whatsapp.number.declined")]
    WhatsappNumberDeclined,
    #[serde(rename = "whatsapp.number.action_required")]
    WhatsappNumberActionRequired,
    #[serde(rename = "whatsapp.number.verification_required")]
    WhatsappNumberVerificationRequired,
    #[serde(rename = "whatsapp.number.suspended")]
    WhatsappNumberSuspended,
    #[serde(rename = "whatsapp.number.reactivated")]
    WhatsappNumberReactivated,
    #[serde(rename = "whatsapp.number.released")]
    WhatsappNumberReleased,
    #[serde(rename = "whatsapp.number.kyc_submitted")]
    WhatsappNumberKycSubmitted,
    #[serde(rename = "phone_number.stock_available")]
    PhoneNumberStockAvailable,
    #[serde(rename = "verification.approved")]
    VerificationApproved,
    #[serde(rename = "verification.failed")]
    VerificationFailed,
    #[serde(rename = "sms.registration.action_required")]
    SmsRegistrationActionRequired,
    #[serde(rename = "sms.registration.status_updated")]
    SmsRegistrationStatusUpdated,
}

impl Default for Events {
    fn default() -> Events {
        Self::PostScheduled
    }
}
/// Resource groups this subscription does not receive (opt-out denylist, same vocabulary and same semantics as the field on API keys). Absent or empty means the subscription receives every event listed in `events`, which is how every subscription created before this field existed behaves. An event whose group is listed here is dropped before delivery even when it is still present in `events`, and the same check runs on every replay path (test fire, redelivery, dead-letter requeue). Editing the denylist applies to every event emitted afterwards; events already queued when the edit landed can still be delivered for up to five minutes after they were enqueued.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum DisabledResourceGroups {
    #[serde(rename = "publishing")]
    Publishing,
    #[serde(rename = "engagement")]
    Engagement,
    #[serde(rename = "messages")]
    Messages,
    #[serde(rename = "contacts")]
    Contacts,
    #[serde(rename = "analytics")]
    Analytics,
    #[serde(rename = "ads")]
    Ads,
    #[serde(rename = "telephony")]
    Telephony,
    #[serde(rename = "accounts")]
    Accounts,
    #[serde(rename = "billing")]
    Billing,
    #[serde(rename = "webhooks")]
    Webhooks,
}

impl Default for DisabledResourceGroups {
    fn default() -> DisabledResourceGroups {
        Self::Publishing
    }
}