Skip to main content

apify_client/clients/
webhook_dispatch_collection.rs

1//! Client for the webhook dispatch collection (`/v2/webhook-dispatches`).
2
3use crate::clients::base::{list_resource, ResourceContext};
4use crate::common::{ListOptions, PaginationList, QueryParams};
5use crate::error::ApifyClientResult;
6use crate::http_client::HttpClient;
7use crate::models::WebhookDispatch;
8
9/// Client for listing webhook dispatches.
10#[derive(Debug, Clone)]
11pub struct WebhookDispatchCollectionClient {
12    ctx: ResourceContext,
13}
14
15impl WebhookDispatchCollectionClient {
16    pub(crate) fn new(http: HttpClient, base_url: &str) -> Self {
17        Self {
18            ctx: ResourceContext::collection(http, base_url, "webhook-dispatches"),
19        }
20    }
21
22    /// Creates a dispatch collection client nested under a webhook.
23    pub(crate) fn with_base(http: HttpClient, base_url: &str, resource_path: &str) -> Self {
24        Self {
25            ctx: ResourceContext::collection(http, base_url, resource_path),
26        }
27    }
28
29    /// Lists webhook dispatches with offset/limit pagination.
30    pub async fn list(
31        &self,
32        options: ListOptions,
33    ) -> ApifyClientResult<PaginationList<WebhookDispatch>> {
34        let mut params = QueryParams::new();
35        params
36            .add_int("offset", options.offset)
37            .add_int("limit", options.limit)
38            .add_bool("desc", options.desc);
39        list_resource(&self.ctx, None, &params).await
40    }
41}