cdyne-address
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -32,15 +32,15 @@ var request = require('request'), | ||
case (1): | ||
desc = 'Invalid input'; | ||
desc = 'Invalid input.'; | ||
break; | ||
case (2): | ||
desc = 'Invalid License Key'; | ||
desc = 'Invalid License Key.'; | ||
break; | ||
case (10): | ||
desc = 'Input address is not found'; | ||
desc = 'Input address is not found.'; | ||
break; | ||
case (101): | ||
desc = 'Input address is found, but not DPV confirmed'; | ||
desc = 'Input address is found, but not DPV confirmed.'; | ||
break; | ||
case (102): | ||
desc = 'Input address primary number is DPV confirmed. Secondary number is present but not DPV confirmed'; | ||
desc = 'Input address primary number is DPV confirmed. Secondary number is present but not DPV confirmed.'; | ||
break; | ||
@@ -74,8 +74,22 @@ case (103): | ||
}, function(error, response, body) { | ||
if (!error && body.ReturnCode !== 100 ) | ||
{ | ||
var description = _this._getReturnCodeInfo(body.ReturnCode); | ||
error = new Error(description); | ||
if (!body || body.ReturnCode === 1 || body.ReturnCode === 2 || body.ReturnCode === 10 ) { | ||
var errorDescription; | ||
if (body){ | ||
errorDescription = _this._getReturnCodeInfo(body.ReturnCode); | ||
} else { | ||
errorDescription = 'Server unavailable.'; | ||
} | ||
// these are failing ReturnCodes, return Error | ||
error = new Error(errorDescription); | ||
error.name = body.ReturnCode; | ||
return callback(error); | ||
} | ||
callback(error, body || {}); | ||
// success case, add ReturnCodeText to hold additional information | ||
// about the ReturnCode we've received | ||
var description = _this._getReturnCodeInfo(body.ReturnCode); | ||
body.ReturnCodeText = description; | ||
callback(null, body); | ||
}); | ||
@@ -82,0 +96,0 @@ }; |
{ | ||
"name": "cdyne-address", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "CDYNE Postal Address Verification API node.js wrapper", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cdyne-address.js", |
6235
124