@publidata/utils-data-manager
Version:
Collection of methods to extract data from publidata
91 lines (73 loc) • 1.96 kB
JavaScript
const PublidataObject = require("../");
/**
* Class representing a post object.
* @extends PublidataObject
*/
class PublidataObjectPost extends PublidataObject {
get id() {
return this.memoize("id", this.object._id);
}
get type() {
return this.memoize("type", this.object._source?.type);
}
get texts() {
return this.memoize("texts", this.object._source?.texts);
}
get blurb() {
return this.memoize("blurb", this.object._source?.body || this.object._source?.blurb);
}
get chapo() {
return this.memoize("chapo", this.object._source?.blurb);
}
get page() {
return this.memoize("page", this.object._source?.pages?.[0]);
}
get icon() {
return this.memoize("icon", this.object._source?.settings?.icon);
}
get color() {
return this.memoize("color", this.object._source?.settings?.color);
}
get todo() {
return this.memoize("todo", this.object._source?.settings?.todo);
}
get social() {
return this.memoize("socials", this.object._source?.socials?.[0]);
}
get picture() {
return this.memoize("picture", this.object._source?.cover_picture);
}
get link () {
return this.memoize("link", this.object._source?.links?.[0]);
}
get tags() {
return this.memoize("tags", this.object._source?.tags);
}
get weight() {
return this.memoize("weight", this.object._source?.settings?.weight);
}
get name () {
return this.memoize("name", this.object._source?.name);
}
toJSON() {
return {
id: this.id,
tags: this.tags,
todo: this.todo,
type: this.type,
icon: this.icon,
link: this.link,
page: this.page,
name: this.name,
color: this.color,
chapo: this.chapo,
texts: this.texts,
blurb: this.blurb,
social: this.social,
weight: this.weight,
picture: this.picture,
_source: this.object._source,
};
}
}
module.exports = PublidataObjectPost;