Skip to main content

safeapp_notifier/
event_keys.rs

1use serde::{
2    Deserialize, Deserializer, Serialize, Serializer,
3    de::{self, Visitor},
4};
5use std::fmt;
6
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum EventKey {
9    Account(AccountEventKey),
10    Sync(SyncEventKey),
11}
12
13impl EventKey {
14    pub fn as_str(&self) -> &'static str {
15        match self {
16            EventKey::Account(key) => key.as_str(),
17            EventKey::Sync(key) => key.as_str(),
18        }
19    }
20
21//    pub fn to_subject(&self) -> String {
22//         match self {
23//             EventKey::Account(account_key) => match account_key {
24//                 // account.*
25//                 AccountEventKey::Welcome => "Welcome to Safe — your AI guard against chargebacks".to_string(),
26//                 AccountEventKey::TierUpgrade => "You’ve been upgraded".to_string(),
27//                 AccountEventKey::ExistingChargebacks => "You have open chargebacks".to_string(),
28//                 AccountEventKey::HighChargebackRatioWarning => "Warning: chargeback rate rising".to_string(),
29//                 AccountEventKey::ProviderDisconnected => "Action needed: connection disconnected".to_string(),
30
31//                 // billing.* (modeled under Account)
32//                 AccountEventKey::BillingPaymentFailed => "Payment failed".to_string(),
33//                 AccountEventKey::BillingInvoiceReady => "Invoice ready".to_string(),
34//             },
35
36//             EventKey::Sync(sync_key) => match sync_key {
37//                 // sync.connection.*
38//                 SyncEventKey::Connection(connection_key) => match connection_key {
39//                     ConnectionEventKey::Finished => "Sync complete — Safe is watching for disputes".to_string(),
40//                     ConnectionEventKey::Added => "Connection successful — monitoring enabled".to_string(),
41//                 },
42
43//                 // sync.disputer.*
44//                 SyncEventKey::Disputer(disputer_key) => match disputer_key {
45//                     DisputerEventKey::PendingCharges(pending_key) => match pending_key {
46//                         PendingChargeEventKey::Payment => "Pending charges payment processed".to_string(),
47//                         PendingChargeEventKey::LimitReached => "Pending charges limit reached".to_string(),
48//                         PendingChargeEventKey::Added => "New pending charge added".to_string(),
49//                     },
50//                     DisputerEventKey::Disputes(dispute_key) => match dispute_key {
51//                         DisputeEventKey::Created => "New dispute detected".to_string(),
52//                         DisputeEventKey::Won => "🎉 You won a chargeback".to_string(),
53//                         DisputeEventKey::Lost => "Outcome: dispute lost".to_string(),
54//                     },
55//                     DisputerEventKey::Evidences(evidence_key) => match evidence_key {
56//                         EvidencesEventKey::Submitted => "Dispute response submitted".to_string(),
57//                     },
58//                 },
59
60//                 // sync.connection.not_created.nudge_day_*
61//                 SyncEventKey::ConnectionNudge(nudge_key) => match nudge_key {
62//                     ConnectionNudgeKey::Day1  => "Connect your account to start protection".to_string(),
63//                     ConnectionNudgeKey::Day2  => "Prevent disputes before they start".to_string(),
64//                     ConnectionNudgeKey::Day4  => "Win disputes automatically with Disputer".to_string(),
65//                     ConnectionNudgeKey::Day7  => "You’re close — finish connecting".to_string(),
66//                     ConnectionNudgeKey::Day30 => "Still here when you’re ready".to_string(),
67//                 },
68
69//                 // sync.chargeback.*
70//                 SyncEventKey::Chargeback(cb_key) => match cb_key {
71//                     ChargebackEventKey::Detected => "New chargeback detected".to_string(),
72//                 },
73
74//                 // sync.response.*
75//                 SyncEventKey::Response(resp_key) => match resp_key {
76//                     ResponseEventKey::DeadlineApproaching => "Urgent: response deadline approaching".to_string(),
77//                 },
78
79//                 // sync.stopper.*
80//                 SyncEventKey::Stopper(stopper_key) => match stopper_key {
81//                     StopperEventKey::PreChargebackAlert => "At-risk transaction detected".to_string(),
82//                     StopperEventKey::AutoRefundExecuted => "Auto-refund executed".to_string(),
83//                 },
84
85//                 // sync.rules.*
86//                 SyncEventKey::Rules(rules_key) => match rules_key {
87//                     RulesEventKey::Created => "Rule created".to_string(),
88//                     RulesEventKey::TriggeredAutoRefund => "Rule triggered: Auto-refund".to_string(),
89//                 },
90//             },
91//         }
92//     }
93}
94
95// Custom serialization (unchanged)
96impl Serialize for EventKey {
97    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
98    where
99        S: Serializer,
100    {
101        serializer.serialize_str(self.as_str())
102    }
103}
104
105// Custom deserialization with fallback for unknown keys
106impl<'de> Deserialize<'de> for EventKey {
107    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
108    where
109        D: Deserializer<'de>,
110    {
111        struct EventKeyVisitor;
112
113        impl<'de> Visitor<'de> for EventKeyVisitor {
114            type Value = EventKey;
115
116            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
117                formatter.write_str("a valid event key string")
118            }
119
120            fn visit_str<E>(self, value: &str) -> Result<EventKey, E>
121            where
122                E: de::Error,
123            {
124                match value {
125                    "account.welcome" => Ok(keys::ACCOUNT_WELCOME),
126                    "account.tier_upgrade" => Ok(keys::ACCOUNT_TIER_UPGRADE),
127                    "sync.connection.finished" => Ok(keys::SYNC_CONNECTION_FINISHED),
128                    "sync.connection.added" => Ok(keys::SYNC_CONNECTION_ADDED),
129                    "sync.disputer.pending_charges.payment" => Ok(keys::SYNC_DISPUTER_PENDING_CHARGES_PAYMENT),
130                    "sync.disputer.pending_charges.limit_reached" => {
131                        Ok(keys::SYNC_DISPUTER_PENDING_CHARGES_LIMIT_REACHED)
132                    }
133                    "sync.disputer.pending_charges.added" => Ok(keys::SYNC_DISPUTER_PENDING_CHARGES_ADDED),
134                    "sync.disputer.disputes.created" => Ok(keys::SYNC_DISPUTER_DISPUTES_CREATED),
135                    "sync.disputer.disputes.won" => Ok(keys::SYNC_DISPUTER_DISPUTES_WON),
136                    "sync.disputer.disputes.lost" => Ok(keys::SYNC_DISPUTER_DISPUTES_LOST),
137                    "sync.disputer.disputes.warning_closed" => Ok(keys::SYNC_DISPUTER_DISPUTES_WARNING_CLOSED),
138                    "sync.disputer.disputes.missing_evidence_reminder" => Ok(keys::SYNC_DISPUTER_DISPUTES_MISSING_EVIDENCE_REMINDER),
139                    "sync.disputer.evidences.submitted" => Ok(keys::SYNC_DISPUTER_EVIDENCES_SUBMITTED),
140                    "sync.disputer.evidences.received" => Ok(keys::SYNC_DISPUTER_EVIDENCES_RECEIVED),
141                    "sync.connection.not_created.nudge_day_1" => Ok(keys::SYNC_CONNECTION_NUDGE_DAY1),
142                    // connection nudges
143                    "sync.connection.not_created.nudge_day_2"  => Ok(keys::SYNC_CONNECTION_NUDGE_DAY2),
144                    "sync.connection.not_created.nudge_day_4"  => Ok(keys::SYNC_CONNECTION_NUDGE_DAY4),
145                    "sync.connection.not_created.nudge_day_7"  => Ok(keys::SYNC_CONNECTION_NUDGE_DAY7),
146                    "sync.connection.not_created.nudge_day_30" => Ok(keys::SYNC_CONNECTION_NUDGE_DAY30),
147
148                    // chargeback + response
149                    // "sync.chargeback.detected"             => Ok(keys::SYNC_CHARGEBACK_DETECTED),
150                    "sync.response.deadline.approaching"   => Ok(keys::SYNC_RESPONSE_DEADLINE_APPROACHING),
151
152                    // stopper
153                    // "sync.stopper.pre_chargeback_alert"    => Ok(keys::SYNC_STOPPER_PRE_CHARGEBACK_ALERT),
154                    // "sync.stopper.auto_refund_executed"    => Ok(keys::SYNC_STOPPER_AUTO_REFUND_EXECUTED),
155
156                    // rules
157                    // "sync.rules.created"                   => Ok(keys::SYNC_RULES_CREATED),
158                    // "sync.rules.triggered.auto_refund"     => Ok(keys::SYNC_RULES_TRIGGERED_AUTO_REFUND),
159
160                    // account extras
161                    "account.existing_chargebacks"         => Ok(keys::ACCOUNT_EXISTING_CHARGEBACKS),
162                    "account.high_chargeback_ratio_warning"=> Ok(keys::ACCOUNT_HIGH_CHARGEBACK_RATIO_WARNING),
163                    "account.provider_disconnected"        => Ok(keys::ACCOUNT_PROVIDER_DISCONNECTED),
164
165                    // billing (mapped under Account variant)
166                    "billing.payment_failed"               => Ok(keys::BILLING_PAYMENT_FAILED),
167                    "billing.invoice_ready"                => Ok(keys::BILLING_INVOICE_READY),
168
169                    // NEW billing email template keys
170                    "welcome"                              => Ok(keys::BILLING_WELCOME),
171                    "payment_succeeded"                    => Ok(keys::BILLING_PAYMENT_SUCCEEDED),
172                    "payment_failed"                       => Ok(keys::BILLING_PAYMENT_FAILED_2),
173                    "overage_invoice_created"              => Ok(keys::BILLING_OVERAGE_INVOICE_CREATED),
174                    "upcoming_invoice"                     => Ok(keys::BILLING_UPCOMING_INVOICE),
175                    "trial_expired"                        => Ok(keys::BILLING_TRIAL_EXPIRED),
176                    "trial_ending"                         => Ok(keys::BILLING_TRIAL_ENDING),
177                    "trial_started"                        => Ok(keys::BILLING_TRIAL_STARTED),
178                    "plan_downgraded"                      => Ok(keys::BILLING_PLAN_DOWNGRADED),
179                    "plan_upgraded"                        => Ok(keys::BILLING_PLAN_UPGRADED),
180                    "plan_renewed"                         => Ok(keys::BILLING_PLAN_RENEWED),
181                    "plan_cancelled"                       => Ok(keys::BILLING_PLAN_CANCELLED),
182                    "plan_purchased"                       => Ok(keys::BILLING_PLAN_PURCHASED),
183
184                    unknown => {
185                        // Optionally log unknown keys for debugging
186                        eprintln!("Unknown event key '{}', expected a known key", unknown);
187                        Err(de::Error::custom(format!("Unknown event key: {}", unknown)))
188                    }
189                }
190            }
191        }
192
193        deserializer.deserialize_str(EventKeyVisitor)
194    }
195}
196
197#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
198pub enum AccountEventKey {
199    Welcome,
200    TierUpgrade,
201
202    // NEW account.* keys
203    ExistingChargebacks,
204    HighChargebackRatioWarning,
205    ProviderDisconnected,
206
207    // NEW billing.* (mapped under Account)
208    BillingPaymentFailed,
209    BillingInvoiceReady,
210
211    // NEW billing email template keys
212    BillingWelcome,
213    BillingPaymentSucceeded,
214    BillingPaymentFailed2,
215    BillingOverageInvoiceCreated,
216    BillingUpcomingInvoice,
217    BillingTrialExpired,
218    BillingTrialEnding,
219    BillingTrialStarted,
220    BillingPlanDowngraded,
221    BillingPlanUpgraded,
222    BillingPlanRenewed,
223    BillingPlanCancelled,
224    BillingPlanPurchased,
225}
226
227impl AccountEventKey {
228    pub fn as_str(&self) -> &'static str {
229        match self {
230            AccountEventKey::Welcome                     => "account.welcome",
231            AccountEventKey::TierUpgrade                 => "account.tier_upgrade",
232            AccountEventKey::ExistingChargebacks         => "account.existing_chargebacks",
233            AccountEventKey::HighChargebackRatioWarning  => "account.high_chargeback_ratio_warning",
234            AccountEventKey::ProviderDisconnected        => "account.provider_disconnected",
235            AccountEventKey::BillingPaymentFailed        => "billing.payment_failed",
236            AccountEventKey::BillingInvoiceReady         => "billing.invoice_ready",
237            AccountEventKey::BillingWelcome              => "welcome",
238            AccountEventKey::BillingPaymentSucceeded     => "payment_succeeded",
239            AccountEventKey::BillingPaymentFailed2       => "payment_failed",
240            AccountEventKey::BillingOverageInvoiceCreated => "overage_invoice_created",
241            AccountEventKey::BillingUpcomingInvoice      => "upcoming_invoice",
242            AccountEventKey::BillingTrialExpired         => "trial_expired",
243            AccountEventKey::BillingTrialEnding          => "trial_ending",
244            AccountEventKey::BillingTrialStarted         => "trial_started",
245            AccountEventKey::BillingPlanDowngraded       => "plan_downgraded",
246            AccountEventKey::BillingPlanUpgraded         => "plan_upgraded",
247            AccountEventKey::BillingPlanRenewed          => "plan_renewed",
248            AccountEventKey::BillingPlanCancelled        => "plan_cancelled",
249            AccountEventKey::BillingPlanPurchased        => "plan_purchased",
250        }
251    }
252}
253
254#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
255pub enum SyncEventKey {
256    Connection(ConnectionEventKey),
257    Disputer(DisputerEventKey),
258
259    // already there:
260    ConnectionNudge(ConnectionNudgeKey),
261
262    // NEW:
263    // Chargeback(ChargebackEventKey),
264    Response(ResponseEventKey),
265    // Stopper(StopperEventKey),
266    // Rules(RulesEventKey),
267}
268
269impl SyncEventKey {
270    pub fn as_str(&self) -> &'static str {
271        match self {
272            SyncEventKey::Connection(key)      => key.as_str(),
273            SyncEventKey::Disputer(key)        => key.as_str(),
274            SyncEventKey::ConnectionNudge(key) => key.as_str(),
275            // SyncEventKey::Chargeback(key)      => key.as_str(),
276            SyncEventKey::Response(key)        => key.as_str(),
277            // SyncEventKey::Stopper(key)         => key.as_str(),
278            // SyncEventKey::Rules(key)           => key.as_str(),
279        }
280    }
281}
282
283#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
284pub enum ConnectionEventKey {
285    Finished,
286    Added,
287}
288
289impl ConnectionEventKey {
290    pub fn as_str(&self) -> &'static str {
291        match self {
292            ConnectionEventKey::Finished => "sync.connection.finished",
293            ConnectionEventKey::Added => "sync.connection.added",
294        }
295    }
296}
297
298#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
299pub enum DisputerEventKey {
300    PendingCharges(PendingChargeEventKey),
301    Disputes(DisputeEventKey),
302    Evidences(EvidencesEventKey),
303}
304
305impl DisputerEventKey {
306    pub fn as_str(&self) -> &'static str {
307        match self {
308            DisputerEventKey::PendingCharges(key) => key.as_str(),
309            DisputerEventKey::Disputes(key) => key.as_str(),
310            DisputerEventKey::Evidences(key) => key.as_str(),
311        }
312    }
313}
314
315#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
316pub enum DisputeEventKey {
317    Created,
318    Won,
319    Lost,
320    WarningClosed,
321    MissingEvidenceReminder
322}
323
324impl DisputeEventKey {
325    pub fn as_str(&self) -> &'static str {
326        match self {
327            DisputeEventKey::Created => "sync.disputer.disputes.created",
328            DisputeEventKey::Won => "sync.disputer.disputes.won",
329            DisputeEventKey::Lost => "sync.disputer.disputes.lost",
330            DisputeEventKey::WarningClosed => "sync.disputer.disputes.warning_closed",
331            DisputeEventKey::MissingEvidenceReminder => "sync.disputer.disputes.missing_evidence_reminder",
332        }
333    }
334}
335
336#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
337pub enum PendingChargeEventKey {
338    Payment,
339    LimitReached,
340    Added,
341}
342
343impl PendingChargeEventKey {
344    pub fn as_str(&self) -> &'static str {
345        match self {
346            PendingChargeEventKey::Payment => "sync.disputer.pending_charges.payment",
347            PendingChargeEventKey::LimitReached => "sync.disputer.pending_charges.limit_reached",
348            PendingChargeEventKey::Added => "sync.disputer.pending_charges.added",
349        }
350    }
351}
352
353#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
354pub enum EvidencesEventKey {
355    Submitted,
356    Received,
357}
358
359impl EvidencesEventKey {
360    pub fn as_str(&self) -> &'static str {
361        match self {
362            EvidencesEventKey::Submitted => "sync.disputer.evidences.submitted",
363            EvidencesEventKey::Received => "sync.disputer.evidences.received",
364        }
365    }
366}
367
368// --- Connection Nudges (extend what you already have) ---
369#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
370pub enum ConnectionNudgeKey {
371    Day1,
372    Day2,
373    Day4,
374    Day7,
375    Day30,
376}
377
378impl ConnectionNudgeKey {
379    pub fn as_str(&self) -> &'static str {
380        match self {
381            ConnectionNudgeKey::Day1  => "sync.connection.not_created.nudge_day_1",
382            ConnectionNudgeKey::Day2  => "sync.connection.not_created.nudge_day_2",
383            ConnectionNudgeKey::Day4  => "sync.connection.not_created.nudge_day_4",
384            ConnectionNudgeKey::Day7  => "sync.connection.not_created.nudge_day_7",
385            ConnectionNudgeKey::Day30 => "sync.connection.not_created.nudge_day_30",
386        }
387    }
388}
389
390// // --- Chargeback ---
391// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
392// pub enum ChargebackEventKey {
393//     Detected,
394// }
395// impl ChargebackEventKey {
396//     pub fn as_str(&self) -> &'static str {
397//         match self {
398//             ChargebackEventKey::Detected => "sync.chargeback.detected",
399//         }
400//     }
401// }
402
403// --- Response (deadlines etc) ---
404#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
405pub enum ResponseEventKey {
406    DeadlineApproaching,
407}
408impl ResponseEventKey {
409    pub fn as_str(&self) -> &'static str {
410        match self {
411            ResponseEventKey::DeadlineApproaching => "sync.response.deadline.approaching",
412        }
413    }
414}
415
416// --- Stopper (pre-chargeback / actions) ---
417// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
418// pub enum StopperEventKey {
419//     PreChargebackAlert,
420//     AutoRefundExecuted,
421// }
422// impl StopperEventKey {
423//     pub fn as_str(&self) -> &'static str {
424//         match self {
425//             StopperEventKey::PreChargebackAlert => "sync.stopper.pre_chargeback_alert",
426//             StopperEventKey::AutoRefundExecuted => "sync.stopper.auto_refund_executed",
427//         }
428//     }
429// }
430
431// // --- Rules (created / triggered) ---
432// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
433// pub enum RulesEventKey {
434//     Created,
435//     TriggeredAutoRefund,
436// }
437// impl RulesEventKey {
438//     pub fn as_str(&self) -> &'static str {
439//         match self {
440//             RulesEventKey::Created => "sync.rules.created",
441//             RulesEventKey::TriggeredAutoRefund => "sync.rules.triggered.auto_refund",
442//         }
443//     }
444// }
445
446pub mod keys {
447    use super::*;
448
449    pub const ACCOUNT_WELCOME: EventKey = EventKey::Account(AccountEventKey::Welcome);
450    pub const ACCOUNT_TIER_UPGRADE: EventKey = EventKey::Account(AccountEventKey::TierUpgrade);
451
452    pub const SYNC_CONNECTION_FINISHED: EventKey =
453        EventKey::Sync(SyncEventKey::Connection(ConnectionEventKey::Finished));
454        
455    pub const SYNC_CONNECTION_ADDED: EventKey = EventKey::Sync(SyncEventKey::Connection(ConnectionEventKey::Added));
456
457    pub const SYNC_DISPUTER_PENDING_CHARGES_PAYMENT: EventKey = EventKey::Sync(SyncEventKey::Disputer(
458        DisputerEventKey::PendingCharges(PendingChargeEventKey::Payment),
459    ));
460    pub const SYNC_DISPUTER_PENDING_CHARGES_LIMIT_REACHED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
461        DisputerEventKey::PendingCharges(PendingChargeEventKey::LimitReached),
462    ));
463    pub const SYNC_DISPUTER_PENDING_CHARGES_ADDED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
464        DisputerEventKey::PendingCharges(PendingChargeEventKey::Added),
465    ));
466    pub const SYNC_DISPUTER_DISPUTES_CREATED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
467        DisputerEventKey::Disputes(DisputeEventKey::Created),
468    ));
469    pub const SYNC_DISPUTER_DISPUTES_WON: EventKey =
470        EventKey::Sync(SyncEventKey::Disputer(DisputerEventKey::Disputes(DisputeEventKey::Won)));
471    pub const SYNC_DISPUTER_DISPUTES_LOST: EventKey = EventKey::Sync(SyncEventKey::Disputer(
472        DisputerEventKey::Disputes(DisputeEventKey::Lost),
473    ));
474    pub const SYNC_DISPUTER_DISPUTES_WARNING_CLOSED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
475        DisputerEventKey::Disputes(DisputeEventKey::WarningClosed),
476    ));
477    pub const SYNC_DISPUTER_DISPUTES_MISSING_EVIDENCE_REMINDER: EventKey = EventKey::Sync(SyncEventKey::Disputer(
478        DisputerEventKey::Disputes(DisputeEventKey::MissingEvidenceReminder),
479    ));
480    pub const SYNC_DISPUTER_EVIDENCES_SUBMITTED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
481        DisputerEventKey::Evidences(EvidencesEventKey::Submitted),
482    ));
483    pub const SYNC_DISPUTER_EVIDENCES_RECEIVED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
484        DisputerEventKey::Evidences(EvidencesEventKey::Received),
485    ));
486    
487    pub const SYNC_CONNECTION_NUDGE_DAY1: EventKey = EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day1));
488
489    pub const SYNC_CONNECTION_NUDGE_DAY2: EventKey =
490        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day2));
491    pub const SYNC_CONNECTION_NUDGE_DAY4: EventKey =
492        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day4));
493    pub const SYNC_CONNECTION_NUDGE_DAY7: EventKey =
494        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day7));
495    pub const SYNC_CONNECTION_NUDGE_DAY30: EventKey =
496        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day30));
497
498    // pub const SYNC_CHARGEBACK_DETECTED: EventKey =
499    //     EventKey::Sync(SyncEventKey::Chargeback(ChargebackEventKey::Detected));
500
501    pub const SYNC_RESPONSE_DEADLINE_APPROACHING: EventKey =
502        EventKey::Sync(SyncEventKey::Response(ResponseEventKey::DeadlineApproaching));
503
504    // pub const SYNC_STOPPER_PRE_CHARGEBACK_ALERT: EventKey =
505    //     EventKey::Sync(SyncEventKey::Stopper(StopperEventKey::PreChargebackAlert));
506    // pub const SYNC_STOPPER_AUTO_REFUND_EXECUTED: EventKey =
507    //     EventKey::Sync(SyncEventKey::Stopper(StopperEventKey::AutoRefundExecuted));
508
509    // pub const SYNC_RULES_CREATED: EventKey =
510    //     EventKey::Sync(SyncEventKey::Rules(RulesEventKey::Created));
511    // pub const SYNC_RULES_TRIGGERED_AUTO_REFUND: EventKey =
512    //     EventKey::Sync(SyncEventKey::Rules(RulesEventKey::TriggeredAutoRefund));
513
514    // Account-side new keys
515    pub const ACCOUNT_EXISTING_CHARGEBACKS: EventKey =
516        EventKey::Account(AccountEventKey::ExistingChargebacks);
517    pub const ACCOUNT_HIGH_CHARGEBACK_RATIO_WARNING: EventKey =
518        EventKey::Account(AccountEventKey::HighChargebackRatioWarning);
519    pub const ACCOUNT_PROVIDER_DISCONNECTED: EventKey =
520        EventKey::Account(AccountEventKey::ProviderDisconnected);
521
522    // Billing (kept under Account to avoid new top-level variant)
523    pub const BILLING_PAYMENT_FAILED: EventKey =
524        EventKey::Account(AccountEventKey::BillingPaymentFailed);
525    pub const BILLING_INVOICE_READY: EventKey =
526        EventKey::Account(AccountEventKey::BillingInvoiceReady);
527
528    // NEW billing email template keys
529    pub const BILLING_WELCOME: EventKey =
530        EventKey::Account(AccountEventKey::BillingWelcome);
531    pub const BILLING_PAYMENT_SUCCEEDED: EventKey =
532        EventKey::Account(AccountEventKey::BillingPaymentSucceeded);
533    pub const BILLING_PAYMENT_FAILED_2: EventKey =
534        EventKey::Account(AccountEventKey::BillingPaymentFailed2);
535    pub const BILLING_OVERAGE_INVOICE_CREATED: EventKey =
536        EventKey::Account(AccountEventKey::BillingOverageInvoiceCreated);
537    pub const BILLING_UPCOMING_INVOICE: EventKey =
538        EventKey::Account(AccountEventKey::BillingUpcomingInvoice);
539    pub const BILLING_TRIAL_EXPIRED: EventKey =
540        EventKey::Account(AccountEventKey::BillingTrialExpired);
541    pub const BILLING_TRIAL_ENDING: EventKey =
542        EventKey::Account(AccountEventKey::BillingTrialEnding);
543    pub const BILLING_TRIAL_STARTED: EventKey =
544        EventKey::Account(AccountEventKey::BillingTrialStarted);
545    pub const BILLING_PLAN_DOWNGRADED: EventKey =
546        EventKey::Account(AccountEventKey::BillingPlanDowngraded);
547    pub const BILLING_PLAN_UPGRADED: EventKey =
548        EventKey::Account(AccountEventKey::BillingPlanUpgraded);
549    pub const BILLING_PLAN_RENEWED: EventKey =
550        EventKey::Account(AccountEventKey::BillingPlanRenewed);
551    pub const BILLING_PLAN_CANCELLED: EventKey =
552        EventKey::Account(AccountEventKey::BillingPlanCancelled);
553    pub const BILLING_PLAN_PURCHASED: EventKey =
554        EventKey::Account(AccountEventKey::BillingPlanPurchased);
555
556}