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                    "success-fee-invoice"                  => Ok(keys::BILLING_SUCCESS_FEE_INVOICE),
184
185                    unknown => {
186                        // Optionally log unknown keys for debugging
187                        eprintln!("Unknown event key '{}', expected a known key", unknown);
188                        Err(de::Error::custom(format!("Unknown event key: {}", unknown)))
189                    }
190                }
191            }
192        }
193
194        deserializer.deserialize_str(EventKeyVisitor)
195    }
196}
197
198#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
199pub enum AccountEventKey {
200    Welcome,
201    TierUpgrade,
202
203    // NEW account.* keys
204    ExistingChargebacks,
205    HighChargebackRatioWarning,
206    ProviderDisconnected,
207
208    // NEW billing.* (mapped under Account)
209    BillingPaymentFailed,
210    BillingInvoiceReady,
211
212    // NEW billing email template keys
213    BillingWelcome,
214    BillingPaymentSucceeded,
215    BillingPaymentFailed2,
216    BillingOverageInvoiceCreated,
217    BillingUpcomingInvoice,
218    BillingTrialExpired,
219    BillingTrialEnding,
220    BillingTrialStarted,
221    BillingPlanDowngraded,
222    BillingPlanUpgraded,
223    BillingPlanRenewed,
224    BillingPlanCancelled,
225    BillingPlanPurchased,
226    BillingSuccessFeeInvoice,
227}
228
229impl AccountEventKey {
230    pub fn as_str(&self) -> &'static str {
231        match self {
232            AccountEventKey::Welcome                     => "account.welcome",
233            AccountEventKey::TierUpgrade                 => "account.tier_upgrade",
234            AccountEventKey::ExistingChargebacks         => "account.existing_chargebacks",
235            AccountEventKey::HighChargebackRatioWarning  => "account.high_chargeback_ratio_warning",
236            AccountEventKey::ProviderDisconnected        => "account.provider_disconnected",
237            AccountEventKey::BillingPaymentFailed        => "billing.payment_failed",
238            AccountEventKey::BillingInvoiceReady         => "billing.invoice_ready",
239            AccountEventKey::BillingWelcome              => "welcome",
240            AccountEventKey::BillingPaymentSucceeded     => "payment_succeeded",
241            AccountEventKey::BillingPaymentFailed2       => "payment_failed",
242            AccountEventKey::BillingOverageInvoiceCreated => "overage_invoice_created",
243            AccountEventKey::BillingUpcomingInvoice      => "upcoming_invoice",
244            AccountEventKey::BillingTrialExpired         => "trial_expired",
245            AccountEventKey::BillingTrialEnding          => "trial_ending",
246            AccountEventKey::BillingTrialStarted         => "trial_started",
247            AccountEventKey::BillingPlanDowngraded       => "plan_downgraded",
248            AccountEventKey::BillingPlanUpgraded         => "plan_upgraded",
249            AccountEventKey::BillingPlanRenewed          => "plan_renewed",
250            AccountEventKey::BillingPlanCancelled        => "plan_cancelled",
251            AccountEventKey::BillingPlanPurchased        => "plan_purchased",
252            AccountEventKey::BillingSuccessFeeInvoice    => "success-fee-invoice",
253        }
254    }
255}
256
257#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
258pub enum SyncEventKey {
259    Connection(ConnectionEventKey),
260    Disputer(DisputerEventKey),
261
262    // already there:
263    ConnectionNudge(ConnectionNudgeKey),
264
265    // NEW:
266    // Chargeback(ChargebackEventKey),
267    Response(ResponseEventKey),
268    // Stopper(StopperEventKey),
269    // Rules(RulesEventKey),
270}
271
272impl SyncEventKey {
273    pub fn as_str(&self) -> &'static str {
274        match self {
275            SyncEventKey::Connection(key)      => key.as_str(),
276            SyncEventKey::Disputer(key)        => key.as_str(),
277            SyncEventKey::ConnectionNudge(key) => key.as_str(),
278            // SyncEventKey::Chargeback(key)      => key.as_str(),
279            SyncEventKey::Response(key)        => key.as_str(),
280            // SyncEventKey::Stopper(key)         => key.as_str(),
281            // SyncEventKey::Rules(key)           => key.as_str(),
282        }
283    }
284}
285
286#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
287pub enum ConnectionEventKey {
288    Finished,
289    Added,
290}
291
292impl ConnectionEventKey {
293    pub fn as_str(&self) -> &'static str {
294        match self {
295            ConnectionEventKey::Finished => "sync.connection.finished",
296            ConnectionEventKey::Added => "sync.connection.added",
297        }
298    }
299}
300
301#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
302pub enum DisputerEventKey {
303    PendingCharges(PendingChargeEventKey),
304    Disputes(DisputeEventKey),
305    Evidences(EvidencesEventKey),
306}
307
308impl DisputerEventKey {
309    pub fn as_str(&self) -> &'static str {
310        match self {
311            DisputerEventKey::PendingCharges(key) => key.as_str(),
312            DisputerEventKey::Disputes(key) => key.as_str(),
313            DisputerEventKey::Evidences(key) => key.as_str(),
314        }
315    }
316}
317
318#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
319pub enum DisputeEventKey {
320    Created,
321    Won,
322    Lost,
323    WarningClosed,
324    MissingEvidenceReminder
325}
326
327impl DisputeEventKey {
328    pub fn as_str(&self) -> &'static str {
329        match self {
330            DisputeEventKey::Created => "sync.disputer.disputes.created",
331            DisputeEventKey::Won => "sync.disputer.disputes.won",
332            DisputeEventKey::Lost => "sync.disputer.disputes.lost",
333            DisputeEventKey::WarningClosed => "sync.disputer.disputes.warning_closed",
334            DisputeEventKey::MissingEvidenceReminder => "sync.disputer.disputes.missing_evidence_reminder",
335        }
336    }
337}
338
339#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
340pub enum PendingChargeEventKey {
341    Payment,
342    LimitReached,
343    Added,
344}
345
346impl PendingChargeEventKey {
347    pub fn as_str(&self) -> &'static str {
348        match self {
349            PendingChargeEventKey::Payment => "sync.disputer.pending_charges.payment",
350            PendingChargeEventKey::LimitReached => "sync.disputer.pending_charges.limit_reached",
351            PendingChargeEventKey::Added => "sync.disputer.pending_charges.added",
352        }
353    }
354}
355
356#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
357pub enum EvidencesEventKey {
358    Submitted,
359    Received,
360}
361
362impl EvidencesEventKey {
363    pub fn as_str(&self) -> &'static str {
364        match self {
365            EvidencesEventKey::Submitted => "sync.disputer.evidences.submitted",
366            EvidencesEventKey::Received => "sync.disputer.evidences.received",
367        }
368    }
369}
370
371// --- Connection Nudges (extend what you already have) ---
372#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
373pub enum ConnectionNudgeKey {
374    Day1,
375    Day2,
376    Day4,
377    Day7,
378    Day30,
379}
380
381impl ConnectionNudgeKey {
382    pub fn as_str(&self) -> &'static str {
383        match self {
384            ConnectionNudgeKey::Day1  => "sync.connection.not_created.nudge_day_1",
385            ConnectionNudgeKey::Day2  => "sync.connection.not_created.nudge_day_2",
386            ConnectionNudgeKey::Day4  => "sync.connection.not_created.nudge_day_4",
387            ConnectionNudgeKey::Day7  => "sync.connection.not_created.nudge_day_7",
388            ConnectionNudgeKey::Day30 => "sync.connection.not_created.nudge_day_30",
389        }
390    }
391}
392
393// // --- Chargeback ---
394// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
395// pub enum ChargebackEventKey {
396//     Detected,
397// }
398// impl ChargebackEventKey {
399//     pub fn as_str(&self) -> &'static str {
400//         match self {
401//             ChargebackEventKey::Detected => "sync.chargeback.detected",
402//         }
403//     }
404// }
405
406// --- Response (deadlines etc) ---
407#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
408pub enum ResponseEventKey {
409    DeadlineApproaching,
410}
411impl ResponseEventKey {
412    pub fn as_str(&self) -> &'static str {
413        match self {
414            ResponseEventKey::DeadlineApproaching => "sync.response.deadline.approaching",
415        }
416    }
417}
418
419// --- Stopper (pre-chargeback / actions) ---
420// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
421// pub enum StopperEventKey {
422//     PreChargebackAlert,
423//     AutoRefundExecuted,
424// }
425// impl StopperEventKey {
426//     pub fn as_str(&self) -> &'static str {
427//         match self {
428//             StopperEventKey::PreChargebackAlert => "sync.stopper.pre_chargeback_alert",
429//             StopperEventKey::AutoRefundExecuted => "sync.stopper.auto_refund_executed",
430//         }
431//     }
432// }
433
434// // --- Rules (created / triggered) ---
435// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
436// pub enum RulesEventKey {
437//     Created,
438//     TriggeredAutoRefund,
439// }
440// impl RulesEventKey {
441//     pub fn as_str(&self) -> &'static str {
442//         match self {
443//             RulesEventKey::Created => "sync.rules.created",
444//             RulesEventKey::TriggeredAutoRefund => "sync.rules.triggered.auto_refund",
445//         }
446//     }
447// }
448
449pub mod keys {
450    use super::*;
451
452    pub const ACCOUNT_WELCOME: EventKey = EventKey::Account(AccountEventKey::Welcome);
453    pub const ACCOUNT_TIER_UPGRADE: EventKey = EventKey::Account(AccountEventKey::TierUpgrade);
454
455    pub const SYNC_CONNECTION_FINISHED: EventKey =
456        EventKey::Sync(SyncEventKey::Connection(ConnectionEventKey::Finished));
457        
458    pub const SYNC_CONNECTION_ADDED: EventKey = EventKey::Sync(SyncEventKey::Connection(ConnectionEventKey::Added));
459
460    pub const SYNC_DISPUTER_PENDING_CHARGES_PAYMENT: EventKey = EventKey::Sync(SyncEventKey::Disputer(
461        DisputerEventKey::PendingCharges(PendingChargeEventKey::Payment),
462    ));
463    pub const SYNC_DISPUTER_PENDING_CHARGES_LIMIT_REACHED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
464        DisputerEventKey::PendingCharges(PendingChargeEventKey::LimitReached),
465    ));
466    pub const SYNC_DISPUTER_PENDING_CHARGES_ADDED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
467        DisputerEventKey::PendingCharges(PendingChargeEventKey::Added),
468    ));
469    pub const SYNC_DISPUTER_DISPUTES_CREATED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
470        DisputerEventKey::Disputes(DisputeEventKey::Created),
471    ));
472    pub const SYNC_DISPUTER_DISPUTES_WON: EventKey =
473        EventKey::Sync(SyncEventKey::Disputer(DisputerEventKey::Disputes(DisputeEventKey::Won)));
474    pub const SYNC_DISPUTER_DISPUTES_LOST: EventKey = EventKey::Sync(SyncEventKey::Disputer(
475        DisputerEventKey::Disputes(DisputeEventKey::Lost),
476    ));
477    pub const SYNC_DISPUTER_DISPUTES_WARNING_CLOSED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
478        DisputerEventKey::Disputes(DisputeEventKey::WarningClosed),
479    ));
480    pub const SYNC_DISPUTER_DISPUTES_MISSING_EVIDENCE_REMINDER: EventKey = EventKey::Sync(SyncEventKey::Disputer(
481        DisputerEventKey::Disputes(DisputeEventKey::MissingEvidenceReminder),
482    ));
483    pub const SYNC_DISPUTER_EVIDENCES_SUBMITTED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
484        DisputerEventKey::Evidences(EvidencesEventKey::Submitted),
485    ));
486    pub const SYNC_DISPUTER_EVIDENCES_RECEIVED: EventKey = EventKey::Sync(SyncEventKey::Disputer(
487        DisputerEventKey::Evidences(EvidencesEventKey::Received),
488    ));
489    
490    pub const SYNC_CONNECTION_NUDGE_DAY1: EventKey = EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day1));
491
492    pub const SYNC_CONNECTION_NUDGE_DAY2: EventKey =
493        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day2));
494    pub const SYNC_CONNECTION_NUDGE_DAY4: EventKey =
495        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day4));
496    pub const SYNC_CONNECTION_NUDGE_DAY7: EventKey =
497        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day7));
498    pub const SYNC_CONNECTION_NUDGE_DAY30: EventKey =
499        EventKey::Sync(SyncEventKey::ConnectionNudge(ConnectionNudgeKey::Day30));
500
501    // pub const SYNC_CHARGEBACK_DETECTED: EventKey =
502    //     EventKey::Sync(SyncEventKey::Chargeback(ChargebackEventKey::Detected));
503
504    pub const SYNC_RESPONSE_DEADLINE_APPROACHING: EventKey =
505        EventKey::Sync(SyncEventKey::Response(ResponseEventKey::DeadlineApproaching));
506
507    // pub const SYNC_STOPPER_PRE_CHARGEBACK_ALERT: EventKey =
508    //     EventKey::Sync(SyncEventKey::Stopper(StopperEventKey::PreChargebackAlert));
509    // pub const SYNC_STOPPER_AUTO_REFUND_EXECUTED: EventKey =
510    //     EventKey::Sync(SyncEventKey::Stopper(StopperEventKey::AutoRefundExecuted));
511
512    // pub const SYNC_RULES_CREATED: EventKey =
513    //     EventKey::Sync(SyncEventKey::Rules(RulesEventKey::Created));
514    // pub const SYNC_RULES_TRIGGERED_AUTO_REFUND: EventKey =
515    //     EventKey::Sync(SyncEventKey::Rules(RulesEventKey::TriggeredAutoRefund));
516
517    // Account-side new keys
518    pub const ACCOUNT_EXISTING_CHARGEBACKS: EventKey =
519        EventKey::Account(AccountEventKey::ExistingChargebacks);
520    pub const ACCOUNT_HIGH_CHARGEBACK_RATIO_WARNING: EventKey =
521        EventKey::Account(AccountEventKey::HighChargebackRatioWarning);
522    pub const ACCOUNT_PROVIDER_DISCONNECTED: EventKey =
523        EventKey::Account(AccountEventKey::ProviderDisconnected);
524
525    // Billing (kept under Account to avoid new top-level variant)
526    pub const BILLING_PAYMENT_FAILED: EventKey =
527        EventKey::Account(AccountEventKey::BillingPaymentFailed);
528    pub const BILLING_INVOICE_READY: EventKey =
529        EventKey::Account(AccountEventKey::BillingInvoiceReady);
530
531    // NEW billing email template keys
532    pub const BILLING_WELCOME: EventKey =
533        EventKey::Account(AccountEventKey::BillingWelcome);
534    pub const BILLING_PAYMENT_SUCCEEDED: EventKey =
535        EventKey::Account(AccountEventKey::BillingPaymentSucceeded);
536    pub const BILLING_PAYMENT_FAILED_2: EventKey =
537        EventKey::Account(AccountEventKey::BillingPaymentFailed2);
538    pub const BILLING_OVERAGE_INVOICE_CREATED: EventKey =
539        EventKey::Account(AccountEventKey::BillingOverageInvoiceCreated);
540    pub const BILLING_UPCOMING_INVOICE: EventKey =
541        EventKey::Account(AccountEventKey::BillingUpcomingInvoice);
542    pub const BILLING_TRIAL_EXPIRED: EventKey =
543        EventKey::Account(AccountEventKey::BillingTrialExpired);
544    pub const BILLING_TRIAL_ENDING: EventKey =
545        EventKey::Account(AccountEventKey::BillingTrialEnding);
546    pub const BILLING_TRIAL_STARTED: EventKey =
547        EventKey::Account(AccountEventKey::BillingTrialStarted);
548    pub const BILLING_PLAN_DOWNGRADED: EventKey =
549        EventKey::Account(AccountEventKey::BillingPlanDowngraded);
550    pub const BILLING_PLAN_UPGRADED: EventKey =
551        EventKey::Account(AccountEventKey::BillingPlanUpgraded);
552    pub const BILLING_PLAN_RENEWED: EventKey =
553        EventKey::Account(AccountEventKey::BillingPlanRenewed);
554    pub const BILLING_PLAN_CANCELLED: EventKey =
555        EventKey::Account(AccountEventKey::BillingPlanCancelled);
556    pub const BILLING_PLAN_PURCHASED: EventKey =
557        EventKey::Account(AccountEventKey::BillingPlanPurchased);
558    pub const BILLING_SUCCESS_FEE_INVOICE: EventKey =
559        EventKey::Account(AccountEventKey::BillingSuccessFeeInvoice);
560
561}