/* * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ import * as msRest from "@azure/ms-rest-js"; import * as Models from "../models"; import * as Mappers from "../models/mailMappers"; import * as Parameters from "../models/parameters"; import { OutlookConnectorContext } from "../outlookConnectorContext"; /** Class representing a Mail. */ export class Mail { private readonly client: OutlookConnectorContext; /** * Create a Mail. * @param {OutlookConnectorContext} client Reference to the service client. */ constructor(client: OutlookConnectorContext) { this.client = client; } /** * This operation gets emails from a folder. * @summary Get emails * @param [options] The optional parameters * @deprecated This operation is deprecated. Please do not use it any longer. * @returns Promise */ getEmails(options?: Models.MailGetEmailsOptionalParams): Promise; /** * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ getEmails(callback: msRest.ServiceCallback): void; /** * @param options The optional parameters * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ getEmails(options: Models.MailGetEmailsOptionalParams, callback: msRest.ServiceCallback): void; getEmails(options?: Models.MailGetEmailsOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { options }, getEmailsOperationSpec, callback) as Promise; } /** * This operation sends an email message. * @summary Send an email * @param emailMessage Email. * @param [options] The optional parameters * @deprecated This operation is deprecated. Please do not use it any longer. * @returns Promise */ sendEmail(emailMessage: Models.ClientSendMessage, options?: msRest.RequestOptionsBase): Promise; /** * @param emailMessage Email. * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ sendEmail(emailMessage: Models.ClientSendMessage, callback: msRest.ServiceCallback): void; /** * @param emailMessage Email. * @param options The optional parameters * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ sendEmail(emailMessage: Models.ClientSendMessage, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; sendEmail(emailMessage: Models.ClientSendMessage, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { emailMessage, options }, sendEmailOperationSpec, callback); } /** * This operation flags an email. * @summary Flag email * @param messageId Id of the email to be flagged. * @param [options] The optional parameters * @returns Promise */ flag(messageId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param messageId Id of the email to be flagged. * @param callback The callback */ flag(messageId: string, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email to be flagged. * @param options The optional parameters * @param callback The callback */ flag(messageId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; flag(messageId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, options }, flagOperationSpec, callback); } /** * This operation marks an email as having been read. * @summary Mark as read * @param messageId Id of the email to be marked as read. * @param [options] The optional parameters * @returns Promise */ markAsRead(messageId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param messageId Id of the email to be marked as read. * @param callback The callback */ markAsRead(messageId: string, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email to be marked as read. * @param options The optional parameters * @param callback The callback */ markAsRead(messageId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; markAsRead(messageId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, options }, markAsReadOperationSpec, callback); } /** * This operation moves an email to the specified folder. * @summary Move email * @param messageId Id of the email to be moved. * @param folderPath Mail folder to move the email to. * @param [options] The optional parameters * @returns Promise */ move(messageId: string, folderPath: string, options?: msRest.RequestOptionsBase): Promise; /** * @param messageId Id of the email to be moved. * @param folderPath Mail folder to move the email to. * @param callback The callback */ move(messageId: string, folderPath: string, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email to be moved. * @param folderPath Mail folder to move the email to. * @param options The optional parameters * @param callback The callback */ move(messageId: string, folderPath: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; move(messageId: string, folderPath: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, folderPath, options }, moveOperationSpec, callback) as Promise; } /** * This operation replies to an email. * @summary Reply to email * @param messageId Id of the email to reply to. * @param comment Reply comment. * @param [options] The optional parameters * @deprecated This operation is deprecated. Please do not use it any longer. * @returns Promise */ replyTo(messageId: string, comment: string, options?: Models.MailReplyToOptionalParams): Promise; /** * @param messageId Id of the email to reply to. * @param comment Reply comment. * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ replyTo(messageId: string, comment: string, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email to reply to. * @param comment Reply comment. * @param options The optional parameters * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ replyTo(messageId: string, comment: string, options: Models.MailReplyToOptionalParams, callback: msRest.ServiceCallback): void; replyTo(messageId: string, comment: string, options?: Models.MailReplyToOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, comment, options }, replyToOperationSpec, callback); } /** * This operation deletes an email by id. * @summary Delete email * @param messageId Id of the email to delete. * @param [options] The optional parameters * @returns Promise */ deleteEmail(messageId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param messageId Id of the email to delete. * @param callback The callback */ deleteEmail(messageId: string, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email to delete. * @param options The optional parameters * @param callback The callback */ deleteEmail(messageId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; deleteEmail(messageId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, options }, deleteEmailOperationSpec, callback); } /** * This operation gets an email by id. * @summary Get email * @param messageId Id of the email. * @param [options] The optional parameters * @returns Promise */ getEmail(messageId: string, options?: Models.MailGetEmailOptionalParams): Promise; /** * @param messageId Id of the email. * @param callback The callback */ getEmail(messageId: string, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email. * @param options The optional parameters * @param callback The callback */ getEmail(messageId: string, options: Models.MailGetEmailOptionalParams, callback: msRest.ServiceCallback): void; getEmail(messageId: string, options?: Models.MailGetEmailOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, options }, getEmailOperationSpec, callback) as Promise; } /** * This operation gets an email attachment by id. * @summary Get attachment * @param messageId Id of the email. * @param attachmentId Id of the attachment to download. * @param [options] The optional parameters * @returns Promise */ getAttachment(messageId: string, attachmentId: string, options?: msRest.RequestOptionsBase): Promise; /** * @param messageId Id of the email. * @param attachmentId Id of the attachment to download. * @param callback The callback */ getAttachment(messageId: string, attachmentId: string, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email. * @param attachmentId Id of the attachment to download. * @param options The optional parameters * @param callback The callback */ getAttachment(messageId: string, attachmentId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; getAttachment(messageId: string, attachmentId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, attachmentId, options }, getAttachmentOperationSpec, callback) as Promise; } /** * This operation gets emails from a folder. * @summary Get emails (V2) * @param [options] The optional parameters * @returns Promise */ getEmailsV2(options?: Models.MailGetEmailsV2OptionalParams): Promise; /** * @param callback The callback */ getEmailsV2(callback: msRest.ServiceCallback): void; /** * @param options The optional parameters * @param callback The callback */ getEmailsV2(options: Models.MailGetEmailsV2OptionalParams, callback: msRest.ServiceCallback): void; getEmailsV2(options?: Models.MailGetEmailsV2OptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { options }, getEmailsV2OperationSpec, callback) as Promise; } /** * This operation sends an email message. * @summary Send an email (V2) * @param emailMessage Email. * @param [options] The optional parameters * @returns Promise */ sendEmailV2(emailMessage: Models.ClientSendHtmlMessage, options?: msRest.RequestOptionsBase): Promise; /** * @param emailMessage Email. * @param callback The callback */ sendEmailV2(emailMessage: Models.ClientSendHtmlMessage, callback: msRest.ServiceCallback): void; /** * @param emailMessage Email. * @param options The optional parameters * @param callback The callback */ sendEmailV2(emailMessage: Models.ClientSendHtmlMessage, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; sendEmailV2(emailMessage: Models.ClientSendHtmlMessage, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { emailMessage, options }, sendEmailV2OperationSpec, callback); } /** * This operation replies to an email. * @summary Reply to email (V2) * @param messageId Id of the email to reply to. * @param replyParameters Details of the email reply. * @param [options] The optional parameters * @deprecated This operation is deprecated. Please do not use it any longer. * @returns Promise */ replyToV2(messageId: string, replyParameters: Models.ReplyMessage, options?: msRest.RequestOptionsBase): Promise; /** * @param messageId Id of the email to reply to. * @param replyParameters Details of the email reply. * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ replyToV2(messageId: string, replyParameters: Models.ReplyMessage, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email to reply to. * @param replyParameters Details of the email reply. * @param options The optional parameters * @param callback The callback * @deprecated This operation is deprecated. Please do not use it any longer. */ replyToV2(messageId: string, replyParameters: Models.ReplyMessage, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; replyToV2(messageId: string, replyParameters: Models.ReplyMessage, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, replyParameters, options }, replyToV2OperationSpec, callback); } /** * This operation replies to an email. * @summary Reply to email (V3) * @param messageId Id of the email to reply to. * @param replyParameters Details of the email reply. * @param [options] The optional parameters * @returns Promise */ replyToV3(messageId: string, replyParameters: Models.ReplyHtmlMessage, options?: msRest.RequestOptionsBase): Promise; /** * @param messageId Id of the email to reply to. * @param replyParameters Details of the email reply. * @param callback The callback */ replyToV3(messageId: string, replyParameters: Models.ReplyHtmlMessage, callback: msRest.ServiceCallback): void; /** * @param messageId Id of the email to reply to. * @param replyParameters Details of the email reply. * @param options The optional parameters * @param callback The callback */ replyToV3(messageId: string, replyParameters: Models.ReplyHtmlMessage, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; replyToV3(messageId: string, replyParameters: Models.ReplyHtmlMessage, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { messageId, replyParameters, options }, replyToV3OperationSpec, callback); } } // Operation Specifications const serializer = new msRest.Serializer(Mappers); const getEmailsOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "apim/outlook/{connectionId}/Mail", urlParameters: [ Parameters.connectionId ], queryParameters: [ Parameters.folderPath0, Parameters.fetchOnlyUnread, Parameters.includeAttachments, Parameters.searchQuery, Parameters.top0, Parameters.skip0 ], responses: { 200: { bodyMapper: { serializedName: "parsedResponse", type: { name: "Sequence", element: { type: { name: "Composite", className: "ClientReceiveMessageStringEnums" } } } } }, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const sendEmailOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/Mail", urlParameters: [ Parameters.connectionId ], requestBody: { parameterPath: "emailMessage", mapper: { ...Mappers.ClientSendMessage, required: true } }, responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const flagOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/Mail/Flag/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const markAsReadOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/Mail/MarkAsRead/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const moveOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/Mail/Move/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], queryParameters: [ Parameters.folderPath1 ], responses: { 200: { bodyMapper: Mappers.ClientReceiveMessageStringEnums }, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const replyToOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/Mail/ReplyTo/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], queryParameters: [ Parameters.comment, Parameters.replyAll ], responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const deleteEmailOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "apim/outlook/{connectionId}/Mail/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const getEmailOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "apim/outlook/{connectionId}/Mail/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], queryParameters: [ Parameters.includeAttachments ], responses: { 200: { bodyMapper: Mappers.ClientReceiveMessage }, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const getAttachmentOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "apim/outlook/{connectionId}/Mail/{messageId}/Attachments/{attachmentId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0, Parameters.attachmentId ], responses: { 200: { bodyMapper: { serializedName: "parsedResponse", type: { name: "String" } } }, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const getEmailsV2OperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "apim/outlook/{connectionId}/v2/Mail", urlParameters: [ Parameters.connectionId ], queryParameters: [ Parameters.folderPath0, Parameters.to, Parameters.cc, Parameters.toOrCc, Parameters.from, Parameters.importance, Parameters.fetchOnlyWithAttachment, Parameters.subjectFilter, Parameters.fetchOnlyUnread, Parameters.fetchOnlyFlagged, Parameters.mailboxAddress, Parameters.includeAttachments, Parameters.searchQuery, Parameters.top0 ], responses: { 200: { bodyMapper: Mappers.BatchResponseClientReceiveMessage }, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const sendEmailV2OperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/v2/Mail", urlParameters: [ Parameters.connectionId ], requestBody: { parameterPath: "emailMessage", mapper: { ...Mappers.ClientSendHtmlMessage, required: true } }, responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const replyToV2OperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/v2/Mail/ReplyTo/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], requestBody: { parameterPath: "replyParameters", mapper: { ...Mappers.ReplyMessage, required: true } }, responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer }; const replyToV3OperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apim/outlook/{connectionId}/v3/Mail/ReplyTo/{messageId}", urlParameters: [ Parameters.connectionId, Parameters.messageId0 ], requestBody: { parameterPath: "replyParameters", mapper: { ...Mappers.ReplyHtmlMessage, required: true } }, responses: { 200: {}, 400: {}, 401: {}, 403: {}, 500: {}, default: {} }, serializer };