export type PatchApiV20AnalyticsArgs = {Accept?: ('application/json' | 'application/hal+json' | 'application/xml' | 'text/xml' | 'text/csv') | undefined, body: {contactId?: string | undefined, projectId?: string | undefined, sessionId?: string | undefined, inputId?: string | undefined, properties?: ({state?: string | undefined, mode?: string | undefined, userType?: string | undefined, channel?: string | undefined, flowLanguage?: string | undefined, intent?: string | undefined, intentScore?: number | undefined, intentFlow?: string | undefined, flowName?: string | undefined, inHandoverRequest?: boolean | undefined, inHandoverConversation?: boolean | undefined, localeName?: string | undefined, rating?: number | undefined, ratingComment?: string | undefined, entrypointType?: string | undefined, trackedGoals?: Array | undefined, endpointName?: string | undefined, endpointUrlToken?: string | undefined, handoverEscalations?: number | undefined, snapshotName?: string | undefined, slots?: Record | undefined, custom1?: string | undefined, custom2?: string | undefined, custom3?: string | undefined, custom4?: string | undefined, custom5?: string | undefined, custom6?: string | undefined, custom7?: string | undefined, custom8?: string | undefined, custom9?: string | undefined, custom10?: string | undefined}) | undefined}}; export type PatchApiV20AnalyticsOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update an Analytics Record * * PATCH /v2.0/analytics * * Also accepts auth: APIKeyQueryParam, CXoneTokenHeader, OAuth2 */ export const patchApiV20Analytics = async (args: PatchApiV20AnalyticsArgs, options?: PatchApiV20AnalyticsOptions) => { const {baseUrl = "https://api-trial.cognigy.ai/testing", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (APIKeyHeader !== undefined) headers.set("X-API-Key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v2.0/analytics${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };