enbbox 1.0.1

Notification infrastructure API — open-source alternative to Novu/Courier
Documentation
/*
 * enbbox API
 *
 * Notification infrastructure API — open-source alternative to Novu/Courier
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 * Generated by: https://openapi-generator.tech
 */

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

/// TriggerEvent : Trigger a notification workflow. Sends notifications through the configured channels (email, SMS, push, etc.) to the specified recipients.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TriggerEvent {
    /// Context data for template personalization. Keys are context types (e.g. `tenant`, `region`). Values can be a string ID (resolved from store) or an object with `id` and optional `data`. Available in templates as `{{ context.type.data.field }}`.
    #[serde(rename = "context")]
    pub context: serde_json::Value,
    /// Workflow identifier — must match the `identifier` field of an existing workflow.
    #[serde(rename = "name")]
    pub name: String,
    /// Per-provider overrides (e.g. custom sender, priority). Keys are provider IDs.
    #[serde(rename = "overrides")]
    pub overrides: serde_json::Value,
    /// Template variables available inside {{handlebar}} expressions.
    #[serde(rename = "payload")]
    pub payload: serde_json::Value,
    /// Recipient specification — a single subscriber ID, multiple IDs, inline subscriber data, or a topic key.
    #[serde(rename = "to")]
    pub to: models::TriggerRecipients,
    /// Client-generated idempotency key. Duplicate `transaction_id` values within 24 h are silently ignored.
    #[serde(rename = "transaction_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub transaction_id: Option<Option<String>>,
}

impl TriggerEvent {
    /// Trigger a notification workflow. Sends notifications through the configured channels (email, SMS, push, etc.) to the specified recipients.
    pub fn new(context: serde_json::Value, name: String, overrides: serde_json::Value, payload: serde_json::Value, to: models::TriggerRecipients) -> TriggerEvent {
        TriggerEvent {
            context,
            name,
            overrides,
            payload,
            to,
            transaction_id: None,
        }
    }
}