@ambassify/ambassify-client
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -14,2 +14,8 @@ # Changelog | ||
## 4.1.0 | ||
#### :rocket: New Feature | ||
- Every returned promise from requests has a `.hal.embedded('resourceName')` decorator that helps extract resources from `_embedded` on HAL responses. `const things = api.get('/list').hal.embedded('thing');` | ||
## 4.0.0 | ||
@@ -80,1 +86,15 @@ | ||
@@ -189,3 +189,11 @@ "use strict"; | ||
return (0, _get3["default"])((0, _getPrototypeOf2["default"])(AmbassifyApi.prototype), "request", this).call(this, method, url, query, body, options); | ||
var promise = (0, _get3["default"])((0, _getPrototypeOf2["default"])(AmbassifyApi.prototype), "request", this).call(this, method, url, query, body, options); | ||
promise.hal = { | ||
embedded: function embedded(resourceName) { | ||
return promise.then(function (res) { | ||
return _get(res.body, "_embedded.".concat(resourceName)) || []; | ||
}); | ||
} | ||
}; | ||
return promise; | ||
} | ||
@@ -192,0 +200,0 @@ }], [{ |
{ | ||
"name": "@ambassify/ambassify-client", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Base API client library for all Ambassify clients", | ||
@@ -57,3 +57,3 @@ "engines": { | ||
"homepage": "https://github.com/ambassify/api-clients#readme", | ||
"gitHead": "199ab9b0e0ab1cf87b103d936a1d7f861afc0d95" | ||
"gitHead": "a05866fc9f60257ad978e7186ee1c4f53e5eaf43" | ||
} |
@@ -190,3 +190,11 @@ const _get = require('lodash/get'); | ||
return super.request(method, url, query, body, options); | ||
const promise = super.request(method, url, query, body, options); | ||
promise.hal = { | ||
embedded: resourceName => promise.then(res => { | ||
return _get(res.body, `_embedded.${resourceName}`) || []; | ||
}) | ||
}; | ||
return promise; | ||
} | ||
@@ -197,1 +205,2 @@ | ||
module.exports = AmbassifyApi; | ||
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
50701
1161