notifme/notifme-sdk

View on GitHub
src/providers/email/notificationCatcher.js

Summary

Maintainability
A
1 hr
Test Coverage
A
100%
/* @flow */
import NotificationCatcherProvider from '../notificationCatcherProvider'
// Types
import type { EmailRequestType } from '../../models/notification-request'

export default class EmailNotificationCatcherProvider extends NotificationCatcherProvider {
  async send (request: EmailRequestType): Promise<string> {
    const { to, from, html, text, subject, replyTo, attachments } =
      request.customize ? (await request.customize(this.id, request)) : request
    return this.sendToCatcher({
      to,
      from,
      html,
      text,
      subject,
      replyTo,
      attachments,
      headers: {
        'X-to': `[email] ${to}`
      }
    })
  }
}