rs-restangular
Version:
Restful Resources service for Angular 2 apps
53 lines • 2.1 kB
JavaScript
;
var http_1 = require('./http');
var one_path_1 = require('./one-path');
var all_path_1 = require('./all-path');
require('rxjs/add/operator/map');
var RestangularPath = (function () {
function RestangularPath(config, parent) {
this.config = config;
this.parent = parent;
}
RestangularPath.prototype.__normalizeRoute = function (route) {
return route.replace(/^\/+|\/+$/g, '');
};
RestangularPath.prototype.all = function (route) {
this.route = new all_path_1.RestangularAllPath(this.__normalizeRoute(route));
return new RestangularPath(this.config, this);
};
RestangularPath.prototype.one = function (route, id) {
this.route = new one_path_1.RestangularOnePath(this.__normalizeRoute(route), id);
return new RestangularPath(this.config, this);
};
RestangularPath.prototype.get = function (options) {
return http_1.RestangularHttp.get(this, options);
};
RestangularPath.prototype.getList = function (options) {
return http_1.RestangularHttp.getList(this, options);
};
RestangularPath.prototype.post = function (body, options) {
return http_1.RestangularHttp.post(this, body, options);
};
RestangularPath.prototype.put = function (body, options) {
return http_1.RestangularHttp.put(this, body, options);
};
RestangularPath.prototype.remove = function (options) {
return http_1.RestangularHttp.remove(this, options);
};
RestangularPath.prototype.toArray = function () {
var path = [];
var current = this;
while (current.parent) {
path.push.apply(path, current.parent.route.path().reverse());
current = current.parent;
}
path.push(this.config.baseUrl);
return path.reverse();
};
RestangularPath.prototype.toString = function () {
return this.toArray().join('/');
};
return RestangularPath;
}());
exports.RestangularPath = RestangularPath;
//# sourceMappingURL=/home/rodolfosilva/htdocs/outros/restangular/src/path.js.map