export type CreateApiCatalogBundlesArgs = {body: {title: string, description?: string | undefined, category_id: number, barcode?: ({type: 'ean8' | 'ean13' | 'qrcode' | 'code128' | 'upc', code: string}) | undefined}}; export type CreateApiCatalogBundlesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Bundle * * POST /catalog/bundles */ export const createApiCatalogBundles = async (args: CreateApiCatalogBundlesArgs, options?: CreateApiCatalogBundlesOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/catalog/bundles${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 };