/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api 
 *
 * The version of the OpenAPI document: 1.0.4
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */


use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};


/// struct for typed errors of method [`on_account_ads_initial_sync_completed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnAccountAdsInitialSyncCompletedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_account_connected`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnAccountConnectedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_account_disconnected`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnAccountDisconnectedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_ad_status_changed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnAdStatusChangedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_call_ended`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnCallEndedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_call_failed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnCallFailedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_call_permission_request`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnCallPermissionRequestError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_call_received`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnCallReceivedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_comment_received`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnCommentReceivedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_conversation_started`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnConversationStartedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_lead_received`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnLeadReceivedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_message_deleted`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnMessageDeletedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_message_delivered`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnMessageDeliveredError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_message_edited`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnMessageEditedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_message_failed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnMessageFailedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_message_read`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnMessageReadError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_message_received`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnMessageReceivedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_message_sent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnMessageSentError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_cancelled`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostCancelledError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_external_created`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostExternalCreatedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_external_deleted`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostExternalDeletedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_external_updated`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostExternalUpdatedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_failed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostFailedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_partial`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostPartialError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_platform_failed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostPlatformFailedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_platform_published`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostPlatformPublishedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_published`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostPublishedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_recycled`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostRecycledError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_post_scheduled`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnPostScheduledError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_reaction_received`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnReactionReceivedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_review_new`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnReviewNewError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_review_updated`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnReviewUpdatedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_webhook_test`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWebhookTestError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_whats_app_number_activated`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWhatsAppNumberActivatedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_whats_app_number_declined`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWhatsAppNumberDeclinedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_whats_app_number_reactivated`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWhatsAppNumberReactivatedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_whats_app_number_released`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWhatsAppNumberReleasedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_whats_app_number_suspended`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWhatsAppNumberSuspendedError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_whats_app_number_verification_required`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWhatsAppNumberVerificationRequiredError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`on_whats_app_template_status_updated`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnWhatsAppTemplateStatusUpdatedError {
    UnknownValue(serde_json::Value),
}


/// Fired once per ads-enabled account when the initial sync (ad-account discovery + 90-day historical ad backfill) completes. The `sync` block reports whether the backfill succeeded and how many ads were synced. 
pub async fn on_account_ads_initial_sync_completed(configuration: &configuration::Configuration, webhook_payload_account_ads_initial_sync_completed: models::WebhookPayloadAccountAdsInitialSyncCompleted) -> Result<(), Error<OnAccountAdsInitialSyncCompletedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_account_ads_initial_sync_completed = webhook_payload_account_ads_initial_sync_completed;

    let uri_str = format!("{}/account.ads.initial_sync_completed", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_account_ads_initial_sync_completed);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnAccountAdsInitialSyncCompletedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a social account is successfully connected.
pub async fn on_account_connected(configuration: &configuration::Configuration, webhook_payload_account_connected: models::WebhookPayloadAccountConnected) -> Result<(), Error<OnAccountConnectedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_account_connected = webhook_payload_account_connected;

    let uri_str = format!("{}/account.connected", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_account_connected);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnAccountConnectedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a connected social account becomes disconnected.
pub async fn on_account_disconnected(configuration: &configuration::Configuration, webhook_payload_account_disconnected: models::WebhookPayloadAccountDisconnected) -> Result<(), Error<OnAccountDisconnectedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_account_disconnected = webhook_payload_account_disconnected;

    let uri_str = format!("{}/account.disconnected", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_account_disconnected);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnAccountDisconnectedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a campaign, ad set, or ad on a connected ad platform changes status. Currently emitted only for Meta (`metaads`).  Subscribed to two Meta `ad_account` webhook fields:   - `in_process_ad_objects` - the ad object finished processing and exited     the `IN_PROCESS` state. `status.raw` carries Meta's `status_name`     (e.g. `ACTIVE`, `PAUSED`, `ARCHIVED`, `DELETED`).   - `with_issues_ad_objects` - the ad object entered the `WITH_ISSUES`     state. `status.raw` is set to `WITH_ISSUES` and the `error` block is     populated from Meta's `error_code` / `error_summary` / `error_message`.  `adObject.level` mirrors Meta's `level` and is one of `CAMPAIGN`, `AD_SET`, or `AD`. Creative-level events are not forwarded.  Branch on `status.raw` to handle each transition; use `error.code` (when present) as the stable discriminator — `error.summary` and `error.message` are localized to the ad-account owner's Meta locale.  The `error` block is optional. It's present on most `WITH_ISSUES` events but can be absent (Meta does not always include diagnostics), and is never present on any other status. Always null-check `error` before reading `error.code`.  **Fan-out:** matching is keyed on `adObject.platformAdAccountId`. When multiple connected Zernio `metaads` accounts are linked to the same Meta ad account, each receives its own delivery. 
