export type GetApiWebhooksV2Args = {tokenAPI: string, cryptKey: string, type: string, uuid: string}; export type GetApiWebhooksV2Options = {baseUrl?: string | undefined, sec0?: string | undefined, sec1?: string | undefined, fetch?: typeof fetch | undefined}; /** * Listar Webhook de um cofre ou documento (Versão 2.0) * * GET /webhooks/v2/ */ export const getApiWebhooksV2 = async (args: GetApiWebhooksV2Args, options?: GetApiWebhooksV2Options) => { const {baseUrl = "https://sandbox.d4sign.com.br/api/v1", fetch: fetchFn = fetch, sec0, sec1} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.tokenAPI != null) query.append("tokenAPI", String(args.tokenAPI)) if (args.cryptKey != null) query.append("cryptKey", String(args.cryptKey)) if (args.type != null) query.append("type", String(args.type)) if (args.uuid != null) query.append("uuid", String(args.uuid)) if (sec0 !== undefined) query.set("tokenAPI", sec0) if (sec1 !== undefined) query.set("cryptKey", sec1) const url = `${baseUrl.replace(/\/+$/, '')}/webhooks/v2/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };