Skip to main content

apify_client/clients/
webhook_dispatch.rs

1//! Client for a single webhook dispatch (`/v2/webhook-dispatches/{dispatchId}`).
2
3use crate::clients::base::{get_resource, ResourceContext};
4use crate::common::QueryParams;
5use crate::error::ApifyClientResult;
6use crate::http_client::HttpClient;
7use crate::models::WebhookDispatch;
8
9/// Client for a specific webhook dispatch.
10#[derive(Debug, Clone)]
11pub struct WebhookDispatchClient {
12    ctx: ResourceContext,
13}
14
15impl WebhookDispatchClient {
16    pub(crate) fn new(http: HttpClient, base_url: &str, id: &str) -> Self {
17        Self {
18            ctx: ResourceContext::single(http, base_url, "webhook-dispatches", id),
19        }
20    }
21
22    /// Fetches the webhook dispatch, or `None` if it does not exist.
23    pub async fn get(&self) -> ApifyClientResult<Option<WebhookDispatch>> {
24        get_resource(&self.ctx, None, &QueryParams::new()).await
25    }
26}