notifme/notifme-sdk

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

Summary

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

export default class VoiceNotificationCatcherProvider extends NotificationCatcherProvider {
  async send (request: VoiceRequestType): Promise<string> {
    const { to, from, url } = request.customize ? (await request.customize(this.id, request)) : request
    return this.sendToCatcher({
      to: `${to}@voice`,
      from,
      subject: `${to}@voice`,
      text: url,
      headers: {
        'X-type': 'voice',
        'X-to': `[voice] ${to}`
      }
    })
  }
}