export type CallDisposition = 'answered' | 'noanswer' | 'busy' | 'failed' | 'all'; export type GetApiV1CdrsAllArgs = {from: string, to: string, type: string, disposition?: CallDisposition | undefined, from_search?: string | undefined, to_search?: string | undefined, sip_trunk?: string | undefined, uuid?: string | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiV1CdrsAllOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export CDRs * * GET /v1/cdrs/all */ export const getApiV1CdrsAll = async (args: GetApiV1CdrsAllArgs, options?: GetApiV1CdrsAllOptions) => { const {baseUrl = "https://api.wavix.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-ndjson") if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.type != null) query.append("type", String(args.type)) if (args.disposition != null) query.append("disposition", String(args.disposition)) if (args.from_search != null) query.append("from_search", String(args.from_search)) if (args.to_search != null) query.append("to_search", String(args.to_search)) if (args.sip_trunk != null) query.append("sip_trunk", String(args.sip_trunk)) if (args.uuid != null) query.append("uuid", String(args.uuid)) if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/cdrs/all${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 res.blob() };