Skip to content

Commit 4af2ef8

Browse files
author
Max Pothier
committed
changing the example back
1 parent 8c2bf1b commit 4af2ef8

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

examples/us_street.js

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

@@ -8,8 +8,7 @@ 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-
// Note: key must be a string
12-
let key = "your key";
11+
let key = process.env.SMARTY_EMBEDDED_KEY;
1312
const credentials = new SmartyCore.SharedCredentials(key);
1413

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

2625
let lookup1 = new Lookup();
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-
})();
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);
3857

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

0 commit comments

Comments
 (0)