@azure/communication-chat
Version:
Azure client library for Azure Communication Chat services
695 lines • 24.8 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.
*/
import { tracingClient } from "../tracing.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
/** Class containing ChatThread operations. */
export class ChatThreadImpl {
/**
* Initialize a new instance of the class ChatThread class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Gets chat message read receipts for a thread.
* @param chatThreadId Thread id to get the chat message read receipts for.
* @param options The options parameters.
*/
async listChatReadReceipts(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.listChatReadReceipts", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, listChatReadReceiptsOperationSpec);
});
}
/**
* Sends a read receipt event to a thread, on behalf of a user.
* @param chatThreadId Thread id to send the read receipt event to.
* @param sendReadReceiptRequest Read receipt details.
* @param options The options parameters.
*/
async sendChatReadReceipt(chatThreadId, sendReadReceiptRequest, options) {
return tracingClient.withSpan("ChatApiClient.sendChatReadReceipt", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, sendReadReceiptRequest, options }, sendChatReadReceiptOperationSpec);
});
}
/**
* Sends a message to a thread.
* @param chatThreadId The thread id to send the message to.
* @param sendChatMessageRequest Details of the message to send.
* @param options The options parameters.
*/
async sendChatMessage(chatThreadId, sendChatMessageRequest, options) {
return tracingClient.withSpan("ChatApiClient.sendChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, sendChatMessageRequest, options }, sendChatMessageOperationSpec);
});
}
/**
* Gets a list of messages from a thread.
* @param chatThreadId The thread id of the message.
* @param options The options parameters.
*/
async listChatMessages(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.listChatMessages", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, listChatMessagesOperationSpec);
});
}
/**
* Gets a message by id.
* @param chatThreadId The thread id to which the message was sent.
* @param chatMessageId The message id.
* @param options The options parameters.
*/
async getChatMessage(chatThreadId, chatMessageId, options) {
return tracingClient.withSpan("ChatApiClient.getChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, getChatMessageOperationSpec);
});
}
/**
* Updates a message.
* @param chatThreadId The thread id to which the message was sent.
* @param chatMessageId The message id.
* @param updateChatMessageRequest Details of the request to update the message.
* @param options The options parameters.
*/
async updateChatMessage(chatThreadId, chatMessageId, updateChatMessageRequest, options) {
return tracingClient.withSpan("ChatApiClient.updateChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, updateChatMessageRequest, options }, updateChatMessageOperationSpec);
});
}
/**
* Deletes a message.
* @param chatThreadId The thread id to which the message was sent.
* @param chatMessageId The message id.
* @param options The options parameters.
*/
async deleteChatMessage(chatThreadId, chatMessageId, options) {
return tracingClient.withSpan("ChatApiClient.deleteChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, deleteChatMessageOperationSpec);
});
}
/**
* Gets the participants of a thread.
* @param chatThreadId Thread id to get participants for.
* @param options The options parameters.
*/
async listChatParticipants(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.listChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, listChatParticipantsOperationSpec);
});
}
/**
* Remove a participant from a thread.
* @param chatThreadId Thread id to remove the participant from.
* @param participantCommunicationIdentifier Id of the thread participant to remove from the thread.
* @param options The options parameters.
*/
async removeChatParticipant(chatThreadId, participantCommunicationIdentifier, options) {
return tracingClient.withSpan("ChatApiClient.removeChatParticipant", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, participantCommunicationIdentifier, options }, removeChatParticipantOperationSpec);
});
}
/**
* Adds thread participants to a thread. If participants already exist, no change occurs.
* @param chatThreadId Id of the thread to add participants to.
* @param addChatParticipantsRequest Thread participants to be added to the thread.
* @param options The options parameters.
*/
async addChatParticipants(chatThreadId, addChatParticipantsRequest, options) {
return tracingClient.withSpan("ChatApiClient.addChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, addChatParticipantsRequest, options }, addChatParticipantsOperationSpec);
});
}
/**
* Updates a thread's properties.
* @param chatThreadId The id of the thread to update.
* @param updateChatThreadRequest Request payload for updating a chat thread.
* @param options The options parameters.
*/
async updateChatThreadProperties(chatThreadId, updateChatThreadRequest, options) {
return tracingClient.withSpan("ChatApiClient.updateChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, updateChatThreadRequest, options }, updateChatThreadPropertiesOperationSpec);
});
}
/**
* Gets a chat thread's properties.
* @param chatThreadId Id of the thread.
* @param options The options parameters.
*/
async getChatThreadProperties(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.getChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, getChatThreadPropertiesOperationSpec);
});
}
/**
* Posts a typing event to a thread, on behalf of a user.
* @param chatThreadId Id of the thread.
* @param options The options parameters.
*/
async sendTypingNotification(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.sendTypingNotification", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, sendTypingNotificationOperationSpec);
});
}
/**
* ListChatReadReceiptsNext
* @param chatThreadId Thread id to get the chat message read receipts for.
* @param nextLink The nextLink from the previous successful call to the ListChatReadReceipts method.
* @param options The options parameters.
*/
async listChatReadReceiptsNext(chatThreadId, nextLink, options) {
return tracingClient.withSpan("ChatApiClient.listChatReadReceiptsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatReadReceiptsNextOperationSpec);
});
}
/**
* ListChatMessagesNext
* @param chatThreadId The thread id of the message.
* @param nextLink The nextLink from the previous successful call to the ListChatMessages method.
* @param options The options parameters.
*/
async listChatMessagesNext(chatThreadId, nextLink, options) {
return tracingClient.withSpan("ChatApiClient.listChatMessagesNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatMessagesNextOperationSpec);
});
}
/**
* ListChatParticipantsNext
* @param chatThreadId Thread id to get participants for.
* @param nextLink The nextLink from the previous successful call to the ListChatParticipants method.
* @param options The options parameters.
*/
async listChatParticipantsNext(chatThreadId, nextLink, options) {
return tracingClient.withSpan("ChatApiClient.listChatParticipantsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatParticipantsNextOperationSpec);
});
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listChatReadReceiptsOperationSpec = {
path: "/chat/threads/{chatThreadId}/readReceipts",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatMessageReadReceiptsCollection,
},
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.skip,
Parameters.apiVersion,
],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept],
serializer,
};
const sendChatReadReceiptOperationSpec = {
path: "/chat/threads/{chatThreadId}/readReceipts",
httpMethod: "POST",
responses: {
200: {},
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.sendReadReceiptRequest,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer,
};
const sendChatMessageOperationSpec = {
path: "/chat/threads/{chatThreadId}/messages",
httpMethod: "POST",
responses: {
201: {
bodyMapper: Mappers.SendChatMessageResult,
},
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.sendChatMessageRequest,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer,
};
const listChatMessagesOperationSpec = {
path: "/chat/threads/{chatThreadId}/messages",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatMessagesCollection,
},
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, Parameters.chatThreadId],
headerParameters: [Parameters.accept],
serializer,
};
const getChatMessageOperationSpec = {
path: "/chat/threads/{chatThreadId}/messages/{chatMessageId}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatMessage,
},
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,
Parameters.chatMessageId,
],
headerParameters: [Parameters.accept],
serializer,
};
const updateChatMessageOperationSpec = {
path: "/chat/threads/{chatThreadId}/messages/{chatMessageId}",
httpMethod: "PATCH",
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,
},
},
requestBody: Parameters.updateChatMessageRequest,
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.endpoint,
Parameters.chatThreadId,
Parameters.chatMessageId,
],
headerParameters: [Parameters.accept, Parameters.contentType1],
mediaType: "json",
serializer,
};
const deleteChatMessageOperationSpec = {
path: "/chat/threads/{chatThreadId}/messages/{chatMessageId}",
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,
Parameters.chatMessageId,
],
headerParameters: [Parameters.accept],
serializer,
};
const listChatParticipantsOperationSpec = {
path: "/chat/threads/{chatThreadId}/participants",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatParticipantsCollection,
},
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.skip,
Parameters.apiVersion,
],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept],
serializer,
};
const removeChatParticipantOperationSpec = {
path: "/chat/threads/{chatThreadId}/participants/:remove",
httpMethod: "POST",
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,
},
},
requestBody: Parameters.participantCommunicationIdentifier,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer,
};
const addChatParticipantsOperationSpec = {
path: "/chat/threads/{chatThreadId}/participants/:add",
httpMethod: "POST",
responses: {
201: {
bodyMapper: Mappers.AddChatParticipantsResult,
},
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.addChatParticipantsRequest,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer,
};
const updateChatThreadPropertiesOperationSpec = {
path: "/chat/threads/{chatThreadId}",
httpMethod: "PATCH",
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,
},
},
requestBody: Parameters.updateChatThreadRequest,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept, Parameters.contentType1],
mediaType: "json",
serializer,
};
const getChatThreadPropertiesOperationSpec = {
path: "/chat/threads/{chatThreadId}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatThreadProperties,
},
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 sendTypingNotificationOperationSpec = {
path: "/chat/threads/{chatThreadId}/typing",
httpMethod: "POST",
responses: {
200: {},
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.sendTypingNotificationRequest,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.chatThreadId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer,
};
const listChatReadReceiptsNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatMessageReadReceiptsCollection,
},
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.chatThreadId,
Parameters.nextLink,
],
headerParameters: [Parameters.accept],
serializer,
};
const listChatMessagesNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatMessagesCollection,
},
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.chatThreadId,
Parameters.nextLink,
],
headerParameters: [Parameters.accept],
serializer,
};
const listChatParticipantsNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ChatParticipantsCollection,
},
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.chatThreadId,
Parameters.nextLink,
],
headerParameters: [Parameters.accept],
serializer,
};
//# sourceMappingURL=chatThread.js.map