Skip to main content

kellnr_webhooks/
types.rs

1use kellnr_common::webhook::{Webhook, WebhookEvent};
2use serde::{Deserialize, Serialize};
3use thiserror::Error;
4use utoipa::ToSchema;
5
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
7pub struct RegisterWebhookRequest {
8    // `type` alias included for webhook standards compatibility
9    #[serde(alias = "type")]
10    pub event: WebhookEvent,
11    pub callback_url: String,
12    pub name: Option<String>,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
16pub struct RegisterWebhookResponse {
17    pub id: String,
18}
19
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
21pub struct GetWebhookResponse {
22    pub id: String,
23    pub event: WebhookEvent,
24    pub callback_url: String,
25    pub name: Option<String>,
26}
27
28#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
29pub struct GetAllWebhooksResponse(pub Vec<Webhook>);
30
31#[derive(Error, Debug)]
32pub enum WebhookError {
33    #[error("Database error: {0}")]
34    DatabaseError(#[from] kellnr_db::error::DbError),
35}