export type CreateApiWebhookSubscriptionsIdPingArgs = {Accept: string, id: string}; export type CreateApiWebhookSubscriptionsIdPingOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Test a webhook subscription * * POST /webhook_subscriptions/{id}/ping */ export const createApiWebhookSubscriptionsIdPing = async (args: CreateApiWebhookSubscriptionsIdPingArgs, options?: CreateApiWebhookSubscriptionsIdPingOptions) => { const {baseUrl = "https://api.pagerduty.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/webhook_subscriptions/${encodeURIComponent(String(args.id))}/ping${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };