Skip to content

Commit ba595cf

Browse files
author
Max Pothier
committed
add county_source to the sdk
1 parent d6c0c59 commit ba595cf

File tree

3 files changed

+32
-34
lines changed

3 files changed

+32
-34
lines changed

examples/us_street.js

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const SmartySDK = require("smartystreets-javascript-sdk");
1+
const SmartySDK = require("../dist/cjs/index.cjs");
22
const SmartyCore = SmartySDK.core;
33
const Lookup = SmartySDK.usStreet.Lookup;
44

@@ -8,7 +8,8 @@ const Lookup = SmartySDK.usStreet.Lookup;
88
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
99

1010
// for client-side requests (browser/mobile), use this code:
11-
let key = process.env.SMARTY_EMBEDDED_KEY;
11+
// Note: key must be a string
12+
let key = "your key";
1213
const credentials = new SmartyCore.SharedCredentials(key);
1314

1415
// The appropriate license values to be used for your subscriptions
@@ -23,37 +24,17 @@ let client = clientBuilder.buildUsStreetApiClient();
2324
// https://www.smarty.com/docs/us-street-api#input-fields
2425

2526
let lookup1 = new Lookup();
26-
lookup1.inputId = "24601"; // Optional ID from your system
27-
lookup1.addressee = "John Doe";
28-
lookup1.street = "330 N 100 W";
29-
lookup1.street2 = "closet under the stairs";
30-
lookup1.secondary = "APT 2";
31-
lookup1.urbanization = ""; // Only applies to Puerto Rico addresses
32-
lookup1.city = "Provo";
33-
lookup1.state = "Utah";
34-
lookup1.zipCode = "84601";
35-
lookup1.maxCandidates = 3;
36-
lookup1.match = "invalid"; // "invalid" is the most permissive match,
37-
// this will always return at least one result even if the address is invalid.
38-
// Refer to the documentation for additional MatchStrategy options.
39-
40-
let lookup2 = new Lookup();
41-
lookup2.street = "1600 Amphitheater Pkwy";
42-
lookup2.lastLine = "Mountainview, CA";
43-
lookup2.maxCandidates = 5;
44-
45-
let lookup3 = new Lookup();
46-
lookup3.inputId = "8675309";
47-
lookup3.street = "1600 Amphitheatre Parkway Mountain View, CA 94043";
48-
lookup3.maxCandidates = 1;
49-
50-
// NOTE: batches are not supported when using SharedCredentials.
51-
let batch = new SmartyCore.Batch();
52-
batch.add(lookup1);
53-
batch.add(lookup2);
54-
batch.add(lookup3);
55-
56-
await handleResponse(batch);
27+
lookup1.street = "805 Tye Crossing Ct";
28+
lookup1.city = "Burleson";
29+
lookup1.state = "TX";
30+
lookup1.zipCode = "76028";
31+
lookup1.candidates = 10;
32+
lookup1.match = "enhanced";
33+
// lookup1.countySource = "geographic";
34+
35+
(async () => {
36+
await handleResponse(lookup1);
37+
})();
5738

5839
function handleSuccess(response) {
5940
response.lookups.map(lookup => console.log(lookup.result));

src/us_street/Lookup.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,22 @@
44
* @see "https://www.smarty.com/docs/cloud/us-street-api#input-fields"
55
*/
66
class Lookup {
7-
constructor(street, street2, secondary, city, state, zipCode, lastLine, addressee, urbanization, match, maxCandidates, inputId, format) {
7+
constructor(
8+
street,
9+
street2,
10+
secondary,
11+
city,
12+
state,
13+
zipCode,
14+
lastLine,
15+
addressee,
16+
urbanization,
17+
match,
18+
maxCandidates,
19+
inputId,
20+
format,
21+
countySource,
22+
) {
823
this.street = street;
924
this.street2 = street2;
1025
this.secondary = secondary;
@@ -18,6 +33,7 @@ class Lookup {
1833
this.maxCandidates = maxCandidates;
1934
this.inputId = inputId;
2035
this.format = format;
36+
this.countySource = countySource;
2137
this.result = [];
2238
}
2339
}

src/util/apiToSDKKeyMap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
"match": "match",
1313
"format": "format",
1414
"candidates": "maxCandidates",
15+
"county_source": "countySource"
1516
},
1617
usAutocompletePro: {
1718
search: "search",

0 commit comments

Comments
 (0)