@iotile/iotile-cloud
Version:
A typescript library for interfacing with the IOTile Cloud API
66 lines • 2.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var DataFilterArgs = /** @class */ (function () {
function DataFilterArgs() {
}
DataFilterArgs.prototype.buildFilterString = function () {
var parameters = [];
if (this.startDate) {
parameters.push('start=' + this.startDate.toISOString());
}
var now = new Date();
if (!this.endDate || this.endDate > now) {
this.endDate = now;
}
if (this.endDate) {
parameters.push('end=' + this.endDate.toISOString());
}
if (this.lastN) {
parameters.push('lastn=' + this.lastN);
}
if (this.page) {
parameters.push('page=' + this.page);
}
if (this.pageSize) {
parameters.push('page_size=' + this.pageSize);
}
if (this.filter) {
parameters.push('filter=' + this.filter);
}
if (this.startIncrementalId) {
parameters.push('streamer_id_0=' + this.startIncrementalId);
}
if (this.endIncrementalId) {
parameters.push('streamer_id_1=' + this.endIncrementalId);
}
if (this.extras && this.extras.length > 0) {
this.extras.forEach(function (p) {
parameters.push(p);
});
}
if (parameters.length) {
var dataFilter = '?' + parameters.join('&');
return dataFilter;
}
return '';
};
DataFilterArgs.prototype.buildFilterLabel = function () {
var filterLabel = '';
if (this.startDate) {
filterLabel += ' from ' + this.startDate.toLocaleDateString('en-US');
}
if (this.endDate) {
filterLabel += ' to ' + this.endDate.toLocaleDateString('en-US');
}
if (this.lastN) {
filterLabel += ' last ' + this.lastN + ' entries';
}
if (!this.startDate && !this.endDate && !this.lastN) {
filterLabel = '';
}
return filterLabel;
};
return DataFilterArgs;
}());
exports.DataFilterArgs = DataFilterArgs;
//# sourceMappingURL=datafilterargs.js.map