export type CreateApiV1BoardsBoardIdCustomBackgroundsJsonArgs = {token: string, boardId: number}; export type CreateApiV1BoardsBoardIdCustomBackgroundsJsonOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Upload custom background to board * * POST /v1/boards/{boardId}/custom_backgrounds.json */ export const createApiV1BoardsBoardIdCustomBackgroundsJson = async (args: CreateApiV1BoardsBoardIdCustomBackgroundsJsonArgs, options: CreateApiV1BoardsBoardIdCustomBackgroundsJsonOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.token != null) query.append("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/boards/${encodeURIComponent(String(args.boardId))}/custom_backgrounds.json${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 };