export type CreateApiV1StoragesDropboxWebhookArgs = {'X-Dropbox-Signature': string}; export type CreateApiV1StoragesDropboxWebhookOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Receive a Dropbox change notification * * POST /v1/storages/dropbox/webhook/ */ export const createApiV1StoragesDropboxWebhook = async (args: CreateApiV1StoragesDropboxWebhookArgs, options: CreateApiV1StoragesDropboxWebhookOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-Dropbox-Signature'] != null) headers.set("X-Dropbox-Signature", String(args['X-Dropbox-Signature'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/storages/dropbox/webhook/${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 };