pub async fn on_ad_status_changed(configuration: &configuration::Configuration, webhook_payload_ad_status_changed: models::WebhookPayloadAdStatusChanged) -> Result<(), Error<OnAdStatusChangedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_ad_status_changed = webhook_payload_ad_status_changed;

    let uri_str = format!("{}/ad.status_changed", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_ad_status_changed);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnAdStatusChangedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired on call hangup with the duration and a zero-markup billing breakdown (Meta cost, Telnyx cost, recording surcharge, total). Costs are pass-through; no margin is applied. 
pub async fn on_call_ended(configuration: &configuration::Configuration, webhook_payload_call_ended: models::WebhookPayloadCallEnded) -> Result<(), Error<OnCallEndedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_call_ended = webhook_payload_call_ended;

    let uri_str = format!("{}/call.ended", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_call_ended);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnCallEndedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a call setup or in-progress call fails (Meta rejected the connect, Telnyx returned an error, etc.). Payload carries the upstream error code and message. 
pub async fn on_call_failed(configuration: &configuration::Configuration, webhook_payload_call_failed: models::WebhookPayloadCallFailed) -> Result<(), Error<OnCallFailedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_call_failed = webhook_payload_call_failed;

    let uri_str = format!("{}/call.failed", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_call_failed);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnCallFailedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a consumer replies to a `call_permission_request` interactive message (or its marketing-template variant). Carries the response (`accept` / `reject`), whether the grant is permanent, and the expiration timestamp when it is temporary. 
pub async fn on_call_permission_request(configuration: &configuration::Configuration, webhook_payload_call_permission_request: models::WebhookPayloadCallPermissionRequest) -> Result<(), Error<OnCallPermissionRequestError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_call_permission_request = webhook_payload_call_permission_request;

    let uri_str = format!("{}/call.permission_request", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_call_permission_request);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnCallPermissionRequestError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a WhatsApp Business Call connects. For inbound (UIC) calls the event fires at the moment our Telnyx trunk bridges the consumer leg to the customer&apos;s forward-to destination; for outbound (BIC) calls it fires immediately after Meta accepts the connect. Branch on `call.direction` to distinguish. 
pub async fn on_call_received(configuration: &configuration::Configuration, webhook_payload_call_received: models::WebhookPayloadCallReceived) -> Result<(), Error<OnCallReceivedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_call_received = webhook_payload_call_received;

    let uri_str = format!("{}/call.received", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_call_received);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnCallReceivedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a new comment is received on a tracked post.
pub async fn on_comment_received(configuration: &configuration::Configuration, webhook_payload_comment: models::WebhookPayloadComment) -> Result<(), Error<OnCommentReceivedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_comment = webhook_payload_comment;

    let uri_str = format!("{}/comment.received", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_comment);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnCommentReceivedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired once when a new conversation begins between one of your connected accounts and a contact, in either direction. Works across every DM platform (Instagram, Messenger/Facebook, Telegram, WhatsApp, Twitter, Reddit, Bluesky). Naturally deduped — a given conversation only fires this event the very first time it appears. 
pub async fn on_conversation_started(configuration: &configuration::Configuration, webhook_payload_conversation_started: models::WebhookPayloadConversationStarted) -> Result<(), Error<OnConversationStartedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_conversation_started = webhook_payload_conversation_started;

    let uri_str = format!("{}/conversation.started", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_conversation_started);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnConversationStartedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a new lead is submitted against a Meta Lead Gen (Instant) Form and ingested via the Page `leadgen` webhook. `lead.fields` is the question-key to answer map; `lead.formId` / `lead.adId` give provenance. Requires the Ads add-on. 
pub async fn on_lead_received(configuration: &configuration::Configuration, webhook_payload_lead: models::WebhookPayloadLead) -> Result<(), Error<OnLeadReceivedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_lead = webhook_payload_lead;

    let uri_str = format!("{}/lead.received", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_lead);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnLeadReceivedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a sender deletes (unsends) a message. Supported on Instagram (incoming unsend) and WhatsApp (when the business deletes an outgoing message via the Cloud API). The payload retains the pre-delete text and attachments so API consumers can access the original content for moderation or compliance — the Zernio dashboard UI hides it. 
pub async fn on_message_deleted(configuration: &configuration::Configuration, webhook_payload_message_deleted: models::WebhookPayloadMessageDeleted) -> Result<(), Error<OnMessageDeletedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_message_deleted = webhook_payload_message_deleted;

    let uri_str = format!("{}/message.deleted", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_message_deleted);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnMessageDeletedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when an outgoing message is delivered to the recipient. Supported on WhatsApp and Facebook Messenger. 
