/*
 * 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 crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct InlineObject2 {
    /// Human-readable error message suitable for end-user display.
    #[serde(rename = "error")]
    pub error: String,
    /// Machine-readable error code. Stable across versions.
    #[serde(rename = "code")]
    pub code: Code,
    /// Discriminator for which gate fired.
    #[serde(rename = "reason")]
    pub reason: Reason,
    /// Link to the relevant documentation page.
    #[serde(rename = "documentation_url", skip_serializing_if = "Option::is_none")]
    pub documentation_url: Option<String>,
    /// Deep-link to send the end-user to. For `free_tier_exceeded` and `twitter_passthrough` this is the Zernio billing tab. For `enterprise_required` this is the Zernio enterprise contact page.
    #[serde(rename = "dashboard_url", skip_serializing_if = "Option::is_none")]
    pub dashboard_url: Option<String>,
    #[serde(rename = "details", skip_serializing_if = "Option::is_none")]
    pub details: Option<Box<models::InlineObject2Details>>,
}

impl InlineObject2 {
    pub fn new(error: String, code: Code, reason: Reason) -> InlineObject2 {
        InlineObject2 {
            error,
            code,
            reason,
            documentation_url: None,
            dashboard_url: None,
            details: None,
        }
    }
}
/// Machine-readable error code. Stable across versions.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Code {
    #[serde(rename = "PAYMENT_REQUIRED")]
    PaymentRequired,
}

impl Default for Code {
    fn default() -> Code {
        Self::PaymentRequired
    }
}
/// Discriminator for which gate fired.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Reason {
    #[serde(rename = "free_tier_exceeded")]
    FreeTierExceeded,
    #[serde(rename = "twitter_passthrough")]
    TwitterPassthrough,
    #[serde(rename = "enterprise_required")]
    EnterpriseRequired,
}

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