export type PatchApiCatalogServicesServiceIdArgs = {service_id: string, body: {category_id?: number | undefined, title?: string | undefined, description?: string | undefined, type?: ('labor' | 'service') | undefined, uom_id?: number | undefined, cost?: string | undefined, prices?: Array<{id: number, price: string}> | undefined, duration?: number | undefined, warranty?: ({period: number, unit: 'days' | 'months'}) | undefined, barcodes?: (Array<{type: 'ean8' | 'ean13' | 'qrcode' | 'code128', code: string}>) | undefined}}; export type PatchApiCatalogServicesServiceIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Service * * PATCH /catalog/services/{service_id} */ export const patchApiCatalogServicesServiceId = async (args: PatchApiCatalogServicesServiceIdArgs, options?: PatchApiCatalogServicesServiceIdOptions) => { 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/services/${encodeURIComponent(String(args.service_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };