UNPKG

@adv-ui/boros-tcf

Version:

Adevinta GDPR - Transparency and Consent Framework - API

114 lines (84 loc) 4.17 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.LoadUserConsentUseCase = void 0; var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator")); var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/inheritsLoose")); var _ioc = require("../../../core/ioc/ioc"); var _LoadConsentService = require("../../../domain/consent/LoadConsentService"); var _EventStatusService = require("../../../domain/service/EventStatusService"); var _ConsentFactory = require("../../../domain/consent/ConsentFactory"); var _AsyncUseCase2 = require("../AsyncUseCase"); var _DomainEventBus = require("../../../domain/service/DomainEventBus"); var _constants = require("../../../core/constants"); var LoadUserConsentUseCase = /*#__PURE__*/function (_AsyncUseCase) { (0, _inheritsLoose2["default"])(LoadUserConsentUseCase, _AsyncUseCase); function LoadUserConsentUseCase(_temp) { var _this; var _ref = _temp === void 0 ? {} : _temp, _ref$domainEventBus = _ref.domainEventBus, domainEventBus = _ref$domainEventBus === void 0 ? (0, _ioc.inject)(_DomainEventBus.DomainEventBus) : _ref$domainEventBus, _ref$loadConsentServi = _ref.loadConsentService, loadConsentService = _ref$loadConsentServi === void 0 ? (0, _ioc.inject)(_LoadConsentService.LoadConsentService) : _ref$loadConsentServi, _ref$eventStatusServi = _ref.eventStatusService, eventStatusService = _ref$eventStatusServi === void 0 ? (0, _ioc.inject)(_EventStatusService.EventStatusService) : _ref$eventStatusServi, _ref$consentFactory = _ref.consentFactory, consentFactory = _ref$consentFactory === void 0 ? (0, _ioc.inject)(_ConsentFactory.ConsentFactory) : _ref$consentFactory; _this = _AsyncUseCase.call(this) || this; _this._domainEventBus = domainEventBus; _this._loadConsentService = loadConsentService; _this._eventStatusService = eventStatusService; _this._consentFactory = consentFactory; return _this; } var _proto = LoadUserConsentUseCase.prototype; _proto.execute = /*#__PURE__*/function () { var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_temp2) { var _ref2, _ref2$notify, notify, consent, consentDto, _consent; return _regenerator["default"].wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _ref2 = _temp2 === void 0 ? {} : _temp2, _ref2$notify = _ref2.notify, notify = _ref2$notify === void 0 ? false : _ref2$notify; _context.prev = 1; _context.next = 4; return this._loadConsentService.loadConsent(); case 4: consent = _context.sent; consentDto = consent.toJSON(); if (consentDto.valid) { this._eventStatusService.updateTCLoaded({ notify: notify }); } return _context.abrupt("return", consentDto); case 10: _context.prev = 10; _context.t0 = _context["catch"](1); this._domainEventBus.raise({ eventName: _constants.EVENT_LOAD_CONSENT_ERROR, payload: { error: _context.t0 } }); _consent = this._consentFactory.createEmpty(); return _context.abrupt("return", _consent.toJSON()); case 15: case "end": return _context.stop(); } } }, _callee, this, [[1, 10]]); })); function execute(_x) { return _execute.apply(this, arguments); } return execute; }(); return LoadUserConsentUseCase; }(_AsyncUseCase2.AsyncUseCase); exports.LoadUserConsentUseCase = LoadUserConsentUseCase; LoadUserConsentUseCase.ID = 'LoadUserConsentUseCase';