UNPKG

e2e-mailbox

Version:

E2E test your email notification system using GuerrillaMail API.

62 lines (61 loc) 2.85 kB
import { EmailResponse, MailboxProvider, SetEmailResponse } from '../types'; import MailboxService from './mailboxService'; declare class GuerrillaMailService extends MailboxService { API_URL: string; PROVIDER: MailboxProvider; private sidToken; /** * Send request to the GuerrillaMail API. * @param payload * @param isRetry * @returns AxiosResponse on success, undefined on failure. */ private sendRequest; /** * Initialize a session and set the client with an email address. If the session already exists, * then it will return the email address details of the existing session. If a new session needs to be created, then it * will first check for the SUBSCR cookie to create a session for a subscribed address, otherwise it will create new email * address randomly. * @returns email address */ createEmailAddress(): Promise<string>; /** * Get the current list of emails from the email inbox. * @returns Array of emails */ fetchEmailList(): Promise<EmailResponse[]>; /** * Set the email address to a different email address. If the email address is a subscriber, * then return the subscription details. If the email is not a subscriber, then the email address * will be given 60 minutes again. A new email address will be generated if the email address is * not in the database and a welcome email message will be generated. * @param emailAddress * @returns True on success, false on failure */ setEmailAddress(emailAddress: string): Promise<SetEmailResponse | undefined>; /** * Forget the current email address. This will not stop the session, the existing session will be maintained. * A subsequent call to get_email_address will fetch a new email address or the client can call set_email_user * to set a new address. Typically, a user would want to set a new address manually after clicking the * ‘forget me’ button. * @param emailAddress * @returns True on success, false on failure */ forgetEmailAddress(emailAddress: string): Promise<boolean | undefined>; /** * Delete a specific email by ID. * @param emailId * @returns true on success, false on failure */ deleteEmailById(emailId: string): Promise<boolean | undefined>; /** * Get the contents of an email. All HTML in the body of the email is filtered. * Eg, Javascript, applets, iframes, etc is removed. Subject and email excerpt are escaped using HTML Entities. * Only emails owned by the current session id can be fetched. * @param emailId * @returns */ fetchEmailById(emailId: string): Promise<EmailResponse | undefined>; sendSelfMail(subject: string, body: string): Promise<boolean>; } export default GuerrillaMailService;