crawlrs 0.2.0

crawlrs - Enterprise-grade web scraping and crawling platform built with Rust
Documentation
// Copyright (c) 2025-2026 Kirky.X🌠
// SPDX-License-Identifier: Apache-2.0

//! Webhook request and response DTOs

use serde::{Deserialize, Serialize};

/// 创建 Webhook 的请求 DTO
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct CreateWebhookRequest {
    /// Webhook 回调 URL
    pub url: String,
}

/// Webhook 响应 DTO
#[derive(Debug, Clone, Serialize)]
pub struct WebhookResponse {
    /// Webhook ID
    pub id: crate::domain::id::Id,
    /// 团队 ID
    pub team_id: crate::domain::id::Id,
    /// Webhook 回调 URL
    pub url: String,
    /// 创建时间
    pub created_at: chrono::DateTime<chrono::Utc>,
    /// 是否已激活
    pub is_active: bool,
    /// 密钥(仅在创建时返回)
    pub secret: Option<String>,
}

/// Webhook 列表条目(不含密钥,防止列表接口泄露 secret)
#[derive(Debug, Clone, Serialize)]
pub struct WebhookListEntry {
    pub id: crate::domain::id::Id,
    pub team_id: crate::domain::id::Id,
    pub url: String,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub is_active: bool,
}

impl From<WebhookResponse> for WebhookListEntry {
    fn from(resp: WebhookResponse) -> Self {
        Self {
            id: resp.id,
            team_id: resp.team_id,
            url: resp.url,
            created_at: resp.created_at,
            is_active: resp.is_active,
        }
    }
}

/// Webhook 列表响应 DTO
#[derive(Debug, Clone, Serialize)]
pub struct WebhookListResponse {
    pub webhooks: Vec<WebhookListEntry>,
    pub total: usize,
}