export type CreateApiV1PublicEventsImportFileArgs = {dryRun: boolean, includeImportEvents: boolean, format: string}; export type CreateApiV1PublicEventsImportFileOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Create or update events (shifts) through a CSV file * * POST /v1/public/events/import-file */ export const createApiV1PublicEventsImportFile = async (args: CreateApiV1PublicEventsImportFileArgs, options?: CreateApiV1PublicEventsImportFileOptions) => { const {baseUrl = "https://api.evolia.com", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.dryRun != null) query.append("dryRun", String(args.dryRun)) if (args.includeImportEvents != null) query.append("includeImportEvents", String(args.includeImportEvents)) if (args.format != null) query.append("format", String(args.format)) if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/public/events/import-file${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 };