export type CallDirectionType = 0 | 1; export type CallSourceType = 0 | 1 | 2 | 3 | 4; export type CallDestinationType = 0 | 1 | 2 | 3 | 4; export type CallStatus = 0 | 1 | 2; export type DepartmentPageSelection = Record; export type ViewType = 0 | 1; export type GetApiV1CallcenterCalllogsDownloadArgs = {Id?: number | undefined, DepartmentId?: number | undefined, CallerName?: string | undefined, CallerNumber?: string | undefined, CalledName?: string | undefined, CalledNumber?: string | undefined, Dtmf?: string | undefined, Notes?: string | undefined, CallDirection?: CallDirectionType | undefined, RecordStatus?: number | undefined, SourceType?: CallSourceType | undefined, SourceId?: number | undefined, DestinationType?: CallDestinationType | undefined, DestinationId?: number | undefined, FromDate?: string | undefined, ToDate?: string | undefined, EventType?: CallStatus | undefined, HasRecording?: boolean | undefined, TagIds?: string | undefined, MinUserRatingScore?: number | undefined, MaxUserRatingScore?: number | undefined, MinCsatRate?: number | undefined, MaxCsatRate?: number | undefined, SipServerId?: number | undefined, DepartmentScope?: DepartmentPageSelection | undefined, ViewType?: ViewType | undefined, Page?: number | undefined, ItemsPerPage?: number | undefined, ReturnTotalItems?: boolean | undefined}; export type GetApiV1CallcenterCalllogsDownloadOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/callcenter/calllogs/download * * Also accepts auth: API Key */ export const getApiV1CallcenterCalllogsDownload = async (args: GetApiV1CallcenterCalllogsDownloadArgs, options: GetApiV1CallcenterCalllogsDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Id != null) query.append("Id", String(args.Id)) if (args.DepartmentId != null) query.append("DepartmentId", String(args.DepartmentId)) if (args.CallerName != null) query.append("CallerName", String(args.CallerName)) if (args.CallerNumber != null) query.append("CallerNumber", String(args.CallerNumber)) if (args.CalledName != null) query.append("CalledName", String(args.CalledName)) if (args.CalledNumber != null) query.append("CalledNumber", String(args.CalledNumber)) if (args.Dtmf != null) query.append("Dtmf", String(args.Dtmf)) if (args.Notes != null) query.append("Notes", String(args.Notes)) if (args.CallDirection != null) query.append("CallDirection", String(args.CallDirection)) if (args.RecordStatus != null) query.append("RecordStatus", String(args.RecordStatus)) if (args.SourceType != null) query.append("SourceType", String(args.SourceType)) if (args.SourceId != null) query.append("SourceId", String(args.SourceId)) if (args.DestinationType != null) query.append("DestinationType", String(args.DestinationType)) if (args.DestinationId != null) query.append("DestinationId", String(args.DestinationId)) if (args.FromDate != null) query.append("FromDate", String(args.FromDate)) if (args.ToDate != null) query.append("ToDate", String(args.ToDate)) if (args.EventType != null) query.append("EventType", String(args.EventType)) if (args.HasRecording != null) query.append("HasRecording", String(args.HasRecording)) if (args.TagIds != null) query.append("TagIds", String(args.TagIds)) if (args.MinUserRatingScore != null) query.append("MinUserRatingScore", String(args.MinUserRatingScore)) if (args.MaxUserRatingScore != null) query.append("MaxUserRatingScore", String(args.MaxUserRatingScore)) if (args.MinCsatRate != null) query.append("MinCsatRate", String(args.MinCsatRate)) if (args.MaxCsatRate != null) query.append("MaxCsatRate", String(args.MaxCsatRate)) if (args.SipServerId != null) query.append("SipServerId", String(args.SipServerId)) if (args.DepartmentScope != null) query.append("DepartmentScope", JSON.stringify(args.DepartmentScope)) if (args.ViewType != null) query.append("ViewType", String(args.ViewType)) if (args.Page != null) query.append("Page", String(args.Page)) if (args.ItemsPerPage != null) query.append("ItemsPerPage", String(args.ItemsPerPage)) if (args.ReturnTotalItems != null) query.append("ReturnTotalItems", String(args.ReturnTotalItems)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/callcenter/calllogs/download${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 };