address-geoservices
Advanced tools
Comparing version 0.0.1 to 0.0.3
26
index.js
@@ -44,14 +44,32 @@ 'use strict'; | ||
validateAddress: function(addressObj, cb) { | ||
var endpoint = 'http://app.yurisw.com/YAddressWebService/YAddress.asmx/ProcessJson'; | ||
var endpoint = 'http://app.yurisw.com/YAddressWebService/YAddress.asmx/ProcessJson' | ||
, line1, line2; | ||
if (!addressObj.line1) { | ||
line1 = addressObj.street1 + ' ' + addressObj.street2; | ||
line2 = addressObj.city + ' ' + addressObj.state + ' ' + addressObj.zip; | ||
} else { | ||
line1 = addressObj.line1; | ||
line2 = addressObj.line2; | ||
} | ||
request({ | ||
url: endpoint, | ||
qs: { | ||
AddressLine1: addressObj.line1, | ||
AddressLine2: addressObj.line2, | ||
AddressLine1: line1, | ||
AddressLine2: line2, | ||
UserKey: '' | ||
} | ||
}, function(err, incomingMessage, response) { | ||
if (err) { cb(err); } | ||
if (err) { return cb(err); } | ||
try { | ||
var response = JSON.parse(response); | ||
} catch (e) { | ||
return cb(e); | ||
} | ||
if (response.ErrorMessage) { | ||
return cb(response.ErrorMessage); | ||
} | ||
cb(null, JSON.parse(response)); | ||
@@ -58,0 +76,0 @@ }) |
{ | ||
"name": "address-geoservices", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"description": "Interacts with geoservices apis to help with managing addresses", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
2420
66