UNPKG

stackexchange-api

Version:
110 lines (109 loc) 8.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Answer_1 = require("./Answer"); const ClosedDetails_1 = require("./ClosedDetails"); const Comment_1 = require("./Comment"); const MigrationInfo_1 = require("./MigrationInfo"); const Notice_1 = require("./Notice"); const ShallowUser_1 = require("./ShallowUser"); /** * The equivalent of [Type question](https://api.stackexchange.com/docs/types/question).<br> * This object represents a Question on one of the [Stack Exchange sites](https://stackexchange.com/sites).<br> * This object is heavily inspired by the Question page itself, and can optionally return [[Comment|Comments]] and [[Answer|Answers]] accordingly. */ class Question { constructor(question) { 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, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52; this.acceptedAnswerId = (_b = (_a = question) === null || _a === void 0 ? void 0 : _a.accepted_answer_id, (_b !== null && _b !== void 0 ? _b : null)); this.answerCount = (_d = (_c = question) === null || _c === void 0 ? void 0 : _c.answer_count, (_d !== null && _d !== void 0 ? _d : null)); if (typeof ((_e = question) === null || _e === void 0 ? void 0 : _e.answers) === 'undefined') { this.answers = null; } else { this.answers = question.answers .map((answer) => new Answer_1.Answer(answer)); } this.body = (_g = (_f = question) === null || _f === void 0 ? void 0 : _f.body, (_g !== null && _g !== void 0 ? _g : null)); this.bodyMarkdown = (_j = (_h = question) === null || _h === void 0 ? void 0 : _h.body_markdown, (_j !== null && _j !== void 0 ? _j : null)); this.bountyAmount = (_l = (_k = question) === null || _k === void 0 ? void 0 : _k.bounty_amount, (_l !== null && _l !== void 0 ? _l : null)); this.bountyClosesDate = (_o = (_m = question) === null || _m === void 0 ? void 0 : _m.bounty_closes_date, (_o !== null && _o !== void 0 ? _o : null)); if (typeof ((_p = question) === null || _p === void 0 ? void 0 : _p.bounty_user) === 'undefined') { this.bountyUser = null; } else { this.bountyUser = new ShallowUser_1.ShallowUser(question.bounty_user); } this.canClose = (_r = (_q = question) === null || _q === void 0 ? void 0 : _q.can_close, (_r !== null && _r !== void 0 ? _r : null)); this.canFlag = (_t = (_s = question) === null || _s === void 0 ? void 0 : _s.can_flag, (_t !== null && _t !== void 0 ? _t : null)); this.closeVoteCount = (_v = (_u = question) === null || _u === void 0 ? void 0 : _u.close_vote_count, (_v !== null && _v !== void 0 ? _v : null)); this.closedDate = (_x = (_w = question) === null || _w === void 0 ? void 0 : _w.closed_date, (_x !== null && _x !== void 0 ? _x : null)); if (typeof ((_y = question) === null || _y === void 0 ? void 0 : _y.closed_details) === 'undefined') { this.closedDetails = null; } else { this.closedDetails = new ClosedDetails_1.ClosedDetails(question.closed_details); } this.closedReason = (_0 = (_z = question) === null || _z === void 0 ? void 0 : _z.closed_reason, (_0 !== null && _0 !== void 0 ? _0 : null)); this.commentCount = (_2 = (_1 = question) === null || _1 === void 0 ? void 0 : _1.comment_count, (_2 !== null && _2 !== void 0 ? _2 : null)); if (typeof ((_3 = question) === null || _3 === void 0 ? void 0 : _3.comments) === 'undefined') { this.comments = null; } else { this.comments = question.comments .map((comment) => new Comment_1.Comment(comment)); } this.communityOwnedDate = (_5 = (_4 = question) === null || _4 === void 0 ? void 0 : _4.community_owned_date, (_5 !== null && _5 !== void 0 ? _5 : null)); this.creationDate = (_7 = (_6 = question) === null || _6 === void 0 ? void 0 : _6.creation_date, (_7 !== null && _7 !== void 0 ? _7 : null)); this.deleteVoteCount = (_9 = (_8 = question) === null || _8 === void 0 ? void 0 : _8.delete_vote_count, (_9 !== null && _9 !== void 0 ? _9 : null)); this.downVoteCount = (_11 = (_10 = question) === null || _10 === void 0 ? void 0 : _10.down_vote_count, (_11 !== null && _11 !== void 0 ? _11 : null)); this.downvoted = (_13 = (_12 = question) === null || _12 === void 0 ? void 0 : _12.downvoted, (_13 !== null && _13 !== void 0 ? _13 : null)); this.favoriteCount = (_15 = (_14 = question) === null || _14 === void 0 ? void 0 : _14.favorite_count, (_15 !== null && _15 !== void 0 ? _15 : null)); this.favorited = (_17 = (_16 = question) === null || _16 === void 0 ? void 0 : _16.favorited, (_17 !== null && _17 !== void 0 ? _17 : null)); this.isAnswered = (_19 = (_18 = question) === null || _18 === void 0 ? void 0 : _18.is_answered, (_19 !== null && _19 !== void 0 ? _19 : null)); this.lastActivityDate = (_21 = (_20 = question) === null || _20 === void 0 ? void 0 : _20.last_activity_date, (_21 !== null && _21 !== void 0 ? _21 : null)); this.lastEditDate = (_23 = (_22 = question) === null || _22 === void 0 ? void 0 : _22.last_edit_date, (_23 !== null && _23 !== void 0 ? _23 : null)); if (typeof ((_24 = question) === null || _24 === void 0 ? void 0 : _24.last_editor) === 'undefined') { this.lastEditor = null; } else { this.lastEditor = new ShallowUser_1.ShallowUser(question.last_editor); } this.link = (_26 = (_25 = question) === null || _25 === void 0 ? void 0 : _25.link, (_26 !== null && _26 !== void 0 ? _26 : null)); this.lockedDate = (_28 = (_27 = question) === null || _27 === void 0 ? void 0 : _27.locked_date, (_28 !== null && _28 !== void 0 ? _28 : null)); if (typeof ((_29 = question) === null || _29 === void 0 ? void 0 : _29.migrated_from) === 'undefined') { this.migratedFrom = null; } else { this.migratedFrom = new MigrationInfo_1.MigrationInfo(question.migrated_from); } if (typeof ((_30 = question) === null || _30 === void 0 ? void 0 : _30.migrated_to) === 'undefined') { this.migratedTo = null; } else { this.migratedTo = new MigrationInfo_1.MigrationInfo(question.migrated_to); } if (typeof ((_31 = question) === null || _31 === void 0 ? void 0 : _31.notice) === 'undefined') { this.notice = null; } else { this.notice = new Notice_1.Notice(question.notice); } if (typeof ((_32 = question) === null || _32 === void 0 ? void 0 : _32.owner) === 'undefined') { this.owner = null; } else { this.owner = new ShallowUser_1.ShallowUser(question.owner); } this.protectedDate = (_34 = (_33 = question) === null || _33 === void 0 ? void 0 : _33.protected_date, (_34 !== null && _34 !== void 0 ? _34 : null)); this.questionId = (_36 = (_35 = question) === null || _35 === void 0 ? void 0 : _35.question_id, (_36 !== null && _36 !== void 0 ? _36 : null)); this.reopenVoteCount = (_38 = (_37 = question) === null || _37 === void 0 ? void 0 : _37.reopen_vote_count, (_38 !== null && _38 !== void 0 ? _38 : null)); this.score = (_40 = (_39 = question) === null || _39 === void 0 ? void 0 : _39.score, (_40 !== null && _40 !== void 0 ? _40 : null)); this.shareLink = (_42 = (_41 = question) === null || _41 === void 0 ? void 0 : _41.share_link, (_42 !== null && _42 !== void 0 ? _42 : null)); this.tags = (_44 = (_43 = question) === null || _43 === void 0 ? void 0 : _43.tags, (_44 !== null && _44 !== void 0 ? _44 : null)); this.title = (_46 = (_45 = question) === null || _45 === void 0 ? void 0 : _45.title, (_46 !== null && _46 !== void 0 ? _46 : null)); this.upVoteCount = (_48 = (_47 = question) === null || _47 === void 0 ? void 0 : _47.up_vote_count, (_48 !== null && _48 !== void 0 ? _48 : null)); this.upvoted = (_50 = (_49 = question) === null || _49 === void 0 ? void 0 : _49.upvoted, (_50 !== null && _50 !== void 0 ? _50 : null)); this.viewCount = (_52 = (_51 = question) === null || _51 === void 0 ? void 0 : _51.view_count, (_52 !== null && _52 !== void 0 ? _52 : null)); } } exports.Question = Question;