lib/providers/sms/notificationCatcher.js
"use strict";
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
var _notificationCatcherProvider = _interopRequireDefault(require("../notificationCatcherProvider"));
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
// Types
var SmsNotificationCatcherProvider = exports["default"] = /*#__PURE__*/function (_NotificationCatcherP) {
function SmsNotificationCatcherProvider() {
(0, _classCallCheck2["default"])(this, SmsNotificationCatcherProvider);
return _callSuper(this, SmsNotificationCatcherProvider, arguments);
}
(0, _inherits2["default"])(SmsNotificationCatcherProvider, _NotificationCatcherP);
return (0, _createClass2["default"])(SmsNotificationCatcherProvider, [{
key: "send",
value: function () {
var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
var _ref, to, from, text;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (!request.customize) {
_context.next = 6;
break;
}
_context.next = 3;
return request.customize(this.id, request);
case 3:
_context.t0 = _context.sent;
_context.next = 7;
break;
case 6:
_context.t0 = request;
case 7:
_ref = _context.t0;
to = _ref.to;
from = _ref.from;
text = _ref.text;
return _context.abrupt("return", this.sendToCatcher({
to: "".concat(to, "@sms"),
from: from,
subject: "".concat(text.substring(0, 20)).concat(text.length > 20 ? '...' : ''),
text: text,
headers: {
'X-type': 'sms',
'X-to': "[sms] ".concat(to)
}
}));
case 12:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function send(_x) {
return _send.apply(this, arguments);
}
return send;
}()
}]);
}(_notificationCatcherProvider["default"]);