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

/**
 * 用于获取用户信息，同时也可以用来校验 AccessToken 的有效性。
 * @example
 * ```ts
 * const info = await getTencentDocUserInfo({ accessToken: 'xxx' });
 * console.log(info);
 * // { ret: 0, msg: 'ok', data: { user_name: '...', avatar_url: '...' } }
 * ```
 */
function getTencentDocUserInfo(_ref) {
  var accessToken = _ref.accessToken;
  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: 'GET',
            url: 'https://docs.qq.com/oauth/v2/userinfo',
            params: {
              access_token: accessToken
            }
          });
        case 1:
          result = _context.sent;
          return _context.abrupt("return", result.data);
        case 2:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
}

export { getTencentDocUserInfo };
