@iotile/iotile-cloud
Version:
A typescript library for interfacing with the IOTile Cloud API
62 lines • 2.32 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var index_file_1 = require("./index-file");
var user_1 = require("./user");
var GeneratedReport = /** @class */ (function () {
function GeneratedReport(data) {
if (data === void 0) { data = {}; }
this.userInfo = new user_1.User();
this.id = data['id'] || '';
this.label = data['label'] || '';
this.sourceRef = data['source_ref'] || '';
this.createdOn = new Date(data['created_on']) || new Date();
this.createdBy = data['created_by'] || '';
this.org = data['org'] || '';
this.status = data['status'] || '';
this.template = data['template'] || '';
this.groupSlug = data['group_slug'] || '';
this.token = data['token'] || '';
this.userInfo.email = data['user'] || '';
if ('index_file' in data && data['index_file'] != null) {
this.indexFile = new index_file_1.IndexFile(data['index_file']);
}
else {
delete this.indexFile;
}
if ('user_info' in data && data['user_info'] != null) {
this.userInfo.username = data['user_info']['username'];
this.userInfo.slug = data['user_info']['slug'];
this.userInfo.avatarUrl = data['user_info']['tiny_avatar'];
}
if ('args' in data && data['args'] != null) {
this.args = data['args'];
}
else {
delete this.args;
}
}
GeneratedReport.prototype.getSchedulPostPayload = function () {
var payload = {
slug: this.sourceRef,
template: this.template
};
if (this.args) {
payload.args = this.args;
}
if (!payload.slug || !payload.template) {
throw new Error("Payload cannot be returned because of missing fields: " + JSON.stringify(payload, null, 2) + ".");
}
return payload;
};
GeneratedReport.prototype.getStatusDisplay = function () {
var factory = {
'G0': 'In Progress...',
'G1': 'Completed',
'GE': 'Error'
};
return factory[this.status];
};
return GeneratedReport;
}());
exports.GeneratedReport = GeneratedReport;
//# sourceMappingURL=generated-report.js.map