@publidata/utils-data-manager
Version:
Collection of methods to extract data from publidata
68 lines (55 loc) • 1.45 kB
JavaScript
const PublidataObject = require("../");
/**
* Class representing an alert.
* @extends PublidataObject
*/
class PublidataObjectAlert extends PublidataObject {
get blurb() {
const { blurb } = this._source;
return this.memoize("blurb", blurb);
}
get endAt() {
const { end_at } = this._source;
return this.memoize("endAt", end_at);
}
get id() {
const { id } = this._source;
return this.memoize("id", id);
}
get linkedObjects() {
const { linked_objects } = this._source;
return this.memoize("linkedObjects", linked_objects);
}
get name() {
const { name } = this._source;
return this.memoize("name", name);
}
get publishedAt() {
const { published_at } = this._source;
return this.memoize("publishedAt", published_at);
}
get source() {
return this.memoize("source", this._source);
}
get startAt() {
const { start_at } = this._source;
return this.memoize("startAt", start_at);
}
get type () {
const { alert_type, type} = this._source;
return this.memoize("type", alert_type || type);
}
toJSON() {
const json = {};
json.blurb = this.blurb;
json.endAt = this.endAt;
json.id = this.id;
json.linkedObjects = this.linkedObjects;
json.name = this.name;
json.publishedAt = this.publishedAt;
json.startAt = this.startAt;
json.type = this.type;
return json;
}
}
module.exports = PublidataObjectAlert;