From 2ef3d581e62c553462d241312b1949ec0b4099fa Mon Sep 17 00:00:00 2001 From: harwinderjit <83585294+harwinderjit@users.noreply.github.com> Date: Thu, 27 May 2021 14:04:10 +0530 Subject: [PATCH 1/7] APIPLAT-3908 js sdk retry policy implemented --- lib/AvaTaxClient.js | 116 ++++++++++++++++++++++++--------------- lib/UserConfiguration.js | 9 +++ package.json | 6 +- 3 files changed, 84 insertions(+), 47 deletions(-) create mode 100644 lib/UserConfiguration.js diff --git a/lib/AvaTaxClient.js b/lib/AvaTaxClient.js index 624af3af..27140f6b 100644 --- a/lib/AvaTaxClient.js +++ b/lib/AvaTaxClient.js @@ -13,14 +13,15 @@ * @version 21.3.1 * @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK */ - -import fetch from 'isomorphic-fetch'; +import fetch from 'isomorphic-fetch' import { createBasicAuthHeader } from './utils/basic_auth'; import { withTimeout } from './utils/withTimeout'; var JSONbig = require('json-bigint')({ useNativeBigInt: true }); +import polly from 'polly-js' +import UserConfiguration from './UserConfiguration.js' export default class AvaTaxClient { - /** +/** * Construct a new AvaTaxClient * * @constructor @@ -29,8 +30,15 @@ export default class AvaTaxClient { * @param string machineName Specify the machine name of the machine on which this code is executing here. Should not contain any semicolons. * @param string environment Indicates which server to use; acceptable values are "sandbox" or "production", or the full URL of your AvaTax instance. */ - constructor({ appName, appVersion, machineName, environment }) { + constructor({ appName, appVersion, machineName, environment,user=null}) { this.baseUrl = 'https://rest.avatax.com'; + if(user){ + this.user=user; + } + else{ + this.user=new UserConfiguration(0,120000); + } + if (environment == 'sandbox') { this.baseUrl = 'https://sandbox-rest.avatax.com'; } else if ( @@ -43,10 +51,9 @@ export default class AvaTaxClient { appName + '; ' + appVersion + - '; JavascriptSdk; 21.3.1; ' + + '; JavascriptSdk; 21.3.2; ' + machineName; } - /** * Configure this client to use the specified username/password security settings * @@ -75,45 +82,61 @@ export default class AvaTaxClient { * @param string verb The HTTP verb being used in this request * @param string payload The request body, if this is being sent to a POST/PUT API call */ - restCall({ url, verb, payload }) { - return withTimeout(1200000, fetch(url, { - method: verb, - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - Authorization: this.auth, - 'X-Avalara-Client': this.clientId - }, - body: JSON.stringify(payload) - })).then(res => { - var contentType = res.headers._headers['content-type'][0]; - - if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { - return res; - } - return res.text(); - }).then(text => { - var json; - try { - json = JSONbig.parse(text); - } catch (e) { - let ex = new Error('The response is in an unexpected format. See details for the complete response.'); - ex.target = 'Unknown'; - ex.details = text; - throw ex; - } - // handle error - if (json.error) { - let ex = new Error(json.error.message); - ex.code = json.error.code; - ex.target = json.error.target; - ex.details = json.error.details; - throw ex; - } else { - return json; - } - }) - } + + + restCall({ url, verb, payload }) { +let arr=[]; +for(let i=0;i{ + return withTimeout(this.user.TimeOut, fetch(url, { + method: verb, + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: this.auth, + 'X-Avalara-Client': this.clientId + }, + body: JSON.stringify(payload) + })).then(res => { +var contentType = res.headers._headers['content-type'][0]; +if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { + return res; + } + return res.text(); + }).then(text => { + var json; + try { + json = JSONbig.parse(text); + } catch (e) { + let ex = new Error('The response is in an unexpected format. See details for the complete response.'); + ex.target = 'Unknown'; + ex.details = text; + throw ex; + } + //handle error + if (json.error) { + let ex = new Error(json.error.message); + ex.code = json.error.code; + ex.target = json.error.target; + ex.details = json.error.details; + throw ex; + } else { + return json; + } + }).catch(err=>{ + if(err.message=='timeout'){ + return Promise.reject(err) + } + else if(err.code&&err.code=='InternalServerError'){ + return Promise.reject(err) + } + else return err; + }) + }) +} /** * Construct a URL with query string parameters @@ -172,6 +195,9 @@ export default class AvaTaxClient { return this.restCall({ url: path, verb: 'post', payload: model }); } + + + /** * Activate an account by accepting terms and conditions * diff --git a/lib/UserConfiguration.js b/lib/UserConfiguration.js new file mode 100644 index 00000000..d2292621 --- /dev/null +++ b/lib/UserConfiguration.js @@ -0,0 +1,9 @@ +export default class UserConfiguration { + + constructor(maxRetryattempts, TimeOut) { + this.maxRetryattempts=maxRetryattempts; + this.TimeOut=TimeOut + } + } + + diff --git a/package.json b/package.json index 37920d93..ba9db5a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { + "type": "module", "name": "avatax", - "version": "21.3.1", + "version": "21.3.2", "description": "AvaTax v2 SDK for languages using JavaScript", "main": "index.js", "homepage": "https://github.com/avadev/AvaTax-REST-V2-JS-SDK", @@ -24,7 +25,8 @@ "license": "Apache-2.0", "dependencies": { "isomorphic-fetch": "^2.2.1", - "json-bigint": "^1.0.0" + "json-bigint": "^1.0.0", + "polly-js": "^1.8.2" }, "devDependencies": { "babel-cli": "^6.22.2", From 6c1e4e7b57f0f6043bb6d1198ca468e97975aa62 Mon Sep 17 00:00:00 2001 From: svc-developer Date: Fri, 28 May 2021 17:37:51 +0530 Subject: [PATCH 2/7] Retry implemented with negative checks --- lib/AvaTaxClient.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/AvaTaxClient.js b/lib/AvaTaxClient.js index 27140f6b..b4f7677c 100644 --- a/lib/AvaTaxClient.js +++ b/lib/AvaTaxClient.js @@ -32,9 +32,18 @@ export default class AvaTaxClient { */ constructor({ appName, appVersion, machineName, environment,user=null}) { this.baseUrl = 'https://rest.avatax.com'; - if(user){ - this.user=user; - } + if(user){ + + if(user.maxRetryattempts<=0) + { + user.maxRetryattempts=0; + } + if(user.TimeOut<=0) + { + user.TimeOut=120000; + } + this.user=user; + } else{ this.user=new UserConfiguration(0,120000); } From 6a2924cb3d97fc4fe7d6d88ac9b8e101443f8379 Mon Sep 17 00:00:00 2001 From: svc-developer Date: Fri, 28 May 2021 21:00:31 +0530 Subject: [PATCH 3/7] Retry fixed on vpn error --- lib/AvaTaxClient.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/AvaTaxClient.js b/lib/AvaTaxClient.js index b4f7677c..fc1566e8 100644 --- a/lib/AvaTaxClient.js +++ b/lib/AvaTaxClient.js @@ -14,8 +14,8 @@ * @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK */ import fetch from 'isomorphic-fetch' -import { createBasicAuthHeader } from './utils/basic_auth'; -import { withTimeout } from './utils/withTimeout'; +import { createBasicAuthHeader } from './utils/basic_auth.js'; +import { withTimeout } from './utils/withTimeout.js'; var JSONbig = require('json-bigint')({ useNativeBigInt: true }); import polly from 'polly-js' import UserConfiguration from './UserConfiguration.js' @@ -139,6 +139,9 @@ if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { if(err.message=='timeout'){ return Promise.reject(err) } + else if(err.code&&err.code=='ETIMEDOUT'){ + return Promise.reject(err); + } else if(err.code&&err.code=='InternalServerError'){ return Promise.reject(err) } From 43f7aef5914c15134c152eadb517174f50f07502 Mon Sep 17 00:00:00 2001 From: svc-developer Date: Mon, 31 May 2021 15:33:05 +0530 Subject: [PATCH 4/7] Retry fixed with timeout changed in minutes --- lib/AvaTaxClient.js | 12 ++++++------ lib/UserConfiguration.js | 4 ++-- yarn.lock | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/AvaTaxClient.js b/lib/AvaTaxClient.js index fc1566e8..236cba75 100644 --- a/lib/AvaTaxClient.js +++ b/lib/AvaTaxClient.js @@ -38,14 +38,14 @@ export default class AvaTaxClient { { user.maxRetryattempts=0; } - if(user.TimeOut<=0) + if(user.TimeoutInMinutes<=0) { - user.TimeOut=120000; + user.TimeoutInMinutes=2; } this.user=user; } else{ - this.user=new UserConfiguration(0,120000); + this.user=new UserConfiguration(0,2); } if (environment == 'sandbox') { @@ -95,12 +95,12 @@ export default class AvaTaxClient { restCall({ url, verb, payload }) { let arr=[]; -for(let i=0;i{ - return withTimeout(this.user.TimeOut, fetch(url, { + return withTimeout(this.user.TimeoutInMinutes*60*1000, fetch(url, { method: verb, headers: { Accept: 'application/json', diff --git a/lib/UserConfiguration.js b/lib/UserConfiguration.js index d2292621..004bc264 100644 --- a/lib/UserConfiguration.js +++ b/lib/UserConfiguration.js @@ -1,8 +1,8 @@ export default class UserConfiguration { - constructor(maxRetryattempts, TimeOut) { + constructor(maxRetryattempts, TimeoutInMinutes) { this.maxRetryattempts=maxRetryattempts; - this.TimeOut=TimeOut + this.TimeoutInMinutes=TimeoutInMinutes } } diff --git a/yarn.lock b/yarn.lock index f1f67f7a..1bea4358 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2472,6 +2472,11 @@ pluralize@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" +polly-js@^1.8.2: + version "1.8.2" + resolved "https://registry.yarnpkg.com/polly-js/-/polly-js-1.8.2.tgz#6643376f4ec3feb91300ade628d14f11231b9d49" + integrity sha512-xLP03RU7rnczJgul5YtCbk9SRtuvE/f0hMntAoH4mMmqRoLaHBO9SXPG2UFZRBjqv0ResUCmXhQPwQXkYhBxsg== + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" From ab61a7656a239cb78b6a660a28166d3a23359d99 Mon Sep 17 00:00:00 2001 From: svc-developer Date: Tue, 1 Jun 2021 12:15:02 +0530 Subject: [PATCH 5/7] Retry fixed with user changed to userConfig --- lib/AvaTaxClient.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/AvaTaxClient.js b/lib/AvaTaxClient.js index 236cba75..bb8f5e77 100644 --- a/lib/AvaTaxClient.js +++ b/lib/AvaTaxClient.js @@ -14,11 +14,11 @@ * @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK */ import fetch from 'isomorphic-fetch' -import { createBasicAuthHeader } from './utils/basic_auth.js'; -import { withTimeout } from './utils/withTimeout.js'; +import { createBasicAuthHeader } from './utils/basic_auth'; +import { withTimeout } from './utils/withTimeout'; var JSONbig = require('json-bigint')({ useNativeBigInt: true }); import polly from 'polly-js' -import UserConfiguration from './UserConfiguration.js' +import UserConfiguration from './UserConfiguration' export default class AvaTaxClient { /** @@ -30,22 +30,22 @@ export default class AvaTaxClient { * @param string machineName Specify the machine name of the machine on which this code is executing here. Should not contain any semicolons. * @param string environment Indicates which server to use; acceptable values are "sandbox" or "production", or the full URL of your AvaTax instance. */ - constructor({ appName, appVersion, machineName, environment,user=null}) { + constructor({ appName, appVersion, machineName, environment,userConfig=null}) { this.baseUrl = 'https://rest.avatax.com'; - if(user){ + if(userConfig){ - if(user.maxRetryattempts<=0) + if(userConfig.maxRetryattempts<=0) { - user.maxRetryattempts=0; + userConfig.maxRetryattempts=0; } - if(user.TimeoutInMinutes<=0) + if(userConfig.TimeoutInMinutes<=0) { - user.TimeoutInMinutes=2; + userConfig.TimeoutInMinutes=2; } - this.user=user; + this.userConfig=userConfig; } else{ - this.user=new UserConfiguration(0,2); + this.userConfig=new UserConfiguration(0,2); } if (environment == 'sandbox') { @@ -95,12 +95,12 @@ export default class AvaTaxClient { restCall({ url, verb, payload }) { let arr=[]; -for(let i=1;i<=this.user.maxRetryattempts;i++) +for(let i=1;i<=this.userConfig.maxRetryattempts;i++) arr.push(2*i*1000); return polly(). waitAndRetry(arr) .executeForPromise(()=>{ - return withTimeout(this.user.TimeoutInMinutes*60*1000, fetch(url, { + return withTimeout(this.userConfig.TimeoutInMinutes*60*1000, fetch(url, { method: verb, headers: { Accept: 'application/json', From 660715d4770cfcc6f91f65061c3a00999e16d2bf Mon Sep 17 00:00:00 2001 From: svc-developer Date: Wed, 23 Jun 2021 10:50:01 +0530 Subject: [PATCH 6/7] Formatting changes done --- lib/AvaTaxClient.js | 109 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/lib/AvaTaxClient.js b/lib/AvaTaxClient.js index bb8f5e77..598e7711 100644 --- a/lib/AvaTaxClient.js +++ b/lib/AvaTaxClient.js @@ -16,10 +16,11 @@ import fetch from 'isomorphic-fetch' import { createBasicAuthHeader } from './utils/basic_auth'; import { withTimeout } from './utils/withTimeout'; -var JSONbig = require('json-bigint')({ useNativeBigInt: true }); import polly from 'polly-js' import UserConfiguration from './UserConfiguration' +var JSONbig = require('json-bigint')({ useNativeBigInt: true }); + export default class AvaTaxClient { /** * Construct a new AvaTaxClient @@ -50,19 +51,13 @@ export default class AvaTaxClient { if (environment == 'sandbox') { this.baseUrl = 'https://sandbox-rest.avatax.com'; - } else if ( - environment.substring(0, 8) == 'https://' || - environment.substring(0, 7) == 'http://' - ) { + } + else if (environment.substring(0, 8) == 'https://' || environment.substring(0, 7) == 'http://') { this.baseUrl = environment; } - this.clientId = - appName + - '; ' + - appVersion + - '; JavascriptSdk; 21.3.2; ' + - machineName; + this.clientId = appName + '; ' + appVersion + '; JavascriptSdk; 21.3.2; ' + machineName; } + /** * Configure this client to use the specified username/password security settings * @@ -73,6 +68,7 @@ export default class AvaTaxClient { * @param string bearerToken The OAuth 2.0 token provided by Avalara Identity * @return AvaTaxClient */ + withSecurity({ username, password, accountId, licenseKey, bearerToken }) { if (username != null && password != null) { this.auth = createBasicAuthHeader(username, password); @@ -93,38 +89,41 @@ export default class AvaTaxClient { */ - restCall({ url, verb, payload }) { -let arr=[]; -for(let i=1;i<=this.userConfig.maxRetryattempts;i++) -arr.push(2*i*1000); - return polly(). - waitAndRetry(arr) - .executeForPromise(()=>{ - return withTimeout(this.userConfig.TimeoutInMinutes*60*1000, fetch(url, { - method: verb, - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - Authorization: this.auth, - 'X-Avalara-Client': this.clientId - }, - body: JSON.stringify(payload) - })).then(res => { -var contentType = res.headers._headers['content-type'][0]; -if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { - return res; +restCall({ url, verb, payload }) { + let arr=[]; + for (let i = 1; i <= this.userConfig.maxRetryattempts; i++) { + arr.push(2 * i * 1000); } - return res.text(); - }).then(text => { - var json; - try { - json = JSONbig.parse(text); - } catch (e) { - let ex = new Error('The response is in an unexpected format. See details for the complete response.'); - ex.target = 'Unknown'; - ex.details = text; - throw ex; - } + return polly(). + waitAndRetry(arr) + .executeForPromise(()=>{ + return withTimeout(this.userConfig.TimeoutInMinutes*60*1000, fetch(url, { + method: verb, + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: this.auth, + 'X-Avalara-Client': this.clientId + }, + body: JSON.stringify(payload) + })).then(res => { + var contentType = res.headers._headers['content-type'][0]; + if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { + return res; + } + return res.text(); + }).then(text => { + var json; + try { + json = JSONbig.parse(text); + } + catch (e) { + let ex = new Error('The response is in an unexpected format. See details for the complete response.'); + ex.target = 'Unknown'; + ex.details = text; + throw ex; + } + //handle error if (json.error) { let ex = new Error(json.error.message); @@ -136,18 +135,20 @@ if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { return json; } }).catch(err=>{ - if(err.message=='timeout'){ - return Promise.reject(err) - } - else if(err.code&&err.code=='ETIMEDOUT'){ - return Promise.reject(err); - } - else if(err.code&&err.code=='InternalServerError'){ - return Promise.reject(err) - } - else return err; - }) - }) + if (err.message == 'timeout') { + return Promise.reject(err) + } + else if (err.code && err.code == 'ETIMEDOUT') { + return Promise.reject(err); + } + else if (err.code && err.code == 'InternalServerError') { + return Promise.reject(err) + } + else { + return err; + } + }) + }) } /** From dc7907121a6291d83ba0983264b6bfe3528984ee Mon Sep 17 00:00:00 2001 From: "harwinderjit.singh" Date: Thu, 24 Jun 2021 12:22:20 +0530 Subject: [PATCH 7/7] Formatting changes for JS SDK --- lib/AvaTaxClient.js | 160 +++++++++++++++++++-------------------- lib/UserConfiguration.js | 8 +- 2 files changed, 81 insertions(+), 87 deletions(-) diff --git a/lib/AvaTaxClient.js b/lib/AvaTaxClient.js index 598e7711..b8f52fdc 100644 --- a/lib/AvaTaxClient.js +++ b/lib/AvaTaxClient.js @@ -22,32 +22,30 @@ import UserConfiguration from './UserConfiguration' var JSONbig = require('json-bigint')({ useNativeBigInt: true }); export default class AvaTaxClient { -/** - * Construct a new AvaTaxClient - * - * @constructor - * @param string appName Specify the name of your application here. Should not contain any semicolons. - * @param string appVersion Specify the version number of your application here. Should not contain any semicolons. - * @param string machineName Specify the machine name of the machine on which this code is executing here. Should not contain any semicolons. - * @param string environment Indicates which server to use; acceptable values are "sandbox" or "production", or the full URL of your AvaTax instance. - */ - constructor({ appName, appVersion, machineName, environment,userConfig=null}) { + /** + * Construct a new AvaTaxClient + * + * @constructor + * @param string appName Specify the name of your application here. Should not contain any semicolons. + * @param string appVersion Specify the version number of your application here. Should not contain any semicolons. + * @param string machineName Specify the machine name of the machine on which this code is executing here. Should not contain any semicolons. + * @param string environment Indicates which server to use; acceptable values are "sandbox" or "production", or the full URL of your AvaTax instance. + */ + constructor({ appName, appVersion, machineName, environment, userConfig = null }) { this.baseUrl = 'https://rest.avatax.com'; - if(userConfig){ - - if(userConfig.maxRetryattempts<=0) - { - userConfig.maxRetryattempts=0; - } - if(userConfig.TimeoutInMinutes<=0) - { - userConfig.TimeoutInMinutes=2; - } - this.userConfig=userConfig; - } - else{ - this.userConfig=new UserConfiguration(0,2); - } + if (userConfig) { + + if (userConfig.maxRetryattempts <= 0) { + userConfig.maxRetryattempts = 0; + } + if (userConfig.TimeoutInMinutes <= 0) { + userConfig.TimeoutInMinutes = 2; + } + this.userConfig = userConfig; + } + else { + this.userConfig = new UserConfiguration(0, 2); + } if (environment == 'sandbox') { this.baseUrl = 'https://sandbox-rest.avatax.com'; @@ -57,7 +55,7 @@ export default class AvaTaxClient { } this.clientId = appName + '; ' + appVersion + '; JavascriptSdk; 21.3.2; ' + machineName; } - + /** * Configure this client to use the specified username/password security settings * @@ -68,7 +66,6 @@ export default class AvaTaxClient { * @param string bearerToken The OAuth 2.0 token provided by Avalara Identity * @return AvaTaxClient */ - withSecurity({ username, password, accountId, licenseKey, bearerToken }) { if (username != null && password != null) { this.auth = createBasicAuthHeader(username, password); @@ -87,69 +84,66 @@ export default class AvaTaxClient { * @param string verb The HTTP verb being used in this request * @param string payload The request body, if this is being sent to a POST/PUT API call */ - - -restCall({ url, verb, payload }) { - let arr=[]; + restCall({ url, verb, payload }) { + let arr = []; for (let i = 1; i <= this.userConfig.maxRetryattempts; i++) { - arr.push(2 * i * 1000); + arr.push(2 * i * 1000); } return polly(). - waitAndRetry(arr) - .executeForPromise(()=>{ - return withTimeout(this.userConfig.TimeoutInMinutes*60*1000, fetch(url, { - method: verb, - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - Authorization: this.auth, - 'X-Avalara-Client': this.clientId - }, - body: JSON.stringify(payload) - })).then(res => { - var contentType = res.headers._headers['content-type'][0]; - if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { - return res; - } - return res.text(); - }).then(text => { - var json; - try { - json = JSONbig.parse(text); - } - catch (e) { + waitAndRetry(arr) + .executeForPromise(() => { + return withTimeout(this.userConfig.TimeoutInMinutes * 60 * 1000, fetch(url, { + method: verb, + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: this.auth, + 'X-Avalara-Client': this.clientId + }, + body: JSON.stringify(payload) + })).then(res => { + var contentType = res.headers._headers['content-type'][0]; + if (contentType === 'application/vnd.ms-excel' || contentType === 'text/csv') { + return res; + } + return res.text(); + }).then(text => { + var json; + try { + json = JSONbig.parse(text); + } + catch (e) { let ex = new Error('The response is in an unexpected format. See details for the complete response.'); ex.target = 'Unknown'; ex.details = text; throw ex; - } - - //handle error - if (json.error) { - let ex = new Error(json.error.message); - ex.code = json.error.code; - ex.target = json.error.target; - ex.details = json.error.details; - throw ex; - } else { - return json; - } - }).catch(err=>{ - if (err.message == 'timeout') { + } + //handle error + if (json.error) { + let ex = new Error(json.error.message); + ex.code = json.error.code; + ex.target = json.error.target; + ex.details = json.error.details; + throw ex; + } else { + return json; + } + }).catch(err => { + if (err.message == 'timeout') { return Promise.reject(err) - } - else if (err.code && err.code == 'ETIMEDOUT') { + } + else if (err.code && err.code == 'ETIMEDOUT') { return Promise.reject(err); - } - else if (err.code && err.code == 'InternalServerError') { + } + else if (err.code && err.code == 'InternalServerError') { return Promise.reject(err) - } - else { + } + else { return err; - } - }) - }) -} + } + }) + }) + } /** * Construct a URL with query string parameters @@ -2309,7 +2303,7 @@ restCall({ url, verb, payload }) { * * @return FetchResult */ - listMrsCompanies({ } = {}) { + listMrsCompanies({ } = {}) { var path = this.buildUrl({ url: `/api/v2/companies/mrs`, parameters: {} @@ -3673,7 +3667,7 @@ restCall({ url, verb, payload }) { * * @return FetchResult */ - listCrossBorderSections({ } = {}) { + listCrossBorderSections({ } = {}) { var path = this.buildUrl({ url: `/api/v2/definitions/crossborder/sections`, parameters: {} @@ -10858,7 +10852,7 @@ restCall({ url, verb, payload }) { * * @return FetchResult */ - listMySubscriptions({ } = {}) { + listMySubscriptions({ } = {}) { var path = this.buildUrl({ url: `/api/v2/utilities/subscriptions`, parameters: {} @@ -10893,7 +10887,7 @@ restCall({ url, verb, payload }) { * * @return object */ - ping({ } = {}) { + ping({ } = {}) { var path = this.buildUrl({ url: `/api/v2/utilities/ping`, parameters: {} diff --git a/lib/UserConfiguration.js b/lib/UserConfiguration.js index 004bc264..d73370ac 100644 --- a/lib/UserConfiguration.js +++ b/lib/UserConfiguration.js @@ -1,9 +1,9 @@ export default class UserConfiguration { - constructor(maxRetryattempts, TimeoutInMinutes) { - this.maxRetryattempts=maxRetryattempts; - this.TimeoutInMinutes=TimeoutInMinutes - } + constructor(maxRetryattempts, TimeoutInMinutes) { + this.maxRetryattempts = maxRetryattempts; + this.TimeoutInMinutes = TimeoutInMinutes; } +}