Skip to content

Commit

Permalink
feat(autocomplete): Allow Query Params (#269)
Browse files Browse the repository at this point in the history
* add query parms to lob-node

* test fixes

Co-authored-by: David Xu <david.xu@lob.com>
  • Loading branch information
Thexumaker and David Xu committed Mar 24, 2022
1 parent 3997fd8 commit 014e874
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/resources/usAutocompletions.js
Expand Up @@ -8,8 +8,12 @@ class USAutocompletions extends ResourceBase {
super('us_autocompletions', config);
}

autocomplete (params, callback) {
return this._transmit('POST', null, null, params, null, callback);
autocomplete (params, query_param, callback) {
if (typeof query_param === 'function') {
callback = query_param;
query_param = {};
}
return this._transmit('POST', null, query_param, params, null, callback);
}

}
Expand Down
16 changes: 16 additions & 0 deletions test/usAutocompletions.js
Expand Up @@ -18,6 +18,22 @@ describe('us_autocompletions', () => {
});
});

it.only('returns a list of suggestions with custom case', (done) => {
Lob.usAutocompletions.autocomplete({
address_prefix: '185 BER',
city: 'San Francisco',
state: 'CA'
}, {
case: 'proper'
}, (err, res) => {
expect(err).to.not.exist;
expect(res.suggestions).to.exist;
expect(res.suggestions[0].primary_line).to.eql('Test Keys Do Not Autocomplete Us Addresses');

return done();
});
});

});

});

0 comments on commit 014e874

Please sign in to comment.