smartystreets-javascript-sdk 1.11.2 → 1.11.5
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
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const SmartyStreetsSDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyStreetsCore = SmartyStreetsSDK.core;
|
|
3
|
+
const Lookup = SmartyStreetsSDK.internationalAddressAutocomplete.Lookup;
|
|
4
|
+
|
|
5
|
+
// US Autocomplete Pro only supports using Website Keys
|
|
6
|
+
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
7
|
+
const credentials = new SmartyStreetsCore.SharedCredentials(key);
|
|
8
|
+
|
|
9
|
+
// The appropriate license values to be used for your subscriptions
|
|
10
|
+
// can be found on the Subscription page of the account dashboard.
|
|
11
|
+
// https://www.smartystreets.com/docs/cloud/licensing
|
|
12
|
+
let clientBuilder = new SmartyStreetsCore.ClientBuilder(credentials).withLicenses(["international-autocomplete-cloud"])
|
|
13
|
+
// .withBaseUrl("");
|
|
14
|
+
let client = clientBuilder.buildInternationalAddressAutocompleteClient();
|
|
15
|
+
|
|
16
|
+
// Documentation for input fields can be found at:
|
|
17
|
+
//www.smartystreets.com/docs/cloud/international-address-autocomplete-api#pro-http-request-input-fields
|
|
18
|
+
|
|
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);
|
|
26
|
+
|
|
27
|
+
// *** Using Filter and Prefer ***
|
|
28
|
+
lookup = new Lookup("Ave", "CAN");
|
|
29
|
+
|
|
30
|
+
lookup.maxResults = 10;
|
|
31
|
+
lookup.include_only_locality = "Sherwood Park";
|
|
32
|
+
|
|
33
|
+
client.send(lookup)
|
|
34
|
+
.then(function(results) { logSuggestions(results, "Using Filter and Prefer")})
|
|
35
|
+
.catch(console.log);
|
|
36
|
+
|
|
37
|
+
function logSuggestions(response, message) {
|
|
38
|
+
console.log(message);
|
|
39
|
+
console.log(response.result);
|
|
40
|
+
console.log("*********************");
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartystreets-javascript-sdk",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.5",
|
|
4
4
|
"description": "Quick and easy SmartyStreets address validation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"smartystreets",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"axios-proxy-fix": "^0.16.3",
|
|
48
|
-
"axios-retry": "
|
|
48
|
+
"axios-retry": "3.2.0",
|
|
49
49
|
"promise": "^8.1.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -15,6 +15,9 @@ class Client {
|
|
|
15
15
|
request.parameters = {
|
|
16
16
|
search: lookup.search,
|
|
17
17
|
country: lookup.country,
|
|
18
|
+
include_only_administrative_area: lookup.include_only_administrative_area,
|
|
19
|
+
include_only_locality: lookup.include_only_locality,
|
|
20
|
+
include_only_postal_code: lookup.include_only_postal_code,
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
return new Promise((resolve, reject) => {
|
|
@@ -17,6 +17,9 @@ describe("An International Address Autocomplete Client", function () {
|
|
|
17
17
|
let lookup = new Lookup(search);
|
|
18
18
|
let expectedParameters = {
|
|
19
19
|
search: search,
|
|
20
|
+
include_only_administrative_area: "",
|
|
21
|
+
include_only_locality: "",
|
|
22
|
+
include_only_postal_code: "",
|
|
20
23
|
country: "United States",
|
|
21
24
|
};
|
|
22
25
|
|
|
@@ -32,8 +35,11 @@ describe("An International Address Autocomplete Client", function () {
|
|
|
32
35
|
lookup.search = search;
|
|
33
36
|
lookup.country = "Russia";
|
|
34
37
|
let expectedParameters = {
|
|
35
|
-
search: search,
|
|
36
38
|
country: "Russia",
|
|
39
|
+
include_only_administrative_area: "",
|
|
40
|
+
include_only_locality: "",
|
|
41
|
+
include_only_postal_code: "",
|
|
42
|
+
search: search,
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
client.send(lookup);
|