smartystreets-javascript-sdk 2.1.2 → 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.
@@ -13,7 +13,7 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- node-version: [10.x, 12.x, 14.x]
16
+ node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v2
@@ -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
- // let authId = process.env.SMARTY_AUTH_ID;
7
- // let authToken = process.env.SMARTY_AUTH_TOKEN;
8
- // const credentials = new SmartyCore.StaticCredentials(authId, authToken);
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
- await handleRequest(lookup, "Simple Lookup");
28
-
29
- // *** Using Filter and Prefer ***
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartystreets-javascript-sdk",
3
- "version": "2.1.2",
3
+ "version": "2.2.1",
4
4
  "description": "Quick and easy Smarty address validation.",
5
5
  "keywords": [
6
6
  "smarty",
@@ -21,14 +21,14 @@ const InternationalStreetClient = require("./international_street/Client");
21
21
  const UsReverseGeoClient = require("./us_reverse_geo/Client");
22
22
  const InternationalAddressAutocompleteClient = require("./international_address_autocomplete/Client");
23
23
 
24
- const INTERNATIONAL_STREET_API_URI = "https://international-street.api.smartystreets.com/verify";
25
- const US_AUTOCOMPLETE_API_URL = "https://us-autocomplete.api.smartystreets.com/suggest";
26
- const US_AUTOCOMPLETE_PRO_API_URL = "https://us-autocomplete-pro.api.smartystreets.com/lookup";
27
- const US_EXTRACT_API_URL = "https://us-extract.api.smartystreets.com/";
28
- const US_STREET_API_URL = "https://us-street.api.smartystreets.com/street-address";
29
- const US_ZIP_CODE_API_URL = "https://us-zipcode.api.smartystreets.com/lookup";
30
- const US_REVERSE_GEO_API_URL = "https://us-reverse-geo.api.smartystreets.com/lookup";
31
- const INTERNATIONAL_ADDRESS_AUTOCOMPLETE_API_URL = "https://international-autocomplete.api.smartystreets.com/lookup";
24
+ const INTERNATIONAL_STREET_API_URI = "https://international-street.api.smarty.com/verify";
25
+ const US_AUTOCOMPLETE_API_URL = "https://us-autocomplete.api.smarty.com/suggest";
26
+ const US_AUTOCOMPLETE_PRO_API_URL = "https://us-autocomplete-pro.api.smarty.com/lookup";
27
+ const US_EXTRACT_API_URL = "https://us-extract.api.smarty.com/";
28
+ const US_STREET_API_URL = "https://us-street.api.smarty.com/street-address";
29
+ const US_ZIP_CODE_API_URL = "https://us-zipcode.api.smarty.com/lookup";
30
+ const US_REVERSE_GEO_API_URL = "https://us-reverse-geo.api.smarty.com/lookup";
31
+ const INTERNATIONAL_ADDRESS_AUTOCOMPLETE_API_URL = "https://international-autocomplete.api.smarty.com/lookup";
32
32
 
33
33
  /**
34
34
  * The ClientBuilder class helps you build a client object for one of the supported Smarty APIs.<br>
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
- Axios(requestConfig)
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
- Axios.interceptors.request.use(request => {
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
- Axios.interceptors.response.use(response => {
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);