export type GetApiApiV2WidgetsFinancialRiskArgs = {companyId: number, widgetWidth?: (number | null) | undefined}; export type GetApiApiV2WidgetsFinancialRiskOptions = {baseUrl?: string | undefined, OAuthv2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the financial risk widget. * * GET /api/v2/widgets/financial-risk */ export const getApiApiV2WidgetsFinancialRisk = async (args: GetApiApiV2WidgetsFinancialRiskArgs, options?: GetApiApiV2WidgetsFinancialRiskOptions) => { const {baseUrl = "https://app.blackkitetech.com", fetch: fetchFn = fetch, OAuthv2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.companyId != null) query.append("companyId", String(args.companyId)) if (args.widgetWidth != null) query.append("widgetWidth", String(args.widgetWidth)) if (OAuthv2 !== undefined) headers.set('authorization', `Bearer ${OAuthv2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/widgets/financial-risk${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };