1use std::time::Duration;
2
3use kellnr_common::webhook::{Webhook, WebhookEvent};
4use serde::{Deserialize, Serialize};
5use thiserror::Error;
6use utoipa::ToSchema;
7
8pub fn build_client() -> reqwest::Client {
14 reqwest::Client::builder()
15 .connect_timeout(Duration::from_secs(5))
16 .timeout(Duration::from_secs(30))
17 .build()
18 .unwrap_or_default()
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
22pub struct RegisterWebhookRequest {
23 #[serde(alias = "type")]
25 pub event: WebhookEvent,
26 pub callback_url: String,
27 pub name: Option<String>,
28}
29
30#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
31pub struct RegisterWebhookResponse {
32 pub id: String,
33}
34
35#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
36pub struct GetWebhookResponse {
37 pub id: String,
38 pub event: WebhookEvent,
39 pub callback_url: String,
40 pub name: Option<String>,
41}
42
43#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
44pub struct GetAllWebhooksResponse(pub Vec<Webhook>);
45
46#[derive(Error, Debug)]
47pub enum WebhookError {
48 #[error("Database error: {0}")]
49 DatabaseError(#[from] kellnr_db::error::DbError),
50}