stackexchange-api
Version:
A Node.js wrapper for the StackExchange API
38 lines (37 loc) • 2.74 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ShallowUser_1 = require("./ShallowUser");
/**
* The equivalent of [Type comment](https://api.stackexchange.com/docs/types/comment).<br>
* All [[Question|Questions]] and [[Answer|Answers]] on a [Stack Exchange site](https://stackexchange.com/sites) can be commented on, and this object represents those Comments.<br>
* Comments can also be optionally directed at users, when this is the case the [[replyToUser]] property is set.
*/
class Comment {
constructor(comment) {
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;
this.body = (_b = (_a = comment) === null || _a === void 0 ? void 0 : _a.body, (_b !== null && _b !== void 0 ? _b : null));
this.bodyMarkdown = (_d = (_c = comment) === null || _c === void 0 ? void 0 : _c.body_markdown, (_d !== null && _d !== void 0 ? _d : null));
this.canFlag = (_f = (_e = comment) === null || _e === void 0 ? void 0 : _e.can_flag, (_f !== null && _f !== void 0 ? _f : null));
this.commentId = (_h = (_g = comment) === null || _g === void 0 ? void 0 : _g.comment_id, (_h !== null && _h !== void 0 ? _h : null));
this.creationDate = (_k = (_j = comment) === null || _j === void 0 ? void 0 : _j.creation_date, (_k !== null && _k !== void 0 ? _k : null));
this.edited = (_m = (_l = comment) === null || _l === void 0 ? void 0 : _l.edited, (_m !== null && _m !== void 0 ? _m : null));
this.link = (_p = (_o = comment) === null || _o === void 0 ? void 0 : _o.link, (_p !== null && _p !== void 0 ? _p : null));
if (typeof ((_q = comment) === null || _q === void 0 ? void 0 : _q.owner) === 'undefined') {
this.owner = null;
}
else {
this.owner = new ShallowUser_1.ShallowUser(comment.owner);
}
this.postId = (_s = (_r = comment) === null || _r === void 0 ? void 0 : _r.post_id, (_s !== null && _s !== void 0 ? _s : null));
this.postType = (_u = (_t = comment) === null || _t === void 0 ? void 0 : _t.post_type, (_u !== null && _u !== void 0 ? _u : null));
if (typeof ((_v = comment) === null || _v === void 0 ? void 0 : _v.reply_to_user) === 'undefined') {
this.replyToUser = null;
}
else {
this.replyToUser = new ShallowUser_1.ShallowUser(comment.reply_to_user);
}
this.score = (_x = (_w = comment) === null || _w === void 0 ? void 0 : _w.score, (_x !== null && _x !== void 0 ? _x : null));
this.upvoted = (_z = (_y = comment) === null || _y === void 0 ? void 0 : _y.upvoted, (_z !== null && _z !== void 0 ? _z : null));
}
}
exports.Comment = Comment;