smartystreets-javascript-sdk 1.11.6 → 1.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +2 -2
- package/examples/international_address_autocomplete.js +12 -9
- package/examples/international_street.js +11 -6
- package/examples/us_autocomplete_pro.js +12 -9
- package/examples/us_extract.js +10 -3
- package/examples/us_reverse_geo.js +10 -3
- package/examples/us_street.js +10 -3
- package/examples/us_zipcode.js +10 -3
- package/package.json +1 -1
package/Makefile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/make -f
|
|
2
2
|
|
|
3
|
-
VERSION :=
|
|
3
|
+
VERSION := $(shell tagit -p --dry-run)
|
|
4
4
|
VERSION_FILE1 := package.json
|
|
5
5
|
VERSION_FILE2 := package-lock.json
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ node_modules:
|
|
|
14
14
|
npm install
|
|
15
15
|
|
|
16
16
|
publish: clean test version upload unversion
|
|
17
|
-
|
|
17
|
+
tagit -p
|
|
18
18
|
git push origin --tags
|
|
19
19
|
|
|
20
20
|
upload:
|
|
@@ -17,12 +17,7 @@ let client = clientBuilder.buildInternationalAddressAutocompleteClient();
|
|
|
17
17
|
//www.smartystreets.com/docs/cloud/international-address-autocomplete-api#pro-http-request-input-fields
|
|
18
18
|
|
|
19
19
|
let lookup = new Lookup("Ave", "CAN");
|
|
20
|
-
|
|
21
|
-
client.send(lookup)
|
|
22
|
-
.then(function (results) {
|
|
23
|
-
logSuggestions(results, "Simple Lookup");
|
|
24
|
-
})
|
|
25
|
-
.catch(console.log);
|
|
20
|
+
await handleRequest(lookup, "Simple Request");
|
|
26
21
|
|
|
27
22
|
// *** Using Filter and Prefer ***
|
|
28
23
|
lookup = new Lookup("Ave", "CAN");
|
|
@@ -32,12 +27,20 @@ lookup.maxResults = 10;
|
|
|
32
27
|
lookup.include_only_locality = "Sherwood Park";
|
|
33
28
|
// lookup.include_only_postal_code = "";
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.catch(console.log);
|
|
30
|
+
await handleRequest(lookup, "Using Filter and Prefer");
|
|
31
|
+
|
|
38
32
|
|
|
39
33
|
function logSuggestions(response, message) {
|
|
40
34
|
console.log(message);
|
|
41
35
|
console.log(response.result);
|
|
42
36
|
console.log("*********************");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function handleRequest(lookup, lookupType) {
|
|
40
|
+
try {
|
|
41
|
+
const results = await client.send(lookup);
|
|
42
|
+
logSuggestions(results, lookupType);
|
|
43
|
+
} catch(err) {
|
|
44
|
+
console.log(err)
|
|
45
|
+
}
|
|
43
46
|
}
|
|
@@ -33,12 +33,8 @@ lookup2.administrativeArea = "SP";
|
|
|
33
33
|
lookup2.country = "Brazil";
|
|
34
34
|
lookup2.postalCode = "02516-050";
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.catch(handleError);
|
|
39
|
-
client.send(lookup2)
|
|
40
|
-
.then(displayResult)
|
|
41
|
-
.catch(handleError);
|
|
36
|
+
await handleRequest(lookup1)
|
|
37
|
+
await handleRequest(lookup2)
|
|
42
38
|
|
|
43
39
|
function displayResult(result) {
|
|
44
40
|
console.log(result.result[0].components);
|
|
@@ -46,4 +42,13 @@ function displayResult(result) {
|
|
|
46
42
|
|
|
47
43
|
function handleError(error) {
|
|
48
44
|
console.log("ERROR:", error);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function handleRequest(lookup) {
|
|
48
|
+
try {
|
|
49
|
+
const result = await client.send(lookup);
|
|
50
|
+
displayResult(result);
|
|
51
|
+
} catch(err) {
|
|
52
|
+
handleError(err);
|
|
53
|
+
}
|
|
49
54
|
}
|
|
@@ -19,9 +19,7 @@ let client = clientBuilder.buildUsAutocompleteProClient();
|
|
|
19
19
|
// *** Simple Lookup ***
|
|
20
20
|
let lookup = new Lookup("4770 Lincoln");
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
.then(function(results) { logSuggestions(results, "Simple Lookup") })
|
|
24
|
-
.catch(console.log);
|
|
22
|
+
await handleRequest(lookup, "Simple Lookup");
|
|
25
23
|
|
|
26
24
|
// *** Using Filter and Prefer ***
|
|
27
25
|
lookup = new Lookup("4770 Lincoln");
|
|
@@ -32,18 +30,14 @@ lookup.preferStates = ["IL"];
|
|
|
32
30
|
lookup.preferRatio = 33;
|
|
33
31
|
lookup.source = "all";
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
.then(function(results) { logSuggestions(results, "Using Filter and Prefer") })
|
|
37
|
-
.catch(console.log);
|
|
33
|
+
await handleRequest(lookup, "Using Filter and Prefer");
|
|
38
34
|
|
|
39
35
|
// *** Using 'selected' to Expand Secondaries ***
|
|
40
36
|
lookup = new Lookup("4770 Lincoln");
|
|
41
37
|
|
|
42
38
|
lookup.selected = "4770 N Lincoln Ave Ste 2 (3) Chicago, IL 60625";
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
.then(function(results) { logSuggestions(results, "Using 'selected' to Expand Secondaries") })
|
|
46
|
-
.catch(console.log);
|
|
40
|
+
await handleRequest(lookup, "Using 'selected' to Expand Secondaries")
|
|
47
41
|
|
|
48
42
|
// ************************************************
|
|
49
43
|
|
|
@@ -51,4 +45,13 @@ function logSuggestions(response, message) {
|
|
|
51
45
|
console.log(message);
|
|
52
46
|
console.log(response.result);
|
|
53
47
|
console.log("*********************");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function handleRequest(lookup, lookupType) {
|
|
51
|
+
try {
|
|
52
|
+
const results = await client.send(lookup);
|
|
53
|
+
logSuggestions(results, lookupType);
|
|
54
|
+
} catch(err) {
|
|
55
|
+
console.log(err)
|
|
56
|
+
}
|
|
54
57
|
}
|
package/examples/us_extract.js
CHANGED
|
@@ -23,10 +23,17 @@ lookup.aggressive = true;
|
|
|
23
23
|
lookup.addressesHaveLineBreaks = false;
|
|
24
24
|
lookup.addressesPerLine = 1;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
.then(logResult)
|
|
28
|
-
.catch(console.log);
|
|
26
|
+
await handleRequest(lookup);
|
|
29
27
|
|
|
30
28
|
function logResult(response) {
|
|
31
29
|
console.log(response.result);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function handleRequest(lookup) {
|
|
33
|
+
try {
|
|
34
|
+
const response = await client.send(lookup);
|
|
35
|
+
logResult(response);
|
|
36
|
+
} catch(err) {
|
|
37
|
+
console.log(err);
|
|
38
|
+
}
|
|
32
39
|
}
|
|
@@ -20,9 +20,7 @@ let client = clientBuilder.buildUsReverseGeoClient();
|
|
|
20
20
|
|
|
21
21
|
let lookup1 = new Lookup(40.27644, -111.65747);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
.then(displayResult)
|
|
25
|
-
.catch(handleError);
|
|
23
|
+
await handleResponse(lookup1);
|
|
26
24
|
|
|
27
25
|
function displayResult(result) {
|
|
28
26
|
console.log(result.result[0].address);
|
|
@@ -31,3 +29,12 @@ function displayResult(result) {
|
|
|
31
29
|
function handleError(error) {
|
|
32
30
|
console.log("ERROR:", error);
|
|
33
31
|
}
|
|
32
|
+
|
|
33
|
+
async function handleResponse(lookup) {
|
|
34
|
+
try {
|
|
35
|
+
const result = await client.send(lookup);
|
|
36
|
+
displayResult(result);
|
|
37
|
+
} catch(err) {
|
|
38
|
+
handleError(err);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/examples/us_street.js
CHANGED
|
@@ -51,9 +51,7 @@ batch.add(lookup1);
|
|
|
51
51
|
batch.add(lookup2);
|
|
52
52
|
batch.add(lookup3);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
.then(handleSuccess)
|
|
56
|
-
.catch(handleError);
|
|
54
|
+
await handleResponse(batch);
|
|
57
55
|
|
|
58
56
|
function handleSuccess(response) {
|
|
59
57
|
response.lookups.map(lookup => console.log(lookup.result));
|
|
@@ -61,4 +59,13 @@ function handleSuccess(response) {
|
|
|
61
59
|
|
|
62
60
|
function handleError(response) {
|
|
63
61
|
console.log(response);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function handleResponse(lookup) {
|
|
65
|
+
try {
|
|
66
|
+
const result = await client.send(lookup);
|
|
67
|
+
handleSuccess(result);
|
|
68
|
+
} catch(err) {
|
|
69
|
+
handleError(err);
|
|
70
|
+
}
|
|
64
71
|
}
|
package/examples/us_zipcode.js
CHANGED
|
@@ -37,13 +37,20 @@ batch.add(lookup1);
|
|
|
37
37
|
batch.add(lookup2);
|
|
38
38
|
batch.add(lookup3);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
.then(viewResults)
|
|
42
|
-
.catch(console.log);
|
|
40
|
+
await handleResponse(batch);
|
|
43
41
|
|
|
44
42
|
function viewResults(response) {
|
|
45
43
|
response.lookups.map(lookup => lookup.result.map(candidate => {
|
|
46
44
|
candidate.cities.map(city => console.log(city.city));
|
|
47
45
|
// candidate.zipcodes.map(zipcode => console.log(zipcode.zipcode));
|
|
48
46
|
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function handleResponse(lookup) {
|
|
50
|
+
try {
|
|
51
|
+
const result = await client.send(lookup);
|
|
52
|
+
viewResults(result);
|
|
53
|
+
} catch(err) {
|
|
54
|
+
console.log(err);
|
|
55
|
+
}
|
|
49
56
|
}
|