Skip to main content

fizzy_sdk/generated/services/
webhooks.rs

1// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9/// The `Webhooks` operations.
10pub 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    /// The client and account these operations send through.
20    pub fn scope(&self) -> &Scope<'a> {
21        &self.scope
22    }
23
24    /// `ActivateWebhook` — `POST /{accountId}/boards/{boardId}/webhooks/{webhookId}/activation.json`.
25    ///
26    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
27    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    /// `CreateWebhook` — `POST /{accountId}/boards/{boardId}/webhooks.json`.
36    ///
37    /// Sent once and never resent.
38    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    /// `DeleteWebhook` — `DELETE /{accountId}/boards/{boardId}/webhooks/{webhookId}`.
52    ///
53    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
54    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    /// `GetWebhook` — `GET /{accountId}/boards/{boardId}/webhooks/{webhookId}`.
63    ///
64    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
65    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    /// `ListWebhooks` — `GET /{accountId}/boards/{boardId}/webhooks.json`.
74    ///
75    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
76    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    /// `ListWebhookDeliveries` — `GET /{accountId}/boards/{boardId}/webhooks/{webhookId}/deliveries.json`.
83    ///
84    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
85    ///
86    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
87    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    /// `UpdateWebhook` — `PATCH /{accountId}/boards/{boardId}/webhooks/{webhookId}`.
100    ///
101    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
102    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}