smartystreets-javascript-sdk 2.2.0 → 2.2.1
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/us_autocomplete_pro.js +9 -24
- package/package.json +1 -1
- package/src/HttpSender.js +4 -4
package/Makefile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/make -f
|
|
2
2
|
|
|
3
|
-
VERSION := $(shell tagit -
|
|
3
|
+
VERSION := $(shell tagit -p --dry-run)
|
|
4
4
|
VERSION_FILE1 := package.json
|
|
5
5
|
VERSION_FILE2 := package-lock.json
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ node_modules:
|
|
|
11
11
|
npm install
|
|
12
12
|
|
|
13
13
|
publish: test version upload unversion
|
|
14
|
-
tagit -
|
|
14
|
+
tagit -p
|
|
15
15
|
git push origin --tags
|
|
16
16
|
|
|
17
17
|
upload:
|
|
@@ -3,13 +3,13 @@ const SmartyCore = SmartySDK.core;
|
|
|
3
3
|
const Lookup = SmartySDK.usAutocompletePro.Lookup;
|
|
4
4
|
|
|
5
5
|
// for Server-to-server requests, use this code:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let authId = "f0fd813a-2c37-2afe-a322-1a46794d6c91";
|
|
7
|
+
let authToken = "sPDMxTLaMh8BCp6YWSNW";
|
|
8
|
+
const credentials = new SmartyCore.StaticCredentials(authId, authToken);
|
|
9
9
|
|
|
10
10
|
// for client-side requests (browser/mobile), use this code:
|
|
11
|
-
let key = process.env.SMARTY_EMBEDDED_KEY;
|
|
12
|
-
const credentials = new SmartyCore.SharedCredentials(key);
|
|
11
|
+
// let key = process.env.SMARTY_EMBEDDED_KEY;
|
|
12
|
+
// const credentials = new SmartyCore.SharedCredentials(key);
|
|
13
13
|
|
|
14
14
|
// The appropriate license values to be used for your subscriptions
|
|
15
15
|
// can be found on the Subscription page of the account dashboard.
|
|
@@ -23,26 +23,11 @@ let client = clientBuilder.buildUsAutocompleteProClient();
|
|
|
23
23
|
|
|
24
24
|
// *** Simple Lookup ***
|
|
25
25
|
let lookup = new Lookup("4770 Lincoln");
|
|
26
|
+
lookup.excludeStates = ["CA"];
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
lookup = new Lookup("4770 Lincoln");
|
|
31
|
-
|
|
32
|
-
lookup.maxResults = 10;
|
|
33
|
-
lookup.includeOnlyCities = ["Chicago,La Grange,IL", "Blaine,WA"];
|
|
34
|
-
lookup.preferStates = ["IL"];
|
|
35
|
-
lookup.preferRatio = 33;
|
|
36
|
-
lookup.source = "all";
|
|
37
|
-
|
|
38
|
-
await handleRequest(lookup, "Using Filter and Prefer");
|
|
39
|
-
|
|
40
|
-
// *** Using 'selected' to Expand Secondaries ***
|
|
41
|
-
lookup = new Lookup("4770 Lincoln");
|
|
42
|
-
|
|
43
|
-
lookup.selected = "4770 N Lincoln Ave Ste 2 (3) Chicago, IL 60625";
|
|
44
|
-
|
|
45
|
-
await handleRequest(lookup, "Using 'selected' to Expand Secondaries")
|
|
28
|
+
(async () => {
|
|
29
|
+
await handleRequest(lookup, "Simple Lookup");
|
|
30
|
+
})()
|
|
46
31
|
|
|
47
32
|
// ************************************************
|
|
48
33
|
|
package/package.json
CHANGED
package/src/HttpSender.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const Response = require("./Response");
|
|
2
1
|
const Axios = require("axios");
|
|
3
2
|
const {buildSmartyResponse} = require("../src/util/buildSmartyResponse");
|
|
4
3
|
|
|
5
4
|
class HttpSender {
|
|
6
5
|
constructor(timeout = 10000, proxyConfig, debug = false) {
|
|
6
|
+
this.axiosInstance = Axios.create();
|
|
7
7
|
this.timeout = timeout;
|
|
8
8
|
this.proxyConfig = proxyConfig;
|
|
9
9
|
if (debug) this.enableDebug();
|
|
@@ -34,7 +34,7 @@ class HttpSender {
|
|
|
34
34
|
return new Promise((resolve, reject) => {
|
|
35
35
|
let requestConfig = this.buildRequestConfig(request);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
this.axiosInstance(requestConfig)
|
|
38
38
|
.then(response => {
|
|
39
39
|
let smartyResponse = buildSmartyResponse(response);
|
|
40
40
|
|
|
@@ -47,13 +47,13 @@ class HttpSender {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
enableDebug() {
|
|
50
|
-
|
|
50
|
+
this.axiosInstance.interceptors.request.use(request => {
|
|
51
51
|
console.log('Request:\r\n', request);
|
|
52
52
|
console.log('\r\n*******************************************\r\n');
|
|
53
53
|
return request
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
this.axiosInstance.interceptors.response.use(response => {
|
|
57
57
|
console.log('Response:\r\n');
|
|
58
58
|
console.log('Status:', response.status, response.statusText);
|
|
59
59
|
console.log('Headers:', response.headers);
|