Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cimpress-fulfillment-location

Package Overview
Dependencies
Maintainers
7
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cimpress-fulfillment-location - npm Package Compare versions

Comparing version 0.1.21 to 1.0.0

9

CHANGELOG.md

@@ -13,2 +13,9 @@ # Change Log

### Added
- Enable showArchived flag for listing fulfillment locations.
- Enable showArchived flag for listing fulfillment locations.
## [1.0] - 2018-11-29
### Changed
- Aditional properties of getLocations and getLocation moved to a single object paramenter `options`.
### Added
- Added new skipCache option that disables all the caches.

55

fulfillmentLocation.js

@@ -80,8 +80,8 @@ 'use strict';

key: 'getLocation',
value: function getLocation(locationId, authorization) {
value: function getLocation(locationId, options) {
var _this = this;
return new Promise(function (resolve, reject) {
handleAuthorization(authorization, reject);
var opts = options || {};
handleAuthorization(opts.accessToken, reject);
var instance = axios.create({

@@ -92,6 +92,6 @@ baseURL: _this.url,

instance.defaults.headers.common['Authorization'] = authorization;
instance.defaults.headers.common['Authorization'] = opts.accessToken;
if (!_this.useCaching) {
return _this._getFulfillmentLocationFromService(instance, locationId).then(function (location) {
if (!_this.useCaching || opts.skipCache) {
return _this._getFulfillmentLocationFromService(instance, locationId, opts).then(function (location) {
return resolve(location);

@@ -103,3 +103,3 @@ }).catch(function (err) {

var cacheKey = 'fulfillmentLocation_' + locationId + '_' + authorization;
var cacheKey = 'fulfillmentLocation_' + locationId + '_' + opts.accessToken;
flCache.get(cacheKey, function (err, fulfillmentLocation) {

@@ -113,3 +113,3 @@

return _this._getFulfillmentLocationFromService(instance, locationId).then(function (location) {
return _this._getFulfillmentLocationFromService(instance, locationId, opts).then(function (location) {
flCache.set(cacheKey, location);

@@ -128,11 +128,8 @@ return resolve(location);

key: 'getLocations',
value: function getLocations(authorization) {
value: function getLocations(options) {
var _this2 = this;
var showArchived = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
return new Promise(function (resolve, reject) {
handleAuthorization(authorization, reject);
var opts = options || {};
handleAuthorization(opts.accessToken, reject);
var instance = axios.create({

@@ -143,6 +140,6 @@ baseURL: _this2.url,

instance.defaults.headers.common['Authorization'] = authorization;
instance.defaults.headers.common['Authorization'] = opts.accessToken;
if (!_this2.useCaching) {
return _this2._getFulfillmentLocationsFromService(instance, showArchived).then(function (locations) {
if (!_this2.useCaching || opts.skipCache) {
return _this2._getFulfillmentLocationsFromService(instance, opts).then(function (locations) {
return resolve(locations);

@@ -154,3 +151,3 @@ }).catch(function (err) {

var cacheKey = 'fulfillmentLocations_' + authorization;
var cacheKey = 'fulfillmentLocations_' + opts.accessToken;
flCache.get(cacheKey, function (err, fulfillmentLocations) {

@@ -164,3 +161,3 @@

return _this2._getFulfillmentLocationsFromService(instance, showArchived).then(function (locations) {
return _this2._getFulfillmentLocationsFromService(instance, opts).then(function (locations) {
flCache.set(cacheKey, locations);

@@ -179,3 +176,3 @@ return resolve(locations);

key: '_getFulfillmentLocationFromService',
value: function _getFulfillmentLocationFromService(instance, fulfillmentLocationId) {
value: function _getFulfillmentLocationFromService(instance, fulfillmentLocationId, options) {
var _this3 = this;

@@ -188,5 +185,11 @@

url: endpoint,
timeout: _this3.timeout
timeout: _this3.timeout,
headers: {}
};
if (options.skipCache) {
requestConfig.headers['Cache-Control'] = 'no-cache';
requestConfig.headers['X-Cache-Id'] = Math.random();
}
if (_this3.log && _this3.log.info) {

@@ -214,3 +217,3 @@ _this3.log.info("->" + endpoint, requestConfig);

key: '_getFulfillmentLocationsFromService',
value: function _getFulfillmentLocationsFromService(instance, showArchived) {
value: function _getFulfillmentLocationsFromService(instance, options) {
var _this4 = this;

@@ -224,7 +227,13 @@

params: {
showArchived: showArchived
showArchived: options.showArchived || false
},
headers: {},
timeout: _this4.timeout
};
if (options.skipCache) {
requestConfig.headers['Cache-Control'] = 'no-cache';
requestConfig.headers['X-Cache-Id'] = Math.random();
}
if (_this4.log && _this4.log.info) {

@@ -231,0 +240,0 @@ _this4.log.info("->" + endpoint, requestConfig);

{
"name": "cimpress-fulfillment-location",
"version": "0.1.21",
"version": "1.0.0",
"author": "LogisticsQuotingandPlanning@cimpress.com",

@@ -5,0 +5,0 @@ "description": "A simple client for the Cimpress Fulfillment Location service",

@@ -18,3 +18,6 @@ # Cimpress Fulfillment Location client

client.getLocation(fulfillmentLocationId, req.headers.authorization)
client.getLocation(fulfillmentLocationId, {
accessToken: "Your access token",
skipCache: false, // Skips the cache so the results will be fresh, if not set is false by default
})
.then(fulfillmentLocation => {

@@ -31,3 +34,7 @@ // do stuff

client.getLocations(req.headers.authorization)
client.getLocations({
accessToken: "Your access token",
showArchived: false, // By default is false, shows archived fulfillment locations
skipCache: false // Skips the cache so the results will be fresh, if not set is false by default
})
.then(fulfillmentLocations => {

@@ -37,8 +44,2 @@ // do stuff

// To include also archived fulfillment locations
client.getLocations(req.headers.authorization, true)
.then(fulfillmentLocations => {
// do stuff
});
```

@@ -45,0 +46,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc