credger/public/ts/services/API.ts

39 lines
939 B
TypeScript
Raw Normal View History

2017-11-24 10:58:58 +01:00
app.service('API',
['$http',
function($http) {
let API = this;
2017-11-27 15:19:10 +01:00
API.balance = function(period, categories, depth) {
2017-11-24 10:58:58 +01:00
return $http.get('/api/ledger/balance', {
params: {
2017-11-24 14:58:56 +01:00
period: period,
categories: categories,
depth: depth
2017-11-24 10:58:58 +01:00
}
});
2017-11-27 15:19:10 +01:00
};
2017-11-24 10:58:58 +01:00
2017-11-27 15:19:10 +01:00
API.register = function(period, categories) {
2017-11-24 10:58:58 +01:00
return $http.get('/api/ledger/register', {
params: {
2017-11-24 14:58:56 +01:00
period: period,
categories: categories
2017-11-24 10:58:58 +01:00
}
});
2017-11-27 15:19:10 +01:00
};
2017-11-24 10:58:58 +01:00
2017-12-15 20:25:37 +01:00
API.graph_values = function(period, granularity, categories) {
2017-11-24 10:58:58 +01:00
return $http.get('/api/ledger/graph_values', {
params: {
2017-11-24 14:58:56 +01:00
period: period,
2017-12-15 20:25:37 +01:00
granularity: granularity,
2017-11-24 14:58:56 +01:00
categories: categories
2017-11-24 10:58:58 +01:00
}
});
2017-11-27 15:19:10 +01:00
};
2017-11-24 10:58:58 +01:00
2017-11-24 14:58:56 +01:00
API.accounts = _.memoize(function() {
2017-11-24 10:58:58 +01:00
return $http.get('/api/ledger/accounts');
2017-11-24 14:58:56 +01:00
});
2017-11-24 10:58:58 +01:00
}]);