export type CreateApiFeedbackWebArgs = {body: {toggl_version: string, date: string, details: string, update_channel?: string | undefined, subject?: string | undefined, latest?: boolean | undefined, files?: string | undefined}}; export type CreateApiFeedbackWebOptions = {baseUrl: string, BasicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * FeedbackWeb * * POST /feedback/web */ export const createApiFeedbackWeb = async (args: CreateApiFeedbackWebArgs, options: CreateApiFeedbackWebOptions) => { const {baseUrl, fetch: fetchFn = fetch, BasicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") if (BasicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${BasicAuth.username}:${BasicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/feedback/web${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 undefined };