export type GetApiV1StoragesDropboxWebhookArgs = {challenge: string}; export type GetApiV1StoragesDropboxWebhookOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Echo the Dropbox webhook verification challenge * * GET /v1/storages/dropbox/webhook/ */ export const getApiV1StoragesDropboxWebhook = async (args: GetApiV1StoragesDropboxWebhookArgs, options: GetApiV1StoragesDropboxWebhookOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.challenge != null) query.append("challenge", String(args.challenge)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/storages/dropbox/webhook/${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 };