Skip to main content

efi_bank/
webhooks.rs

1use reqwest::Method;
2
3use crate::client::Client;
4use crate::error::Error;
5use crate::types::{WebhookPayload, WebhookResponse, WebhooksListResponse};
6
7impl Client {
8    pub async fn webhook_create(&self, payload: &WebhookPayload) -> Result<WebhookResponse, Error> {
9        self.send_authenticated(Method::POST, "/v2/webhook", Some(payload))
10            .await
11    }
12
13    pub async fn webhook_update(
14        &self,
15        webhook_id: &str,
16        payload: &WebhookPayload,
17    ) -> Result<WebhookResponse, Error> {
18        let path = format!("/v2/webhook/{webhook_id}");
19        self.send_authenticated(Method::PUT, &path, Some(payload))
20            .await
21    }
22
23    pub async fn webhook_get(&self, webhook_id: &str) -> Result<WebhookResponse, Error> {
24        let path = format!("/v2/webhook/{webhook_id}");
25        self.send_authenticated::<serde_json::Value, WebhookResponse>(Method::GET, &path, None)
26            .await
27    }
28
29    pub async fn webhook_list(&self) -> Result<WebhooksListResponse, Error> {
30        self.send_authenticated::<serde_json::Value, WebhooksListResponse>(
31            Method::GET,
32            "/v2/webhook",
33            None,
34        )
35        .await
36    }
37
38    pub async fn webhook_delete(&self, webhook_id: &str) -> Result<(), Error> {
39        let path = format!("/v2/webhook/{webhook_id}");
40        self.send_authenticated::<serde_json::Value, serde_json::Value>(
41            Method::DELETE,
42            &path,
43            None,
44        )
45        .await?;
46        Ok(())
47    }
48}