/* 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; page?: number; size?: number; sort?: GetEmailsOffsetPaginatedSortEnum; unreadOnly?: boolean; searchFilter?: string; since?: Date; before?: Date; favourited?: boolean; syncConnectors?: boolean; plusAddressId?: string; include?: Array; } export interface GetEmailsPaginatedRequest { inboxId?: Array; 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; } export interface GetLatestEmailInInbox1Request { inboxId: string; } export interface GetOrganizationEmailsPaginatedRequest { inboxId?: Array; 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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> { 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 { 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>> { 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> { 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> { 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 { 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> { 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 { 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> { 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) ); } /** * 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 getEmailContentPart( requestParameters: GetEmailContentPartRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailContentPartRaw( requestParameters, initOverrides ); return await response.value(); } /** * Extracts one MIME body part by `contentType` and optional `index`, and returns raw content with matching response content type when valid. * Get multipart content part as raw response */ async getEmailContentPartContentRaw( requestParameters: GetEmailContentPartContentRequest, initOverrides?: RequestInit ): Promise> { 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; } /** * Extracts one MIME body part by `contentType` and optional `index`, and returns raw content with matching response content type when valid. * Get multipart content part as raw response */ async getEmailContentPartContent( requestParameters: GetEmailContentPartContentRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailContentPartContentRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns total email count for the authenticated user, or count scoped to a specific inbox when `inboxId` is provided. * Get email count */ async getEmailCountRaw( requestParameters: GetEmailCountRequest, initOverrides?: RequestInit ): Promise> { 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) ); } /** * Returns total email count for the authenticated user, or count scoped to a specific inbox when `inboxId` is provided. * Get email count */ async getEmailCount( requestParameters: GetEmailCountRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailCountRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns hydrated HTML body directly with `text/html` content type. Supports temporary access/browser usage and optional CID replacement for inline asset rendering. * Get hydrated email HTML for browser rendering */ async getEmailHTMLRaw( requestParameters: GetEmailHTMLRequest, initOverrides?: RequestInit ): Promise> { 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.replaceCidImages !== undefined) { queryParameters['replaceCidImages'] = requestParameters.replaceCidImages; } 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; } /** * Returns hydrated HTML body directly with `text/html` content type. Supports temporary access/browser usage and optional CID replacement for inline asset rendering. * Get hydrated email HTML for browser rendering */ async getEmailHTML( requestParameters: GetEmailHTMLRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailHTMLRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns hydrated HTML body and subject in a JSON DTO. Useful for API clients that need structured response payloads instead of raw HTML responses. * Get hydrated email HTML wrapped in JSON */ async getEmailHTMLJsonRaw( requestParameters: GetEmailHTMLJsonRequest, initOverrides?: RequestInit ): Promise> { 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.replaceCidImages !== undefined) { queryParameters['replaceCidImages'] = requestParameters.replaceCidImages; } 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) ); } /** * Returns hydrated HTML body and subject in a JSON DTO. Useful for API clients that need structured response payloads instead of raw HTML responses. * Get hydrated email HTML wrapped in JSON */ async getEmailHTMLJson( requestParameters: GetEmailHTMLJsonRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailHTMLJsonRaw( requestParameters, initOverrides ); return await response.value(); } /** * Applies a JSoup/CSS selector to hydrated HTML email body and returns matching text lines. * Query hydrated HTML body and return matching text lines */ async getEmailHTMLQueryRaw( requestParameters: GetEmailHTMLQueryRequest, initOverrides?: RequestInit ): Promise> { 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) ); } /** * Applies a JSoup/CSS selector to hydrated HTML email body and returns matching text lines. * Query hydrated HTML body and return matching text lines */ async getEmailHTMLQuery( requestParameters: GetEmailHTMLQueryRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailHTMLQueryRaw( requestParameters, initOverrides ); return await response.value(); } /** * Parses HTML content and extracts link URLs (`href`). For non-HTML emails this endpoint returns a validation error. * Extract links from an email HTML body */ async getEmailLinksRaw( requestParameters: GetEmailLinksRequest, initOverrides?: RequestInit ): Promise> { 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 = {}; if (requestParameters.selector !== undefined) { queryParameters['selector'] = requestParameters.selector; } 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) ); } /** * Parses HTML content and extracts link URLs (`href`). For non-HTML emails this endpoint returns a validation error. * Extract links from an email HTML body */ async getEmailLinks( requestParameters: GetEmailLinksRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailLinksRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns precomputed URLs for preview and raw message access for the specified email. * Get email URLs for viewing in browser or downloading */ async getEmailPreviewURLsRaw( requestParameters: GetEmailPreviewURLsRequest, initOverrides?: RequestInit ): Promise> { 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) ); } /** * Returns precomputed URLs for preview and raw message access for the specified email. * Get email URLs for viewing in browser or downloading */ async getEmailPreviewURLs( requestParameters: GetEmailPreviewURLsRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailPreviewURLsRaw( requestParameters, initOverrides ); return await response.value(); } /** * Renders the email in a browser engine and returns PNG data as base64. Useful for APIs and dashboards that cannot easily stream binary responses. * Take a screenshot of an email in a browser and return base64 encoded string */ async getEmailScreenshotAsBase64Raw( requestParameters: GetEmailScreenshotAsBase64Request, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailScreenshotAsBase64.' ); } if ( requestParameters.getEmailScreenshotOptions === null || requestParameters.getEmailScreenshotOptions === undefined ) { throw new runtime.RequiredError( 'getEmailScreenshotOptions', 'Required parameter requestParameters.getEmailScreenshotOptions was null or undefined when calling getEmailScreenshotAsBase64.' ); } 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}/screenshot/base64`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, body: GetEmailScreenshotOptionsToJSON( requestParameters.getEmailScreenshotOptions ), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailScreenshotResultFromJSON(jsonValue) ); } /** * Renders the email in a browser engine and returns PNG data as base64. Useful for APIs and dashboards that cannot easily stream binary responses. * Take a screenshot of an email in a browser and return base64 encoded string */ async getEmailScreenshotAsBase64( requestParameters: GetEmailScreenshotAsBase64Request, initOverrides?: RequestInit ): Promise { const response = await this.getEmailScreenshotAsBase64Raw( requestParameters, initOverrides ); return await response.value(); } /** * Renders the email in a browser engine and returns PNG bytes. Intended for visual QA and rendering regression checks. * Take a screenshot of an email in a browser */ async getEmailScreenshotAsBinaryRaw( requestParameters: GetEmailScreenshotAsBinaryRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailScreenshotAsBinary.' ); } if ( requestParameters.getEmailScreenshotOptions === null || requestParameters.getEmailScreenshotOptions === undefined ) { throw new runtime.RequiredError( 'getEmailScreenshotOptions', 'Required parameter requestParameters.getEmailScreenshotOptions was null or undefined when calling getEmailScreenshotAsBinary.' ); } 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}/screenshot/binary`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, body: GetEmailScreenshotOptionsToJSON( requestParameters.getEmailScreenshotOptions ), }, initOverrides ); return new runtime.VoidApiResponse(response); } /** * Renders the email in a browser engine and returns PNG bytes. Intended for visual QA and rendering regression checks. * Take a screenshot of an email in a browser */ async getEmailScreenshotAsBinary( requestParameters: GetEmailScreenshotAsBinaryRequest, initOverrides?: RequestInit ): Promise { await this.getEmailScreenshotAsBinaryRaw(requestParameters, initOverrides); } /** * Attempts to parse a sender signature block from an email body. Uses raw MIME content parts when possible and falls back to hydrated body parsing. This is heuristic and may not be accurate for all email clients or formats. * Extract signature from an inbound email */ async getEmailSignatureRaw( requestParameters: GetEmailSignatureRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailSignature.' ); } 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}/signature`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailSignatureParseResultFromJSON(jsonValue) ); } /** * Attempts to parse a sender signature block from an email body. Uses raw MIME content parts when possible and falls back to hydrated body parsing. This is heuristic and may not be accurate for all email clients or formats. * Extract signature from an inbound email */ async getEmailSignature( requestParameters: GetEmailSignatureRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailSignatureRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns lightweight metadata and headers for an email. Use `getEmail` for hydrated body content or `getRawEmail` for original SMTP content. * Get email summary (headers/metadata only) */ async getEmailSummaryRaw( requestParameters: GetEmailSummaryRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailSummary.' ); } 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}/summary`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailPreviewFromJSON(jsonValue) ); } /** * Returns lightweight metadata and headers for an email. Use `getEmail` for hydrated body content or `getRawEmail` for original SMTP content. * Get email summary (headers/metadata only) */ async getEmailSummary( requestParameters: GetEmailSummaryRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailSummaryRaw( requestParameters, initOverrides ); return await response.value(); } /** * Converts email body content to line-based plain text with optional HTML entity decoding and custom line separator. * Extract normalized text lines from email body */ async getEmailTextLinesRaw( requestParameters: GetEmailTextLinesRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getEmailTextLines.' ); } const queryParameters: any = {}; if (requestParameters.decodeHtmlEntities !== undefined) { queryParameters['decodeHtmlEntities'] = requestParameters.decodeHtmlEntities; } if (requestParameters.lineSeparator !== undefined) { queryParameters['lineSeparator'] = requestParameters.lineSeparator; } 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}/textLines`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailTextLinesResultFromJSON(jsonValue) ); } /** * Converts email body content to line-based plain text with optional HTML entity decoding and custom line separator. * Extract normalized text lines from email body */ async getEmailTextLines( requestParameters: GetEmailTextLinesRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailTextLinesRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns thread metadata built from RFC 5322 `Message-ID`, `In-Reply-To`, and `References` headers. Use `getEmailThreadItems` to fetch the thread messages. * Get email thread metadata by thread ID */ async getEmailThreadRaw( requestParameters: GetEmailThreadRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.threadId === null || requestParameters.threadId === undefined ) { throw new runtime.RequiredError( 'threadId', 'Required parameter requestParameters.threadId was null or undefined when calling getEmailThread.' ); } 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/threads/{threadId}`.replace( `{${'threadId'}}`, encodeURIComponent(String(requestParameters.threadId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailThreadDtoFromJSON(jsonValue) ); } /** * Returns thread metadata built from RFC 5322 `Message-ID`, `In-Reply-To`, and `References` headers. Use `getEmailThreadItems` to fetch the thread messages. * Get email thread metadata by thread ID */ async getEmailThread( requestParameters: GetEmailThreadRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailThreadRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns all messages in a thread ordered by `createdAt` using the requested sort direction. * Get messages in a specific email thread */ async getEmailThreadItemsRaw( requestParameters: GetEmailThreadItemsRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.threadId === null || requestParameters.threadId === undefined ) { throw new runtime.RequiredError( 'threadId', 'Required parameter requestParameters.threadId was null or undefined when calling getEmailThreadItems.' ); } const queryParameters: any = {}; if (requestParameters.sort !== undefined) { queryParameters['sort'] = requestParameters.sort; } 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/threads/{threadId}/items`.replace( `{${'threadId'}}`, encodeURIComponent(String(requestParameters.threadId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailThreadItemsDtoFromJSON(jsonValue) ); } /** * Returns all messages in a thread ordered by `createdAt` using the requested sort direction. * Get messages in a specific email thread */ async getEmailThreadItems( requestParameters: GetEmailThreadItemsRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailThreadItemsRaw( requestParameters, initOverrides ); return await response.value(); } /** * Lists conversation threads inferred from `Message-ID`, `In-Reply-To`, and `References`. Supports filtering by inbox, search text, and time range. * List email threads in paginated form */ async getEmailThreadsRaw( requestParameters: GetEmailThreadsRequest, initOverrides?: RequestInit ): Promise> { const queryParameters: any = {}; if (requestParameters.htmlSelector !== undefined) { queryParameters['htmlSelector'] = requestParameters.htmlSelector; } if (requestParameters.page !== undefined) { queryParameters['page'] = requestParameters.page; } if (requestParameters.size !== undefined) { queryParameters['size'] = requestParameters.size; } if (requestParameters.sort !== undefined) { queryParameters['sort'] = requestParameters.sort; } if (requestParameters.searchFilter !== undefined) { queryParameters['searchFilter'] = requestParameters.searchFilter; } if (requestParameters.since !== undefined) { queryParameters['since'] = (requestParameters.since as any).toISOString(); } if (requestParameters.before !== undefined) { queryParameters['before'] = ( requestParameters.before as any ).toISOString(); } 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/threads`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => PageEmailThreadProjectionFromJSON(jsonValue) ); } /** * Lists conversation threads inferred from `Message-ID`, `In-Reply-To`, and `References`. Supports filtering by inbox, search text, and time range. * List email threads in paginated form */ async getEmailThreads( requestParameters: GetEmailThreadsRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailThreadsRaw( requestParameters, initOverrides ); return await response.value(); } /** * Offset-style pagination endpoint for listing emails across inboxes. Supports inbox filters, unread-only, search, date boundaries, favourites, connector sync, plus-address filtering, and explicit include IDs. * Get all emails in all inboxes in paginated form. Email API list all. */ async getEmailsOffsetPaginatedRaw( requestParameters: GetEmailsOffsetPaginatedRequest, initOverrides?: RequestInit ): Promise> { const queryParameters: any = {}; if (requestParameters.inboxId) { queryParameters['inboxId'] = requestParameters.inboxId; } if (requestParameters.page !== undefined) { queryParameters['page'] = requestParameters.page; } if (requestParameters.size !== undefined) { queryParameters['size'] = requestParameters.size; } if (requestParameters.sort !== undefined) { queryParameters['sort'] = requestParameters.sort; } if (requestParameters.unreadOnly !== undefined) { queryParameters['unreadOnly'] = requestParameters.unreadOnly; } if (requestParameters.searchFilter !== undefined) { queryParameters['searchFilter'] = requestParameters.searchFilter; } if (requestParameters.since !== undefined) { queryParameters['since'] = (requestParameters.since as any).toISOString(); } if (requestParameters.before !== undefined) { queryParameters['before'] = ( requestParameters.before as any ).toISOString(); } if (requestParameters.favourited !== undefined) { queryParameters['favourited'] = requestParameters.favourited; } if (requestParameters.syncConnectors !== undefined) { queryParameters['syncConnectors'] = requestParameters.syncConnectors; } if (requestParameters.plusAddressId !== undefined) { queryParameters['plusAddressId'] = requestParameters.plusAddressId; } if (requestParameters.include) { queryParameters['include'] = requestParameters.include; } 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/offset-paginated`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => PageEmailProjectionFromJSON(jsonValue) ); } /** * Offset-style pagination endpoint for listing emails across inboxes. Supports inbox filters, unread-only, search, date boundaries, favourites, connector sync, plus-address filtering, and explicit include IDs. * Get all emails in all inboxes in paginated form. Email API list all. */ async getEmailsOffsetPaginated( requestParameters: GetEmailsOffsetPaginatedRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailsOffsetPaginatedRaw( requestParameters, initOverrides ); return await response.value(); } /** * Primary paginated email listing endpoint. Returns emails across inboxes with support for inbox filters, unread-only, search, date boundaries, favourites, connector sync, and plus-address filtering. * Get all emails in all inboxes in paginated form. Email API list all. */ async getEmailsPaginatedRaw( requestParameters: GetEmailsPaginatedRequest, initOverrides?: RequestInit ): Promise> { const queryParameters: any = {}; if (requestParameters.inboxId) { queryParameters['inboxId'] = requestParameters.inboxId; } if (requestParameters.page !== undefined) { queryParameters['page'] = requestParameters.page; } if (requestParameters.size !== undefined) { queryParameters['size'] = requestParameters.size; } if (requestParameters.sort !== undefined) { queryParameters['sort'] = requestParameters.sort; } if (requestParameters.unreadOnly !== undefined) { queryParameters['unreadOnly'] = requestParameters.unreadOnly; } if (requestParameters.searchFilter !== undefined) { queryParameters['searchFilter'] = requestParameters.searchFilter; } if (requestParameters.since !== undefined) { queryParameters['since'] = (requestParameters.since as any).toISOString(); } if (requestParameters.before !== undefined) { queryParameters['before'] = ( requestParameters.before as any ).toISOString(); } if (requestParameters.syncConnectors !== undefined) { queryParameters['syncConnectors'] = requestParameters.syncConnectors; } if (requestParameters.plusAddressId !== undefined) { queryParameters['plusAddressId'] = requestParameters.plusAddressId; } if (requestParameters.favourited !== undefined) { queryParameters['favourited'] = requestParameters.favourited; } 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: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => PageEmailProjectionFromJSON(jsonValue) ); } /** * Primary paginated email listing endpoint. Returns emails across inboxes with support for inbox filters, unread-only, search, date boundaries, favourites, connector sync, and plus-address filtering. * Get all emails in all inboxes in paginated form. Email API list all. */ async getEmailsPaginated( requestParameters: GetEmailsPaginatedRequest, initOverrides?: RequestInit ): Promise { const response = await this.getEmailsPaginatedRaw( requestParameters, initOverrides ); return await response.value(); } /** * Builds a Gravatar image URL from the provided email address and optional size. This endpoint does not fetch image bytes; it only returns the computed URL. * Get Gravatar URL for an email address */ async getGravatarUrlForEmailAddressRaw( requestParameters: GetGravatarUrlForEmailAddressRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailAddress === null || requestParameters.emailAddress === undefined ) { throw new runtime.RequiredError( 'emailAddress', 'Required parameter requestParameters.emailAddress was null or undefined when calling getGravatarUrlForEmailAddress.' ); } const queryParameters: any = {}; if (requestParameters.emailAddress !== undefined) { queryParameters['emailAddress'] = requestParameters.emailAddress; } if (requestParameters.size !== undefined) { queryParameters['size'] = requestParameters.size; } 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/gravatarFor`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => GravatarUrlFromJSON(jsonValue) ); } /** * Builds a Gravatar image URL from the provided email address and optional size. This endpoint does not fetch image bytes; it only returns the computed URL. * Get Gravatar URL for an email address */ async getGravatarUrlForEmailAddress( requestParameters: GetGravatarUrlForEmailAddressRequest, initOverrides?: RequestInit ): Promise { const response = await this.getGravatarUrlForEmailAddressRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns the most recently received email across all inboxes or an optional subset of inbox IDs. * Get latest email in all inboxes. Most recently received. */ async getLatestEmailRaw( requestParameters: GetLatestEmailRequest, initOverrides?: RequestInit ): Promise> { const queryParameters: any = {}; if (requestParameters.inboxIds) { queryParameters['inboxIds'] = requestParameters.inboxIds; } 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/latest`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailFromJSON(jsonValue) ); } /** * Returns the most recently received email across all inboxes or an optional subset of inbox IDs. * Get latest email in all inboxes. Most recently received. */ async getLatestEmail( requestParameters: GetLatestEmailRequest, initOverrides?: RequestInit ): Promise { const response = await this.getLatestEmailRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns the newest email for the specified inbox ID. For polling/wait semantics use wait endpoints. * Get latest email in an inbox. Use `WaitForController` to get emails that may not have arrived yet. */ async getLatestEmailInInbox1Raw( requestParameters: GetLatestEmailInInbox1Request, initOverrides?: RequestInit ): Promise> { if ( requestParameters.inboxId === null || requestParameters.inboxId === undefined ) { throw new runtime.RequiredError( 'inboxId', 'Required parameter requestParameters.inboxId was null or undefined when calling getLatestEmailInInbox1.' ); } 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/latestIn`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailFromJSON(jsonValue) ); } /** * Returns the newest email for the specified inbox ID. For polling/wait semantics use wait endpoints. * Get latest email in an inbox. Use `WaitForController` to get emails that may not have arrived yet. */ async getLatestEmailInInbox1( requestParameters: GetLatestEmailInInbox1Request, initOverrides?: RequestInit ): Promise { const response = await this.getLatestEmailInInbox1Raw( requestParameters, initOverrides ); return await response.value(); } /** * Returns paginated emails visible through organization/team access. Supports inbox filtering, unread-only filtering, search, favourites, plus-address filtering, and optional connector sync. * List organization-visible emails */ async getOrganizationEmailsPaginatedRaw( requestParameters: GetOrganizationEmailsPaginatedRequest, initOverrides?: RequestInit ): Promise> { const queryParameters: any = {}; if (requestParameters.inboxId) { queryParameters['inboxId'] = requestParameters.inboxId; } if (requestParameters.page !== undefined) { queryParameters['page'] = requestParameters.page; } if (requestParameters.size !== undefined) { queryParameters['size'] = requestParameters.size; } if (requestParameters.sort !== undefined) { queryParameters['sort'] = requestParameters.sort; } if (requestParameters.unreadOnly !== undefined) { queryParameters['unreadOnly'] = requestParameters.unreadOnly; } if (requestParameters.searchFilter !== undefined) { queryParameters['searchFilter'] = requestParameters.searchFilter; } if (requestParameters.since !== undefined) { queryParameters['since'] = (requestParameters.since as any).toISOString(); } if (requestParameters.before !== undefined) { queryParameters['before'] = ( requestParameters.before as any ).toISOString(); } if (requestParameters.syncConnectors !== undefined) { queryParameters['syncConnectors'] = requestParameters.syncConnectors; } if (requestParameters.favourited !== undefined) { queryParameters['favourited'] = requestParameters.favourited; } if (requestParameters.plusAddressId !== undefined) { queryParameters['plusAddressId'] = requestParameters.plusAddressId; } 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/organization`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => PageEmailProjectionFromJSON(jsonValue) ); } /** * Returns paginated emails visible through organization/team access. Supports inbox filtering, unread-only filtering, search, favourites, plus-address filtering, and optional connector sync. * List organization-visible emails */ async getOrganizationEmailsPaginated( requestParameters: GetOrganizationEmailsPaginatedRequest, initOverrides?: RequestInit ): Promise { const response = await this.getOrganizationEmailsPaginatedRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns the original unparsed SMTP/MIME message as `text/plain`. Use JSON variant if your client expects JSON transport. * Get raw email string. Returns unparsed raw SMTP message with headers and body. */ async getRawEmailContentsRaw( requestParameters: GetRawEmailContentsRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getRawEmailContents.' ); } 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}/raw`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.VoidApiResponse(response); } /** * Returns the original unparsed SMTP/MIME message as `text/plain`. Use JSON variant if your client expects JSON transport. * Get raw email string. Returns unparsed raw SMTP message with headers and body. */ async getRawEmailContents( requestParameters: GetRawEmailContentsRequest, initOverrides?: RequestInit ): Promise { await this.getRawEmailContentsRaw(requestParameters, initOverrides); } /** * Returns the original unparsed SMTP/MIME message wrapped in a JSON DTO for API clients that avoid plain-text stream responses. * Get raw email in JSON. Unparsed SMTP message in JSON wrapper format. */ async getRawEmailJsonRaw( requestParameters: GetRawEmailJsonRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling getRawEmailJson.' ); } 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}/raw/json`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => RawEmailJsonFromJSON(jsonValue) ); } /** * Returns the original unparsed SMTP/MIME message wrapped in a JSON DTO for API clients that avoid plain-text stream responses. * Get raw email in JSON. Unparsed SMTP message in JSON wrapper format. */ async getRawEmailJson( requestParameters: GetRawEmailJsonRequest, initOverrides?: RequestInit ): Promise { const response = await this.getRawEmailJsonRaw( requestParameters, initOverrides ); return await response.value(); } /** * Returns unread email count. An email is considered read after dashboard/API retrieval depending on your read workflow. * Get unread email count */ async getUnreadEmailCountRaw( requestParameters: GetUnreadEmailCountRequest, initOverrides?: RequestInit ): Promise> { 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/unreadCount`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => UnreadCountFromJSON(jsonValue) ); } /** * Returns unread email count. An email is considered read after dashboard/API retrieval depending on your read workflow. * Get unread email count */ async getUnreadEmailCount( requestParameters: GetUnreadEmailCountRequest, initOverrides?: RequestInit ): Promise { const response = await this.getUnreadEmailCountRaw( requestParameters, initOverrides ); return await response.value(); } /** * Sets read state for all emails, optionally scoped to one inbox. Use `read=false` to reset unread state in bulk. * Mark all emails as read or unread */ async markAllAsReadRaw( requestParameters: MarkAllAsReadRequest, initOverrides?: RequestInit ): Promise> { const queryParameters: any = {}; if (requestParameters.read !== undefined) { queryParameters['read'] = requestParameters.read; } 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/read`, method: 'PATCH', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.VoidApiResponse(response); } /** * Sets read state for all emails, optionally scoped to one inbox. Use `read=false` to reset unread state in bulk. * Mark all emails as read or unread */ async markAllAsRead( requestParameters: MarkAllAsReadRequest, initOverrides?: RequestInit ): Promise { await this.markAllAsReadRaw(requestParameters, initOverrides); } /** * Sets read state for one email. Useful when implementing custom mailbox workflows that treat viewed messages as unread. * Mark an email as read or unread */ async markAsReadRaw( requestParameters: MarkAsReadRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling markAsRead.' ); } const queryParameters: any = {}; if (requestParameters.read !== undefined) { queryParameters['read'] = requestParameters.read; } 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}/read`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'PATCH', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => EmailPreviewFromJSON(jsonValue) ); } /** * Sets read state for one email. Useful when implementing custom mailbox workflows that treat viewed messages as unread. * Mark an email as read or unread */ async markAsRead( requestParameters: MarkAsReadRequest, initOverrides?: RequestInit ): Promise { const response = await this.markAsReadRaw(requestParameters, initOverrides); return await response.value(); } /** * Sends a reply using the original conversation context (subject/thread headers). Reply target resolution honors sender/reply-to semantics. * Reply to an email */ async replyToEmailRaw( requestParameters: ReplyToEmailRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling replyToEmail.' ); } if ( requestParameters.replyToEmailOptions === null || requestParameters.replyToEmailOptions === undefined ) { throw new runtime.RequiredError( 'replyToEmailOptions', 'Required parameter requestParameters.replyToEmailOptions was null or undefined when calling replyToEmail.' ); } 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}`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'PUT', headers: headerParameters, query: queryParameters, body: ReplyToEmailOptionsToJSON(requestParameters.replyToEmailOptions), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => SentEmailDtoFromJSON(jsonValue) ); } /** * Sends a reply using the original conversation context (subject/thread headers). Reply target resolution honors sender/reply-to semantics. * Reply to an email */ async replyToEmail( requestParameters: ReplyToEmailRequest, initOverrides?: RequestInit ): Promise { const response = await this.replyToEmailRaw( requestParameters, initOverrides ); return await response.value(); } /** * Searches emails by sender/recipient/address/subject/id fields and returns paginated matches. Does not perform full-text body search. * Get all emails by search criteria. Return in paginated form. */ async searchEmailsRaw( requestParameters: SearchEmailsRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.searchEmailsOptions === null || requestParameters.searchEmailsOptions === undefined ) { throw new runtime.RequiredError( 'searchEmailsOptions', 'Required parameter requestParameters.searchEmailsOptions was null or undefined when calling searchEmails.' ); } const queryParameters: any = {}; if (requestParameters.syncConnectors !== undefined) { queryParameters['syncConnectors'] = requestParameters.syncConnectors; } if (requestParameters.favourited !== undefined) { queryParameters['favourited'] = requestParameters.favourited; } if (requestParameters.plusAddressId !== undefined) { queryParameters['plusAddressId'] = requestParameters.plusAddressId; } 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/search`, method: 'POST', headers: headerParameters, query: queryParameters, body: SearchEmailsOptionsToJSON(requestParameters.searchEmailsOptions), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => PageEmailProjectionFromJSON(jsonValue) ); } /** * Searches emails by sender/recipient/address/subject/id fields and returns paginated matches. Does not perform full-text body search. * Get all emails by search criteria. Return in paginated form. */ async searchEmails( requestParameters: SearchEmailsRequest, initOverrides?: RequestInit ): Promise { const response = await this.searchEmailsRaw( requestParameters, initOverrides ); return await response.value(); } /** * Sends an email from an existing inbox, or creates a temporary inbox when `inboxId` is not provided. Supports `useDomainPool` and `virtualSend` inbox creation behavior for convenience sends. * Send email */ async sendEmailSourceOptionalRaw( requestParameters: SendEmailSourceOptionalRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.sendEmailOptions === null || requestParameters.sendEmailOptions === undefined ) { throw new runtime.RequiredError( 'sendEmailOptions', 'Required parameter requestParameters.sendEmailOptions was null or undefined when calling sendEmailSourceOptional.' ); } const queryParameters: any = {}; if (requestParameters.inboxId !== undefined) { queryParameters['inboxId'] = requestParameters.inboxId; } if (requestParameters.useDomainPool !== undefined) { queryParameters['useDomainPool'] = requestParameters.useDomainPool; } if (requestParameters.virtualSend !== undefined) { queryParameters['virtualSend'] = requestParameters.virtualSend; } 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`, method: 'POST', headers: headerParameters, query: queryParameters, body: SendEmailOptionsToJSON(requestParameters.sendEmailOptions), }, initOverrides ); return new runtime.VoidApiResponse(response); } /** * Sends an email from an existing inbox, or creates a temporary inbox when `inboxId` is not provided. Supports `useDomainPool` and `virtualSend` inbox creation behavior for convenience sends. * Send email */ async sendEmailSourceOptional( requestParameters: SendEmailSourceOptionalRequest, initOverrides?: RequestInit ): Promise { await this.sendEmailSourceOptionalRaw(requestParameters, initOverrides); } /** * Sets favourite state for an email for dashboard/search workflows. * Set email favourited state */ async setEmailFavouritedRaw( requestParameters: SetEmailFavouritedRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling setEmailFavourited.' ); } if ( requestParameters.favourited === null || requestParameters.favourited === undefined ) { throw new runtime.RequiredError( 'favourited', 'Required parameter requestParameters.favourited was null or undefined when calling setEmailFavourited.' ); } const queryParameters: any = {}; if (requestParameters.favourited !== undefined) { queryParameters['favourited'] = requestParameters.favourited; } 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}/favourite`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'PUT', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.VoidApiResponse(response); } /** * Sets favourite state for an email for dashboard/search workflows. * Set email favourited state */ async setEmailFavourited( requestParameters: SetEmailFavouritedRequest, initOverrides?: RequestInit ): Promise { await this.setEmailFavouritedRaw(requestParameters, initOverrides); } /** * Runs HTML validation on the email body when HTML is present. Non-HTML emails are treated as valid for this check. * Validate email HTML contents */ async validateEmailRaw( requestParameters: ValidateEmailRequest, initOverrides?: RequestInit ): Promise> { if ( requestParameters.emailId === null || requestParameters.emailId === undefined ) { throw new runtime.RequiredError( 'emailId', 'Required parameter requestParameters.emailId was null or undefined when calling validateEmail.' ); } 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}/validate`.replace( `{${'emailId'}}`, encodeURIComponent(String(requestParameters.emailId)) ), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => ValidationDtoFromJSON(jsonValue) ); } /** * Runs HTML validation on the email body when HTML is present. Non-HTML emails are treated as valid for this check. * Validate email HTML contents */ async validateEmail( requestParameters: ValidateEmailRequest, initOverrides?: RequestInit ): Promise { const response = await this.validateEmailRaw( requestParameters, initOverrides ); return await response.value(); } } /** * @export * @enum {string} */ export enum GetEmailThreadItemsSortEnum { ASC = 'ASC', DESC = 'DESC', } /** * @export * @enum {string} */ export enum GetEmailThreadsSortEnum { ASC = 'ASC', DESC = 'DESC', } /** * @export * @enum {string} */ export enum GetEmailsOffsetPaginatedSortEnum { ASC = 'ASC', DESC = 'DESC', } /** * @export * @enum {string} */ export enum GetEmailsPaginatedSortEnum { ASC = 'ASC', DESC = 'DESC', } /** * @export * @enum {string} */ export enum GetOrganizationEmailsPaginatedSortEnum { ASC = 'ASC', DESC = 'DESC', }