export type CreateApiCatalogProductsArgs = {body: {product_type_id: number, category_id: number, title: string, description?: string | undefined, sku?: string | undefined, code?: string | undefined, mpn?: string | undefined, uom_id: number, barcodes?: (Array<{type: 'ean8' | 'ean13' | 'qrcode' | 'code128' | 'upc', code: string}>) | undefined, prices?: Array<{id: number, price: string}> | undefined, dimensions_and_weight?: ({is_enabled: boolean, dimensions: {length: string, width: string, height: string, unit: 'mm' | 'cm' | 'in'}, weight: {value: string, unit: 'g' | 'kg' | 'lb'}}) | undefined, expiration_tracking?: ({is_enabled: boolean, expiration_soon_alert: {is_enabled: boolean, value: string, unit: 'days' | 'months'}, critical_alert: {is_enabled: boolean, value: string, unit: 'days' | 'months'}}) | undefined, default_supplier_id?: number | undefined, warranty?: ({period: number, unit: 'days' | 'months'}) | undefined, is_serial?: boolean | undefined}}; export type CreateApiCatalogProductsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Product * * POST /catalog/products */ export const createApiCatalogProducts = async (args: CreateApiCatalogProductsArgs, options?: CreateApiCatalogProductsOptions) => { 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/products${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 };