UNPKG

mailslurp-client

Version:

Official client for MailSlurp Email and SMS API. Create email addresses and phone numbers in Javascript without a mail server. Send and receive real emails in applications or tests.

1,595 lines (1,393 loc) 110 kB
/* tslint:disable */ /* eslint-disable */ /** * MailSlurp API * MailSlurp is an API for sending and receiving emails and SMS from dynamically allocated email addresses and phone numbers. It\'s designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository * * The version of the OpenAPI document: 6.5.2 * Contact: contact@mailslurp.dev * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import { AttachmentMetaData, AttachmentMetaDataFromJSON, AttachmentMetaDataToJSON, CanSendEmailResults, CanSendEmailResultsFromJSON, CanSendEmailResultsToJSON, CheckEmailBodyFeatureSupportResults, CheckEmailBodyFeatureSupportResultsFromJSON, CheckEmailBodyFeatureSupportResultsToJSON, CheckEmailBodyResults, CheckEmailBodyResultsFromJSON, CheckEmailBodyResultsToJSON, CheckEmailClientSupportOptions, CheckEmailClientSupportOptionsFromJSON, CheckEmailClientSupportOptionsToJSON, CheckEmailClientSupportResults, CheckEmailClientSupportResultsFromJSON, CheckEmailClientSupportResultsToJSON, ContentMatchOptions, ContentMatchOptionsFromJSON, ContentMatchOptionsToJSON, CountDto, CountDtoFromJSON, CountDtoToJSON, DownloadAttachmentDto, DownloadAttachmentDtoFromJSON, DownloadAttachmentDtoToJSON, Email, EmailFromJSON, EmailToJSON, EmailContentMatchResult, EmailContentMatchResultFromJSON, EmailContentMatchResultToJSON, EmailContentPartResult, EmailContentPartResultFromJSON, EmailContentPartResultToJSON, EmailHtmlDto, EmailHtmlDtoFromJSON, EmailHtmlDtoToJSON, EmailLinksResult, EmailLinksResultFromJSON, EmailLinksResultToJSON, EmailPreview, EmailPreviewFromJSON, EmailPreviewToJSON, EmailPreviewUrls, EmailPreviewUrlsFromJSON, EmailPreviewUrlsToJSON, EmailScreenshotResult, EmailScreenshotResultFromJSON, EmailScreenshotResultToJSON, EmailTextLinesResult, EmailTextLinesResultFromJSON, EmailTextLinesResultToJSON, EmailThreadDto, EmailThreadDtoFromJSON, EmailThreadDtoToJSON, EmailThreadItemsDto, EmailThreadItemsDtoFromJSON, EmailThreadItemsDtoToJSON, ForwardEmailOptions, ForwardEmailOptionsFromJSON, ForwardEmailOptionsToJSON, GetEmailScreenshotOptions, GetEmailScreenshotOptionsFromJSON, GetEmailScreenshotOptionsToJSON, GravatarUrl, GravatarUrlFromJSON, GravatarUrlToJSON, ImapFlagOperationOptions, ImapFlagOperationOptionsFromJSON, ImapFlagOperationOptionsToJSON, PageEmailProjection, PageEmailProjectionFromJSON, PageEmailProjectionToJSON, PageEmailThreadProjection, PageEmailThreadProjectionFromJSON, PageEmailThreadProjectionToJSON, RawEmailJson, RawEmailJsonFromJSON, RawEmailJsonToJSON, ReplyToEmailOptions, ReplyToEmailOptionsFromJSON, ReplyToEmailOptionsToJSON, SearchEmailsOptions, SearchEmailsOptionsFromJSON, SearchEmailsOptionsToJSON, SendEmailOptions, SendEmailOptionsFromJSON, SendEmailOptionsToJSON, SentEmailDto, SentEmailDtoFromJSON, SentEmailDtoToJSON, UnreadCount, UnreadCountFromJSON, UnreadCountToJSON, ValidationDto, ValidationDtoFromJSON, ValidationDtoToJSON, } from '../models'; export interface ApplyImapFlagOperationRequest { emailId: string; imapFlagOperationOptions: ImapFlagOperationOptions; } export interface CanSendRequest { inboxId: string; sendEmailOptions: SendEmailOptions; } export interface CheckEmailBodyRequest { emailId: string; } export interface CheckEmailBodyFeatureSupportRequest { emailId: string; } export interface CheckEmailClientSupportRequest { checkEmailClientSupportOptions: CheckEmailClientSupportOptions; } export interface DeleteEmailRequest { emailId: string; } export interface DownloadAttachmentRequest { emailId: string; attachmentId: string; apiKey?: string; } export interface DownloadAttachmentBase64Request { emailId: string; attachmentId: string; } export interface DownloadBodyRequest { emailId: string; } export interface DownloadBodyBytesRequest { emailId: string; } export interface ForwardEmailRequest { emailId: string; forwardEmailOptions: ForwardEmailOptions; } export interface GetAttachmentMetaDataRequest { emailId: string; attachmentId: string; } export interface GetEmailRequest { emailId: string; } export interface GetEmailAttachmentsRequest { emailId: string; } export interface GetEmailContentMatchRequest { emailId: string; contentMatchOptions: ContentMatchOptions; } export interface GetEmailContentPartRequest { emailId: string; contentType: string; strict?: boolean; index?: number; } export interface GetEmailContentPartContentRequest { emailId: string; contentType: string; strict?: boolean; index?: number; } export interface GetEmailCountRequest { inboxId?: string; } export interface GetEmailHTMLRequest { emailId: string; replaceCidImages?: boolean; } export interface GetEmailHTMLJsonRequest { emailId: string; replaceCidImages?: boolean; } export interface GetEmailHTMLQueryRequest { emailId: string; htmlSelector: string; } export interface GetEmailLinksRequest { emailId: string; selector?: string; } export interface GetEmailPreviewURLsRequest { emailId: string; } export interface GetEmailScreenshotAsBase64Request { emailId: string; getEmailScreenshotOptions: GetEmailScreenshotOptions; } export interface GetEmailScreenshotAsBinaryRequest { emailId: string; getEmailScreenshotOptions: GetEmailScreenshotOptions; } export interface GetEmailSummaryRequest { emailId: string; decode?: boolean; } export interface GetEmailTextLinesRequest { emailId: string; decodeHtmlEntities?: boolean; lineSeparator?: string; } export interface GetEmailThreadRequest { threadId: string; } export interface GetEmailThreadItemsRequest { threadId: string; sort?: GetEmailThreadItemsSortEnum; } export interface GetEmailThreadsRequest { htmlSelector?: string; page?: number; size?: number; sort?: GetEmailThreadsSortEnum; searchFilter?: string; since?: Date; before?: Date; } export interface GetEmailsOffsetPaginatedRequest { inboxId?: Array<string>; page?: number; size?: number; sort?: GetEmailsOffsetPaginatedSortEnum; unreadOnly?: boolean; searchFilter?: string; since?: Date; before?: Date; favourited?: boolean; syncConnectors?: boolean; plusAddressId?: string; } export interface GetEmailsPaginatedRequest { inboxId?: Array<string>; page?: number; size?: number; sort?: GetEmailsPaginatedSortEnum; unreadOnly?: boolean; searchFilter?: string; since?: Date; before?: Date; syncConnectors?: boolean; plusAddressId?: string; favourited?: boolean; } export interface GetGravatarUrlForEmailAddressRequest { emailAddress: string; size?: string; } export interface GetLatestEmailRequest { inboxIds?: Array<string>; } export interface GetLatestEmailInInbox1Request { inboxId: string; } export interface GetOrganizationEmailsPaginatedRequest { inboxId?: Array<string>; page?: number; size?: number; sort?: GetOrganizationEmailsPaginatedSortEnum; unreadOnly?: boolean; searchFilter?: string; since?: Date; before?: Date; syncConnectors?: boolean; favourited?: boolean; plusAddressId?: string; } export interface GetRawEmailContentsRequest { emailId: string; } export interface GetRawEmailJsonRequest { emailId: string; } export interface GetUnreadEmailCountRequest { inboxId?: string; } export interface MarkAllAsReadRequest { read?: boolean; inboxId?: string; } export interface MarkAsReadRequest { emailId: string; read?: boolean; } export interface ReplyToEmailRequest { emailId: string; replyToEmailOptions: ReplyToEmailOptions; } export interface SearchEmailsRequest { searchEmailsOptions: SearchEmailsOptions; syncConnectors?: boolean; favourited?: boolean; plusAddressId?: string; } export interface SendEmailSourceOptionalRequest { sendEmailOptions: SendEmailOptions; inboxId?: string; useDomainPool?: boolean; virtualSend?: boolean; } export interface SetEmailFavouritedRequest { emailId: string; favourited: boolean; } export interface ValidateEmailRequest { emailId: string; } /** * */ export class EmailControllerApi extends runtime.BaseAPI { /** * Apply RFC3501 section-2.3.2 IMAP flag operations on an email * Set IMAP flags associated with a message. Only supports \'\\Seen\' flag. */ async applyImapFlagOperationRaw( requestParameters: ApplyImapFlagOperationRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<EmailPreview>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling applyImapFlagOperation.' ); } if ( requestParameters.imapFlagOperationOptions === null || requestParameters.imapFlagOperationOptions === undefined ) { throw new runtime.RequiredError( 'imapFlagOperationOptions', 'Required parameter requestParameters.imapFlagOperationOptions was null or undefined when calling applyImapFlagOperation.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/imap-flag-operation`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, body: ImapFlagOperationOptionsToJSON( requestParameters.imapFlagOperationOptions ), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailPreviewFromJSON(jsonValue) ); } /** * Apply RFC3501 section-2.3.2 IMAP flag operations on an email * Set IMAP flags associated with a message. Only supports \'\\Seen\' flag. */ async applyImapFlagOperation( requestParameters: ApplyImapFlagOperationRequest, initOverrides?: RequestInit ): Promise<EmailPreview> { const response = await this.applyImapFlagOperationRaw( requestParameters, initOverrides ); return await response.value(); } /** * Can user send email to given recipient or is the recipient blocked * Check if email can be sent and options are valid. */ async canSendRaw( requestParameters: CanSendRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<CanSendEmailResults>> { if ( requestParameters.inboxId === null || requestParameters.inboxId === undefined ) { throw new runtime.RequiredError( 'inboxId', 'Required parameter requestParameters.inboxId was null or undefined when calling canSend.' ); } if ( requestParameters.sendEmailOptions === null || requestParameters.sendEmailOptions === undefined ) { throw new runtime.RequiredError( 'sendEmailOptions', 'Required parameter requestParameters.sendEmailOptions was null or undefined when calling canSend.' ); } const queryParameters: any = {}; if (requestParameters.inboxId !== undefined) { queryParameters['inboxId'] = requestParameters.inboxId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/can-send`, method: 'POST', headers: headerParameters, query: queryParameters, body: SendEmailOptionsToJSON(requestParameters.sendEmailOptions), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => CanSendEmailResultsFromJSON(jsonValue) ); } /** * Can user send email to given recipient or is the recipient blocked * Check if email can be sent and options are valid. */ async canSend( requestParameters: CanSendRequest, initOverrides?: RequestInit ): Promise<CanSendEmailResults> { const response = await this.canSendRaw(requestParameters, initOverrides); return await response.value(); } /** * Find dead links, broken images, and spelling mistakes in email body. Will call included links via HTTP so do not invoke if your links are sensitive or stateful. Any resource that returns a 4xx or 5xx response or is not reachable via HEAD or GET HTTP operations will be considered unhealthy. * Detect broken links, spelling, and images in email content */ async checkEmailBodyRaw( requestParameters: CheckEmailBodyRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<CheckEmailBodyResults>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling checkEmailBody.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/check-email-body`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => CheckEmailBodyResultsFromJSON(jsonValue) ); } /** * Find dead links, broken images, and spelling mistakes in email body. Will call included links via HTTP so do not invoke if your links are sensitive or stateful. Any resource that returns a 4xx or 5xx response or is not reachable via HEAD or GET HTTP operations will be considered unhealthy. * Detect broken links, spelling, and images in email content */ async checkEmailBody( requestParameters: CheckEmailBodyRequest, initOverrides?: RequestInit ): Promise<CheckEmailBodyResults> { const response = await this.checkEmailBodyRaw( requestParameters, initOverrides ); return await response.value(); } /** * Detect HTML and CSS features inside an email body and return a report of email client support across different platforms and versions. * Show which mail clients support the HTML and CSS features used in an email body. */ async checkEmailBodyFeatureSupportRaw( requestParameters: CheckEmailBodyFeatureSupportRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<CheckEmailBodyFeatureSupportResults>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling checkEmailBodyFeatureSupport.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/check-email-body-feature-support`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => CheckEmailBodyFeatureSupportResultsFromJSON(jsonValue) ); } /** * Detect HTML and CSS features inside an email body and return a report of email client support across different platforms and versions. * Show which mail clients support the HTML and CSS features used in an email body. */ async checkEmailBodyFeatureSupport( requestParameters: CheckEmailBodyFeatureSupportRequest, initOverrides?: RequestInit ): Promise<CheckEmailBodyFeatureSupportResults> { const response = await this.checkEmailBodyFeatureSupportRaw( requestParameters, initOverrides ); return await response.value(); } /** * Evaluate the features used in an email body and return a report of email client support across different platforms and versions. * Show which email programs and devices support the features used in an email body. */ async checkEmailClientSupportRaw( requestParameters: CheckEmailClientSupportRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<CheckEmailClientSupportResults>> { if ( requestParameters.checkEmailClientSupportOptions === null || requestParameters.checkEmailClientSupportOptions === undefined ) { throw new runtime.RequiredError( 'checkEmailClientSupportOptions', 'Required parameter requestParameters.checkEmailClientSupportOptions was null or undefined when calling checkEmailClientSupport.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/check-email-client-support`, method: 'POST', headers: headerParameters, query: queryParameters, body: CheckEmailClientSupportOptionsToJSON( requestParameters.checkEmailClientSupportOptions ), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => CheckEmailClientSupportResultsFromJSON(jsonValue) ); } /** * Evaluate the features used in an email body and return a report of email client support across different platforms and versions. * Show which email programs and devices support the features used in an email body. */ async checkEmailClientSupport( requestParameters: CheckEmailClientSupportRequest, initOverrides?: RequestInit ): Promise<CheckEmailClientSupportResults> { const response = await this.checkEmailClientSupportRaw( requestParameters, initOverrides ); return await response.value(); } /** * Deletes all emails in your account. Be careful as emails cannot be recovered * Delete all emails in all inboxes. */ async deleteAllEmailsRaw( initOverrides?: RequestInit ): Promise<runtime.ApiResponse<void>> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails`, method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.VoidApiResponse(response); } /** * Deletes all emails in your account. Be careful as emails cannot be recovered * Delete all emails in all inboxes. */ async deleteAllEmails(initOverrides?: RequestInit): Promise<void> { await this.deleteAllEmailsRaw(initOverrides); } /** * Deletes an email and removes it from the inbox. Deleted emails cannot be recovered. * Delete an email */ async deleteEmailRaw( requestParameters: DeleteEmailRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<void>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling deleteEmail.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.VoidApiResponse(response); } /** * Deletes an email and removes it from the inbox. Deleted emails cannot be recovered. * Delete an email */ async deleteEmail( requestParameters: DeleteEmailRequest, initOverrides?: RequestInit ): Promise<void> { await this.deleteEmailRaw(requestParameters, initOverrides); } /** * Returns the specified attachment for a given email as a stream / array of bytes. You can find attachment ids in email responses endpoint responses. The response type is application/octet-stream. * Get email attachment bytes. Returned as `octet-stream` with content type header. If you have trouble with byte responses try the `downloadAttachmentBase64` response endpoints and convert the base 64 encoded content to a file or string. */ async downloadAttachmentRaw( requestParameters: DownloadAttachmentRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<string>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling downloadAttachment.' ); } if ( requestParameters.attachmentId === null || requestParameters.attachmentId === undefined ) { throw new runtime.RequiredError( 'attachmentId', 'Required parameter requestParameters.attachmentId was null or undefined when calling downloadAttachment.' ); } const queryParameters: any = {}; if (requestParameters.apiKey !== undefined) { queryParameters['apiKey'] = requestParameters.apiKey; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/attachments/{attachmentId}` .replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ) .replace( `{${'attachmentId'}}`, encodeURIComponent(String(requestParameters.attachmentId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.TextApiResponse(response) as any; } /** * Returns the specified attachment for a given email as a stream / array of bytes. You can find attachment ids in email responses endpoint responses. The response type is application/octet-stream. * Get email attachment bytes. Returned as `octet-stream` with content type header. If you have trouble with byte responses try the `downloadAttachmentBase64` response endpoints and convert the base 64 encoded content to a file or string. */ async downloadAttachment( requestParameters: DownloadAttachmentRequest, initOverrides?: RequestInit ): Promise<string> { const response = await this.downloadAttachmentRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns the specified attachment for a given email as a base 64 encoded string. The response type is application/json. This method is similar to the `downloadAttachment` method but allows some clients to get around issues with binary responses. * Get email attachment as base64 encoded string as an alternative to binary responses. Decode the `base64FileContents` as a `utf-8` encoded string or array of bytes depending on the `contentType`. */ async downloadAttachmentBase64Raw( requestParameters: DownloadAttachmentBase64Request, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<DownloadAttachmentDto>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling downloadAttachmentBase64.' ); } if ( requestParameters.attachmentId === null || requestParameters.attachmentId === undefined ) { throw new runtime.RequiredError( 'attachmentId', 'Required parameter requestParameters.attachmentId was null or undefined when calling downloadAttachmentBase64.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/attachments/{attachmentId}/base64` .replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ) .replace( `{${'attachmentId'}}`, encodeURIComponent(String(requestParameters.attachmentId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => DownloadAttachmentDtoFromJSON(jsonValue) ); } /** * Returns the specified attachment for a given email as a base 64 encoded string. The response type is application/json. This method is similar to the `downloadAttachment` method but allows some clients to get around issues with binary responses. * Get email attachment as base64 encoded string as an alternative to binary responses. Decode the `base64FileContents` as a `utf-8` encoded string or array of bytes depending on the `contentType`. */ async downloadAttachmentBase64( requestParameters: DownloadAttachmentBase64Request, initOverrides?: RequestInit ): Promise<DownloadAttachmentDto> { const response = await this.downloadAttachmentBase64Raw( requestParameters, initOverrides ); return await response.value(); } /** * Returns the specified email body for a given email as a string * Get email body as string. Returned as `plain/text` with content type header. */ async downloadBodyRaw( requestParameters: DownloadBodyRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<string>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling downloadBody.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/body`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.TextApiResponse(response) as any; } /** * Returns the specified email body for a given email as a string * Get email body as string. Returned as `plain/text` with content type header. */ async downloadBody( requestParameters: DownloadBodyRequest, initOverrides?: RequestInit ): Promise<string> { const response = await this.downloadBodyRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns the specified email body for a given email as a stream / array of bytes. * Get email body in bytes. Returned as `octet-stream` with content type header. */ async downloadBodyBytesRaw( requestParameters: DownloadBodyBytesRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<string>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling downloadBodyBytes.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/body-bytes`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.TextApiResponse(response) as any; } /** * Returns the specified email body for a given email as a stream / array of bytes. * Get email body in bytes. Returned as `octet-stream` with content type header. */ async downloadBodyBytes( requestParameters: DownloadBodyBytesRequest, initOverrides?: RequestInit ): Promise<string> { const response = await this.downloadBodyBytesRaw( requestParameters, initOverrides ); return await response.value(); } /** * Forward an existing email to new recipients. The sender of the email will be the inbox that received the email you are forwarding. You can override the sender with the `from` option. Note you must have access to the from address in MailSlurp to use the override. For more control consider fetching the email and sending it a new using the send email endpoints. * Forward email to recipients */ async forwardEmailRaw( requestParameters: ForwardEmailRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<SentEmailDto>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling forwardEmail.' ); } if ( requestParameters.forwardEmailOptions === null || requestParameters.forwardEmailOptions === undefined ) { throw new runtime.RequiredError( 'forwardEmailOptions', 'Required parameter requestParameters.forwardEmailOptions was null or undefined when calling forwardEmail.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/forward`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, body: ForwardEmailOptionsToJSON(requestParameters.forwardEmailOptions), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => SentEmailDtoFromJSON(jsonValue) ); } /** * Forward an existing email to new recipients. The sender of the email will be the inbox that received the email you are forwarding. You can override the sender with the `from` option. Note you must have access to the from address in MailSlurp to use the override. For more control consider fetching the email and sending it a new using the send email endpoints. * Forward email to recipients */ async forwardEmail( requestParameters: ForwardEmailRequest, initOverrides?: RequestInit ): Promise<SentEmailDto> { const response = await this.forwardEmailRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns the metadata such as name and content-type for a given attachment and email. * Get email attachment metadata. This is the `contentType` and `contentLength` of an attachment. To get the individual attachments use the `downloadAttachment` methods. */ async getAttachmentMetaDataRaw( requestParameters: GetAttachmentMetaDataRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<AttachmentMetaData>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getAttachmentMetaData.' ); } if ( requestParameters.attachmentId === null || requestParameters.attachmentId === undefined ) { throw new runtime.RequiredError( 'attachmentId', 'Required parameter requestParameters.attachmentId was null or undefined when calling getAttachmentMetaData.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/attachments/{attachmentId}/metadata` .replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ) .replace( `{${'attachmentId'}}`, encodeURIComponent(String(requestParameters.attachmentId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => AttachmentMetaDataFromJSON(jsonValue) ); } /** * Returns the metadata such as name and content-type for a given attachment and email. * Get email attachment metadata. This is the `contentType` and `contentLength` of an attachment. To get the individual attachments use the `downloadAttachment` methods. */ async getAttachmentMetaData( requestParameters: GetAttachmentMetaDataRequest, initOverrides?: RequestInit ): Promise<AttachmentMetaData> { const response = await this.getAttachmentMetaDataRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns a email summary object with headers and content. To retrieve the raw unparsed email use the getRawEmail endpoints * Get email content including headers and body. Expects email to exist by ID. For emails that may not have arrived yet use the WaitForController. */ async getEmailRaw( requestParameters: GetEmailRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<Email>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmail.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailFromJSON(jsonValue) ); } /** * Returns a email summary object with headers and content. To retrieve the raw unparsed email use the getRawEmail endpoints * Get email content including headers and body. Expects email to exist by ID. For emails that may not have arrived yet use the WaitForController. */ async getEmail( requestParameters: GetEmailRequest, initOverrides?: RequestInit ): Promise<Email> { const response = await this.getEmailRaw(requestParameters, initOverrides); return await response.value(); } /** * Returns an array of attachment metadata such as name and content-type for a given email if present. * Get all email attachment metadata. Metadata includes name and size of attachments. */ async getEmailAttachmentsRaw( requestParameters: GetEmailAttachmentsRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<Array<AttachmentMetaData>>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailAttachments.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/attachments`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(AttachmentMetaDataFromJSON) ); } /** * Returns an array of attachment metadata such as name and content-type for a given email if present. * Get all email attachment metadata. Metadata includes name and size of attachments. */ async getEmailAttachments( requestParameters: GetEmailAttachmentsRequest, initOverrides?: RequestInit ): Promise<Array<AttachmentMetaData>> { const response = await this.getEmailAttachmentsRaw( requestParameters, initOverrides ); return await response.value(); } /** * Return the matches for a given Java style regex pattern. Do not include the typical `/` at start or end of regex in some languages. Given an example `your code is: 12345` the pattern to extract match looks like `code is: (\\d{6})`. This will return an array of matches with the first matching the entire pattern and the subsequent matching the groups: `[\'code is: 123456\', \'123456\']` See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html for more information of available patterns. * Get email content regex pattern match results. Runs regex against email body and returns match groups. */ async getEmailContentMatchRaw( requestParameters: GetEmailContentMatchRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<EmailContentMatchResult>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailContentMatch.' ); } if ( requestParameters.contentMatchOptions === null || requestParameters.contentMatchOptions === undefined ) { throw new runtime.RequiredError( 'contentMatchOptions', 'Required parameter requestParameters.contentMatchOptions was null or undefined when calling getEmailContentMatch.' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/contentMatch`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, body: ContentMatchOptionsToJSON(requestParameters.contentMatchOptions), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailContentMatchResultFromJSON(jsonValue) ); } /** * Return the matches for a given Java style regex pattern. Do not include the typical `/` at start or end of regex in some languages. Given an example `your code is: 12345` the pattern to extract match looks like `code is: (\\d{6})`. This will return an array of matches with the first matching the entire pattern and the subsequent matching the groups: `[\'code is: 123456\', \'123456\']` See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html for more information of available patterns. * Get email content regex pattern match results. Runs regex against email body and returns match groups. */ async getEmailContentMatch( requestParameters: GetEmailContentMatchRequest, initOverrides?: RequestInit ): Promise<EmailContentMatchResult> { const response = await this.getEmailContentMatchRaw( requestParameters, initOverrides ); return await response.value(); } /** * Get email body content parts from a multipart email message for a given content type * Get email content part by content type */ async getEmailContentPartRaw( requestParameters: GetEmailContentPartRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<EmailContentPartResult>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailContentPart.' ); } if ( requestParameters.contentType === null || requestParameters.contentType === undefined ) { throw new runtime.RequiredError( 'contentType', 'Required parameter requestParameters.contentType was null or undefined when calling getEmailContentPart.' ); } const queryParameters: any = {}; if (requestParameters.contentType !== undefined) { queryParameters['contentType'] = requestParameters.contentType; } if (requestParameters.strict !== undefined) { queryParameters['strict'] = requestParameters.strict; } if (requestParameters.index !== undefined) { queryParameters['index'] = requestParameters.index; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/contentPart`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailContentPartResultFromJSON(jsonValue) ); } /** * Get email body content parts from a multipart email message for a given content type * Get email content part by content type */ async getEmailContentPart( requestParameters: GetEmailContentPartRequest, initOverrides?: RequestInit ): Promise<EmailContentPartResult> { const response = await this.getEmailContentPartRaw( requestParameters, initOverrides ); return await response.value(); } /** * Get email body content parts from a multipart email message for a given content type and return as response * Get email content part by content type raw response */ async getEmailContentPartContentRaw( requestParameters: GetEmailContentPartContentRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<string>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailContentPartContent.' ); } if ( requestParameters.contentType === null || requestParameters.contentType === undefined ) { throw new runtime.RequiredError( 'contentType', 'Required parameter requestParameters.contentType was null or undefined when calling getEmailContentPartContent.' ); } const queryParameters: any = {}; if (requestParameters.contentType !== undefined) { queryParameters['contentType'] = requestParameters.contentType; } if (requestParameters.strict !== undefined) { queryParameters['strict'] = requestParameters.strict; } if (requestParameters.index !== undefined) { queryParameters['index'] = requestParameters.index; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/{emailId}/contentPart/raw`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.TextApiResponse(response) as any; } /** * Get email body content parts from a multipart email message for a given content type and return as response * Get email content part by content type raw response */ async getEmailContentPartContent( requestParameters: GetEmailContentPartContentRequest, initOverrides?: RequestInit ): Promise<string> { const response = await this.getEmailContentPartContentRaw( requestParameters, initOverrides ); return await response.value(); } /** * Get email count */ async getEmailCountRaw( requestParameters: GetEmailCountRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<CountDto>> { const queryParameters: any = {}; if (requestParameters.inboxId !== undefined) { queryParameters['inboxId'] = requestParameters.inboxId; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication } const response = await this.request( { path: `/emails/emails/count`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => CountDtoFromJSON(jsonValue) ); } /** * Get email count */ async getEmailCount( requestParameters: GetEmailCountRequest, initOverrides?: RequestInit ): Promise<CountDto> { const response = await this.getEmailCountRaw( requestParameters, initOverrides ); return await response.value(); } /** * Retrieve email content as HTML response for viewing in browsers. Decodes quoted-printable entities and converts charset to UTF-8. Pass your API KEY as a request parameter when viewing in a browser: `?apiKey=xxx`. Returns content-type `text/html;charset=utf-8` so