@azure/communication-chat
Version:
Azure client library for Azure Communication Chat services
191 lines • 6.42 kB
JavaScript
;
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatImpl = void 0;
const tslib_1 = require("tslib");
const tracing_js_1 = require("../tracing.js");
const coreClient = tslib_1.__importStar(require("@azure/core-client"));
const Mappers = tslib_1.__importStar(require("../models/mappers.js"));
const Parameters = tslib_1.__importStar(require("../models/parameters.js"));
/** Class containing Chat operations. */
class ChatImpl {
/**
* Initialize a new instance of the class Chat class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Creates a chat thread.
* @param createChatThreadRequest Request payload for creating a chat thread.
* @param options The options parameters.
*/
async createChatThread(createChatThreadRequest, options) {
return tracing_js_1.tracingClient.withSpan("ChatApiClient.createChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ createChatThreadRequest, options }, createChatThreadOperationSpec);
});
}
/**
* Gets the list of chat threads of a user.
* @param options The options parameters.
*/
async listChatThreads(options) {
return tracing_js_1.tracingClient.withSpan("ChatApiClient.listChatThreads", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ options }, listChatThreadsOperationSpec);
});
}
/**
* Deletes a thread.
* @param chatThreadId Id of the thread to be deleted.
* @param options The options parameters.
*/
async deleteChatThread(chatThreadId, options) {
return tracing_js_1.tracingClient.withSpan("ChatApiClient.deleteChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, deleteChatThreadOperationSpec);
});
}
/**
* ListChatThreadsNext
* @param nextLink The nextLink from the previous successful call to the ListChatThreads method.
* @param options The options parameters.
*/
async listChatThreadsNext(nextLink, options) {
return tracing_js_1.tracingClient.withSpan("ChatApiClient.listChatThreadsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ nextLink, options }, listChatThreadsNextOperationSpec);
});
}
}
exports.ChatImpl = ChatImpl;
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const createChatThreadOperationSpec = {
path: "/chat/threads",
httpMethod: "POST",
responses: {
201: {
bodyMapper: Mappers.CreateChatThreadResult,
},
401: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
403: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
429: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
503: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
},
requestBody: Parameters.createChatThreadRequest,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint],
headerParameters: [
Parameters.accept,
Parameters.contentType,
Parameters.repeatabilityRequestId,
],
mediaType: "json",
serializer,
};
const listChatThreadsOperationSpec = {
path: "/chat/threads",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatThreadsItemCollection,
},
401: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
403: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
429: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
503: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
},
queryParameters: [
Parameters.maxPageSize,
Parameters.apiVersion,
Parameters.startTime,
],
urlParameters: [Parameters.endpoint],
headerParameters: [Parameters.accept],
serializer,
};
const deleteChatThreadOperationSpec = {
path: "/chat/threads/{chatThreadId}",
httpMethod: "DELETE",
responses: {
204: {},
401: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
403: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
429: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
503: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
},
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept],
serializer,
};
const listChatThreadsNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatThreadsItemCollection,
},
401: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
403: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
429: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
503: {
bodyMapper: Mappers.CommunicationErrorResponse,
isError: true,
},
},
urlParameters: [Parameters.endpoint, Parameters.nextLink],
headerParameters: [Parameters.accept],
serializer,
};
//# sourceMappingURL=chat.js.map