export type ProductsType = 'ITEM' | 'BUNDLE'; export type FormatTypes = 'csv' | 'jsonl'; export type CreateApiCatalogConnectorTemplatesActionsGenerateArgs = {'x-fabric-tenant-id': string, 'x-fabric-request-id'?: string | undefined, body: {type: ProductsType, formatType: FormatTypes}}; export type CreateApiCatalogConnectorTemplatesActionsGenerateOptions = {baseUrl?: string | undefined, authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve an import template * * POST /catalog-connector-templates/actions/generate */ export const createApiCatalogConnectorTemplatesActionsGenerate = async (args: CreateApiCatalogConnectorTemplatesActionsGenerateArgs, options?: CreateApiCatalogConnectorTemplatesActionsGenerateOptions) => { const {baseUrl = "https://api.fabric.inc/v3", fetch: fetchFn = fetch, authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/csv") if (args['x-fabric-tenant-id'] != null) headers.set("x-fabric-tenant-id", String(args['x-fabric-tenant-id'])) if (args['x-fabric-request-id'] != null) headers.set("x-fabric-request-id", String(args['x-fabric-request-id'])) if (authorization !== undefined) headers.set('authorization', `Bearer ${authorization}`) const url = `${baseUrl.replace(/\/+$/, '')}/catalog-connector-templates/actions/generate${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };