1- const SmartySDK = require ( "smartystreets-javascript-sdk " ) ;
1+ const SmartySDK = require ( "../dist/cjs/index.cjs " ) ;
22const SmartyCore = SmartySDK . core ;
33const 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" ;
1213const 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
2526let 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
5839function handleSuccess ( response ) {
5940 response . lookups . map ( lookup => console . log ( lookup . result ) ) ;
0 commit comments