react-native-persona
Version:
Launch a mobile native implementation of the Persona inquiry flow from React Native.
50 lines (49 loc) • 2.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.InquiryEvent = void 0;
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
let InquiryEvent = exports.InquiryEvent = void 0;
(function (_InquiryEvent) {
class Start {
constructor(inquiryId, sessionToken) {
_defineProperty(this, "type", 'start');
_defineProperty(this, "inquiryId", void 0);
_defineProperty(this, "sessionToken", void 0);
this.inquiryId = inquiryId;
this.sessionToken = sessionToken;
}
}
_InquiryEvent.Start = Start;
class PageChange {
constructor(name, path) {
_defineProperty(this, "type", 'page_change');
_defineProperty(this, "name", void 0);
_defineProperty(this, "path", void 0);
this.name = name;
this.path = path;
}
}
_InquiryEvent.PageChange = PageChange;
const isStart = event => {
return event.type === 'start' && event.inquiryId !== undefined && event.sessionToken !== undefined;
};
const isPageChange = event => {
return event.type === 'page_change' && event.name !== undefined && event.path !== undefined;
};
const fromJson = _InquiryEvent.fromJson = eventJson => {
let event;
if (isStart(eventJson)) {
event = new Start(eventJson.inquiryId, eventJson.sessionToken);
} else if (isPageChange(eventJson)) {
event = new PageChange(eventJson.name, eventJson.path);
} else {
event = null;
}
return event;
};
})(InquiryEvent || (exports.InquiryEvent = InquiryEvent = {}));
//# sourceMappingURL=InquiryEvent.js.map