export type GetApiAnalyticAccountTemplatesArgs = {template_name?: string | undefined, id?: number | undefined, module_type: string, filters?: Record | undefined, 'sort[asc]'?: ('id' | 'template_name' | 'module_type') | undefined, 'sort[desc]'?: ('id' | 'name') | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiAnalyticAccountTemplatesOptions = {baseUrl?: string | undefined, passport?: string | undefined, fetch?: typeof fetch | undefined}; /** * List all analytic accounts templates * * GET /analytic-account-templates */ export const getApiAnalyticAccountTemplates = async (args: GetApiAnalyticAccountTemplatesArgs, options?: GetApiAnalyticAccountTemplatesOptions) => { const {baseUrl = "http://localhost/app4legal/api/v2/money", fetch: fetchFn = fetch, passport} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.template_name != null) query.append("template_name", String(args.template_name)) if (args.id != null) query.append("id", String(args.id)) if (args.module_type != null) query.append("module_type", String(args.module_type)) if (args.filters != null) query.append("filters", JSON.stringify(args.filters)) if (args['sort[asc]'] != null) query.append("sort[asc]", String(args['sort[asc]'])) if (args['sort[desc]'] != null) query.append("sort[desc]", String(args['sort[desc]'])) if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (passport !== undefined) headers.set('authorization', `Bearer ${passport}`) const url = `${baseUrl.replace(/\/+$/, '')}/analytic-account-templates${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 };