fizzy_sdk/generated/services/
webhooks.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9pub struct WebhooksService<'a> {
11 scope: Scope<'a>,
12}
13
14impl<'a> WebhooksService<'a> {
15 pub(crate) fn new(scope: Scope<'a>) -> Self {
16 Self { scope }
17 }
18
19 pub fn scope(&self) -> &Scope<'a> {
21 &self.scope
22 }
23
24 pub async fn activate(&self, board_id: &str, webhook_id: &str) -> Result<(), Error> {
28 let mut operation = self
29 .scope
30 .operation(&routes::ACTIVATE_WEBHOOK, &[&board_id, &webhook_id])?;
31 operation.resource_id(board_id);
32 self.scope.client().send_unit(operation).await
33 }
34
35 pub async fn create(
39 &self,
40 board_id: &str,
41 body: &CreateWebhookRequestContent,
42 ) -> Result<Webhook, Error> {
43 let mut operation = self
44 .scope
45 .operation(&routes::CREATE_WEBHOOK, &[&board_id])?;
46 operation.resource_id(board_id);
47 operation.json(body)?;
48 self.scope.client().send(operation).await
49 }
50
51 pub async fn delete(&self, board_id: &str, webhook_id: &str) -> Result<(), Error> {
55 let mut operation = self
56 .scope
57 .operation(&routes::DELETE_WEBHOOK, &[&board_id, &webhook_id])?;
58 operation.resource_id(webhook_id);
59 self.scope.client().send_unit(operation).await
60 }
61
62 pub async fn get(&self, board_id: &str, webhook_id: &str) -> Result<Webhook, Error> {
66 let mut operation = self
67 .scope
68 .operation(&routes::GET_WEBHOOK, &[&board_id, &webhook_id])?;
69 operation.resource_id(webhook_id);
70 self.scope.client().send(operation).await
71 }
72
73 pub async fn list(&self, board_id: &str) -> Result<Vec<Webhook>, Error> {
77 let mut operation = self.scope.operation(&routes::LIST_WEBHOOKS, &[&board_id])?;
78 operation.resource_id(board_id);
79 self.scope.client().send(operation).await
80 }
81
82 pub async fn list_webhook_deliveries(
88 &self,
89 board_id: &str,
90 webhook_id: &str,
91 ) -> Result<Page<Vec<WebhookDelivery>>, Error> {
92 let mut operation = self
93 .scope
94 .operation(&routes::LIST_WEBHOOK_DELIVERIES, &[&board_id, &webhook_id])?;
95 operation.resource_id(board_id);
96 self.scope.client().send_page(operation).await
97 }
98
99 pub async fn update(
103 &self,
104 board_id: &str,
105 webhook_id: &str,
106 body: &UpdateWebhookRequestContent,
107 ) -> Result<Webhook, Error> {
108 let mut operation = self
109 .scope
110 .operation(&routes::UPDATE_WEBHOOK, &[&board_id, &webhook_id])?;
111 operation.resource_id(webhook_id);
112 operation.json(body)?;
113 self.scope.client().send(operation).await
114 }
115}