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,648 lines (1,441 loc) 116 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, EmailAuditAnalysisResult, EmailAuditAnalysisResultFromJSON, EmailAuditAnalysisResultToJSON, EmailAuditDto, EmailAuditDtoFromJSON, EmailAuditDtoToJSON, EmailContentMatchResult, EmailContentMatchResultFromJSON, EmailContentMatchResultToJSON, EmailContentPartResult, EmailContentPartResultFromJSON, EmailContentPartResultToJSON, EmailHtmlDto, EmailHtmlDtoFromJSON, EmailHtmlDtoToJSON, EmailLinksResult, EmailLinksResultFromJSON, EmailLinksResultToJSON, EmailPreview, EmailPreviewFromJSON, EmailPreviewToJSON, EmailPreviewUrls, EmailPreviewUrlsFromJSON, EmailPreviewUrlsToJSON, EmailScreenshotResult, EmailScreenshotResultFromJSON, EmailScreenshotResultToJSON, EmailSignatureParseResult, EmailSignatureParseResultFromJSON, EmailSignatureParseResultToJSON, EmailTextLinesResult, EmailTextLinesResultFromJSON, EmailTextLinesResultToJSON, EmailThreadDto, EmailThreadDtoFromJSON, EmailThreadDtoToJSON, EmailThreadItemsDto, EmailThreadItemsDtoFromJSON, EmailThreadItemsDtoToJSON, ExtractCodesOptions, ExtractCodesOptionsFromJSON, ExtractCodesOptionsToJSON, ExtractCodesResult, ExtractCodesResultFromJSON, ExtractCodesResultToJSON, 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 CheckEmailAudit1Request { emailId: string; } export interface CheckEmailBodyRequest { emailId: string; } export interface CheckEmailBodyFeatureSupportRequest { emailId: string; } export interface CheckEmailClientSupportRequest { checkEmailClientSupportOptions: CheckEmailClientSupportOptions; } export interface CreateEmailAuditForEmailRequest { emailId: string; } 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 GetEmailCodesRequest { emailId: string; extractCodesOptions?: ExtractCodesOptions; } 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 GetEmailSignatureRequest { emailId: string; } 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; include?: Array<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 { /** * Applies RFC3501 IMAP flag operations on a message. Current implementation supports read/unread semantics via the `\\\\Seen` flag only. * 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) ); } /** * Applies RFC3501 IMAP flag operations on a message. Current implementation supports read/unread semantics via the `\\\\Seen` flag only. * 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(); } /** * Validates sender/inbox context and recipient eligibility before attempting a send. Useful for preflight checks in UI or test workflows. * Check whether an email send would be accepted */ 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) ); } /** * Validates sender/inbox context and recipient eligibility before attempting a send. Useful for preflight checks in UI or test workflows. * Check whether an email send would be accepted */ async canSend( requestParameters: CanSendRequest, initOverrides?: RequestInit ): Promise<CanSendEmailResults> { const response = await this.canSendRaw(requestParameters, initOverrides); return await response.value(); } /** * Runs the same message-level audit bundle used by the email audit dashboard in one request. Combines content checks, HTML validation, compatibility analysis, and reputation verdict rollup when available. * Run aggregate email audit for a stored email */ async checkEmailAudit1Raw( requestParameters: CheckEmailAudit1Request, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<EmailAuditAnalysisResult>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling checkEmailAudit1.' ); } 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-audit`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailAuditAnalysisResultFromJSON(jsonValue) ); } /** * Runs the same message-level audit bundle used by the email audit dashboard in one request. Combines content checks, HTML validation, compatibility analysis, and reputation verdict rollup when available. * Run aggregate email audit for a stored email */ async checkEmailAudit1( requestParameters: CheckEmailAudit1Request, initOverrides?: RequestInit ): Promise<EmailAuditAnalysisResult> { const response = await this.checkEmailAudit1Raw( requestParameters, initOverrides ); return await response.value(); } /** * Runs content quality checks against hydrated email body content. This endpoint performs outbound HTTP checks for linked resources, so avoid use with sensitive or stateful URLs. * Check email body for broken links, images, and spelling issues */ 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) ); } /** * Runs content quality checks against hydrated email body content. This endpoint performs outbound HTTP checks for linked resources, so avoid use with sensitive or stateful URLs. * Check email body for broken links, images, and spelling issues */ async checkEmailBody( requestParameters: CheckEmailBodyRequest, initOverrides?: RequestInit ): Promise<CheckEmailBodyResults> { const response = await this.checkEmailBodyRaw( requestParameters, initOverrides ); return await response.value(); } /** * Detects HTML/CSS features in the target email body and reports compatibility across major email clients and devices. * Check client support for features used in a stored 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) ); } /** * Detects HTML/CSS features in the target email body and reports compatibility across major email clients and devices. * Check client support for features used in a stored email body */ async checkEmailBodyFeatureSupport( requestParameters: CheckEmailBodyFeatureSupportRequest, initOverrides?: RequestInit ): Promise<CheckEmailBodyFeatureSupportResults> { const response = await this.checkEmailBodyFeatureSupportRaw( requestParameters, initOverrides ); return await response.value(); } /** * Evaluates HTML/CSS features in the supplied body and reports support coverage across major email clients and platforms. * Check email-client support for a provided HTML 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) ); } /** * Evaluates HTML/CSS features in the supplied body and reports support coverage across major email clients and platforms. * Check email-client support for a provided HTML body */ async checkEmailClientSupport( requestParameters: CheckEmailClientSupportRequest, initOverrides?: RequestInit ): Promise<CheckEmailClientSupportResults> { const response = await this.checkEmailClientSupportRaw( requestParameters, initOverrides ); return await response.value(); } /** * Runs the aggregate audit bundle for the target email and stores the resulting audit record for later review and history tracking. * Persist aggregate email audit for a stored email */ async createEmailAuditForEmailRaw( requestParameters: CreateEmailAuditForEmailRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<EmailAuditDto>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling createEmailAuditForEmail.' ); } 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}/audit`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailAuditDtoFromJSON(jsonValue) ); } /** * Runs the aggregate audit bundle for the target email and stores the resulting audit record for later review and history tracking. * Persist aggregate email audit for a stored email */ async createEmailAuditForEmail( requestParameters: CreateEmailAuditForEmailRequest, initOverrides?: RequestInit ): Promise<EmailAuditDto> { const response = await this.createEmailAuditForEmailRaw( requestParameters, initOverrides ); return await response.value(); } /** * Deletes all emails for the authenticated account context. This operation is destructive and cannot be undone. * 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 for the authenticated account context. This operation is destructive and cannot be undone. * Delete all emails in all inboxes. */ async deleteAllEmails(initOverrides?: RequestInit): Promise<void> { await this.deleteAllEmailsRaw(initOverrides); } /** * Deletes a single email from account scope. Operation is destructive and not reversible. * 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 a single email from account scope. Operation is destructive and not reversible. * Delete an email */ async deleteEmail( requestParameters: DeleteEmailRequest, initOverrides?: RequestInit ): Promise<void> { await this.deleteEmailRaw(requestParameters, initOverrides); } /** * Returns attachment bytes by attachment ID. Use attachment IDs from email payloads or attachment listing endpoints. * 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 attachment bytes by attachment ID. Use attachment IDs from email payloads or attachment listing endpoints. * 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 attachment payload as base64 in JSON. Useful for clients that cannot reliably consume binary streaming 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 attachment payload as base64 in JSON. Useful for clients that cannot reliably consume binary streaming 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 hydrated email body text as a string with content type aligned to the underlying body format. * 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 hydrated email body text as a string with content type aligned to the underlying body format. * 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(); } /** * Streams hydrated email body bytes with content type derived from the message body format. * 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; } /** * Streams hydrated email body bytes with content type derived from the message body format. * 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(); } /** * Forwards an existing email to new recipients. Uses the owning inbox context unless overridden by allowed sender options. * 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) ); } /** * Forwards an existing email to new recipients. Uses the owning inbox context unless overridden by allowed sender options. * Forward email to recipients */ async forwardEmail( requestParameters: ForwardEmailRequest, initOverrides?: RequestInit ): Promise<SentEmailDto> { const response = await this.forwardEmailRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns metadata for a specific attachment ID (name, content type, and size fields). * 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 metadata for a specific attachment ID (name, content type, and size fields). * 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 parsed email content including headers and body fields. Accessing hydrated content may mark the email as read depending on read-state rules. * Get hydrated email (headers and body) */ 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 parsed email content including headers and body fields. Accessing hydrated content may mark the email as read depending on read-state rules. * Get hydrated email (headers and body) */ async getEmail( requestParameters: GetEmailRequest, initOverrides?: RequestInit ): Promise<Email> { const response = await this.getEmailRaw(requestParameters, initOverrides); return await response.value(); } /** * Returns metadata for all attachment IDs associated with the email (name, content type, size, and IDs). * List attachment metadata for an email */ 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 metadata for all attachment IDs associated with the email (name, content type, size, and IDs). * List attachment metadata for an email */ async getEmailAttachments( requestParameters: GetEmailAttachmentsRequest, initOverrides?: RequestInit ): Promise<Array<AttachmentMetaData>> { const response = await this.getEmailAttachmentsRaw( requestParameters, initOverrides ); return await response.value(); } /** * Extracts one-time passcodes and similar tokens from email content using the selected extraction method and fallback options. * Extract verification codes from an email */ async getEmailCodesRaw( requestParameters: GetEmailCodesRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<ExtractCodesResult>> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailCodes.' ); } 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}/codes`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, body: ExtractCodesOptionsToJSON(requestParameters.extractCodesOptions), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => ExtractCodesResultFromJSON(jsonValue) ); } /** * Extracts one-time passcodes and similar tokens from email content using the selected extraction method and fallback options. * Extract verification codes from an email */ async getEmailCodes( requestParameters: GetEmailCodesRequest, initOverrides?: RequestInit ): Promise<ExtractCodesResult> { const response = await this.getEmailCodesRaw( requestParameters, initOverrides ); return await response.value(); } /** * Executes a Java regex pattern over hydrated email body text and returns the full match plus capture groups. Pattern syntax follows Java `Pattern` rules. * Run regex against hydrated email body and return matches */ 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) ); } /** * Executes a Java regex pattern over hydrated email body text and returns the full match plus capture groups. Pattern syntax follows Java `Pattern` rules. * Run regex against hydrated email body and return matches */ async getEmailContentMatch( requestParameters: GetEmailContentMatchRequest, initOverrides?: RequestInit ): Promise<EmailContentMatchResult> { const response = await this.getEmailContentMatchRaw( requestParameters, initOverrides ); return await response.value(); } /** * Extracts one MIME body part by `contentType` and optional `index`, returned in a structured DTO with metadata. * 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( {