@@ -436,13 +436,27 @@ class Repository extends Requestable {
436436 * List the users who are collaborators on the repository. The currently authenticated user must have
437437 * push access to use this method
438438 * @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
439- * @param {Requestable.callback } cb - will receive the list of collaborators
439+ * @param {Requestable.callback } cb - will receive the fetched data
440440 * @return {Promise } - the promise for the http request
441441 */
442442 getCollaborators ( cb ) {
443443 return this . _request ( 'GET' , `/repos/${ this . __fullname } /collaborators` , null , cb ) ;
444444 }
445445
446+ /**
447+ * Adds user as a collaborator on the repository. The currently authenticated user must have admin access for the
448+ * repo to use this method
449+ * @see https://developer.github.com/enterprise/2.10/v3/repos/collaborators/#add-user-as-a-collaborator
450+ * @param {string } username - the user to add as a collaborator
451+ * @param {Object } [options] - collaborator permissions, only applicable on repos in an org
452+ * @param {Object } [options.permission=push] - can be one of: `pull`, `push`, or `admin`
453+ * @param {Requestable.callback } cb - will receive the information about the newly added contributor
454+ * @return {Promise } - the promise for the http request
455+ */
456+ addCollaborator ( username , options , cb ) {
457+ return this . _request ( 'PUT' , `/repos/${ this . __fullname } /collaborators/${ username } ` , options , cb ) ;
458+ }
459+
446460 /**
447461 * Check if a user is a collaborator on the repository
448462 * @see https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
@@ -451,7 +465,7 @@ class Repository extends Requestable {
451465 * @return {Promise } - the promise for the http request {Boolean} [description]
452466 */
453467 isCollaborator ( username , cb ) {
454- return this . _request ( 'GET' , `/repos/${ this . __fullname } /collaborators/${ username } ` , null , cb ) ;
468+ return this . _request204or404 ( `/repos/${ this . __fullname } /collaborators/${ username } ` , null , cb ) ;
455469 }
456470
457471 /**
0 commit comments