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,549 lines (1,353 loc) • 76.4 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* MailSlurp API
* MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. 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,
CheckEmailClientSupportOptions,
CheckEmailClientSupportOptionsFromJSON,
CheckEmailClientSupportOptionsToJSON,
CheckEmailClientSupportResults,
CheckEmailClientSupportResultsFromJSON,
CheckEmailClientSupportResultsToJSON,
ContentMatchOptions,
ContentMatchOptionsFromJSON,
ContentMatchOptionsToJSON,
CountDto,
CountDtoFromJSON,
CountDtoToJSON,
DownloadAttachmentDto,
DownloadAttachmentDtoFromJSON,
DownloadAttachmentDtoToJSON,
Email,
EmailFromJSON,
EmailToJSON,
EmailContentMatchResult,
EmailContentMatchResultFromJSON,
EmailContentMatchResultToJSON,
EmailHtmlDto,
EmailHtmlDtoFromJSON,
EmailHtmlDtoToJSON,
EmailLinksResult,
EmailLinksResultFromJSON,
EmailLinksResultToJSON,
EmailPreview,
EmailPreviewFromJSON,
EmailPreviewToJSON,
EmailPreviewUrls,
EmailPreviewUrlsFromJSON,
EmailPreviewUrlsToJSON,
EmailTextLinesResult,
EmailTextLinesResultFromJSON,
EmailTextLinesResultToJSON,
ForwardEmailOptions,
ForwardEmailOptionsFromJSON,
ForwardEmailOptionsToJSON,
GravatarUrl,
GravatarUrlFromJSON,
GravatarUrlToJSON,
ImapFlagOperationOptions,
ImapFlagOperationOptionsFromJSON,
ImapFlagOperationOptionsToJSON,
PageEmailProjection,
PageEmailProjectionFromJSON,
PageEmailProjectionToJSON,
RawEmailJson,
RawEmailJsonFromJSON,
RawEmailJsonToJSON,
ReplyToEmailOptions,
ReplyToEmailOptionsFromJSON,
ReplyToEmailOptionsToJSON,
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 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;
decode?: boolean;
}
export interface GetEmailAttachmentsRequest {
emailId: string;
}
export interface GetEmailContentMatchRequest {
emailId: string;
contentMatchOptions: ContentMatchOptions;
}
export interface GetEmailHTMLRequest {
emailId: string;
decode?: boolean;
}
export interface GetEmailHTMLJsonRequest {
emailId: string;
decode?: boolean;
}
export interface GetEmailHTMLQueryRequest {
emailId: string;
htmlSelector: string;
}
export interface GetEmailLinksRequest {
emailId: string;
}
export interface GetEmailPreviewURLsRequest {
emailId: string;
}
export interface GetEmailTextLinesRequest {
emailId: string;
decodeHtmlEntities?: boolean;
lineSeparator?: string;
}
export interface GetEmailsPaginatedRequest {
inboxId?: Array<string>;
page?: number;
size?: number;
sort?: GetEmailsPaginatedSortEnum;
unreadOnly?: boolean;
searchFilter?: string;
since?: Date;
before?: Date;
}
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;
}
export interface GetRawEmailContentsRequest {
emailId: string;
}
export interface GetRawEmailJsonRequest {
emailId: string;
}
export interface MarkAsReadRequest {
emailId: string;
read?: boolean;
}
export interface ReplyToEmailRequest {
emailId: string;
replyToEmailOptions: ReplyToEmailOptions;
}
export interface SendEmailSourceOptionalRequest {
sendEmailOptions: SendEmailOptions;
inboxId?: string;
useDomainPool?: boolean;
virtualSend?: 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();
}
/**
* 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 = {};
if (requestParameters.decode !== undefined) {
queryParameters['decode'] = requestParameters.decode;
}
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 count
*/
async getEmailCountRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<CountDto>> {
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/emails/count`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
CountDtoFromJSON(jsonValue)
);
}
/**
* Get email count
*/
async getEmailCount(initOverrides?: RequestInit): Promise<CountDto> {
const response = await this.getEmailCountRaw(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 you must call expecting that content response not JSON. For JSON response see the `getEmailHTMLJson` method.
* Get email content as HTML. For displaying emails in browser context.
*/
async getEmailHTMLRaw(
requestParameters: GetEmailHTMLRequest,
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 getEmailHTML.'
);
}
const queryParameters: any = {};
if (requestParameters.decode !== undefined) {
queryParameters['decode'] = requestParameters.decode;
}
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}/html`.replace(
`{${'emailId'}}`,
encodeURIComponent(String(requestParameters.emailId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.TextApiResponse(response) as any;
}
/**
* 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 you must call expecting that content response not JSON. For JSON response see the `getEmailHTMLJson` method.
* Get email content as HTML. For displaying emails in browser context.
*/
async getEmailHTML(
requestParameters: GetEmailHTMLRequest,
initOverrides?: RequestInit
): Promise<string> {
const response = await this.getEmailHTMLRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Retrieve email content as HTML response. Decodes quoted-printable entities and converts charset to UTF-8. Returns content-type `application/json;charset=utf-8` so you must call expecting that content response not JSON.
* Get email content as HTML in JSON wrapper. For fetching entity decoded HTML content
*/
async getEmailHTMLJsonRaw(
requestParameters: GetEmailHTMLJsonRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<EmailHtmlDto>> {
if (
requestParameters.emailId === null ||
requestParameters.emailId === undefined
) {
throw new runtime.RequiredError(
'emailId',
'Required parameter requestParameters.emailId was null or undefined when calling getEmailHTMLJson.'
);
}
const queryParameters: any = {};
if (requestParameters.decode !== undefined) {
queryParameters['decode'] = requestParameters.decode;
}
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}/html/json`.replace(
`{${'emailId'}}`,
encodeURIComponent(String(requestParameters.emailId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
EmailHtmlDtoFromJSON(jsonValue)
);
}
/**
* Retrieve email content as HTML response. Decodes quoted-printable entities and converts charset to UTF-8. Returns content-type `application/json;charset=utf-8` so you must call expecting that content response not JSON.
* Get email content as HTML in JSON wrapper. For fetching entity decoded HTML content
*/
async getEmailHTMLJson(
requestParameters: GetEmailHTMLJsonRequest,
initOverrides?: RequestInit
): Promise<EmailHtmlDto> {
const response = await this.getEmailHTMLJsonRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Parse an email body and return the content as an array of text. HTML parsing uses JSoup which supports JQuery/CSS style selectors
* Parse and return text from an email, stripping HTML and decoding encoded characters
*/
async getEmailHTMLQueryRaw(
requestParameters: GetEmailHTMLQueryRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<EmailTextLinesResult>> {
if (
requestParameters.emailId === null ||
requestParameters.emailId === undefined
) {
throw new runtime.RequiredError(
'emailId',
'Required parameter requestParameters.emailId was null or undefined when calling getEmailHTMLQuery.'
);
}
if (
requestParameters.htmlSelector === null ||
requestParameters.htmlSelector === undefined
) {
throw new runtime.RequiredError(
'htmlSelector',
'Required parameter requestParameters.htmlSelector was null or undefined when calling getEmailHTMLQuery.'
);
}
const queryParameters: any = {};
if (requestParameters.htmlSelector !== undefined) {
queryParameters['htmlSelector'] = requestParameters.htmlSelector;
}
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}/htmlQuery`.replace(
`{${'emailId'}}`,
encodeURIComponent(String(requestParameters.emailId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
EmailTextLinesResultFromJSON(jsonValue)
);
}
/**
* Parse an email body and return the content as an array of text. HTML parsing uses JSoup which supports JQuery/CSS style selectors
* Parse and return text from an email, stripping HTML and decoding encoded characters
*/
async getEmailHTMLQuery(
requestParameters: GetEmailHTMLQueryRequest,
initOverrides?: RequestInit
): Promise<EmailTextLinesResult> {
const response = await this.getEmailHTMLQueryRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* HTML parsing uses JSoup and UNIX line separators. Searches content for href attributes
* Parse and return list of links found in an email (only works for HTML content)
*/
async getEmailLinksRaw(
requestParameters: GetEmailLinksRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<EmailLinksResult>> {
if (
requestParameters.emailId === null ||
requestParameters.emailId === undefined
) {
throw new runtime.RequiredError(
'emailId',
'Required parameter requestParameters.emailId was null or undefined when calling getEmailLinks.'
);
}
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}/links`.replace(
`{${'emailId'}}`,
encodeURIComponent(String(requestParameters.emailId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
EmailLinksResultFromJSON(jsonValue)
);
}
/**
* HTML parsing uses JSoup and UNIX line separators. Searches content for href attributes
* Parse and return list of links found in an email (only works for HTML content)
*/
async getEmailLinks(
requestParameters: GetEmailLinksRequest,
initOverrides?: RequestInit
): Promise<EmailLinksResult> {
const response = await this.getEmailLinksRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get a list of URLs for email content as text/html or raw SMTP message for viewing the message in a browser.
* Get email URLs for viewing in browser or downloading
*/
async getEmailPreviewURLsRaw(
requestParameters: GetEmailPreviewURLsRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<EmailPreviewUrls>> {
if (
requestParameters.emailId === null ||
requestParameters.emailId === undefined
) {
throw new runtime.RequiredError(
'emailId',
'Required parameter requestParameters.emailId was null or undefined when calling getEmailPreviewURLs.'
);
}
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}/urls`.replace(
`{${'emailId'}}`,
encodeURIComponent(String(requestParameters.emailId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
EmailPreviewUrlsFromJSON(jsonValue)
);
}
/**
* Get a list of URLs for email content as text/html or raw SMTP message for viewing the message in a browser.
* Get email URLs for viewing