|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>GitHub.js - Documentation</title> |
| 6 | + |
| 7 | + <script src="scripts/prettify/prettify.js"></script> |
| 8 | + <script src="scripts/prettify/lang-css.js"></script> |
| 9 | + <!--[if lt IE 9]> |
| 10 | + <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
| 11 | + <![endif]--> |
| 12 | + <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
| 13 | + <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> |
| 14 | + <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> |
| 15 | +</head> |
| 16 | +<body> |
| 17 | + |
| 18 | +<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
| 19 | +<label for="nav-trigger" class="navicon-button x"> |
| 20 | + <div class="navicon"></div> |
| 21 | +</label> |
| 22 | + |
| 23 | +<label for="nav-trigger" class="overlay"></label> |
| 24 | + |
| 25 | +<nav> |
| 26 | + <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Gist.html">Gist</a><ul class='methods'><li data-type='method'><a href="Gist.html#create">create</a></li><li data-type='method'><a href="Gist.html#createComment">createComment</a></li><li data-type='method'><a href="Gist.html#delete">delete</a></li><li data-type='method'><a href="Gist.html#deleteComment">deleteComment</a></li><li data-type='method'><a href="Gist.html#editComment">editComment</a></li><li data-type='method'><a href="Gist.html#fork">fork</a></li><li data-type='method'><a href="Gist.html#getComment">getComment</a></li><li data-type='method'><a href="Gist.html#isStarred">isStarred</a></li><li data-type='method'><a href="Gist.html#listComments">listComments</a></li><li data-type='method'><a href="Gist.html#read">read</a></li><li data-type='method'><a href="Gist.html#star">star</a></li><li data-type='method'><a href="Gist.html#unstar">unstar</a></li><li data-type='method'><a href="Gist.html#update">update</a></li></ul></li><li><a href="GitHub.html">GitHub</a><ul class='methods'><li data-type='method'><a href="GitHub.html#_getFullName">_getFullName</a></li><li data-type='method'><a href="GitHub.html#getGist">getGist</a></li><li data-type='method'><a href="GitHub.html#getIssues">getIssues</a></li><li data-type='method'><a href="GitHub.html#getMarkdown">getMarkdown</a></li><li data-type='method'><a href="GitHub.html#getOrganization">getOrganization</a></li><li data-type='method'><a href="GitHub.html#getRateLimit">getRateLimit</a></li><li data-type='method'><a href="GitHub.html#getRepo">getRepo</a></li><li data-type='method'><a href="GitHub.html#getTeam">getTeam</a></li><li data-type='method'><a href="GitHub.html#getUser">getUser</a></li><li data-type='method'><a href="GitHub.html#search">search</a></li></ul></li><li><a href="Issue.html">Issue</a><ul class='methods'><li data-type='method'><a href="Issue.html#createIssue">createIssue</a></li><li data-type='method'><a href="Issue.html#createIssueComment">createIssueComment</a></li><li data-type='method'><a href="Issue.html#createMilestone">createMilestone</a></li><li data-type='method'><a href="Issue.html#deleteIssueComment">deleteIssueComment</a></li><li data-type='method'><a href="Issue.html#deleteMilestone">deleteMilestone</a></li><li data-type='method'><a href="Issue.html#editIssue">editIssue</a></li><li data-type='method'><a href="Issue.html#editIssueComment">editIssueComment</a></li><li data-type='method'><a href="Issue.html#editMilestone">editMilestone</a></li><li data-type='method'><a href="Issue.html#getIssue">getIssue</a></li><li data-type='method'><a href="Issue.html#getIssueComment">getIssueComment</a></li><li data-type='method'><a href="Issue.html#getMilestone">getMilestone</a></li><li data-type='method'><a href="Issue.html#listIssueComments">listIssueComments</a></li><li data-type='method'><a href="Issue.html#listIssueEvents">listIssueEvents</a></li><li data-type='method'><a href="Issue.html#listIssues">listIssues</a></li><li data-type='method'><a href="Issue.html#listMilestones">listMilestones</a></li></ul></li><li><a href="Markdown.html">Markdown</a><ul class='methods'><li data-type='method'><a href="Markdown.html#render">render</a></li></ul></li><li><a href="Organization.html">Organization</a><ul class='methods'><li data-type='method'><a href="Organization.html#createRepo">createRepo</a></li><li data-type='method'><a href="Organization.html#createTeam">createTeam</a></li><li data-type='method'><a href="Organization.html#getRepos">getRepos</a></li><li data-type='method'><a href="Organization.html#getTeams">getTeams</a></li><li data-type='method'><a href="Organization.html#isMember">isMember</a></li><li data-type='method'><a href="Organization.html#listMembers">listMembers</a></li></ul></li><li><a href="RateLimit.html">RateLimit</a><ul class='methods'><li data-type='method'><a href="RateLimit.html#getRateLimit">getRateLimit</a></li></ul></li><li><a href="Repository.html">Repository</a><ul class='methods'><li data-type='method'><a href="Repository.html#_getContentObject">_getContentObject</a></li><li data-type='method'><a href="Repository.html#commit">commit</a></li><li data-type='method'><a href="Repository.html#compareBranches">compareBranches</a></li><li data-type='method'><a href="Repository.html#createBlob">createBlob</a></li><li data-type='method'><a href="Repository.html#createBranch">createBranch</a></li><li data-type='method'><a href="Repository.html#createHook">createHook</a></li><li data-type='method'><a href="Repository.html#createPullRequest">createPullRequest</a></li><li data-type='method'><a href="Repository.html#createRef">createRef</a></li><li data-type='method'><a href="Repository.html#createRelease">createRelease</a></li><li data-type='method'><a href="Repository.html#createTree">createTree</a></li><li data-type='method'><a href="Repository.html#deleteFile">deleteFile</a></li><li data-type='method'><a href="Repository.html#deleteHook">deleteHook</a></li><li data-type='method'><a href="Repository.html#deleteRef">deleteRef</a></li><li data-type='method'><a href="Repository.html#deleteRelease">deleteRelease</a></li><li data-type='method'><a href="Repository.html#deleteRepo">deleteRepo</a></li><li data-type='method'><a href="Repository.html#fork">fork</a></li><li data-type='method'><a href="Repository.html#getBlob">getBlob</a></li><li data-type='method'><a href="Repository.html#getCollaborators">getCollaborators</a></li><li data-type='method'><a href="Repository.html#getCommit">getCommit</a></li><li data-type='method'><a href="Repository.html#getContents">getContents</a></li><li data-type='method'><a href="Repository.html#getContributors">getContributors</a></li><li data-type='method'><a href="Repository.html#getDetails">getDetails</a></li><li data-type='method'><a href="Repository.html#getHook">getHook</a></li><li data-type='method'><a href="Repository.html#getPullRequest">getPullRequest</a></li><li data-type='method'><a href="Repository.html#getReadme">getReadme</a></li><li data-type='method'><a href="Repository.html#getRef">getRef</a></li><li data-type='method'><a href="Repository.html#getRelease">getRelease</a></li><li data-type='method'><a href="Repository.html#getSha">getSha</a></li><li data-type='method'><a href="Repository.html#getSingleCommit">getSingleCommit</a></li><li data-type='method'><a href="Repository.html#getTree">getTree</a></li><li data-type='method'><a href="Repository.html#isCollaborator">isCollaborator</a></li><li data-type='method'><a href="Repository.html#isStarred">isStarred</a></li><li data-type='method'><a href="Repository.html#listBranches">listBranches</a></li><li data-type='method'><a href="Repository.html#listCommits">listCommits</a></li><li data-type='method'><a href="Repository.html#listForks">listForks</a></li><li data-type='method'><a href="Repository.html#listHooks">listHooks</a></li><li data-type='method'><a href="Repository.html#listPullRequestFiles">listPullRequestFiles</a></li><li data-type='method'><a href="Repository.html#listPullRequests">listPullRequests</a></li><li data-type='method'><a href="Repository.html#listReleases">listReleases</a></li><li data-type='method'><a href="Repository.html#listStatuses">listStatuses</a></li><li data-type='method'><a href="Repository.html#listTags">listTags</a></li><li data-type='method'><a href="Repository.html#mergePullRequest">mergePullRequest</a></li><li data-type='method'><a href="Repository.html#move">move</a></li><li data-type='method'><a href="Repository.html#star">star</a></li><li data-type='method'><a href="Repository.html#unstar">unstar</a></li><li data-type='method'><a href="Repository.html#updateHead">updateHead</a></li><li data-type='method'><a href="Repository.html#updateHook">updateHook</a></li><li data-type='method'><a href="Repository.html#updatePullRequst">updatePullRequst</a></li><li data-type='method'><a href="Repository.html#updateRelease">updateRelease</a></li><li data-type='method'><a href="Repository.html#updateTree">updateTree</a></li><li data-type='method'><a href="Repository.html#writeFile">writeFile</a></li></ul></li><li><a href="Requestable.html">Requestable</a><ul class='methods'><li data-type='method'><a href="Requestable.html#_dateToISO">_dateToISO</a></li><li data-type='method'><a href="Requestable.html#_getOptionsWithDefaults">_getOptionsWithDefaults</a></li><li data-type='method'><a href="Requestable.html#_request">_request</a></li><li data-type='method'><a href="Requestable.html#_request204or404">_request204or404</a></li><li data-type='method'><a href="Requestable.html#_requestAllPages">_requestAllPages</a></li></ul></li><li><a href="ResponseError.html">ResponseError</a></li><li><a href="Search.html">Search</a><ul class='methods'><li data-type='method'><a href="Search.html#forCode">forCode</a></li><li data-type='method'><a href="Search.html#forIssues">forIssues</a></li><li data-type='method'><a href="Search.html#forRepositories">forRepositories</a></li><li data-type='method'><a href="Search.html#forUsers">forUsers</a></li></ul></li><li><a href="Team.html">Team</a><ul class='methods'><li data-type='method'><a href="Team.html#addMembership">addMembership</a></li><li data-type='method'><a href="Team.html#deleteTeam">deleteTeam</a></li><li data-type='method'><a href="Team.html#editTeam">editTeam</a></li><li data-type='method'><a href="Team.html#getMembership">getMembership</a></li><li data-type='method'><a href="Team.html#getTeam">getTeam</a></li><li data-type='method'><a href="Team.html#isManagedRepo">isManagedRepo</a></li><li data-type='method'><a href="Team.html#listMembers">listMembers</a></li><li data-type='method'><a href="Team.html#listRepos">listRepos</a></li><li data-type='method'><a href="Team.html#manageRepo">manageRepo</a></li><li data-type='method'><a href="Team.html#unmanageRepo">unmanageRepo</a></li></ul></li><li><a href="User.html">User</a><ul class='methods'><li data-type='method'><a href="User.html#createRepo">createRepo</a></li><li data-type='method'><a href="User.html#follow">follow</a></li><li data-type='method'><a href="User.html#getProfile">getProfile</a></li><li data-type='method'><a href="User.html#listGists">listGists</a></li><li data-type='method'><a href="User.html#listNotifications">listNotifications</a></li><li data-type='method'><a href="User.html#listOrgs">listOrgs</a></li><li data-type='method'><a href="User.html#listRepos">listRepos</a></li><li data-type='method'><a href="User.html#listStarredRepos">listStarredRepos</a></li><li data-type='method'><a href="User.html#unfollow">unfollow</a></li></ul></li></ul> |
| 27 | +</nav> |
| 28 | + |
| 29 | +<div id="main"> |
| 30 | + |
| 31 | + <h1 class="page-title">GitHub.js</h1> |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + <section> |
| 40 | + <article> |
| 41 | + <pre class="prettyprint source linenums"><code>/** |
| 42 | + * @file |
| 43 | + * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc. |
| 44 | + * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}. |
| 45 | + * Github.js is freely distributable. |
| 46 | + */ |
| 47 | +/* eslint valid-jsdoc: ["error", {"requireReturnDescription": false}] */ |
| 48 | + |
| 49 | +import Gist from './Gist'; |
| 50 | +import User from './User'; |
| 51 | +import Issue from './Issue'; |
| 52 | +import Search from './Search'; |
| 53 | +import RateLimit from './RateLimit'; |
| 54 | +import Repository from './Repository'; |
| 55 | +import Organization from './Organization'; |
| 56 | +import Team from './Team'; |
| 57 | +import Markdown from './Markdown'; |
| 58 | + |
| 59 | +/** |
| 60 | + * GitHub encapsulates the functionality to create various API wrapper objects. |
| 61 | + */ |
| 62 | +class GitHub { |
| 63 | + /** |
| 64 | + * Create a new GitHub. |
| 65 | + * @param {Requestable.auth} [auth] - the credentials to authenticate to Github. If auth is |
| 66 | + * not provided requests will be made unauthenticated |
| 67 | + * @param {string} [apiBase=https://api.github.com] - the base Github API URL |
| 68 | + */ |
| 69 | + constructor(auth, apiBase = 'https://api.github.com') { |
| 70 | + this.__apiBase = apiBase; |
| 71 | + this.__auth = auth || {}; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * Create a new Gist wrapper |
| 76 | + * @param {number} [id] - the id for the gist, leave undefined when creating a new gist |
| 77 | + * @return {Gist} |
| 78 | + */ |
| 79 | + getGist(id) { |
| 80 | + return new Gist(id, this.__auth, this.__apiBase); |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * Create a new User wrapper |
| 85 | + * @param {string} [user] - the name of the user to get information about |
| 86 | + * leave undefined for the authenticated user |
| 87 | + * @return {User} |
| 88 | + */ |
| 89 | + getUser(user) { |
| 90 | + return new User(user, this.__auth, this.__apiBase); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Create a new Organization wrapper |
| 95 | + * @param {string} organization - the name of the organization |
| 96 | + * @return {Organization} |
| 97 | + */ |
| 98 | + getOrganization(organization) { |
| 99 | + return new Organization(organization, this.__auth, this.__apiBase); |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * create a new Team wrapper |
| 104 | + * @param {string} teamId - the name of the team |
| 105 | + * @return {team} |
| 106 | + */ |
| 107 | + getTeam(teamId) { |
| 108 | + return new Team(teamId, this.__auth, this.__apiBase); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Create a new Repository wrapper |
| 113 | + * @param {string} user - the user who owns the respository |
| 114 | + * @param {string} repo - the name of the repository |
| 115 | + * @return {Repository} |
| 116 | + */ |
| 117 | + getRepo(user, repo) { |
| 118 | + return new Repository(this._getFullName(user, repo), this.__auth, this.__apiBase); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * Create a new Issue wrapper |
| 123 | + * @param {string} user - the user who owns the respository |
| 124 | + * @param {string} repo - the name of the repository |
| 125 | + * @return {Issue} |
| 126 | + */ |
| 127 | + getIssues(user, repo) { |
| 128 | + return new Issue(this._getFullName(user, repo), this.__auth, this.__apiBase); |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * Create a new Search wrapper |
| 133 | + * @param {string} query - the query to search for |
| 134 | + * @return {Search} |
| 135 | + */ |
| 136 | + search(query) { |
| 137 | + return new Search(query, this.__auth, this.__apiBase); |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Create a new RateLimit wrapper |
| 142 | + * @return {RateLimit} |
| 143 | + */ |
| 144 | + getRateLimit() { |
| 145 | + return new RateLimit(this.__auth, this.__apiBase); |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * Create a new Markdown wrapper |
| 150 | + * @return {Markdown} |
| 151 | + */ |
| 152 | + getMarkdown() { |
| 153 | + return new Markdown(this.__auth, this.__apiBase); |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Computes the full repository name |
| 158 | + * @param {string} user - the username (or the full name) |
| 159 | + * @param {string} repo - the repository name, must not be passed if `user` is the full name |
| 160 | + * @return {string} the repository's full name |
| 161 | + */ |
| 162 | + _getFullName(user, repo) { |
| 163 | + let fullname = user; |
| 164 | + |
| 165 | + if (repo) { |
| 166 | + fullname = `${user}/${repo}`; |
| 167 | + } |
| 168 | + |
| 169 | + return fullname; |
| 170 | + } |
| 171 | +} |
| 172 | + |
| 173 | +module.exports = GitHub; |
| 174 | +</code></pre> |
| 175 | + </article> |
| 176 | + </section> |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | +</div> |
| 182 | + |
| 183 | +<br class="clear"> |
| 184 | + |
| 185 | +<footer> |
| 186 | + Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri Jun 17 2016 09:42:34 GMT-0500 (CDT) using the Minami theme. |
| 187 | +</footer> |
| 188 | + |
| 189 | +<script>prettyPrint();</script> |
| 190 | +<script src="scripts/linenumber.js"></script> |
| 191 | +</body> |
| 192 | +</html> |
0 commit comments