export type ProductCategory = {id?: number | undefined, parent_id?: number | undefined, name?: string | undefined, is_active?: boolean | undefined, created_at?: number | undefined, updated_at?: number | undefined, child_categories?: Array | undefined}; export type MeasurementUnit = {id?: number | undefined, name?: string | undefined, abbr?: string | undefined, is_default?: boolean | undefined}; export type Tax = {id?: number | undefined, name?: string | undefined, rate?: number | undefined, is_active?: boolean | undefined}; export type ProductPrice = {id?: number | undefined, price?: number | undefined, currency?: string | undefined, is_default?: boolean | undefined, tax?: Tax | undefined}; export type Files = Array; export type Product = {id?: number | undefined, product_category_id?: number | undefined, measurement_unit_id?: number | undefined, title?: string | undefined, article?: string | undefined, type?: ('goods' | 'service') | undefined, is_active?: boolean | undefined, availability?: ('available' | 'not_available' | 'pending') | undefined, quantity?: number | undefined, reserved_quantity?: number | undefined, description?: string | undefined, comment?: string | undefined, link?: string | undefined, created_at?: number | undefined, updated_at?: number | undefined, product_category?: ProductCategory | undefined, measurement_unit?: MeasurementUnit | undefined, prices?: Array | undefined, files?: Files | undefined}; export type CreateApiCrmV1StaticProductsBulkArgs = {body: Array}; export type CreateApiCrmV1StaticProductsBulkOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Bulk create products * * POST /crm/v1/static/products/bulk */ export const createApiCrmV1StaticProductsBulk = async (args: CreateApiCrmV1StaticProductsBulkArgs, options: CreateApiCrmV1StaticProductsBulkOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/crm/v1/static/products/bulk${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 };