1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-frontend/public/js/stores/StrategyAPI.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
const reqwest = require('reqwest');
2015-03-17 22:01:46 +01:00
2016-06-18 21:53:18 +02:00
const TYPE = 'json';
const CONTENT_TYPE = 'application/json';
2015-03-17 22:01:46 +01:00
2016-06-18 21:53:18 +02:00
const StrategyAPI = {
2016-07-02 11:54:50 +02:00
createStrategy (strategy, cb) {
2015-03-17 22:01:46 +01:00
reqwest({
url: 'strategies',
method: 'post',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(strategy),
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
2015-03-17 22:01:46 +01:00
},
2016-07-02 11:54:50 +02:00
success () {
cb(null, strategy);
2016-06-18 21:55:46 +02:00
},
2015-03-17 22:01:46 +01:00
});
},
2016-07-02 11:54:50 +02:00
removeStrategy (strategy, cb) {
2015-03-17 22:01:46 +01:00
reqwest({
2016-06-18 21:53:18 +02:00
url: `strategies/${strategy.name}`,
2015-03-17 22:01:46 +01:00
method: 'delete',
type: TYPE,
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
2015-03-17 22:01:46 +01:00
},
2016-07-02 11:54:50 +02:00
success () {
cb(null, strategy);
2016-06-18 21:55:46 +02:00
},
2015-03-17 22:01:46 +01:00
});
},
2016-07-02 11:54:50 +02:00
getStrategies (cb) {
2015-03-17 22:01:46 +01:00
reqwest({
url: 'strategies',
method: 'get',
type: TYPE,
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
2015-03-17 22:01:46 +01:00
},
2016-07-02 11:54:50 +02:00
success (data) {
cb(null, data.strategies);
2016-06-18 21:55:46 +02:00
},
2015-03-17 22:01:46 +01:00
});
2016-06-18 21:55:46 +02:00
},
2015-03-17 22:01:46 +01:00
};
module.exports = StrategyAPI;