export type CreateApiV1BoardUserRolesJsonArgs = {token: string, body: {name?: string | undefined, description?: string | undefined}}; export type CreateApiV1BoardUserRolesJsonOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Add a board user roles * * POST /v1/board_user_roles.json */ export const createApiV1BoardUserRolesJson = async (args: CreateApiV1BoardUserRolesJsonArgs, options: CreateApiV1BoardUserRolesJsonOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.token != null) query.append("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/board_user_roles.json${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };