export type GetApiV1InventoryStockMovementArgs = {center_id: string, start_date: string, end_date: string, report_type?: ('1' | '2' | '3') | undefined, product_code?: string | undefined}; export type GetApiV1InventoryStockMovementOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve the consumption details of products for a center * * GET /v1/inventory/stock_movement */ export const getApiV1InventoryStockMovement = async (args: GetApiV1InventoryStockMovementArgs, options?: GetApiV1InventoryStockMovementOptions) => { const {baseUrl = "https://api.zenoti.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.center_id != null) query.append("center_id", String(args.center_id)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (args.report_type != null) query.append("report_type", String(args.report_type)) if (args.product_code != null) query.append("product_code", String(args.product_code)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/inventory/stock_movement${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };