export type GetApiQuickRepliesArgs = {accessTo?: string | undefined, searchTerm?: string | undefined, lastQuickReplyDate?: string | undefined}; export type GetApiQuickRepliesOptions = {baseUrl?: string | undefined, basic?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Quick Replies * * GET /quick-replies */ export const getApiQuickReplies = async (args: GetApiQuickRepliesArgs, options?: GetApiQuickRepliesOptions) => { const {baseUrl = "https://public.doubletick.io", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.accessTo != null) query.append("accessTo", String(args.accessTo)) if (args.searchTerm != null) query.append("searchTerm", String(args.searchTerm)) if (args.lastQuickReplyDate != null) query.append("lastQuickReplyDate", String(args.lastQuickReplyDate)) if (basic !== undefined) headers.set("Authorization", basic) const url = `${baseUrl.replace(/\/+$/, '')}/quick-replies${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 };