smartystreets-javascript-sdk
Advanced tools
Comparing version 1.0.6 to 1.1.0
{ | ||
"name": "smartystreets-javascript-sdk", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"description": "Quick and easy SmartyStreets address validation.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -40,2 +40,3 @@ const HttpSender = require("./HttpSender"); | ||
this.customHeaders = {}; | ||
this.debug = undefined; | ||
@@ -120,6 +121,17 @@ function noCredentialsProvided() { | ||
/** | ||
* Enables debug mode, which will print information about the HTTP request and response to console.log | ||
* @return Returns <b>this</b> to accommodate method chaining. | ||
*/ | ||
withDebug() { | ||
this.debug = true; | ||
return this; | ||
} | ||
buildSender() { | ||
if (this.httpSender) return this.httpSender; | ||
const httpSender = new HttpSender(this.maxTimeout, this.maxRetries, this.proxy); | ||
const httpSender = new HttpSender(this.maxTimeout, this.maxRetries, this.proxy, this.debug); | ||
const statusCodeSender = new StatusCodeSender(httpSender); | ||
@@ -126,0 +138,0 @@ const signingSender = new SigningSender(statusCodeSender, this.signer); |
@@ -7,3 +7,3 @@ const Response = require("./Response"); | ||
class HttpSender { | ||
constructor(timeout = 10000, retries = 5, proxyConfig) { | ||
constructor(timeout = 10000, retries = 5, proxyConfig, debug = false) { | ||
axiosRetry(Axios, { | ||
@@ -14,2 +14,3 @@ retries: retries, | ||
this.proxyConfig = proxyConfig; | ||
if (debug) this.enableDebug(); | ||
} | ||
@@ -58,4 +59,20 @@ | ||
} | ||
enableDebug() { | ||
Axios.interceptors.request.use(request => { | ||
console.log('Request:\r\n', request); | ||
console.log('\r\n*******************************************\r\n'); | ||
return request | ||
}); | ||
Axios.interceptors.response.use(response => { | ||
console.log('Response:\r\n'); | ||
console.log('Status:', response.status, response.statusText); | ||
console.log('Headers:', response.headers); | ||
console.log('Data:', response.data); | ||
return response | ||
}) | ||
} | ||
} | ||
module.exports = HttpSender; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118895
2727