one-msg-sdk 2.0.3

Official Rust SDK for the 1msg WhatsApp Business API
/*
 * 1MSG WhatsApp Business API (Public)
 *
 * Public client API for sending messages, managing groups, flows, and templates.  This is the API exposed to end customers via platform.1msg.io  **Authentication:** Pass the channel token in **one** place. The API checks JSON body (`token`), then query string (`?token=`), then `Authorization: Bearer` header (preferred in production).  **Documentation:** https://help.1msg.io/platform-1msg/getting-start/quick-start **API Docs:** https://docs.1msg.io/ 
 *
 * The version of the OpenAPI document: 2.0.0
 * Contact: support@1msg.io
 * Generated by: https://openapi-generator.tech
 */

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

/// WebhookUrlStatus : Circuit / auto-disable status for one configured webhook URL. The breaker is per URL (`instanceId` + URL hash), not per channel. 
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookUrlStatus {
    /// This webhook URL (same string as in `webhookUrl`)
    #[serde(rename = "url")]
    pub url: String,
    /// Delivery state for this URL only. `ok` delivering; `degraded` recent qualifying fails (still delivering, warning email on the 2nd fail); `open` skipping most deliveries pending a probe; `half_open` probe in flight (resume only on HTTP 2xx); `disabled` sticky auto-disabled until self-serve re-enable (`POST /webhook` / `POST /settings` with this URL) or a successful probe before sticky disable. 
    #[serde(rename = "circuitState")]
    pub circuit_state: CircuitState,
    /// Last qualifying fail reason, e.g. `http_404` or `timeout_or_network`
    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
    /// Diagnostic only — safe for clients to ignore. Number of qualifying delivery failures in the rolling ~10 minute breaker window (not lifetime, not \"how many times the customer retried\"). Prefer `circuitState` / `disabledWebhooks`. 
    #[serde(rename = "fails", skip_serializing_if = "Option::is_none")]
    pub fails: Option<i32>,
    /// Diagnostic only — safe for clients to ignore. How many recovery probes already failed for this URL. Probes run on a schedule (≈15 min → 1 h → 6 h); sticky disable after 3 failed probes. The 6 h step is the last probe, not a blind \"unblock in 6 hours\" timer. 
    #[serde(rename = "trips", skip_serializing_if = "Option::is_none")]
    pub trips: Option<i32>,
    /// Epoch milliseconds when this URL became sticky-disabled
    #[serde(rename = "disabledAt", skip_serializing_if = "Option::is_none")]
    pub disabled_at: Option<i32>,
    /// Diagnostic only. Epoch ms of the first fail in the current ~10 minute window (pairs with `fails`; not a customer-facing period). 
    #[serde(rename = "firstFailAt", skip_serializing_if = "Option::is_none")]
    pub first_fail_at: Option<i32>,
    /// Last HTTP status from this URL, when known
    #[serde(rename = "lastStatus", skip_serializing_if = "Option::is_none")]
    pub last_status: Option<i32>,
    /// Epoch milliseconds of the next half-open probe, if any
    #[serde(rename = "nextProbeAt", skip_serializing_if = "Option::is_none")]
    pub next_probe_at: Option<i32>,
}

impl WebhookUrlStatus {
    /// Circuit / auto-disable status for one configured webhook URL. The breaker is per URL (`instanceId` + URL hash), not per channel. 
    pub fn new(url: String, circuit_state: CircuitState) -> WebhookUrlStatus {
        WebhookUrlStatus {
            url,
            circuit_state,
            reason: None,
            fails: None,
            trips: None,
            disabled_at: None,
            first_fail_at: None,
            last_status: None,
            next_probe_at: None,
        }
    }
}
/// Delivery state for this URL only. `ok` delivering; `degraded` recent qualifying fails (still delivering, warning email on the 2nd fail); `open` skipping most deliveries pending a probe; `half_open` probe in flight (resume only on HTTP 2xx); `disabled` sticky auto-disabled until self-serve re-enable (`POST /webhook` / `POST /settings` with this URL) or a successful probe before sticky disable. 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CircuitState {
    #[serde(rename = "ok")]
    Ok,
    #[serde(rename = "degraded")]
    Degraded,
    #[serde(rename = "open")]
    Open,
    #[serde(rename = "half_open")]
    HalfOpen,
    #[serde(rename = "disabled")]
    Disabled,
}

impl Default for CircuitState {
    fn default() -> CircuitState {
        Self::Ok
    }
}