pebble_cms/models/
webhook.rs1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize)]
4pub struct Webhook {
5 pub id: i64,
6 pub name: String,
7 pub url: String,
8 pub secret: Option<String>,
9 pub events: String,
10 pub active: bool,
11 pub created_at: String,
12 pub updated_at: String,
13}
14
15impl Webhook {
16 pub fn event_list(&self) -> Vec<&str> {
18 self.events.split(',').map(|s| s.trim()).collect()
19 }
20
21 pub fn handles_event(&self, event: &str) -> bool {
23 self.event_list().iter().any(|e| *e == event)
24 }
25}
26
27#[derive(Debug, Clone, Serialize)]
28pub struct WebhookDelivery {
29 pub id: i64,
30 pub webhook_id: i64,
31 pub event: String,
32 pub payload: String,
33 pub response_status: Option<i32>,
34 pub response_body: Option<String>,
35 pub success: bool,
36 pub attempts: i32,
37 pub delivered_at: String,
38}