mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
var reqwest = require('reqwest');
|
|
|
|
var TYPE = 'json';
|
|
var CONTENT_TYPE = 'application/json';
|
|
|
|
var StrategyAPI = {
|
|
createStrategy: function (strategy, cb) {
|
|
reqwest({
|
|
url: 'strategies',
|
|
method: 'post',
|
|
type: TYPE,
|
|
contentType: CONTENT_TYPE,
|
|
data: JSON.stringify(strategy),
|
|
error: function(error) {
|
|
cb(error);
|
|
},
|
|
success: function() {
|
|
cb(null, strategy);
|
|
}
|
|
});
|
|
},
|
|
|
|
removeStrategy: function (strategy, cb) {
|
|
reqwest({
|
|
url: 'strategies/'+strategy.name,
|
|
method: 'delete',
|
|
type: TYPE,
|
|
error: function(error) {
|
|
cb(error);
|
|
},
|
|
success: function() {
|
|
cb(null, strategy);
|
|
}
|
|
});
|
|
},
|
|
|
|
getStrategies: function (cb) {
|
|
reqwest({
|
|
url: 'strategies',
|
|
method: 'get',
|
|
type: TYPE,
|
|
error: function(error) {
|
|
cb(error);
|
|
},
|
|
success: function(data) {
|
|
cb(null, data.strategies);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = StrategyAPI;
|