export type CreateApiApiV0BoardProfessionalsArgs = {emails?: Array | undefined, secret_key?: string | undefined, body: Record}; export type CreateApiApiV0BoardProfessionalsOptions = {baseUrl?: string | undefined, BoardSecretKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Whitelist board professionals * * POST /api/v0/board/professionals */ export const createApiApiV0BoardProfessionals = async (args: CreateApiApiV0BoardProfessionalsArgs, options?: CreateApiApiV0BoardProfessionalsOptions) => { const {baseUrl = "https://www.getonbrd.com", fetch: fetchFn = fetch, BoardSecretKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") headers.set('accept', "text/html") for (const item of args.emails ?? []) query.append("emails", String(item)) if (args.secret_key != null) query.append("secret_key", String(args.secret_key)) if (BoardSecretKey !== undefined) headers.set('authorization', `Bearer ${BoardSecretKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v0/board/professionals${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };