export type CreateApiImportfileSXSXCategorySlotIdArgs = {truncate?: string | undefined, body: BodyInit}; export type CreateApiImportfileSXSXCategorySlotIdOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Import a File * * POST /importfile/SX/{SXCategory}/{slotId} * * Also accepts auth: X-PriceFx-jwt */ export const createApiImportfileSXSXCategorySlotId = async (args: CreateApiImportfileSXSXCategorySlotIdArgs, options?: CreateApiImportfileSXSXCategorySlotIdOptions) => { const {baseUrl = "https://companynode.pricefx.com/pricefx/companypartition", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.truncate != null) query.append("truncate", String(args.truncate)) if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/importfile/SX/${encodeURIComponent(String(args.SXCategory))}/${encodeURIComponent(String(args.slotId))}${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 undefined };