Commit 9c88f92f authored by Matthew Taylor's avatar Matthew Taylor

check street number range for address

rather than exact address, so that we can more flexibly allow outdate post office data
parent 5001d3a1
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});
if (opts.useXDR) {
delete opts.headers;
}
if (opts.authentication) {
var authenticationParams = ['x-token=' + opts.authentication];
var parts = opts.uri.split('?');
......
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment