cimpress-fulfiller-identity
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -8,2 +8,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var axios = require('axios'); | ||
var axiosRetry = require('axios-retry'); | ||
var FulfillerNotFoundError = require("./errors/fulfiller_not_found_error"); | ||
@@ -42,6 +43,13 @@ var XRayProxy = require("./xray_proxy"); | ||
this.xrayPRoxy = new XRayProxy(this.authorizer, awsXRay); | ||
axiosRetry(axios, { | ||
retries: options.retries && options.retries >= 0 ? options.retries : 3, | ||
retryDelay: function retryDelay(retryCount) { | ||
return options.retryDelayInMs && options.retryDelayInMs >= 0 ? options.retryDelayInMs : 1000; | ||
} | ||
}); | ||
} | ||
_createClass(FulfillerIdentityClient, [{ | ||
key: "getUrl", | ||
key: 'getUrl', | ||
value: function getUrl() { | ||
@@ -62,3 +70,3 @@ return this.baseUrl; | ||
}, { | ||
key: "getFulfillers", | ||
key: 'getFulfillers', | ||
value: function getFulfillers(options) { | ||
@@ -68,12 +76,12 @@ return this.xrayPRoxy.capturePromise('FulfillerIdentity.getFulfillers', this._getFulfillers.bind(this), [], options); | ||
}, { | ||
key: "_getFulfillers", | ||
key: '_getFulfillers', | ||
value: function _getFulfillers(authorization, subsegment, options) { | ||
var queryParameters = []; | ||
if (options && options.showArchived) queryParameters.push("showArchived=" + options.showArchived); | ||
if (options && options.showArchived) queryParameters.push('showArchived=' + options.showArchived); | ||
if (options && options.fulfillerName) queryParameters.push("fulfillerName=" + options.fulfillerName); | ||
if (options && options.fulfillerName) queryParameters.push('fulfillerName=' + options.fulfillerName); | ||
if (options && options.noCache) queryParameters.push("noCache=" + Math.random()); | ||
if (options && options.noCache) queryParameters.push('noCache=' + Math.random()); | ||
var url = this.baseUrl + "/v1/fulfillers" + (queryParameters.length ? "?" + queryParameters.join('&') : ""); | ||
var url = this.baseUrl + '/v1/fulfillers' + (queryParameters.length ? "?" + queryParameters.join('&') : ""); | ||
return this.makeRequest(authorization, 'GET', url).then(function (res) { | ||
@@ -101,3 +109,3 @@ subsegment.addMetadata("response", res.data); | ||
}, { | ||
key: "getFulfiller", | ||
key: 'getFulfiller', | ||
value: function getFulfiller(fulfillerId, options) { | ||
@@ -107,8 +115,8 @@ return this.xrayPRoxy.capturePromise('FulfillerIdentity.getFulfillerById', this._getFulfiller.bind(this), [], fulfillerId, options); | ||
}, { | ||
key: "_getFulfiller", | ||
key: '_getFulfiller', | ||
value: function _getFulfiller(authorization, subsegment, fulfillerId, options) { | ||
if (options && options.noCache) queryParameters.push("noCache=" + Math.random()); | ||
if (options && options.noCache) queryParameters.push('noCache=' + Math.random()); | ||
var url = this.baseUrl + "/v1/fulfillers/" + fulfillerId + (options && options.noCache ? "?noCache=" + Math.random() : ""); | ||
var url = this.baseUrl + '/v1/fulfillers/' + fulfillerId + (options && options.noCache ? '?noCache=' + Math.random() : ""); | ||
@@ -122,3 +130,3 @@ subsegment.addAnnotation("FulfillerId", fulfillerId); | ||
}).catch(function (err) { | ||
return Promise.reject(err.response && err.response.status === 404 ? new FulfillerNotFoundError("Fulfiller " + fulfillerId + " does not exits") : new Error("Unable to get fulfiller: " + err.message)); | ||
return Promise.reject(err.response && err.response.status === 404 ? new FulfillerNotFoundError('Fulfiller ' + fulfillerId + ' does not exits') : new Error("Unable to get fulfiller: " + err.message)); | ||
}); | ||
@@ -137,3 +145,3 @@ } | ||
}, { | ||
key: "getFulfillerContacts", | ||
key: 'getFulfillerContacts', | ||
value: function getFulfillerContacts(fulfillerId, options) { | ||
@@ -143,6 +151,6 @@ return this.xrayPRoxy.capturePromise('FulfillerIdentity.getFulfillerContacts', this._getFulfillerContacts.bind(this), [], fulfillerId, options); | ||
}, { | ||
key: "_getFulfillerContacts", | ||
key: '_getFulfillerContacts', | ||
value: function _getFulfillerContacts(authorization, subsegment, fulfillerId, options) { | ||
var url = this.baseUrl + "/v1/fulfillers/" + fulfillerId + "/contacts" + (options && options.noCache ? "?noCache=" + Math.random() : ""); | ||
var url = this.baseUrl + '/v1/fulfillers/' + fulfillerId + '/contacts' + (options && options.noCache ? '?noCache=' + Math.random() : ""); | ||
@@ -158,3 +166,3 @@ subsegment.addAnnotation("FulfillerId", fulfillerId); | ||
}).catch(function (err) { | ||
return Promise.reject(err.response && err.response.status === 404 ? new FulfillerNotFoundError("Fulfiller " + fulfillerId + " does not exits") : new Error("Unable to get fulfiller contacts: " + err.message)); | ||
return Promise.reject(err.response && err.response.status === 404 ? new FulfillerNotFoundError('Fulfiller ' + fulfillerId + ' does not exits') : new Error("Unable to get fulfiller contacts: " + err.message)); | ||
}); | ||
@@ -169,3 +177,3 @@ } | ||
}, { | ||
key: "saveFulfiller", | ||
key: 'saveFulfiller', | ||
value: function saveFulfiller(fulfiller) { | ||
@@ -175,3 +183,3 @@ return this.xrayPRoxy.capturePromise('FulfillerIdentity.saveFulfiller', this._saveFulfiller.bind(this), [], fulfiller); | ||
}, { | ||
key: "_saveFulfiller", | ||
key: '_saveFulfiller', | ||
value: function _saveFulfiller(authorization, subsegment, fulfiller) { | ||
@@ -181,3 +189,3 @@ var fulfillerId = fulfiller.fulfillerId || fulfiller.internalFulfillerId; | ||
subsegment.addAnnotation("FulfillerId", fulfillerId); | ||
return this.makeRequest(authorization, 'PUT', this.baseUrl + "/v1/fulfillers/" + fulfillerId, fulfiller).then(function (f) { | ||
return this.makeRequest(authorization, 'PUT', this.baseUrl + '/v1/fulfillers/' + fulfillerId, fulfiller).then(function (f) { | ||
return Promise.resolve(); | ||
@@ -188,3 +196,3 @@ }).catch(function (err) { | ||
} else { | ||
return this.makeRequest(authorization, 'POST', this.baseUrl + "/v1/fulfillers", fulfiller).then(function (f) { | ||
return this.makeRequest(authorization, 'POST', this.baseUrl + '/v1/fulfillers', fulfiller).then(function (f) { | ||
return Promise.resolve(); | ||
@@ -197,3 +205,3 @@ }).catch(function (err) { | ||
}, { | ||
key: "makeRequest", | ||
key: 'makeRequest', | ||
value: function makeRequest(authorization, method, url, body) { | ||
@@ -200,0 +208,0 @@ var timeout = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 3000; |
{ | ||
"name": "cimpress-fulfiller-identity", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Thin client library for Cimpress' Fulfiller Identity service", | ||
@@ -30,3 +30,4 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"axios": "^0.16.2" | ||
"axios": "^0.18.0", | ||
"axios-retry": "^3.1.1" | ||
}, | ||
@@ -33,0 +34,0 @@ "devDependencies": { |
@@ -26,3 +26,5 @@ # Cimpress Fulfiller Identity client | ||
AWSXRay: aws-xray-sdk, // AWS X-Ray SDK | ||
url: string // Base url of the service, by default it will be fulfilleridentity.trdlnk.cimpress.io | ||
url: 'string', // Base url of the service, by default it will be fulfilleridentity.trdlnk.cimpress.io | ||
retries: 3, // By default there are 3 retries | ||
retryDelayInMs: 1000 //Default: 1000 | ||
} | ||
@@ -29,0 +31,0 @@ const authorization = null || string || function, // Used to authorize the requests. |
const axios = require('axios'); | ||
const axiosRetry = require('axios-retry'); | ||
const FulfillerNotFoundError = require("./errors/fulfiller_not_found_error"); | ||
@@ -27,2 +28,7 @@ const XRayProxy = require("./xray_proxy"); | ||
this.xrayPRoxy = new XRayProxy(this.authorizer, awsXRay); | ||
axiosRetry(axios, { | ||
retries: options.retries && options.retries >= 0 ? options.retries : 3, | ||
retryDelay: retryCount => options.retryDelayInMs && options.retryDelayInMs >= 0 ? options.retryDelayInMs : 1000 | ||
}); | ||
} | ||
@@ -29,0 +35,0 @@ |
55332
1075
133
2
+ Addedaxios-retry@^3.1.1
+ Added@babel/runtime@7.26.9(transitive)
+ Addedaxios@0.18.1(transitive)
+ Addedaxios-retry@3.9.1(transitive)
+ Addedfollow-redirects@1.5.10(transitive)
+ Addedis-buffer@2.0.5(transitive)
+ Addedis-retry-allowed@2.2.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removedaxios@0.16.2(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedis-buffer@1.1.6(transitive)
Updatedaxios@^0.18.0