swagger-pack
Version:
test of swagger generated angular models/services and possibility to reuse them
56 lines (55 loc) • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/* tslint:disable */
const http_1 = require("@angular/common/http");
/**
* Custom parameter codec to correctly handle the plus sign in parameter
* values. See https://github.com/angular/angular/issues/18261
*/
class ParameterCodec {
encodeKey(key) {
return encodeURIComponent(key);
}
encodeValue(value) {
return encodeURIComponent(value);
}
decodeKey(key) {
return decodeURIComponent(key);
}
decodeValue(value) {
return decodeURIComponent(value);
}
}
const PARAMETER_CODEC = new ParameterCodec();
/**
* Base class for API services
*/
class BaseService {
constructor(config, http) {
this.config = config;
this.http = http;
this._rootUrl = '';
}
/**
* Returns the root url for API operations. If not set directly in this
* service, will fallback to ApiConfiguration.rootUrl.
*/
get rootUrl() {
return this._rootUrl || this.config.rootUrl;
}
/**
* Sets the root URL for API operations in this service.
*/
set rootUrl(rootUrl) {
this._rootUrl = rootUrl;
}
/**
* Creates a new `HttpParams` with the correct codec
*/
newParams() {
return new http_1.HttpParams({
encoder: PARAMETER_CODEC
});
}
}
exports.BaseService = BaseService;