1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use revolt_result::Result;

use crate::{FieldsWebhook, PartialWebhook, Webhook};

mod mongodb;
mod reference;

#[async_trait]
pub trait AbstractWebhooks: Sync + Send {
    /// Insert new webhook into the database
    async fn insert_webhook(&self, webhook: &Webhook) -> Result<()>;

    /// Fetch webhook by id
    async fn fetch_webhook(&self, webhook_id: &str) -> Result<Webhook>;

    /// Fetch webhooks for channel
    async fn fetch_webhooks_for_channel(&self, channel_id: &str) -> Result<Vec<Webhook>>;

    /// Update webhook with new information
    async fn update_webhook(
        &self,
        webhook_id: &str,
        partial: &PartialWebhook,
        remove: &[FieldsWebhook],
    ) -> Result<()>;

    /// Delete webhook by id
    async fn delete_webhook(&self, webhook_id: &str) -> Result<()>;
}