export type GetApiCatalogAttributesArgs = {page?: number | undefined, per_page?: number | undefined, id?: string | undefined, code?: string | undefined, type?: ('text' | 'textarea' | 'price' | 'boolean' | 'select' | 'multiselect' | 'datetime' | 'date' | 'image' | 'file' | 'checkbox') | undefined, admin_name?: string | undefined, is_required?: (0 | 1) | undefined, is_unique?: (0 | 1) | undefined, is_filterable?: (0 | 1) | undefined, is_configurable?: (0 | 1) | undefined, is_visible_on_front?: (0 | 1) | undefined, is_user_defined?: (0 | 1) | undefined, value_per_locale?: (0 | 1) | undefined, value_per_channel?: (0 | 1) | undefined, locale?: string | undefined, sort?: ('id' | 'code' | 'admin_name' | 'type' | 'position') | undefined, order?: ('asc' | 'desc') | undefined}; export type GetApiCatalogAttributesOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List attributes (datagrid parity) * * GET /catalog/attributes */ export const getApiCatalogAttributes = async (args: GetApiCatalogAttributesArgs, options?: GetApiCatalogAttributesOptions) => { const {baseUrl = "http://localhost:8000/api/admin", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (args.id != null) query.append("id", String(args.id)) if (args.code != null) query.append("code", String(args.code)) if (args.type != null) query.append("type", String(args.type)) if (args.admin_name != null) query.append("admin_name", String(args.admin_name)) if (args.is_required != null) query.append("is_required", String(args.is_required)) if (args.is_unique != null) query.append("is_unique", String(args.is_unique)) if (args.is_filterable != null) query.append("is_filterable", String(args.is_filterable)) if (args.is_configurable != null) query.append("is_configurable", String(args.is_configurable)) if (args.is_visible_on_front != null) query.append("is_visible_on_front", String(args.is_visible_on_front)) if (args.is_user_defined != null) query.append("is_user_defined", String(args.is_user_defined)) if (args.value_per_locale != null) query.append("value_per_locale", String(args.value_per_locale)) if (args.value_per_channel != null) query.append("value_per_channel", String(args.value_per_channel)) if (args.locale != null) query.append("locale", String(args.locale)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.order != null) query.append("order", String(args.order)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/catalog/attributes${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 };