late 0.0.875

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).
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).
 *
 * 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 CreateWhatsAppTemplateRequest {
    /// WhatsApp account ID
    #[serde(rename = "accountId")]
    pub account_id: String,
    /// Template name (lowercase, letters/numbers/underscores, must start with a letter)
    #[serde(rename = "name")]
    pub name: String,
    /// Template category
    #[serde(rename = "category")]
    pub category: Category,
    /// Template language code (e.g., en_US)
    #[serde(rename = "language")]
    pub language: String,
    /// Variable style: POSITIONAL ({{1}}, the default) or NAMED ({{customer_name}}). Named templates provide examples via body_text_named_params / header_text_named_params. Inferred as NAMED when omitted but a named-params example is present.
    #[serde(rename = "parameter_format", skip_serializing_if = "Option::is_none")]
    pub parameter_format: Option<ParameterFormat>,
    /// Template components (header, body, footer, buttons, carousel, limited_time_offer). Required for custom templates, omit when using library_template_name.
    #[serde(rename = "components", skip_serializing_if = "Option::is_none")]
    pub components: Option<Vec<models::WhatsAppTemplateComponent>>,
    /// Name of a pre-built template from Meta's template library (e.g., \"appointment_reminder\", \"auto_pay_reminder_1\", \"address_update\"). When provided, the template is pre-approved by Meta with no review wait. Omit components when using this field.
    #[serde(
        rename = "library_template_name",
        skip_serializing_if = "Option::is_none"
    )]
    pub library_template_name: Option<String>,
    /// Optional body customizations for library templates. Available options depend on the template (e.g., add_contact_number, add_learn_more_link, add_security_recommendation, add_track_package_link, code_expiration_minutes).
    #[serde(
        rename = "library_template_body_inputs",
        skip_serializing_if = "Option::is_none"
    )]
    pub library_template_body_inputs: Option<serde_json::Value>,
    /// Optional button customizations for library templates. Each item specifies button type and configuration (e.g., URL, phone number, quick reply).
    #[serde(
        rename = "library_template_button_inputs",
        skip_serializing_if = "Option::is_none"
    )]
    pub library_template_button_inputs:
        Option<Vec<models::CreateWhatsAppTemplateRequestLibraryTemplateButtonInputsInner>>,
    /// Delivery validity window in seconds: a message not delivered within it is dropped. Range depends on category: AUTHENTICATION 30 to 900, UTILITY 30 to 43200 (12h), MARKETING 43200 to 2592000 (30 days); -1 (create only) keeps the 30-day default on AUTHENTICATION and UTILITY. Meta defaults to 600 for AUTHENTICATION and 30 days otherwise. If Meta later recategorises the template, it clears the TTL (read it back to check).
    #[serde(
        rename = "message_send_ttl_seconds",
        skip_serializing_if = "Option::is_none"
    )]
    pub message_send_ttl_seconds: Option<i32>,
}

impl CreateWhatsAppTemplateRequest {
    pub fn new(
        account_id: String,
        name: String,
        category: Category,
        language: String,
    ) -> CreateWhatsAppTemplateRequest {
        CreateWhatsAppTemplateRequest {
            account_id,
            name,
            category,
            language,
            parameter_format: None,
            components: None,
            library_template_name: None,
            library_template_body_inputs: None,
            library_template_button_inputs: None,
            message_send_ttl_seconds: None,
        }
    }
}
/// Template category
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Category {
    #[serde(rename = "AUTHENTICATION")]
    Authentication,
    #[serde(rename = "MARKETING")]
    Marketing,
    #[serde(rename = "UTILITY")]
    Utility,
}

impl Default for Category {
    fn default() -> Category {
        Self::Authentication
    }
}
/// Variable style: POSITIONAL ({{1}}, the default) or NAMED ({{customer_name}}). Named templates provide examples via body_text_named_params / header_text_named_params. Inferred as NAMED when omitted but a named-params example is present.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ParameterFormat {
    #[serde(rename = "POSITIONAL")]
    Positional,
    #[serde(rename = "NAMED")]
    Named,
    #[serde(rename = "positional")]
    Positional2,
    #[serde(rename = "named")]
    Named2,
}

impl Default for ParameterFormat {
    fn default() -> ParameterFormat {
        Self::Positional
    }
}