search-client
Version:
Javascript library for executing searches in the Haive search-index via the SearchManager REST interface.
35 lines • 1.26 kB
JavaScript
import moment from 'moment';
var BaseQueryConverter = /** @class */ (function () {
function BaseQueryConverter() {
}
/**
* Returns the url for the REST API.
*
* @param baseUrl is the leading part of the url that is to be generated.
* @param query is the query that is to be converted into the url.
* @returns The url to use for fetching the date, represented as a string.
*/
BaseQueryConverter.prototype.getUrl = function (url, query) {
var params = this.getUrlParams(query).sort();
return url + "?" + params.join('&');
};
BaseQueryConverter.prototype.addParamIfSet = function (params, key, param) {
var value = param.toString();
if (value) {
params.push(key + "=" + encodeURIComponent(value));
}
};
BaseQueryConverter.prototype.createDate = function (date) {
if (!date) {
return '';
}
return typeof date === 'object' &&
!(date instanceof String) &&
!(date instanceof Date)
? moment().add(date).toISOString()
: moment(date).toISOString();
};
return BaseQueryConverter;
}());
export { BaseQueryConverter };
//# sourceMappingURL=BaseQueryConverter.js.map