kick_api/models/event.rs
1use serde::{Deserialize, Serialize};
2
3/// An active event subscription
4#[derive(Debug, Clone, Deserialize)]
5pub struct EventSubscription {
6 /// Unique subscription identifier
7 pub id: String,
8
9 /// The app that created this subscription
10 pub app_id: String,
11
12 /// The broadcaster this subscription is for
13 pub broadcaster_user_id: u64,
14
15 /// Event type name (e.g., "chat.message.created")
16 pub event: String,
17
18 /// Event version
19 pub version: u32,
20
21 /// Delivery method (e.g., "webhook")
22 pub method: String,
23
24 /// When the subscription was created (ISO 8601)
25 pub created_at: String,
26
27 /// When the subscription was last updated (ISO 8601)
28 pub updated_at: String,
29}
30
31/// A single event to subscribe to
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct SubscribeEvent {
34 /// Event type name (e.g., "chat.message.created")
35 pub name: String,
36
37 /// Event version
38 pub version: u32,
39}
40
41/// Request body for creating event subscriptions
42///
43/// # Example
44/// ```
45/// use kick_api::{SubscribeRequest, SubscribeEvent};
46///
47/// let request = SubscribeRequest {
48/// broadcaster_user_id: Some(12345),
49/// method: "webhook".to_string(),
50/// events: vec![
51/// SubscribeEvent { name: "chat.message.created".to_string(), version: 1 },
52/// SubscribeEvent { name: "channel.followed".to_string(), version: 1 },
53/// ],
54/// };
55/// ```
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct SubscribeRequest {
58 /// The broadcaster to subscribe to events for
59 #[serde(skip_serializing_if = "Option::is_none")]
60 pub broadcaster_user_id: Option<u64>,
61
62 /// Delivery method (e.g., "webhook")
63 pub method: String,
64
65 /// List of events to subscribe to
66 pub events: Vec<SubscribeEvent>,
67}
68
69/// Result of a single event subscription attempt
70#[derive(Debug, Clone, Deserialize)]
71pub struct SubscribeResult {
72 /// Event type name
73 pub name: String,
74
75 /// Event version
76 pub version: u32,
77
78 /// Subscription ID if successful
79 pub subscription_id: Option<String>,
80
81 /// Error message if subscription failed
82 pub error: Option<String>,
83}