export type GetApiTelephonyCallsArgs = {page?: number | undefined, direction?: ('incoming' | 'outgoing') | undefined, extension_ids?: Array | undefined, status?: ('completed' | 'noanswer' | 'missed') | undefined, sentiment?: ('positive' | 'neutral' | 'negative') | undefined, insight?: ('booking_not_confirmed' | 'follow_up_required' | 'friendly_service' | 'good_value' | 'information_only' | 'long_wait_time' | 'loyalty_acknowledged' | 'miscommunication' | 'needs_quote_or_estimate' | 'not_in_stock' | 'policy_disagreement' | 'poor_service' | 'potential_sale' | 'pricing_disagreement' | 'quality_issue' | 'quality_satisfaction' | 'quick_resolution' | 'repeat_problem' | 'unresolved_issue' | 'went_above_and_beyond') | undefined, contact_id?: number | undefined, phone_number?: number | undefined, created_at?: Array | undefined, sort?: ('id' | '-id') | undefined}; export type GetApiTelephonyCallsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Calls * * GET /telephony/calls */ export const getApiTelephonyCalls = async (args: GetApiTelephonyCallsArgs, options?: GetApiTelephonyCallsOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.direction != null) query.append("direction", String(args.direction)) for (const item of args.extension_ids ?? []) query.append("extension_ids", String(item)) if (args.status != null) query.append("status", String(args.status)) if (args.sentiment != null) query.append("sentiment", String(args.sentiment)) if (args.insight != null) query.append("insight", String(args.insight)) if (args.contact_id != null) query.append("contact_id", String(args.contact_id)) if (args.phone_number != null) query.append("phone_number", String(args.phone_number)) for (const item of args.created_at ?? []) query.append("created_at", String(item)) if (args.sort != null) query.append("sort", String(args.sort)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/telephony/calls${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 };