export type GetApiTemplateTemplateIdOrVersionIdArgs = {'templateId-or-versionId': string, 'carbone-version': '5' | '4' | '3' | 'staging'}; export type GetApiTemplateTemplateIdOrVersionIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a template or a specific version. * * GET /template/{templateId-or-versionId} */ export const getApiTemplateTemplateIdOrVersionId = async (args: GetApiTemplateTemplateIdOrVersionIdArgs, options?: GetApiTemplateTemplateIdOrVersionIdOptions) => { const {baseUrl = "https://api.carbone.io", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['carbone-version'] != null) headers.set("carbone-version", String(args['carbone-version'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/template/${encodeURIComponent(String(args['templateId-or-versionId']))}${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 };