UNPKG

@azure/communication-call-automation

Version:
495 lines (494 loc) 15.7 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var callConnection_exports = {}; __export(callConnection_exports, { CallConnectionImpl: () => CallConnectionImpl }); module.exports = __toCommonJS(callConnection_exports); var import_pagingHelper = require("../pagingHelper.js"); var coreClient = __toESM(require("@azure/core-client")); var Mappers = __toESM(require("../models/mappers.js")); var Parameters = __toESM(require("../models/parameters.js")); class CallConnectionImpl { client; /** * Initialize a new instance of the class CallConnection class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Get participants from a call. Recording and transcription bots are omitted from this list. * @param callConnectionId The call connection Id * @param options The options parameters. */ listParticipants(callConnectionId, options) { const iter = this.getParticipantsPagingAll(callConnectionId, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.getParticipantsPagingPage( callConnectionId, options, settings ); } }; } async *getParticipantsPagingPage(callConnectionId, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._getParticipants(callConnectionId, options); let page = result.value || []; continuationToken = result.nextLink; (0, import_pagingHelper.setContinuationToken)(page, continuationToken); yield page; } while (continuationToken) { result = await this._getParticipantsNext( callConnectionId, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; (0, import_pagingHelper.setContinuationToken)(page, continuationToken); yield page; } } async *getParticipantsPagingAll(callConnectionId, options) { for await (const page of this.getParticipantsPagingPage( callConnectionId, options )) { yield* page; } } /** * Get the detail properties of an ongoing call. * @param callConnectionId The call connection id. * @param options The options parameters. */ getCall(callConnectionId, options) { return this.client.sendOperationRequest( { callConnectionId, options }, getCallOperationSpec ); } /** * Hang up call automation service from the call. This will make call automation service leave the * call, but does not terminate if there are more than 1 caller in the call. * @param callConnectionId The call connection id. * @param options The options parameters. */ hangupCall(callConnectionId, options) { return this.client.sendOperationRequest( { callConnectionId, options }, hangupCallOperationSpec ); } /** * Terminate a call using CallConnectionId. * @param callConnectionId The terminate call request. * @param options The options parameters. */ terminateCall(callConnectionId, options) { return this.client.sendOperationRequest( { callConnectionId, options }, terminateCallOperationSpec ); } /** * Transfer the call to a participant. * @param callConnectionId The call connection id. * @param transferToParticipantRequest The transfer to participant request. * @param options The options parameters. */ transferToParticipant(callConnectionId, transferToParticipantRequest, options) { return this.client.sendOperationRequest( { callConnectionId, transferToParticipantRequest, options }, transferToParticipantOperationSpec ); } /** * Get participants from a call. Recording and transcription bots are omitted from this list. * @param callConnectionId The call connection Id * @param options The options parameters. */ _getParticipants(callConnectionId, options) { return this.client.sendOperationRequest( { callConnectionId, options }, getParticipantsOperationSpec ); } /** * Add a participant to the call. * @param callConnectionId The call connection Id * @param addParticipantRequest The request payload for adding participant to the call. * @param options The options parameters. */ addParticipant(callConnectionId, addParticipantRequest, options) { return this.client.sendOperationRequest( { callConnectionId, addParticipantRequest, options }, addParticipantOperationSpec ); } /** * Remove a participant from the call using identifier. * @param callConnectionId The call connection id. * @param removeParticipantRequest The participant to be removed from the call. * @param options The options parameters. */ removeParticipant(callConnectionId, removeParticipantRequest, options) { return this.client.sendOperationRequest( { callConnectionId, removeParticipantRequest, options }, removeParticipantOperationSpec ); } /** * Mute participants from the call using identifier. * @param callConnectionId The call connection id. * @param muteParticipantsRequest The participants to be muted from the call. * @param options The options parameters. */ mute(callConnectionId, muteParticipantsRequest, options) { return this.client.sendOperationRequest( { callConnectionId, muteParticipantsRequest, options }, muteOperationSpec ); } /** * Cancel add participant operation. * @param callConnectionId The call connection Id * @param cancelAddParticipantRequest Cancellation request. * @param options The options parameters. */ cancelAddParticipant(callConnectionId, cancelAddParticipantRequest, options) { return this.client.sendOperationRequest( { callConnectionId, cancelAddParticipantRequest, options }, cancelAddParticipantOperationSpec ); } /** * Move a participant to the call. * @param callConnectionId The call connection Id * @param moveParticipantRequest The move participants request. * @param options The options parameters. */ moveParticipants(callConnectionId, moveParticipantRequest, options) { return this.client.sendOperationRequest( { callConnectionId, moveParticipantRequest, options }, moveParticipantsOperationSpec ); } /** * Get participant from a call. * @param callConnectionId The call connection Id * @param participantRawId Raw id of the participant to retrieve. * @param options The options parameters. */ getParticipant(callConnectionId, participantRawId, options) { return this.client.sendOperationRequest( { callConnectionId, participantRawId, options }, getParticipantOperationSpec ); } /** * GetParticipantsNext * @param callConnectionId The call connection Id * @param nextLink The nextLink from the previous successful call to the GetParticipants method. * @param options The options parameters. */ _getParticipantsNext(callConnectionId, nextLink, options) { return this.client.sendOperationRequest( { callConnectionId, nextLink, options }, getParticipantsNextOperationSpec ); } } const serializer = coreClient.createSerializer( Mappers, /* isXml */ false ); const getCallOperationSpec = { path: "/calling/callConnections/{callConnectionId}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CallConnectionPropertiesInternal }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [Parameters.accept], serializer }; const hangupCallOperationSpec = { path: "/calling/callConnections/{callConnectionId}", httpMethod: "DELETE", responses: { 204: {}, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [Parameters.accept], serializer }; const terminateCallOperationSpec = { path: "/calling/callConnections/{callConnectionId}:terminate", httpMethod: "POST", responses: { 204: {}, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent ], serializer }; const transferToParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}:transferToParticipant", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.TransferCallResponse }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, requestBody: Parameters.transferToParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent ], mediaType: "json", serializer }; const getParticipantsOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GetParticipantsResponse }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [Parameters.accept], serializer }; const addParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:add", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.AddParticipantResponse }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, requestBody: Parameters.addParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent ], mediaType: "json", serializer }; const removeParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:remove", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.RemoveParticipantResponse }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, requestBody: Parameters.removeParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent ], mediaType: "json", serializer }; const muteOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:mute", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.MuteParticipantsResult }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, requestBody: Parameters.muteParticipantsRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent ], mediaType: "json", serializer }; const cancelAddParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:cancelAddParticipant", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.CancelAddParticipantResponse }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, requestBody: Parameters.cancelAddParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent ], mediaType: "json", serializer }; const moveParticipantsOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:moveHere", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.MoveParticipantsResponse }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, requestBody: Parameters.moveParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent ], mediaType: "json", serializer }; const getParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants/{participantRawId}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CallParticipantInternal }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.endpoint, Parameters.callConnectionId, Parameters.participantRawId ], headerParameters: [Parameters.accept], serializer }; const getParticipantsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GetParticipantsResponse }, default: { bodyMapper: Mappers.CommunicationErrorResponse } }, urlParameters: [ Parameters.endpoint, Parameters.callConnectionId, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CallConnectionImpl }); //# sourceMappingURL=callConnection.js.map