1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* 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,
}
}
}