export type GetApiSettingsLocalesArgs = {page?: number | undefined, per_page?: number | undefined, id?: string | undefined, code?: string | undefined, name?: string | undefined, direction?: ('ltr' | 'rtl') | undefined, sort?: ('id' | 'code' | 'name') | undefined, order?: ('asc' | 'desc') | undefined}; export type GetApiSettingsLocalesOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List locales * * GET /settings/locales */ export const getApiSettingsLocales = async (args: GetApiSettingsLocalesArgs, options?: GetApiSettingsLocalesOptions) => { 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.name != null) query.append("name", String(args.name)) if (args.direction != null) query.append("direction", String(args.direction)) 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(/\/+$/, '')}/settings/locales${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 };