export type GetApiAssetsBrandsArgs = {page?: number | undefined, branch_ids?: Array | undefined, group_id?: number | undefined, sort?: ('id' | '-id' | 'name' | '-name') | undefined}; export type GetApiAssetsBrandsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Brands * * GET /assets/brands */ export const getApiAssetsBrands = async (args: GetApiAssetsBrandsArgs, options?: GetApiAssetsBrandsOptions) => { 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)) for (const item of args.branch_ids ?? []) query.append("branch_ids", String(item)) if (args.group_id != null) query.append("group_id", String(args.group_id)) if (args.sort != null) query.append("sort", String(args.sort)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/assets/brands${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 };