import _regeneratorRuntime from '@babel/runtime/regenerator';
import { _ as __awaiter } from '../tslib.es6-848120af.js';
import axios from 'axios';

function updateTencentSheet(_ref) {
  var accessToken = _ref.accessToken,
    clientId = _ref.clientId,
    openId = _ref.openId,
    bookId = _ref.bookId,
    range = _ref.range,
    values = _ref.values;
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
    var result;
    return _regeneratorRuntime.wrap(function (_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _context.next = 1;
          return axios({
            method: 'PUT',
            url: "https://docs.qq.com/openapi/sheetbook/v2/".concat(bookId, "/values/").concat(range),
            headers: {
              'Access-Token': accessToken,
              'Client-Id': clientId,
              'Open-Id': openId,
              'Content-Type': 'application/json'
            },
            data: {
              values: values
            }
          });
        case 1:
          result = _context.sent;
          return _context.abrupt("return", result.data);
        case 2:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
}
function updateTencentSheetImage(_ref2) {
  var accessToken = _ref2.accessToken,
    clientId = _ref2.clientId,
    openId = _ref2.openId,
    bookId = _ref2.bookId,
    insertImages = _ref2.insertImages;
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
    var result;
    return _regeneratorRuntime.wrap(function (_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          _context2.next = 1;
          return axios({
            method: 'POST',
            url: "https://docs.qq.com/openapi/sheetbook/v2/".concat(bookId, ":batchUpdate"),
            headers: {
              'Access-Token': accessToken,
              'Client-Id': clientId,
              'Open-Id': openId,
              'Content-Type': 'application/json'
            },
            data: {
              bookID: bookId,
              insertImages: insertImages
            }
          });
        case 1:
          result = _context2.sent;
          return _context2.abrupt("return", result.data);
        case 2:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  }));
}
function batchUpdateTencentSheetV3(_ref3) {
  var accessToken = _ref3.accessToken,
    clientId = _ref3.clientId,
    openId = _ref3.openId,
    bookId = _ref3.bookId,
    requests = _ref3.requests;
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
    var result;
    return _regeneratorRuntime.wrap(function (_context3) {
      while (1) switch (_context3.prev = _context3.next) {
        case 0:
          _context3.next = 1;
          return axios({
            method: 'POST',
            url: "https://docs.qq.com/openapi/spreadsheet/v3/files/".concat(bookId, "/batchUpdate"),
            headers: {
              'Access-Token': accessToken,
              'Client-Id': clientId,
              'Open-Id': openId,
              'Content-Type': 'application/json'
            },
            data: {
              requests: requests
            }
          });
        case 1:
          result = _context3.sent;
          return _context3.abrupt("return", result.data);
        case 2:
        case "end":
          return _context3.stop();
      }
    }, _callee3);
  }));
}

export { batchUpdateTencentSheetV3, updateTencentSheet, updateTencentSheetImage };
