export type GetApiCustomfieldsItemClassArgs = {itemClass: 'accounts' | 'contacts' | 'opportunities', includeDisabled?: boolean | undefined, pipeline?: number | undefined, name?: string | undefined}; export type GetApiCustomfieldsItemClassOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List custom fields of a type * * GET /customfields/{itemClass} */ export const getApiCustomfieldsItemClass = async (args: GetApiCustomfieldsItemClassArgs, options?: GetApiCustomfieldsItemClassOptions) => { const {baseUrl = "https://api.salesflare.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.includeDisabled != null) query.append("includeDisabled", String(args.includeDisabled)) if (args.pipeline != null) query.append("pipeline", String(args.pipeline)) if (args.name != null) query.append("name", String(args.name)) const url = `${baseUrl.replace(/\/+$/, '')}/customfields/${encodeURIComponent(String(args.itemClass))}${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 res.blob() };