export type ReportScope = 1 | 2 | 3 | 4; export type CreateReportRequest = {scope?: ReportScope | undefined, userId?: (number | null) | undefined, userProfileId?: (number | null) | undefined, accountId?: (number | null) | undefined, reportId?: (string | null) | undefined, payload?: (string | null) | undefined}; export type CreateApiV1ReportsArgs = {Account: unknown, body: CreateReportRequest}; export type CreateApiV1ReportsOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Saves (upserts) user defined custom report state * * POST /v1/Reports */ export const createApiV1Reports = async (args: CreateApiV1ReportsArgs, options: CreateApiV1ReportsOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json-patch+json; x-api-version=1.0") if (args.Account != null) query.append("Account", String(args.Account)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/Reports${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 };