check street number range for address

rather than exact address, so that we can more flexibly allow outdate post office data
This commit is contained in:
Matthew Taylor 2016-08-10 15:33:17 -04:00
parent 00920e7da6
commit 4d9fe86f40
2 changed files with 13 additions and 8 deletions

View file

@ -1,4 +1,5 @@
var defaults = require('lodash.defaults');
var defaultsDeep = require('lodash.defaultsdeep');
var xhr = require('xhr');
var jar = require('./jar');
@ -15,17 +16,15 @@ var urlParams = require('./url-params');
*/
module.exports = function (opts, callback) {
defaults(opts, {
defaultsDeep(opts, {
host: process.env.API_HOST,
headers: {},
headers: {
'X-Requested-With': 'XMLHttpRequest'
},
responseType: 'json',
useCsrf: false
});
defaults(opts.headers, {
'X-Requested-With': 'XMLHttpRequest'
});
opts.uri = opts.host + opts.uri;
if (opts.params) {
@ -43,7 +42,9 @@ module.exports = function (opts, callback) {
// For IE < 10, we must use XDR for cross-domain requests. XDR does not support
// custom headers.
defaults(opts, {useXDR: true});
delete opts.headers;
if (opts.useXDR) {
delete opts.headers;
}
if (opts.authentication) {
var authenticationParams = ['x-token=' + opts.authentication];
var parts = opts.uri.split('?');

View file

@ -8,7 +8,11 @@ module.exports = function smartyStreetApi (params, callback) {
api({
host: 'https://api.smartystreets.com',
uri: '/street-address',
params: params
headers: {
'X-Standardize-Only': true
},
params: params,
useXDR: false
}, function (err, body, res) {
if (err) return callback(err);
if (res.statusCode !== 200) {