bitbucket-v2
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ module.exports = function AbstractApi($api) { |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -14,3 +14,3 @@ const Constants = require('./constants'); | ||
module.exports = function Bitbucket({ proxy, useXhr }) { | ||
module.exports = function Bitbucket({ proxy, useXhr } = {}) { | ||
/** | ||
@@ -17,0 +17,0 @@ * Define HTTP proxy in format localhost:3128 |
@@ -27,2 +27,6 @@ const _ = require('lodash'); | ||
// NOTE the below comment has been clarified by TJ Kells at bitbucket - slugification is implemented here: | ||
// https://docs.djangoproject.com/en/1.11/_modules/django/utils/text/#slugify | ||
// Someday the below could be updated to precisely re-implement django's slugification. | ||
// The official API error is that slugs must be alphanumeric with underscore, dot, and dash, lowercase, and | ||
@@ -139,2 +143,42 @@ // no whitespace. Most things convert to dashes with Atlassian's secret converter but apostophes just disappear | ||
/** | ||
* Get the pull requests for a single repo, with the destination and source repos on each pull requests totally | ||
* populated. | ||
* | ||
* @param {String} repo owner | ||
* @param {String} slug (name) of the repo. | ||
* @param {Object} options The fields to populate, and optionally the PR state (defaults to OPEN) | ||
*/ | ||
getPullRequestsWithFields(username, repoSlug, { state, fields } = {}, callback) { | ||
if (!_.isArray(fields) || fields.length < 1) { | ||
throw new Error('getPullRequestsWithFields: options argument missing or has missing/empty \'fields\' array.'); | ||
} | ||
let stateArray = state; | ||
if (!stateArray) { | ||
stateArray = [constants.pullRequest.states.OPEN]; | ||
} | ||
else if (!_.isArray(stateArray)) { | ||
stateArray = [stateArray]; | ||
} | ||
const hasInvalidState = _.find(state, (stateElement) => !_.includes(constants.pullRequest.states, stateElement)); | ||
if (hasInvalidState) { | ||
stateArray = [constants.pullRequest.states.OPEN]; | ||
} | ||
const apiParameters = { | ||
state: stateArray.join(',') | ||
}; | ||
const fieldsWithEncodedPlus = fields.map((field) => `+${field}`); | ||
apiParameters.fields = fieldsWithEncodedPlus.join(','); | ||
api.get( | ||
`repositories/${encodeURI(username)}/${encodeURI(repoSlug)}/pullrequests`, // eslint-disable-line max-len | ||
apiParameters, null, | ||
result.$createListener(callback) | ||
); | ||
}, | ||
/** | ||
* Get the repositories of a user | ||
@@ -141,0 +185,0 @@ * |
@@ -239,3 +239,3 @@ const _ = require('lodash'); | ||
headers['User-Agent'] = 'NodeJS HTTP Client'; | ||
headers['Content-Lengthf'] = '0'; | ||
headers['Content-Length'] = '0'; | ||
} | ||
@@ -242,0 +242,0 @@ |
@@ -0,0 +0,0 @@ const _ = require('lodash'); |
@@ -0,0 +0,0 @@ const _ = require('lodash'); |
@@ -0,0 +0,0 @@ The MIT License |
@@ -0,0 +0,0 @@ node-github-v2 |
{ | ||
"name": "bitbucket-v2", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Wrapper for the BitBucket API v2, the version required to use OAuth2. Includes support for XHR requests.", | ||
@@ -5,0 +5,0 @@ "author": "Jordan Wallet <jjwallet@gmail.com>", |
@@ -0,0 +0,0 @@ # node-bitbucket-v2 |
26510
721
12