UNPKG

sinch-rtc

Version:

RTC JavaScript/Web SDK

79 lines (78 loc) 4.64 kB
import { Configuration, HTTPHeaders, RequestContext, ResponseContext } from "./api"; import { CreateInstanceOperationRequest, GetConfigRequest, GetIceServersRequest, InitiateCallRequest, CreateCallReportRequest, DeletePushProfileRequest, UpdatePushProfileRequest, SendPushNotificationRequest, UpdateInstanceOperationRequest, UpdateInstanceTtlOperationRequest, GetFeatureFlagsRequest } from "./api/apis"; import { CallInitiationResponse, Config, IceServersResponse, Instance, CreateInstanceResponse, UpdateInstanceTtlResponse } from "./api/models"; import { Authentication } from "./auth"; import { InstanceAuthentication } from "./auth/InstanceAuthentication"; import { CorrelationContext } from "./requestHeaders/CorrelationContext"; export interface ApiClient { initiateCall(request: InitiateCallRequest): Promise<CallInitiationResponse>; getConfig(request: GetConfigRequest): Promise<Config>; getIceServers(request: GetIceServersRequest): Promise<IceServersResponse>; createInstance(authentication: Authentication, request: CreateInstanceOperationRequest): Promise<CreateInstanceResponse>; updateInstance(requestParameters: UpdateInstanceOperationRequest): Promise<Instance>; updateInstanceTtl(authentication: Authentication, request: UpdateInstanceTtlOperationRequest): Promise<UpdateInstanceTtlResponse>; createCallReport(request: CreateCallReportRequest): Promise<void>; deletePushProfile(requestParameters: DeletePushProfileRequest): Promise<void>; updatePushProfile(request: UpdatePushProfileRequest): Promise<void>; sendPushNotification(request: SendPushNotificationRequest): Promise<void>; setInstanceAuthentication(authentication: InstanceAuthentication, onAuthenticationRequired: () => Promise<InstanceAuthentication>): void; getFeatureFlags(request: GetFeatureFlagsRequest): Promise<{ [key: string]: boolean | number; }>; setUpdateInstanceTtlWindow(updateTtlWindowDays: number | undefined): void; } export declare class InvalidInstanceAuthenticationError extends Error { error: any; constructor(error: any); get code(): number; } export declare class OcraClient implements ApiClient { private static readonly GENERAL_ERROR_MESSAGE; private static readonly EXPIRED_AUTH_MESSAGE; private static readonly HEADER_CONTENT_TYPE; private static readonly HEADER_VALUE_JSON_CONTENT_TYPE; private static readonly INVALID_INSTANCE_AUTHENTICATION_ERROR_CODE; private instanceApi; private callApi; private configApi; private iceApi; private callReportApi; private pushApi; private instanceAuthentication?; private onAuthenticationRequired?; private featureFlagsApi; private clientId; private updateTtlWindowDays; constructor(configuration: Configuration); getRequestHeaders: (correlationContext: CorrelationContext) => HTTPHeaders; getDefaultCorrelationContext(): CorrelationContext; deletePushProfile(request: DeletePushProfileRequest): Promise<void>; updatePushProfile(request: UpdatePushProfileRequest): Promise<void>; sendPushNotification(request: SendPushNotificationRequest): Promise<void>; initiateCall(request: InitiateCallRequest): Promise<CallInitiationResponse>; getConfig(request: GetConfigRequest): Promise<Config>; getIceServers(request: GetIceServersRequest): Promise<IceServersResponse>; getFeatureFlags(request: GetFeatureFlagsRequest): Promise<{ [key: string]: boolean | number; }>; createInstance(authentication: Authentication, request: CreateInstanceOperationRequest): Promise<CreateInstanceResponse>; createCallReport(request: CreateCallReportRequest): Promise<void>; updateInstance(request: UpdateInstanceOperationRequest): Promise<Instance>; updateInstanceTtl(authentication: Authentication, request: UpdateInstanceTtlOperationRequest): Promise<UpdateInstanceTtlResponse>; setInstanceAuthentication(authentication: InstanceAuthentication, onAuthenticationRequired: () => Promise<InstanceAuthentication>): void; setUpdateInstanceTtlWindow(updateTtlWindowDays: number | undefined): void; private get authentication(); pre(_: RequestContext): Promise<void>; post(context: ResponseContext): Promise<void>; private validateInstanceTtl; private processOcraApiErrors; private getSinchErrorFromJson; private updateRequestInstance; private isAuthenticationInvalid; private newInstanceAuthenticationRequired; private hasAuthenticationExpired; private makeRequest; } export declare class ApiClientFactory { static create(configuration: Configuration): OcraClient; }