export type GetApiInventoryWarehousesWarehouseIdBinsArgs = {warehouse_id: number, page?: number | undefined, is_default?: boolean | undefined, sort?: ('id' | '-id' | 'name' | '-name') | undefined}; export type GetApiInventoryWarehousesWarehouseIdBinsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Warehouse Bins * * GET /inventory/warehouses/{warehouse_id}/bins */ export const getApiInventoryWarehousesWarehouseIdBins = async (args: GetApiInventoryWarehousesWarehouseIdBinsArgs, options?: GetApiInventoryWarehousesWarehouseIdBinsOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.is_default != null) query.append("is_default", String(args.is_default)) if (args.sort != null) query.append("sort", String(args.sort)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/inventory/warehouses/${encodeURIComponent(String(args.warehouse_id))}/bins${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 undefined };