address-geoservices
Advanced tools
Comparing version 0.0.5 to 0.0.6
24
index.js
@@ -12,3 +12,4 @@ 'use strict'; | ||
normalize: function(addressObj, cb) { | ||
if (!texKey) { throw new Error('No API key provided'); } | ||
if (!texKey) { return cb(new Error('No API key provided')); } | ||
var endpoint = 'https://geoservices.tamu.edu/Services/AddressNormalization/WebService/v04_01/HTTP/default.aspx'; | ||
@@ -29,3 +30,6 @@ | ||
}, function(err, incomingMessage, response) { | ||
if (err) { cb(err); } | ||
if (err) { return cb(err); } | ||
if (incomingMessage.statusCode < 200 || incomingMessage.statusCode > 299) { | ||
return cb(incomingMessage.statusCode); | ||
} | ||
@@ -73,7 +77,17 @@ xml2js.parseString(response, cb); | ||
initTex: function(_texKey, _texVersion) { | ||
texKey = _texKey; | ||
texVersion = _texVersion; | ||
if (_texKey) { | ||
texKey = _texKey; | ||
} else { | ||
throw new Error('API key is required'); | ||
} | ||
if (_texVersion) { | ||
texVersion = _texVersion; | ||
} | ||
}, | ||
initYaddress: function(_yuriKey) { | ||
yuriKey = _yuriKey; | ||
if (_yuriKey) { | ||
yuriKey = _yuriKey; | ||
} else { | ||
throw new Error('API key is required'); | ||
} | ||
} | ||
@@ -80,0 +94,0 @@ }; |
{ | ||
"name": "address-geoservices", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Interacts with geoservices apis to help with managing addresses", | ||
@@ -12,3 +12,5 @@ "main": "index.js", | ||
"address normalization", | ||
"address validation" | ||
"address validation", | ||
"address", | ||
"addresses" | ||
], | ||
@@ -21,3 +23,6 @@ "author": "Randall Koutnik <rkoutnik@gmail.com>", | ||
"xml2js": "~0.4.2" | ||
}, | ||
"devDependencies": { | ||
"should": "^3.3.1" | ||
} | ||
} |
@@ -9,6 +9,19 @@ #address-geoservices | ||
###Usage | ||
##Usage | ||
There are two separate services provided by `address-geoservices` - normalization and correction. | ||
###The address object: | ||
Both `normalize` and `validate` expect to be called with two parameters: an address object with the following properties: | ||
{ | ||
street: '', | ||
city: '', | ||
state: '', | ||
zip: '' | ||
} | ||
and a callback. The callback will be called with two parameters: `err` (if an error occurred, null otherwise) and an object with the results of the API call. | ||
####Normalization | ||
@@ -24,11 +37,4 @@ | ||
Once you've called `initTex`, you can use `.normalize` to normalize a given address. `normalize` expects two arguments. One, an object with the following properties: | ||
Once you've called `initTex`, you can use `.normalize` to normalize a given address. | ||
- street | ||
- city | ||
- state | ||
- zip | ||
and a callback, which will be called with `err` or the returned, normalized address: | ||
geoservices.normalize({ | ||
@@ -53,3 +59,3 @@ street: '2301 Westside Drive', | ||
`validate` expects two arguments, an object like the one in `normalize`, and a callback: | ||
Once initalized, `validate` can be used as such: | ||
@@ -56,0 +62,0 @@ geoservices.validate({ |
Sorry, the diff of this file is not supported yet
6141
5
110
68
1