UNPKG

4.25 kBSource Map (JSON)View Raw
1{"version":3,"names":[],"mappings":"","sources":["GitHub.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/* eslint valid-jsdoc: [\"error\", {\"requireReturnDescription\": false}] */\n\nimport Gist from './Gist';\nimport User from './User';\nimport Issue from './Issue';\nimport Search from './Search';\nimport RateLimit from './RateLimit';\nimport Repository from './Repository';\nimport Organization from './Organization';\nimport Team from './Team';\nimport Markdown from './Markdown';\nimport Project from './Project';\n\n/**\n * GitHub encapsulates the functionality to create various API wrapper objects.\n */\nclass GitHub {\n /**\n * Create a new GitHub.\n * @param {Requestable.auth} [auth] - the credentials to authenticate to Github. If auth is\n * not provided requests will be made unauthenticated\n * @param {string} [apiBase=https://api.github.com] - the base Github API URL\n */\n constructor(auth, apiBase = 'https://api.github.com') {\n this.__apiBase = apiBase;\n this.__auth = auth || {};\n }\n\n /**\n * Create a new Gist wrapper\n * @param {string} [id] - the id for the gist, leave undefined when creating a new gist\n * @return {Gist}\n */\n getGist(id) {\n return new Gist(id, this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new User wrapper\n * @param {string} [user] - the name of the user to get information about\n * leave undefined for the authenticated user\n * @return {User}\n */\n getUser(user) {\n return new User(user, this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new Organization wrapper\n * @param {string} organization - the name of the organization\n * @return {Organization}\n */\n getOrganization(organization) {\n return new Organization(organization, this.__auth, this.__apiBase);\n }\n\n /**\n * create a new Team wrapper\n * @param {string} teamId - the name of the team\n * @return {team}\n */\n getTeam(teamId) {\n return new Team(teamId, this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new Repository wrapper\n * @param {string} user - the user who owns the repository\n * @param {string} repo - the name of the repository\n * @return {Repository}\n */\n getRepo(user, repo) {\n return new Repository(this._getFullName(user, repo), this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new Issue wrapper\n * @param {string} user - the user who owns the repository\n * @param {string} repo - the name of the repository\n * @return {Issue}\n */\n getIssues(user, repo) {\n return new Issue(this._getFullName(user, repo), this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new Search wrapper\n * @param {string} query - the query to search for\n * @return {Search}\n */\n search(query) {\n return new Search(query, this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new RateLimit wrapper\n * @return {RateLimit}\n */\n getRateLimit() {\n return new RateLimit(this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new Markdown wrapper\n * @return {Markdown}\n */\n getMarkdown() {\n return new Markdown(this.__auth, this.__apiBase);\n }\n\n /**\n * Create a new Project wrapper\n * @param {string} id - the id of the project\n * @return {Project}\n */\n getProject(id) {\n return new Project(id, this.__auth, this.__apiBase);\n }\n\n /**\n * Computes the full repository name\n * @param {string} user - the username (or the full name)\n * @param {string} repo - the repository name, must not be passed if `user` is the full name\n * @return {string} the repository's full name\n */\n _getFullName(user, repo) {\n let fullname = user;\n\n if (repo) {\n fullname = `${user}/${repo}`;\n }\n\n return fullname;\n }\n}\n\nmodule.exports = GitHub;\n"],"file":"GitHub.js"}
\No newline at end of file