pub async fn on_message_delivered(configuration: &configuration::Configuration, webhook_payload_message_delivery_status: models::WebhookPayloadMessageDeliveryStatus) -> Result<(), Error<OnMessageDeliveredError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_message_delivery_status = webhook_payload_message_delivery_status;

    let uri_str = format!("{}/message.delivered", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_message_delivery_status);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnMessageDeliveredError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a sender edits a previously-sent message. Supported on Instagram, Facebook Messenger, and Telegram. The payload includes the full editHistory so consumers can show prior versions. 
pub async fn on_message_edited(configuration: &configuration::Configuration, webhook_payload_message_edited: models::WebhookPayloadMessageEdited) -> Result<(), Error<OnMessageEditedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_message_edited = webhook_payload_message_edited;

    let uri_str = format!("{}/message.edited", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_message_edited);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnMessageEditedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when an outgoing message fails to deliver. Currently only emitted for WhatsApp (other platforms don't expose per-message failure via webhook). The payload error object contains code, title, and message from the platform. 
pub async fn on_message_failed(configuration: &configuration::Configuration, webhook_payload_message_delivery_status: models::WebhookPayloadMessageDeliveryStatus) -> Result<(), Error<OnMessageFailedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_message_delivery_status = webhook_payload_message_delivery_status;

    let uri_str = format!("{}/message.failed", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_message_delivery_status);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnMessageFailedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when an outgoing message is read by the recipient. Supported on WhatsApp, Facebook Messenger, and Instagram. 
pub async fn on_message_read(configuration: &configuration::Configuration, webhook_payload_message_delivery_status: models::WebhookPayloadMessageDeliveryStatus) -> Result<(), Error<OnMessageReadError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_message_delivery_status = webhook_payload_message_delivery_status;

    let uri_str = format!("{}/message.read", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_message_delivery_status);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnMessageReadError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a new inbox message is received.
pub async fn on_message_received(configuration: &configuration::Configuration, webhook_payload_message: models::WebhookPayloadMessage) -> Result<(), Error<OnMessageReceivedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_message = webhook_payload_message;

    let uri_str = format!("{}/message.received", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_message);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnMessageReceivedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a message is sent via the API.
pub async fn on_message_sent(configuration: &configuration::Configuration, webhook_payload_message_sent: models::WebhookPayloadMessageSent) -> Result<(), Error<OnMessageSentError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_message_sent = webhook_payload_message_sent;

    let uri_str = format!("{}/message.sent", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_message_sent);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnMessageSentError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a post publishing job is cancelled.
pub async fn on_post_cancelled(configuration: &configuration::Configuration, webhook_payload_post: models::WebhookPayloadPost) -> Result<(), Error<OnPostCancelledError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post = webhook_payload_post;

    let uri_str = format!("{}/post.cancelled", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostCancelledError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when Zernio's background sync detects a natively-authored post (created outside Zernio, e.g. a Google Business Profile localPost made in the Google UI) for the first time. Poll-driven (~hourly), not real-time. `post.source` is always \"external\". 
pub async fn on_post_external_created(configuration: &configuration::Configuration, webhook_payload_external_post: models::WebhookPayloadExternalPost) -> Result<(), Error<OnPostExternalCreatedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_external_post = webhook_payload_external_post;

    let uri_str = format!("{}/post.external.created", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_external_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostExternalCreatedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a tracked native post is detected as removed from the platform. `post.deletedAt` carries the detection time. Coverage is bounded to the most recent posts the platform listing returns. 
pub async fn on_post_external_deleted(configuration: &configuration::Configuration, webhook_payload_external_post: models::WebhookPayloadExternalPost) -> Result<(), Error<OnPostExternalDeletedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_external_post = webhook_payload_external_post;

    let uri_str = format!("{}/post.external.deleted", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_external_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostExternalDeletedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a tracked native post's text or media changed on the platform. Detected by comparing text/media structure and, where available, the platform's own edit timestamp; a media-URL-only refresh does not fire this. 
pub async fn on_post_external_updated(configuration: &configuration::Configuration, webhook_payload_external_post: models::WebhookPayloadExternalPost) -> Result<(), Error<OnPostExternalUpdatedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_external_post = webhook_payload_external_post;

    let uri_str = format!("{}/post.external.updated", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_external_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostExternalUpdatedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a post fails to publish on all target platforms.
pub async fn on_post_failed(configuration: &configuration::Configuration, webhook_payload_post: models::WebhookPayloadPost) -> Result<(), Error<OnPostFailedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post = webhook_payload_post;

    let uri_str = format!("{}/post.failed", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostFailedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a post publishes on some platforms and fails on others.
pub async fn on_post_partial(configuration: &configuration::Configuration, webhook_payload_post: models::WebhookPayloadPost) -> Result<(), Error<OnPostPartialError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post = webhook_payload_post;

    let uri_str = format!("{}/post.partial", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostPartialError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired once per platform target inside a post as that platform fails permanently. Temporary/retryable failures do NOT fire this event — only permanent ones, so retry loops stay quiet. The envelope event (`post.failed` / `post.partial`) fires separately AFTER all platforms have terminated. 
pub async fn on_post_platform_failed(configuration: &configuration::Configuration, webhook_payload_post_platform: models::WebhookPayloadPostPlatform) -> Result<(), Error<OnPostPlatformFailedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post_platform = webhook_payload_post_platform;

    let uri_str = format!("{}/post.platform.failed", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post_platform);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostPlatformFailedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired once per platform target inside a post as that platform finishes publishing successfully. Does NOT wait for the post-level rollup — consumers building incremental UIs get notified immediately, even when other platforms on the same post are still processing. The envelope event (`post.published` / `post.partial`) fires separately AFTER all platforms have terminated. 
pub async fn on_post_platform_published(configuration: &configuration::Configuration, webhook_payload_post_platform: models::WebhookPayloadPostPlatform) -> Result<(), Error<OnPostPlatformPublishedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post_platform = webhook_payload_post_platform;

    let uri_str = format!("{}/post.platform.published", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post_platform);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostPlatformPublishedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a post is successfully published.
pub async fn on_post_published(configuration: &configuration::Configuration, webhook_payload_post: models::WebhookPayloadPost) -> Result<(), Error<OnPostPublishedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post = webhook_payload_post;

    let uri_str = format!("{}/post.published", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostPublishedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a post is recycled (cloned and re-scheduled for publishing).
pub async fn on_post_recycled(configuration: &configuration::Configuration, webhook_payload_post: models::WebhookPayloadPost) -> Result<(), Error<OnPostRecycledError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post = webhook_payload_post;

    let uri_str = format!("{}/post.recycled", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostRecycledError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a post is created and scheduled for publishing.
pub async fn on_post_scheduled(configuration: &configuration::Configuration, webhook_payload_post: models::WebhookPayloadPost) -> Result<(), Error<OnPostScheduledError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_post = webhook_payload_post;

    let uri_str = format!("{}/post.scheduled", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_post);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnPostScheduledError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a participant adds or removes an emoji reaction on a message. Supported on WhatsApp and Telegram. Distinct from message.received so a reaction (e.g. a thumbs-up) is not mistaken for an inbound message. The `reaction.action` field is `added` or `removed`. On WhatsApp removals the platform does not report which emoji was removed, so `reaction.emoji` may be an empty string. Requires the Inbox add-on. 
pub async fn on_reaction_received(configuration: &configuration::Configuration, webhook_payload_reaction: models::WebhookPayloadReaction) -> Result<(), Error<OnReactionReceivedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_reaction = webhook_payload_reaction;

    let uri_str = format!("{}/reaction.received", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_reaction);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnReactionReceivedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a new review is posted on a connected account. Currently supported for Google Business Profile (real-time via Pub/Sub). Requires the Inbox add-on. 
pub async fn on_review_new(configuration: &configuration::Configuration, webhook_payload_review_new: models::WebhookPayloadReviewNew) -> Result<(), Error<OnReviewNewError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_review_new = webhook_payload_review_new;

    let uri_str = format!("{}/review.new", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_review_new);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnReviewNewError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a review changes: the reviewer edits their text or rating, or a reply is added (via the API or directly through the Google Business dashboard). Payload shape matches review.new. Requires the Inbox add-on. 
pub async fn on_review_updated(configuration: &configuration::Configuration, webhook_payload_review_updated: models::WebhookPayloadReviewUpdated) -> Result<(), Error<OnReviewUpdatedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_review_updated = webhook_payload_review_updated;

    let uri_str = format!("{}/review.updated", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_review_updated);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnReviewUpdatedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when sending a test webhook to verify the endpoint configuration.
pub async fn on_webhook_test(configuration: &configuration::Configuration, webhook_payload_test: models::WebhookPayloadTest) -> Result<(), Error<OnWebhookTestError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_test = webhook_payload_test;

    let uri_str = format!("{}/webhook.test", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_test);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWebhookTestError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a purchased WhatsApp number becomes active and usable — both the synchronous (Tier 1/2) path and the asynchronous regulated (Tier 3/4) path land here. Lets integrators react without polling GET /v1/whatsapp/phone-numbers. 
pub async fn on_whats_app_number_activated(configuration: &configuration::Configuration, on_whats_app_number_activated_request: models::OnWhatsAppNumberActivatedRequest) -> Result<(), Error<OnWhatsAppNumberActivatedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_on_whats_app_number_activated_request = on_whats_app_number_activated_request;

    let uri_str = format!("{}/whatsapp.number.activated", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_on_whats_app_number_activated_request);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWhatsAppNumberActivatedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a regulated (Tier 3/4) number order is declined or fails review. The number is never billed. `reason` carries the reviewer's rejection reason when available. 
pub async fn on_whats_app_number_declined(configuration: &configuration::Configuration, on_whats_app_number_declined_request: models::OnWhatsAppNumberDeclinedRequest) -> Result<(), Error<OnWhatsAppNumberDeclinedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_on_whats_app_number_declined_request = on_whats_app_number_declined_request;

    let uri_str = format!("{}/whatsapp.number.declined", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_on_whats_app_number_declined_request);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWhatsAppNumberDeclinedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a suspended number is reactivated (e.g. the payment recovered) and is usable again. 
pub async fn on_whats_app_number_reactivated(configuration: &configuration::Configuration, on_whats_app_number_reactivated_request: models::OnWhatsAppNumberReactivatedRequest) -> Result<(), Error<OnWhatsAppNumberReactivatedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_on_whats_app_number_reactivated_request = on_whats_app_number_reactivated_request;

    let uri_str = format!("{}/whatsapp.number.reactivated", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_on_whats_app_number_reactivated_request);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWhatsAppNumberReactivatedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a number is released and is no longer usable (by the user, a billing cleanup, or an admin). Terminal. `reason` carries the cause (e.g. `user_requested`, `cleanup_suspended`). 
pub async fn on_whats_app_number_released(configuration: &configuration::Configuration, on_whats_app_number_released_request: models::OnWhatsAppNumberReleasedRequest) -> Result<(), Error<OnWhatsAppNumberReleasedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_on_whats_app_number_released_request = on_whats_app_number_released_request;

    let uri_str = format!("{}/whatsapp.number.released", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_on_whats_app_number_released_request);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWhatsAppNumberReleasedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when an active number is suspended (e.g. a failed payment). The number stops working until the issue is resolved, after which a `whatsapp.number.reactivated` event is sent. `reason` carries the cause (e.g. `payment_failed`, `subscription_ended`). 
pub async fn on_whats_app_number_suspended(configuration: &configuration::Configuration, on_whats_app_number_suspended_request: models::OnWhatsAppNumberSuspendedRequest) -> Result<(), Error<OnWhatsAppNumberSuspendedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_on_whats_app_number_suspended_request = on_whats_app_number_suspended_request;

    let uri_str = format!("{}/whatsapp.number.suspended", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_on_whats_app_number_suspended_request);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWhatsAppNumberSuspendedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when a regulated number has an out-of-band identity-verification step (e.g. Onfido). `verificationUrl` is the link to forward to the number's end user; the order completes once they pass. 
pub async fn on_whats_app_number_verification_required(configuration: &configuration::Configuration, on_whats_app_number_verification_required_request: models::OnWhatsAppNumberVerificationRequiredRequest) -> Result<(), Error<OnWhatsAppNumberVerificationRequiredError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_on_whats_app_number_verification_required_request = on_whats_app_number_verification_required_request;

    let uri_str = format!("{}/whatsapp.number.verification_required", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_on_whats_app_number_verification_required_request);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWhatsAppNumberVerificationRequiredError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Fired when Meta finishes (re)reviewing a WhatsApp Business template attached to a connected WABA. Forwarded from Meta's `message_template_status_update` webhook field on the WhatsApp Business Account. Consumers branch on `template.status` (APPROVED, REJECTED, PENDING, PAUSED, DISABLED, IN_APPEAL, PENDING_DELETION). Meta does not include the previous status or the template's category in this event. 
pub async fn on_whats_app_template_status_updated(configuration: &configuration::Configuration, webhook_payload_whats_app_template_status_updated: models::WebhookPayloadWhatsAppTemplateStatusUpdated) -> Result<(), Error<OnWhatsAppTemplateStatusUpdatedError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_webhook_payload_whats_app_template_status_updated = webhook_payload_whats_app_template_status_updated;

    let uri_str = format!("{}/whatsapp.template.status_updated", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_webhook_payload_whats_app_template_status_updated);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<OnWhatsAppTemplateStatusUpdatedError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

