export type ListOfGS1s = {codes?: Array | undefined}; export type ImportGS1CodesRequest = {listOfGS1s: ListOfGS1s, organizationId: string}; export type CreateApiApiV1ImportGs1Args = {body: ImportGS1CodesRequest}; export type CreateApiApiV1ImportGs1Options = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Import GS1/MAPP codes * * POST /api/v1/import/gs1 */ export const createApiApiV1ImportGs1 = async (args: CreateApiApiV1ImportGs1Args, options: CreateApiApiV1ImportGs1Options) => { const {baseUrl, fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/import/gs1${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };