@kineticdata/react
Version:
A React library for the Kinetic Platform
117 lines (116 loc) • 5.81 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.validateAgent = exports.updateTaskComponent = exports.updateAgentComponent = exports.fetchTaskComponent = exports.fetchAgentComponents = exports.fetchAgentComponentVersion = exports.fetchAgentComponent = exports.deleteAgentComponent = exports.createAgentComponent = void 0;
var _axios = _interopRequireDefault(require("axios"));
var _helpers = require("../../helpers");
var _http = require("../http");
var fetchTaskComponent = exports.fetchTaskComponent = function fetchTaskComponent() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('fetchTaskComponent', [], options);
return _axios["default"].get("".concat(_helpers.bundle.apiLocation(), "/platformComponents/task"), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
task: response.data.task
};
})["catch"](_http.handleErrors);
};
var updateTaskComponent = exports.updateTaskComponent = function updateTaskComponent() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('updateTaskComponent', ['task'], options);
return _axios["default"].put("".concat(_helpers.bundle.apiLocation(), "/platformComponents/task"), options.task, {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
task: response.data.task
};
})["catch"](_http.handleErrors);
};
var fetchAgentComponents = exports.fetchAgentComponents = function fetchAgentComponents() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return _axios["default"].get("".concat(_helpers.bundle.apiLocation(), "/platformComponents/agents"), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
agents: response.data.agents
};
})["catch"](_http.handleErrors);
};
var fetchAgentComponent = exports.fetchAgentComponent = function fetchAgentComponent() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('fetchAgentComponent', ['slug'], options);
return _axios["default"].get("".concat(_helpers.bundle.apiLocation(), "/platformComponents/agents/").concat(options.slug), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
agent: response.data.agent
};
})["catch"](_http.handleErrors);
};
var createAgentComponent = exports.createAgentComponent = function createAgentComponent() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('createAgentComponent', ['agent'], options);
return _axios["default"].post("".concat(_helpers.bundle.apiLocation(), "/platformComponents/agents"), options.agent, {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
agent: response.data.agent
};
})["catch"](_http.handleErrors);
};
var updateAgentComponent = exports.updateAgentComponent = function updateAgentComponent() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('updateAgentComponent', ['slug', 'agent'], options);
return _axios["default"].put("".concat(_helpers.bundle.apiLocation(), "/platformComponents/agents/").concat(options.slug), options.agent, {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
agent: response.data.agent
};
})["catch"](_http.handleErrors);
};
var deleteAgentComponent = exports.deleteAgentComponent = function deleteAgentComponent() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('deleteAgentComponent', ['slug'], options);
return _axios["default"]["delete"]("".concat(_helpers.bundle.apiLocation(), "/platformComponents/agents/").concat(options.slug), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
agent: response.data.agent
};
})["catch"](_http.handleErrors);
};
var validateAgent = exports.validateAgent = function validateAgent() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('validateAgent', [], options);
return _axios["default"].get("".concat((0, _helpers.buildAgentPath)(options), "/app/api/v1/bridges"), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
successMessage: "".concat(options.agentSlug, " has been successfully validated.")
};
})["catch"](_http.handleErrors);
};
var fetchAgentComponentVersion = exports.fetchAgentComponentVersion = function fetchAgentComponentVersion() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _http.validateOptions)('validateAgent', [], options);
return _axios["default"].get("".concat((0, _helpers.buildAgentPath)(options), "/app/api/v1/version"), {
params: (0, _http.paramBuilder)(options),
headers: (0, _http.headerBuilder)(options)
}).then(function (response) {
return {
version: response.data.version
};
})["catch"](_http.handleErrors);
};