stackexchange-api
Version:
A Node.js wrapper for the StackExchange API
51 lines (50 loc) • 3.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Comment_1 = require("./Comment");
const ShallowUser_1 = require("./ShallowUser");
/**
* The equivalent of [Type post](https://api.stackexchange.com/docs/types/post).<br>
* This object represents the intersection of the [[Question]] and [[Answer]] objects.<br>
* It's used in cases where it would be beneficial to mix [[Question|Questions]] and [[Answer|Answers]] in a response.
*/
class Post {
constructor(post) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
this.body = (_b = (_a = post) === null || _a === void 0 ? void 0 : _a.body, (_b !== null && _b !== void 0 ? _b : null));
this.bodyMarkdown = (_d = (_c = post) === null || _c === void 0 ? void 0 : _c.body_markdown, (_d !== null && _d !== void 0 ? _d : null));
this.commentCount = (_f = (_e = post) === null || _e === void 0 ? void 0 : _e.comment_count, (_f !== null && _f !== void 0 ? _f : null));
if (typeof ((_g = post) === null || _g === void 0 ? void 0 : _g.comments) === 'undefined') {
this.comments = null;
}
else {
this.comments = post.comments
.map((comment) => new Comment_1.Comment(comment));
}
this.creationDate = (_j = (_h = post) === null || _h === void 0 ? void 0 : _h.creation_date, (_j !== null && _j !== void 0 ? _j : null));
this.downVoteCount = (_l = (_k = post) === null || _k === void 0 ? void 0 : _k.down_vote_count, (_l !== null && _l !== void 0 ? _l : null));
this.downvoted = (_o = (_m = post) === null || _m === void 0 ? void 0 : _m.downvoted, (_o !== null && _o !== void 0 ? _o : null));
this.lastActivityDate = (_q = (_p = post) === null || _p === void 0 ? void 0 : _p.last_activity_date, (_q !== null && _q !== void 0 ? _q : null));
this.lastEditDate = (_s = (_r = post) === null || _r === void 0 ? void 0 : _r.last_edit_date, (_s !== null && _s !== void 0 ? _s : null));
if (typeof ((_t = post) === null || _t === void 0 ? void 0 : _t.last_editor) === 'undefined') {
this.lastEditor = null;
}
else {
this.lastEditor = new ShallowUser_1.ShallowUser(post.last_editor);
}
this.link = (_v = (_u = post) === null || _u === void 0 ? void 0 : _u.link, (_v !== null && _v !== void 0 ? _v : null));
if (typeof ((_w = post) === null || _w === void 0 ? void 0 : _w.owner) === 'undefined') {
this.owner = null;
}
else {
this.owner = new ShallowUser_1.ShallowUser(post.owner);
}
this.postId = (_y = (_x = post) === null || _x === void 0 ? void 0 : _x.post_id, (_y !== null && _y !== void 0 ? _y : null));
this.postType = (_0 = (_z = post) === null || _z === void 0 ? void 0 : _z.post_type, (_0 !== null && _0 !== void 0 ? _0 : null));
this.score = (_2 = (_1 = post) === null || _1 === void 0 ? void 0 : _1.score, (_2 !== null && _2 !== void 0 ? _2 : null));
this.shareLink = (_4 = (_3 = post) === null || _3 === void 0 ? void 0 : _3.share_link, (_4 !== null && _4 !== void 0 ? _4 : null));
this.title = (_6 = (_5 = post) === null || _5 === void 0 ? void 0 : _5.title, (_6 !== null && _6 !== void 0 ? _6 : null));
this.upVoteCount = (_8 = (_7 = post) === null || _7 === void 0 ? void 0 : _7.up_vote_count, (_8 !== null && _8 !== void 0 ? _8 : null));
this.upvoted = (_10 = (_9 = post) === null || _9 === void 0 ? void 0 : _9.upvoted, (_10 !== null && _10 !== void 0 ? _10 : null));
}
}
exports.Post = Post;