bitbucket-v2
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -6,2 +6,3 @@ const constants = require('./constants'); | ||
const buildWorkspaces = require('./workspaces'); | ||
const { extractResponseBody } = require('./helpers'); | ||
@@ -98,13 +99,13 @@ | ||
* Check for whether we can iterate to another page using this.getNextPage(response). | ||
* @param {response} response A response that was received from the API. | ||
* @param {response} response A response that was received from the API, or its `body` property. | ||
* @return {boolean} true if the response indicates more pages are available, false otherwise. | ||
*/ | ||
apiModel.hasNextPage = (response) => !!response.next; | ||
apiModel.hasNextPage = (response) => Boolean(extractResponseBody(response).next); | ||
/** | ||
* Check for whether we can iterate to another page using this.getPreviousPage(response). | ||
* @param {response} response A response that was received from the API. | ||
* @param {response} response A response that was received from the API, or its `body` property. | ||
* @return {boolean} true if the response indicates a previous pages is available, false otherwise. | ||
*/ | ||
apiModel.hasPreviousPage = (response) => !!response.previous; | ||
apiModel.hasPreviousPage = (response) => Boolean(extractResponseBody(response).previous); | ||
@@ -115,3 +116,3 @@ /** | ||
* | ||
* @param {response} response A response that was received from the API. | ||
* @param {response} response A response that was received from the API, or its `body` property. | ||
*/ | ||
@@ -125,3 +126,3 @@ apiModel.getNextPage = (response) => { | ||
return apiModel.request.doPrebuiltSend(response.next); | ||
return apiModel.request.doPrebuiltSend(extractResponseBody(response).next); | ||
}; | ||
@@ -133,3 +134,3 @@ | ||
* | ||
* @param {response} response A response that was received from the API. | ||
* @param {response} response A response that was received from the API, or its `body` property. | ||
*/ | ||
@@ -143,3 +144,3 @@ apiModel.getPreviousPage = (response) => { | ||
return apiModel.request.doPrebuiltSend(response.previous); | ||
return apiModel.request.doPrebuiltSend(extractResponseBody(response).previous); | ||
}; | ||
@@ -146,0 +147,0 @@ |
const _ = require('lodash'); | ||
const constants = require('./constants'); | ||
const { extractResponseBody } = require('./helpers'); | ||
@@ -173,6 +174,6 @@ /** | ||
* | ||
* @param {Object} API response | ||
* @param {Object} response API response, or its `body` property | ||
*/ | ||
getForksFromResponse: (response) => { | ||
const prebuiltURL = response && response.links && response.links.forks && response.links.forks.href; | ||
const prebuiltURL = _.get(extractResponseBody(response), ['links', 'forks', 'href']); | ||
@@ -190,6 +191,6 @@ if (!prebuiltURL) { | ||
* | ||
* @param {Object} API response | ||
* @param {Object} response API response, or its `body` property | ||
*/ | ||
getParentFromResponse: (response) => { | ||
const prebuiltURL = _.get(response, 'parent.links.self.href'); | ||
const prebuiltURL = _.get(extractResponseBody(response), ['parent', 'links', 'self', 'href']); | ||
@@ -208,7 +209,7 @@ if (!prebuiltURL) { | ||
* | ||
* @param {Object} API response | ||
* @param {Object} response API response, or its `body` property | ||
* @return {boolean} true if the argument has an associated "parent" (i.e. the response is a fork), false otherwise. | ||
*/ | ||
hasParent: (response) => Boolean(response.parent) | ||
hasParent: (response) => Boolean(extractResponseBody(response).parent) | ||
}; | ||
}; |
@@ -8,3 +8,3 @@ const _ = require('lodash'); | ||
/** | ||
* Performs requests on GitHub API. | ||
* Performs requests on Bitbucket API. | ||
*/ | ||
@@ -11,0 +11,0 @@ module.exports = function Request(_options) { |
# CHANGLOG | ||
## 0.5.2 | ||
- Functions that take an API response as an argument now properly handle taking the _entire_ response, as they did in `0.4.x`. They _also_ still accept just the response's `body` property, as in `0.5.1`. Affected functions: `hasNextPage`, `hasPreviousPage`, `getNextPage`, `getPreviousPage`, `repositories.getForksFromResponse`, `repositories.hasParent`, `repositories.getParentFromResponse`. | ||
## 0.5.0 | ||
## 0.5.1 | ||
@@ -12,3 +14,3 @@ This version is targeted at two main goals: | ||
- Started CHANGLOG document. | ||
- Started CHANGELOG document. | ||
- Added Node 7.6 requirement. | ||
@@ -15,0 +17,0 @@ - All asynchronous functions now return a promise, and no longer accept a callback. |
{ | ||
"name": "bitbucket-v2", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"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>", |
26632
13
608