@kineticdata/react
Version:
A React library for the Kinetic Platform
99 lines (94 loc) • 3.86 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateTeam = exports.fetchTeams = exports.fetchTeam = exports.deleteTeam = exports.createTeam = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
var _axios = _interopRequireDefault(require("axios"));
var _helpers = require("../../helpers");
var _http = require("../http");
var fetchTeams = exports.fetchTeams = function fetchTeams() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// Build URL and fetch the space.
return _axios["default"].get("".concat(_helpers.bundle.apiLocation(), "/teams"), {
params: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _http.paramBuilder)(options)), {}, {
archived: options.archived
}),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
teams: response.data.teams,
count: response.data.count,
nextPageToken: response.data.nextPageToken
};
})["catch"](_http.handleErrors);
};
var fetchTeam = exports.fetchTeam = function fetchTeam() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var teamSlug = options.teamSlug;
if (!teamSlug) {
throw new Error('fetchTeam failed! The option "teamSlug" is required.');
}
// Build URL and fetch the space.
return _axios["default"].get("".concat(_helpers.bundle.apiLocation(), "/teams/").concat(teamSlug), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
team: response.data.team
};
})["catch"](_http.handleErrors);
};
var updateTeam = exports.updateTeam = function updateTeam() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var teamSlug = options.teamSlug,
team = options.team;
if (!teamSlug) {
throw new Error('updateTeam failed! The option "teamSlug" is required.');
}
if (!team) {
throw new Error('updateTeam failed! The option "team" is required.');
}
// Build URL and fetch the space.
return _axios["default"].put("".concat(_helpers.bundle.apiLocation(), "/teams/").concat(teamSlug), team, {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
team: response.data.team
};
})["catch"](_http.handleErrors);
};
var createTeam = exports.createTeam = function createTeam() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var team = options.team;
if (!team) {
throw new Error('createTeam failed! The option "team" is required.');
}
// Build URL and fetch the space.
return _axios["default"].post("".concat(_helpers.bundle.apiLocation(), "/teams"), team, {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
team: response.data.team
};
})["catch"](_http.handleErrors);
};
var deleteTeam = exports.deleteTeam = function deleteTeam() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var teamSlug = options.teamSlug;
if (!teamSlug) {
throw new Error('deleteTeam failed! The option "teamSlug" is required.');
}
// Build URL and fetch the space.
return _axios["default"]["delete"]("".concat(_helpers.bundle.apiLocation(), "/teams/").concat(teamSlug), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
team: response.data.team
};
})["catch"](_http.handleErrors);
};