"use strict";

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

var _instance = _interopRequireDefault(require("./instance"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

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); }); }; }

// const isDev = !!window.location.hostname.match(/work/)
var sendData = function sendData(fields, objectName) {
  return _instance["default"].post('https://skynet-apis.tita.cloud/api/v1/nps/insert', JSON.stringify(fields), {
    headers: Object.assign({
      'Content-Type': 'application/json;charset=utf-8;',
      'x-meta': objectName
    })
  }).then(function (res) {
    return res;
  });
};

exports.sendData = sendData;

var getData = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(objectName) {
    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", _instance["default"].get('https://skynet-apis.tita.cloud/api/v1/nps/list?name=' + objectName).then(function (res) {
              return res;
            }));

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

  return function getData(_x) {
    return _ref.apply(this, arguments);
  };
}(); // export const updateData = () =>{
//   return axios
//   .post(
//     "https://tracker.tita.com/api/v1/metas/update",
//     {
//       "id": recordId,
//       "fields": [
//         { "name": "issue_status", "type": "string", "value": "解决中" },
//         { "name": "issue_owner", "type": "string", "value": newPrinciple },
//         { "name": "issue_bug_start_unix", "type": "long", "value": Math.round(new Date().getTime() / 1000) },
//       ],
//       "objectName": "sentry_issue",
//     },
//     {
//       "headers": Object.assign(
//         {
//           "Content-Type": "application/json",
//           "authorization":localStorage.getItem('BUGFREE_JWT_TOKEN'),
//         },
//         authHeaders,
//       ),
//     },
//   )
//   .then(res => {
//     return res;
//   });
// }


exports.getData = getData;