UNPKG

10.5 kBSource Map (JSON)View Raw
1{"version":3,"names":[],"mappings":"","sources":["Issue.js"],"sourcesContent":["/**\n * @file\n * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.\n * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.\n * Github.js is freely distributable.\n */\n\nimport Requestable from './Requestable';\n\n/**\n * Issue wraps the functionality to get issues for repositories\n */\nclass Issue extends Requestable {\n /**\n * Create a new Issue\n * @param {string} repository - the full name of the repository (`:user/:repo`) to get issues for\n * @param {Requestable.auth} [auth] - information required to authenticate to Github\n * @param {string} [apiBase=https://api.github.com] - the base Github API URL\n */\n constructor(repository, auth, apiBase) {\n super(auth, apiBase);\n this.__repository = repository;\n }\n\n /**\n * Create a new issue\n * @see https://developer.github.com/v3/issues/#create-an-issue\n * @param {Object} issueData - the issue to create\n * @param {Requestable.callback} [cb] - will receive the created issue\n * @return {Promise} - the promise for the http request\n */\n createIssue(issueData, cb) {\n return this._request('POST', `/repos/${this.__repository}/issues`, issueData, cb);\n }\n\n /**\n * List the issues for the repository\n * @see https://developer.github.com/v3/issues/#list-issues-for-a-repository\n * @param {Object} options - filtering options\n * @param {Requestable.callback} [cb] - will receive the array of issues\n * @return {Promise} - the promise for the http request\n */\n listIssues(options, cb) {\n return this._requestAllPages(`/repos/${this.__repository}/issues`, options, cb);\n }\n\n /**\n * List the events for an issue\n * @see https://developer.github.com/v3/issues/events/#list-events-for-an-issue\n * @param {number} issue - the issue to get events for\n * @param {Requestable.callback} [cb] - will receive the list of events\n * @return {Promise} - the promise for the http request\n */\n listIssueEvents(issue, cb) {\n return this._request('GET', `/repos/${this.__repository}/issues/${issue}/events`, null, cb);\n }\n\n /**\n * List comments on an issue\n * @see https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue\n * @param {number} issue - the id of the issue to get comments from\n * @param {Requestable.callback} [cb] - will receive the comments\n * @return {Promise} - the promise for the http request\n */\n listIssueComments(issue, cb) {\n return this._request('GET', `/repos/${this.__repository}/issues/${issue}/comments`, null, cb);\n }\n\n /**\n * Get a single comment on an issue\n * @see https://developer.github.com/v3/issues/comments/#get-a-single-comment\n * @param {number} id - the comment id to get\n * @param {Requestable.callback} [cb] - will receive the comment\n * @return {Promise} - the promise for the http request\n */\n getIssueComment(id, cb) {\n return this._request('GET', `/repos/${this.__repository}/issues/comments/${id}`, null, cb);\n }\n\n /**\n * Comment on an issue\n * @see https://developer.github.com/v3/issues/comments/#create-a-comment\n * @param {number} issue - the id of the issue to comment on\n * @param {string} comment - the comment to add\n * @param {Requestable.callback} [cb] - will receive the created comment\n * @return {Promise} - the promise for the http request\n */\n createIssueComment(issue, comment, cb) {\n return this._request('POST', `/repos/${this.__repository}/issues/${issue}/comments`, {body: comment}, cb);\n }\n\n /**\n * Edit a comment on an issue\n * @see https://developer.github.com/v3/issues/comments/#edit-a-comment\n * @param {number} id - the comment id to edit\n * @param {string} comment - the comment to edit\n * @param {Requestable.callback} [cb] - will receive the edited comment\n * @return {Promise} - the promise for the http request\n */\n editIssueComment(id, comment, cb) {\n return this._request('PATCH', `/repos/${this.__repository}/issues/comments/${id}`, {body: comment}, cb);\n }\n\n /**\n * Delete a comment on an issue\n * @see https://developer.github.com/v3/issues/comments/#delete-a-comment\n * @param {number} id - the comment id to delete\n * @param {Requestable.callback} [cb] - will receive true if the request is successful\n * @return {Promise} - the promise for the http request\n */\n deleteIssueComment(id, cb) {\n return this._request('DELETE', `/repos/${this.__repository}/issues/comments/${id}`, null, cb);\n }\n\n /**\n * Edit an issue\n * @see https://developer.github.com/v3/issues/#edit-an-issue\n * @param {number} issue - the issue number to edit\n * @param {Object} issueData - the new issue data\n * @param {Requestable.callback} [cb] - will receive the modified issue\n * @return {Promise} - the promise for the http request\n */\n editIssue(issue, issueData, cb) {\n return this._request('PATCH', `/repos/${this.__repository}/issues/${issue}`, issueData, cb);\n }\n\n /**\n * Get a particular issue\n * @see https://developer.github.com/v3/issues/#get-a-single-issue\n * @param {number} issue - the issue number to fetch\n * @param {Requestable.callback} [cb] - will receive the issue\n * @return {Promise} - the promise for the http request\n */\n getIssue(issue, cb) {\n return this._request('GET', `/repos/${this.__repository}/issues/${issue}`, null, cb);\n }\n\n /**\n * List the milestones for the repository\n * @see https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository\n * @param {Object} options - filtering options\n * @param {Requestable.callback} [cb] - will receive the array of milestones\n * @return {Promise} - the promise for the http request\n */\n listMilestones(options, cb) {\n return this._request('GET', `/repos/${this.__repository}/milestones`, options, cb);\n }\n\n /**\n * Get a milestone\n * @see https://developer.github.com/v3/issues/milestones/#get-a-single-milestone\n * @param {string} milestone - the id of the milestone to fetch\n * @param {Requestable.callback} [cb] - will receive the milestone\n * @return {Promise} - the promise for the http request\n */\n getMilestone(milestone, cb) {\n return this._request('GET', `/repos/${this.__repository}/milestones/${milestone}`, null, cb);\n }\n\n /**\n * Create a new milestone\n * @see https://developer.github.com/v3/issues/milestones/#create-a-milestone\n * @param {Object} milestoneData - the milestone definition\n * @param {Requestable.callback} [cb] - will receive the milestone\n * @return {Promise} - the promise for the http request\n */\n createMilestone(milestoneData, cb) {\n return this._request('POST', `/repos/${this.__repository}/milestones`, milestoneData, cb);\n }\n\n /**\n * Edit a milestone\n * @see https://developer.github.com/v3/issues/milestones/#update-a-milestone\n * @param {string} milestone - the id of the milestone to edit\n * @param {Object} milestoneData - the updates to make to the milestone\n * @param {Requestable.callback} [cb] - will receive the updated milestone\n * @return {Promise} - the promise for the http request\n */\n editMilestone(milestone, milestoneData, cb) {\n return this._request('PATCH', `/repos/${this.__repository}/milestones/${milestone}`, milestoneData, cb);\n }\n\n /**\n * Delete a milestone (this is distinct from closing a milestone)\n * @see https://developer.github.com/v3/issues/milestones/#delete-a-milestone\n * @param {string} milestone - the id of the milestone to delete\n * @param {Requestable.callback} [cb] - will receive the status\n * @return {Promise} - the promise for the http request\n */\n deleteMilestone(milestone, cb) {\n return this._request('DELETE', `/repos/${this.__repository}/milestones/${milestone}`, null, cb);\n }\n\n /**\n * Create a new label\n * @see https://developer.github.com/v3/issues/labels/#create-a-label\n * @param {Object} labelData - the label definition\n * @param {Requestable.callback} [cb] - will receive the object representing the label\n * @return {Promise} - the promise for the http request\n */\n createLabel(labelData, cb) {\n return this._request('POST', `/repos/${this.__repository}/labels`, labelData, cb);\n }\n\n /**\n * List the labels for the repository\n * @see https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository\n * @param {Object} options - filtering options\n * @param {Requestable.callback} [cb] - will receive the array of labels\n * @return {Promise} - the promise for the http request\n */\n listLabels(options, cb) {\n return this._request('GET', `/repos/${this.__repository}/labels`, options, cb);\n }\n\n /**\n * Get a label\n * @see https://developer.github.com/v3/issues/labels/#get-a-single-label\n * @param {string} label - the name of the label to fetch\n * @param {Requestable.callback} [cb] - will receive the label\n * @return {Promise} - the promise for the http request\n */\n getLabel(label, cb) {\n return this._request('GET', `/repos/${this.__repository}/labels/${label}`, null, cb);\n }\n\n /**\n * Edit a label\n * @see https://developer.github.com/v3/issues/labels/#update-a-label\n * @param {string} label - the name of the label to edit\n * @param {Object} labelData - the updates to make to the label\n * @param {Requestable.callback} [cb] - will receive the updated label\n * @return {Promise} - the promise for the http request\n */\n editLabel(label, labelData, cb) {\n return this._request('PATCH', `/repos/${this.__repository}/labels/${label}`, labelData, cb);\n }\n\n /**\n * Delete a label\n * @see https://developer.github.com/v3/issues/labels/#delete-a-label\n * @param {string} label - the name of the label to delete\n * @param {Requestable.callback} [cb] - will receive the status\n * @return {Promise} - the promise for the http request\n */\n deleteLabel(label, cb) {\n return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb);\n }\n}\n\nmodule.exports = Issue;\n"],"file":"Issue.js"}
\No newline at end of file