export type BagSubstitutionRuleCsvProcessorParams = {startDate: string, endDate: string}; export type CreateApiBagSubstitutionRulesUploadArgs = {params: BagSubstitutionRuleCsvProcessorParams, body: BodyInit}; export type CreateApiBagSubstitutionRulesUploadOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /bag-substitution-rules/upload */ export const createApiBagSubstitutionRulesUpload = async (args: CreateApiBagSubstitutionRulesUploadArgs, options: CreateApiBagSubstitutionRulesUploadOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.params != null) query.append("params", JSON.stringify(args.params)) const url = `${baseUrl.replace(/\/+$/, '')}/bag-substitution-rules/upload${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };