/*
 * 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};

/// WorkflowNode : A node in a workflow graph. `config` shape depends on `type`.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkflowNode {
    /// Stable node id referenced by edges
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "type")]
    pub r#type: Type,
    /// Type-specific settings. trigger: { keywords:[string], matchType: any|contains|exact|regex, onlyFirstMessage:boolean }. send_message: { messageType: text|template|media|interactive, text, template:{name,language,variableMapping}, media:{mediaType,url,caption}, interactive } (template/interactive are WhatsApp-only). wait_for_reply: { timeoutMinutes:int, saveAs:string }. condition: { rules:[{ id, variable, operator: equals|not_equals|contains|not_contains|starts_with|ends_with|exists|not_exists|matches, value }] }. set_variable: { assignments:[{ name, value }] }. delay: { delayMinutes:int }. webhook: { url, method, headers, bodyTemplate, saveAs }. handoff: { note, assignTo }. String fields support {{variable}} interpolation.
    #[serde(rename = "config", skip_serializing_if = "Option::is_none")]
    pub config: Option<std::collections::HashMap<String, serde_json::Value>>,
    #[serde(rename = "position", skip_serializing_if = "Option::is_none")]
    pub position: Option<Box<models::WorkflowNodePosition>>,
}

impl WorkflowNode {
    /// A node in a workflow graph. `config` shape depends on `type`.
    pub fn new(id: String, r#type: Type) -> WorkflowNode {
        WorkflowNode {
            id,
            r#type,
            config: None,
            position: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "trigger")]
    Trigger,
    #[serde(rename = "send_message")]
    SendMessage,
    #[serde(rename = "wait_for_reply")]
    WaitForReply,
    #[serde(rename = "condition")]
    Condition,
    #[serde(rename = "set_variable")]
    SetVariable,
    #[serde(rename = "delay")]
    Delay,
    #[serde(rename = "webhook")]
    Webhook,
    #[serde(rename = "handoff")]
    Handoff,
    #[serde(rename = "end")]
    End,
}

impl Default for Type {
    fn default() -> Type {
        Self::Trigger
    }
}
