export type GetApiV1BotsBotIdTemplatesArgs = {botId: string, query?: string | undefined, status?: ('PENDING' | 'REJECTED' | 'APPROVED') | undefined, category?: ('UTILITY' | 'MARKETING' | 'AUTHENTICATION') | undefined}; export type GetApiV1BotsBotIdTemplatesOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Obtener Plantillas * * GET /v1/bots/{botId}/templates */ export const getApiV1BotsBotIdTemplates = async (args: GetApiV1BotsBotIdTemplatesArgs, options?: GetApiV1BotsBotIdTemplatesOptions) => { const {baseUrl = "https://api.jelou.ai", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.query != null) query.append("query", String(args.query)) if (args.status != null) query.append("status", String(args.status)) if (args.category != null) query.append("category", String(args.category)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/bots/${encodeURIComponent(String(args.botId))}/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 };