export type GetApiAnalyticsBotIdArgs = {bot_id: string, lang: string, platform?: ('messenger' | 'RCS' | 'skype' | 'sms' | 'slack' | 'telegram' | 'twitter' | 'viber' | 'webchat' | 'whatsapp' | 'maxit' | 'application' | 'api' | 'other') | undefined, next_page_token?: string | undefined, start_date: string, end_date: string}; export type GetApiAnalyticsBotIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get analytics * * GET /analytics/{bot_id} */ export const getApiAnalyticsBotId = async (args: GetApiAnalyticsBotIdArgs, options?: GetApiAnalyticsBotIdOptions) => { const {baseUrl = "https://apis.smartly.ai", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.lang != null) query.append("lang", String(args.lang)) if (args.platform != null) query.append("platform", String(args.platform)) if (args.next_page_token != null) query.append("next_page_token", String(args.next_page_token)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/analytics/${encodeURIComponent(String(args.bot_id))}${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 };