"use strict";

require("core-js/modules/es.object.to-string.js");

require("core-js/modules/es.promise.js");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ProtectedPdf = void 0;

require("core-js/modules/es.array.concat.js");

require("core-js/modules/es.object.define-property.js");

require("regenerator-runtime/runtime.js");

var _common = require("../../common");

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

var ProtectedPdf = /*#__PURE__*/function () {
  function ProtectedPdf() {
    _classCallCheck(this, ProtectedPdf);
  }

  _createClass(ProtectedPdf, null, [{
    key: "serviceName",
    get: function get() {
      return "uploads";
    }
  }, {
    key: "get",
    value: function () {
      var _get = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(payload) {
        var server;
        return regeneratorRuntime.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                server = new _common.APIServer();
                _context.next = 3;
                return server.post("".concat(ProtectedPdf.serviceName, "/protected-pdf-file"), undefined, payload);

              case 3:
                return _context.abrupt("return", _context.sent);

              case 4:
              case "end":
                return _context.stop();
            }
          }
        }, _callee);
      }));

      function get(_x) {
        return _get.apply(this, arguments);
      }

      return get;
    }()
  }, {
    key: "getFileName",
    value: function () {
      var _getFileName = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(fileShareId) {
        var server, response;
        return regeneratorRuntime.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                server = new _common.APIServer();
                _context2.next = 3;
                return server.get("".concat(ProtectedPdf.serviceName, "/protected-pdf-name/").concat(fileShareId));

              case 3:
                response = _context2.sent;

                if (!response.error) {
                  _context2.next = 6;
                  break;
                }

                throw new _common.APIResponseError("Error during getting protected pdf file name", response);

              case 6:
                return _context2.abrupt("return", response.data.file_name);

              case 7:
              case "end":
                return _context2.stop();
            }
          }
        }, _callee2);
      }));

      function getFileName(_x2) {
        return _getFileName.apply(this, arguments);
      }

      return getFileName;
    }()
  }]);

  return ProtectedPdf;
}();

exports.ProtectedPdf = ProtectedPdf;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy91cGxvYWRzL3Byb3RlY3RlZC1wZGYvcHJvdGVjdGVkLXBkZi50cyJdLCJuYW1lcyI6WyJQcm90ZWN0ZWRQZGYiLCJwYXlsb2FkIiwic2VydmVyIiwiQVBJU2VydmVyIiwicG9zdCIsInNlcnZpY2VOYW1lIiwidW5kZWZpbmVkIiwiZmlsZVNoYXJlSWQiLCJnZXQiLCJyZXNwb25zZSIsImVycm9yIiwiQVBJUmVzcG9uc2VFcnJvciIsImRhdGEiLCJmaWxlX25hbWUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7Ozs7Ozs7Ozs7OztJQU1hQSxZOzs7Ozs7O1NBQ1gsZUFBd0M7QUFDdEMsYUFBTyxTQUFQO0FBQ0Q7Ozs7eUVBRU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