kentico-cloud-delivery
Version:
Official Kentico Cloud Delivery SDK
53 lines • 1.77 kB
JavaScript
import { Parameters } from '../../models';
var BaseQuery = /** @class */ (function () {
function BaseQuery(config, queryService) {
this.config = config;
this.queryService = queryService;
this.parameters = [];
}
/**
* Adds parameter to query
* @param name Name of parameter
* @param value Value of parameter
*/
BaseQuery.prototype.withParameter = function (name, value) {
this.parameters.push(new Parameters.QueryParameter(name, value));
return this;
};
/**
* Adds parameters to query
* @param parameters Array of parameters
*/
BaseQuery.prototype.withParameters = function (parameters) {
var _a;
(_a = this.parameters).push.apply(_a, parameters);
return this;
};
/**
* Gets headers used by this query
*/
BaseQuery.prototype.getHeaders = function () {
return this.queryService.getHeaders(this._queryConfig);
};
BaseQuery.prototype.withUrl = function (url) {
this.customUrl = url;
return this;
};
BaseQuery.prototype.getParameters = function () {
return this.parameters;
};
BaseQuery.prototype.toPromise = function () {
return this.queryService.retryPromise(this.toObservable().toPromise());
};
BaseQuery.prototype.resolveUrlInternal = function (action) {
// use custom URL if user specified it
if (this.customUrl) {
return this.customUrl;
}
// use original url
return this.queryService.getUrl(action, this._queryConfig, this.getParameters());
};
return BaseQuery;
}());
export { BaseQuery };
//# sourceMappingURL=base-query.class.js.map