UNPKG

stackexchange-api

Version:
65 lines (64 loc) 5.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Comment_1 = require("./Comment"); const ShallowUser_1 = require("./ShallowUser"); /** * The equivalent of [Type answer](https://api.stackexchange.com/docs/types/answer).<br> * This object represents an Answer to a [[Question]] on one of the [Stack Exchange sites](https://stackexchange.com/sites).<br> * As on the [[Question]] page, it is possible to fetch the [[Comment|Comments]] on an Answer as part of a call; though this is not done by default. */ class Answer { constructor(answer) { 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, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25; this.accepted = (_b = (_a = answer) === null || _a === void 0 ? void 0 : _a.accepted, (_b !== null && _b !== void 0 ? _b : null)); this.answerId = (_d = (_c = answer) === null || _c === void 0 ? void 0 : _c.answer_id, (_d !== null && _d !== void 0 ? _d : null)); this.awardedBountyAmount = (_f = (_e = answer) === null || _e === void 0 ? void 0 : _e.awarded_bounty_amount, (_f !== null && _f !== void 0 ? _f : null)); if (typeof ((_g = answer) === null || _g === void 0 ? void 0 : _g.awarded_bounty_users) === 'undefined') { this.awardedBountyUsers = null; } else { this.awardedBountyUsers = answer.awarded_bounty_users .map((shallow_user) => new ShallowUser_1.ShallowUser(shallow_user)); } this.body = (_j = (_h = answer) === null || _h === void 0 ? void 0 : _h.body, (_j !== null && _j !== void 0 ? _j : null)); this.bodyMarkdown = (_l = (_k = answer) === null || _k === void 0 ? void 0 : _k.body_markdown, (_l !== null && _l !== void 0 ? _l : null)); this.canFlag = (_o = (_m = answer) === null || _m === void 0 ? void 0 : _m.can_flag, (_o !== null && _o !== void 0 ? _o : null)); this.commentCount = (_q = (_p = answer) === null || _p === void 0 ? void 0 : _p.comment_count, (_q !== null && _q !== void 0 ? _q : null)); if (typeof ((_r = answer) === null || _r === void 0 ? void 0 : _r.comments) === 'undefined') { this.comments = null; } else { this.comments = answer.comments .map((comment) => new Comment_1.Comment(comment)); } this.communityOwnedDate = (_t = (_s = answer) === null || _s === void 0 ? void 0 : _s.community_owned_date, (_t !== null && _t !== void 0 ? _t : null)); this.creationDate = (_v = (_u = answer) === null || _u === void 0 ? void 0 : _u.creation_date, (_v !== null && _v !== void 0 ? _v : null)); this.downVoteCount = (_x = (_w = answer) === null || _w === void 0 ? void 0 : _w.down_vote_count, (_x !== null && _x !== void 0 ? _x : null)); this.downvoted = (_z = (_y = answer) === null || _y === void 0 ? void 0 : _y.downvoted, (_z !== null && _z !== void 0 ? _z : null)); this.isAccepted = (_1 = (_0 = answer) === null || _0 === void 0 ? void 0 : _0.is_accepted, (_1 !== null && _1 !== void 0 ? _1 : null)); this.lastActivityDate = (_3 = (_2 = answer) === null || _2 === void 0 ? void 0 : _2.last_activity_date, (_3 !== null && _3 !== void 0 ? _3 : null)); this.lastEditDate = (_5 = (_4 = answer) === null || _4 === void 0 ? void 0 : _4.last_edit_date, (_5 !== null && _5 !== void 0 ? _5 : null)); if (typeof ((_6 = answer) === null || _6 === void 0 ? void 0 : _6.last_editor) === 'undefined') { this.lastEditor = null; } else { this.lastEditor = new ShallowUser_1.ShallowUser(answer.last_editor); } this.link = (_8 = (_7 = answer) === null || _7 === void 0 ? void 0 : _7.link, (_8 !== null && _8 !== void 0 ? _8 : null)); this.lockedDate = (_10 = (_9 = answer) === null || _9 === void 0 ? void 0 : _9.locked_date, (_10 !== null && _10 !== void 0 ? _10 : null)); if (typeof ((_11 = answer) === null || _11 === void 0 ? void 0 : _11.owner) === 'undefined') { this.owner = null; } else { this.owner = new ShallowUser_1.ShallowUser(answer.owner); } this.questionId = (_13 = (_12 = answer) === null || _12 === void 0 ? void 0 : _12.question_id, (_13 !== null && _13 !== void 0 ? _13 : null)); this.score = (_15 = (_14 = answer) === null || _14 === void 0 ? void 0 : _14.score, (_15 !== null && _15 !== void 0 ? _15 : null)); this.shareLink = (_17 = (_16 = answer) === null || _16 === void 0 ? void 0 : _16.share_link, (_17 !== null && _17 !== void 0 ? _17 : null)); this.tags = (_19 = (_18 = answer) === null || _18 === void 0 ? void 0 : _18.tags, (_19 !== null && _19 !== void 0 ? _19 : null)); this.title = (_21 = (_20 = answer) === null || _20 === void 0 ? void 0 : _20.title, (_21 !== null && _21 !== void 0 ? _21 : null)); this.upVoteCount = (_23 = (_22 = answer) === null || _22 === void 0 ? void 0 : _22.up_vote_count, (_23 !== null && _23 !== void 0 ? _23 : null)); this.upvoted = (_25 = (_24 = answer) === null || _24 === void 0 ? void 0 : _24.upvoted, (_25 !== null && _25 !== void 0 ? _25 : null)); } } exports.Answer = Answer;