smartystreets-javascript-sdk 1.11.7 → 1.11.11
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 +4 -1
- package/Readme.md +3 -3
- package/examples/international_address_autocomplete.js +7 -7
- package/examples/international_street.js +8 -8
- package/examples/us_autocomplete_pro.js +7 -7
- package/examples/us_extract.js +7 -7
- package/examples/us_reverse_geo.js +7 -7
- package/examples/us_street.js +9 -9
- package/examples/us_zipcode.js +8 -8
- package/package.json +5 -4
- package/src/AgentSender.js +1 -1
- package/src/Batch.js +1 -1
- package/src/ClientBuilder.js +2 -2
- package/src/international_street/Candidate.js +1 -1
- package/src/international_street/Client.js +1 -1
- package/src/international_street/Lookup.js +1 -1
- package/src/us_autocomplete/Client.js +1 -1
- package/src/us_autocomplete/Lookup.js +1 -1
- package/src/us_autocomplete/Suggestion.js +1 -1
- package/src/us_autocomplete_pro/Client.js +1 -1
- package/src/us_autocomplete_pro/Lookup.js +1 -1
- package/src/us_autocomplete_pro/Suggestion.js +1 -1
- package/src/us_extract/Address.js +1 -1
- package/src/us_extract/Client.js +1 -1
- package/src/us_extract/Lookup.js +1 -1
- package/src/us_extract/Result.js +1 -1
- package/src/us_reverse_geo/Client.js +1 -1
- package/src/us_reverse_geo/Lookup.js +1 -1
- package/src/us_reverse_geo/Result.js +1 -1
- package/src/us_street/Candidate.js +1 -1
- package/src/us_street/Client.js +3 -1
- package/src/us_street/Lookup.js +1 -1
- package/src/us_zipcode/Client.js +1 -1
- package/src/us_zipcode/Lookup.js +1 -1
- package/src/us_zipcode/Result.js +1 -1
- package/tests/test_AgentSender.js +1 -1
- package/tests/us_street/test_Client.js +15 -0
package/Makefile
CHANGED
|
@@ -18,7 +18,10 @@ publish: clean test version upload unversion
|
|
|
18
18
|
git push origin --tags
|
|
19
19
|
|
|
20
20
|
upload:
|
|
21
|
-
npm publish
|
|
21
|
+
npm publish
|
|
22
|
+
|
|
23
|
+
upload_s3:
|
|
24
|
+
node browserify.js && node s3.js
|
|
22
25
|
|
|
23
26
|
version:
|
|
24
27
|
sed -i.bak -e 's/^ "version": "0\.0\.0",/ "version": "$(VERSION)",/g' "$(VERSION_FILE1)" && rm -f "$(VERSION_FILE1).bak"
|
package/Readme.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Smarty JavaScript SDK
|
|
2
2
|
|
|
3
|
-
The official client libraries for accessing
|
|
3
|
+
The official client libraries for accessing Smarty APIs with JavaScript.
|
|
4
4
|
|
|
5
5
|
[](https://asciinema.org/a/189101)
|
|
6
6
|
|
|
7
|
-
You may have noticed this page is curiously sparse. Don't panic, there's [documentation](https://
|
|
7
|
+
You may have noticed this page is curiously sparse. Don't panic, there's [documentation](https://www.smarty.com/docs/sdk/javascript) as well as working [examples](examples) over on our website.
|
|
8
8
|
|
|
9
9
|
[Apache 2.0 License](LICENSE)
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const Lookup =
|
|
1
|
+
const SmartySDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyCore = SmartySDK.core;
|
|
3
|
+
const Lookup = SmartySDK.internationalAddressAutocomplete.Lookup;
|
|
4
4
|
|
|
5
5
|
// US Autocomplete Pro only supports using Website Keys
|
|
6
6
|
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
7
|
-
const credentials = new
|
|
7
|
+
const credentials = new SmartyCore.SharedCredentials(key);
|
|
8
8
|
|
|
9
9
|
// The appropriate license values to be used for your subscriptions
|
|
10
10
|
// can be found on the Subscription page of the account dashboard.
|
|
11
|
-
// https://www.
|
|
12
|
-
let clientBuilder = new
|
|
11
|
+
// https://www.smarty.com/docs/cloud/licensing
|
|
12
|
+
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["international-autocomplete-cloud"])
|
|
13
13
|
// .withBaseUrl("");
|
|
14
14
|
let client = clientBuilder.buildInternationalAddressAutocompleteClient();
|
|
15
15
|
|
|
16
16
|
// Documentation for input fields can be found at:
|
|
17
|
-
//www.
|
|
17
|
+
//www.smarty.com/docs/cloud/international-address-autocomplete-api#pro-http-request-input-fields
|
|
18
18
|
|
|
19
19
|
let lookup = new Lookup("Ave", "CAN");
|
|
20
20
|
await handleRequest(lookup, "Simple Request");
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const Lookup =
|
|
1
|
+
const SmartySDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyCore = SmartySDK.core;
|
|
3
|
+
const Lookup = SmartySDK.internationalStreet.Lookup;
|
|
4
4
|
|
|
5
5
|
// for Server-to-server requests, use this code:
|
|
6
6
|
// let authId = process.env.SMARTY_AUTH_ID;
|
|
7
7
|
// let authToken = process.env.SMARTY_AUTH_TOKEN;
|
|
8
|
-
// const credentials = new
|
|
8
|
+
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
|
|
9
9
|
|
|
10
10
|
// for client-side requests (browser/mobile), use this code:
|
|
11
11
|
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
12
|
-
const credentials = new
|
|
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.
|
|
16
|
-
// https://www.
|
|
17
|
-
let clientBuilder = new
|
|
16
|
+
// https://www.smarty.com/docs/cloud/licensing
|
|
17
|
+
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["international-global-plus-cloud"]);
|
|
18
18
|
let client = clientBuilder.buildInternationalStreetClient();
|
|
19
19
|
|
|
20
20
|
// Documentation for input fields can be found at:
|
|
21
|
-
// https://
|
|
21
|
+
// https://www.smarty.com/docs/cloud/international-street-api#http-input-fields
|
|
22
22
|
|
|
23
23
|
let lookup1 = new Lookup("CA", "262 Browndale Cr, Richmond Hill, ON");
|
|
24
24
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const Lookup =
|
|
1
|
+
const SmartySDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyCore = SmartySDK.core;
|
|
3
|
+
const Lookup = SmartySDK.usAutocompletePro.Lookup;
|
|
4
4
|
|
|
5
5
|
// US Autocomplete Pro only supports using Website Keys
|
|
6
6
|
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
7
|
-
const credentials = new
|
|
7
|
+
const credentials = new SmartyCore.SharedCredentials(key);
|
|
8
8
|
|
|
9
9
|
// The appropriate license values to be used for your subscriptions
|
|
10
10
|
// can be found on the Subscription page of the account dashboard.
|
|
11
|
-
// https://www.
|
|
12
|
-
let clientBuilder = new
|
|
11
|
+
// https://www.smarty.com/docs/cloud/licensing
|
|
12
|
+
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["us-autocomplete-pro-cloud"]);
|
|
13
13
|
// .withBaseUrl("");
|
|
14
14
|
let client = clientBuilder.buildUsAutocompleteProClient();
|
|
15
15
|
|
|
16
16
|
// Documentation for input fields can be found at:
|
|
17
|
-
// https://
|
|
17
|
+
// https://www.smarty.com/docs/cloud/us-autocomplete-api#pro-http-request-input-fields
|
|
18
18
|
|
|
19
19
|
// *** Simple Lookup ***
|
|
20
20
|
let lookup = new Lookup("4770 Lincoln");
|
package/examples/us_extract.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const Lookup =
|
|
1
|
+
const SmartySDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyCore = SmartySDK.core;
|
|
3
|
+
const Lookup = SmartySDK.usExtract.Lookup;
|
|
4
4
|
|
|
5
5
|
// for Server-to-server requests, use this code:
|
|
6
6
|
// let authId = process.env.SMARTY_AUTH_ID;
|
|
7
7
|
// let authToken = process.env.SMARTY_AUTH_TOKEN;
|
|
8
|
-
// const credentials = new
|
|
8
|
+
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
|
|
9
9
|
|
|
10
10
|
// for client-side requests (browser/mobile), use this code:
|
|
11
11
|
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
12
|
-
const credentials = new
|
|
12
|
+
const credentials = new SmartyCore.SharedCredentials(key);
|
|
13
13
|
|
|
14
|
-
let clientBuilder = new
|
|
14
|
+
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
|
|
15
15
|
// .withBaseUrl("");
|
|
16
16
|
let client = clientBuilder.buildUsExtractClient();
|
|
17
17
|
|
|
18
18
|
// Documentation for input fields can be found at:
|
|
19
|
-
// https://
|
|
19
|
+
// https://www.smarty.com/docs/cloud/us-extract-api#http-request-input-fields
|
|
20
20
|
|
|
21
21
|
let lookup = new Lookup("If you work at 1600 Pennsylvania Ave NW, Washington DC you're gonna have a hard time.");
|
|
22
22
|
lookup.aggressive = true;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const Lookup =
|
|
1
|
+
const SmartySDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyCore = SmartySDK.core;
|
|
3
|
+
const Lookup = SmartySDK.usReverseGeo.Lookup;
|
|
4
4
|
|
|
5
5
|
// for Server-to-server requests, use this code:
|
|
6
6
|
// let authId = process.env.SMARTY_AUTH_ID;
|
|
7
7
|
// let authToken = process.env.SMARTY_AUTH_TOKEN;
|
|
8
|
-
// const credentials = new
|
|
8
|
+
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
|
|
9
9
|
|
|
10
10
|
// for client-side requests (browser/mobile), use this code:
|
|
11
11
|
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
12
|
-
const credentials = new
|
|
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.
|
|
16
|
-
// https://www.
|
|
17
|
-
let clientBuilder = new
|
|
16
|
+
// https://www.smarty.com/docs/cloud/licensing
|
|
17
|
+
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["us-reverse-geocoding-cloud"]);
|
|
18
18
|
// .withBaseUrl("");
|
|
19
19
|
let client = clientBuilder.buildUsReverseGeoClient();
|
|
20
20
|
|
package/examples/us_street.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const Lookup =
|
|
1
|
+
const SmartySDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyCore = SmartySDK.core;
|
|
3
|
+
const Lookup = SmartySDK.usStreet.Lookup;
|
|
4
4
|
|
|
5
5
|
// for Server-to-server requests, use this code:
|
|
6
6
|
// let authId = process.env.SMARTY_AUTH_ID;
|
|
7
7
|
// let authToken = process.env.SMARTY_AUTH_TOKEN;
|
|
8
|
-
// const credentials = new
|
|
8
|
+
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
|
|
9
9
|
|
|
10
10
|
// for client-side requests (browser/mobile), use this code:
|
|
11
11
|
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
12
|
-
const credentials = new
|
|
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.
|
|
16
|
-
// https://www.
|
|
17
|
-
let clientBuilder = new
|
|
16
|
+
// https://www.smarty.com/docs/cloud/licensing
|
|
17
|
+
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withBaseUrl("YOUR URL").withLicenses(["us-rooftop-geocoding-cloud"]);
|
|
18
18
|
let client = clientBuilder.buildUsStreetApiClient();
|
|
19
19
|
|
|
20
20
|
// Documentation for input fields can be found at:
|
|
21
|
-
// https://
|
|
21
|
+
// https://www.smarty.com/docs/us-street-api#input-fields
|
|
22
22
|
|
|
23
23
|
let lookup1 = new Lookup();
|
|
24
24
|
lookup1.inputId = "24601"; // Optional ID from your system
|
|
@@ -46,7 +46,7 @@ lookup3.street = "1600 Amphitheatre Parkway Mountain View, CA 94043";
|
|
|
46
46
|
lookup3.maxCandidates = 1;
|
|
47
47
|
|
|
48
48
|
// NOTE: batches are not supported when using SharedCredentials.
|
|
49
|
-
let batch = new
|
|
49
|
+
let batch = new SmartyCore.Batch();
|
|
50
50
|
batch.add(lookup1);
|
|
51
51
|
batch.add(lookup2);
|
|
52
52
|
batch.add(lookup3);
|
package/examples/us_zipcode.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const Lookup =
|
|
1
|
+
const SmartySDK = require("smartystreets-javascript-sdk");
|
|
2
|
+
const SmartyCore = SmartySDK.core;
|
|
3
|
+
const Lookup = SmartySDK.usZipcode.Lookup;
|
|
4
4
|
|
|
5
5
|
// for Server-to-server requests, use this code:
|
|
6
6
|
// let authId = process.env.SMARTY_AUTH_ID;
|
|
7
7
|
// let authToken = process.env.SMARTY_AUTH_TOKEN;
|
|
8
|
-
// const credentials = new
|
|
8
|
+
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
|
|
9
9
|
|
|
10
10
|
// for client-side requests (browser/mobile), use this code:
|
|
11
11
|
let key = process.env.SMARTY_WEBSITE_KEY;
|
|
12
|
-
const credentials = new
|
|
12
|
+
const credentials = new SmartyCore.SharedCredentials(key);
|
|
13
13
|
|
|
14
|
-
let clientBuilder = new
|
|
14
|
+
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
|
|
15
15
|
// .withBaseUrl("");
|
|
16
16
|
let client = clientBuilder.buildUsZipcodeClient();
|
|
17
17
|
|
|
18
18
|
// Documentation for input fields can be found at:
|
|
19
|
-
// https://
|
|
19
|
+
// https://www.smarty.com/docs/us-zipcode-api#input-fields
|
|
20
20
|
|
|
21
21
|
let lookup1 = new Lookup();
|
|
22
22
|
lookup1.inputId = "01189998819991197253"; // Optional ID from your system
|
|
@@ -32,7 +32,7 @@ let lookup3 = new Lookup();
|
|
|
32
32
|
lookup3.city = "Phoenix";
|
|
33
33
|
lookup3.state = "AZ";
|
|
34
34
|
|
|
35
|
-
let batch = new
|
|
35
|
+
let batch = new SmartyCore.Batch();
|
|
36
36
|
batch.add(lookup1);
|
|
37
37
|
batch.add(lookup2);
|
|
38
38
|
batch.add(lookup3);
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartystreets-javascript-sdk",
|
|
3
|
-
"version": "1.11.
|
|
4
|
-
"description": "Quick and easy
|
|
3
|
+
"version": "1.11.11",
|
|
4
|
+
"description": "Quick and easy Smarty address validation.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"smarty",
|
|
6
7
|
"smartystreets",
|
|
7
8
|
"address",
|
|
8
9
|
"validation",
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"scripts": {
|
|
25
26
|
"test": "mocha 'tests/**/*.js'"
|
|
26
27
|
},
|
|
27
|
-
"author": "
|
|
28
|
+
"author": "Smarty SDK Team <support@smarty.com> (https://www.smarty.com)",
|
|
28
29
|
"license": "Apache-2.0",
|
|
29
30
|
"repository": {
|
|
30
31
|
"type": "git",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"browserify": "^16.5.2",
|
|
39
40
|
"chai": "^4.2.0",
|
|
40
41
|
"chai-as-promised": "^7.1.1",
|
|
41
|
-
"mocha": "^
|
|
42
|
+
"mocha": "^9.2.1",
|
|
42
43
|
"s3-upload-stream": "^1.0.7",
|
|
43
44
|
"tinyify": "^2.5.2",
|
|
44
45
|
"zlib": "^1.0.5"
|
package/src/AgentSender.js
CHANGED
|
@@ -6,7 +6,7 @@ class AgentSender {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
send(request) {
|
|
9
|
-
request.parameters.agent = "
|
|
9
|
+
request.parameters.agent = "smarty (sdk:javascript@" + require("../package.json").version + ")";
|
|
10
10
|
return new Promise((resolve, reject) => {
|
|
11
11
|
this.sender.send(request)
|
|
12
12
|
.then(resolve)
|
package/src/Batch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const BatchFullError = require("./Errors").BatchFullError;
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* This class contains a collection of up to 100 lookups to be sent to one of the
|
|
4
|
+
* This class contains a collection of up to 100 lookups to be sent to one of the Smarty APIs<br>
|
|
5
5
|
* all at once. This is more efficient than sending them one at a time.
|
|
6
6
|
*/
|
|
7
7
|
class Batch {
|
package/src/ClientBuilder.js
CHANGED
|
@@ -29,7 +29,7 @@ const US_REVERSE_GEO_API_URL = "https://us-reverse-geo.api.smartystreets.com/loo
|
|
|
29
29
|
const INTERNATIONAL_ADDRESS_AUTOCOMPLETE_API_URL = "https://international-autocomplete.api.smartystreets.com/lookup";
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* The ClientBuilder class helps you build a client object for one of the supported
|
|
32
|
+
* The ClientBuilder class helps you build a client object for one of the supported Smarty APIs.<br>
|
|
33
33
|
* You can use ClientBuilder's methods to customize settings like maximum retries or timeout duration. These methods<br>
|
|
34
34
|
* are chainable, so you can usually get set up with one line of code.
|
|
35
35
|
*/
|
|
@@ -81,7 +81,7 @@ class ClientBuilder {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* This may be useful when using a local installation of the
|
|
84
|
+
* This may be useful when using a local installation of the Smarty APIs.
|
|
85
85
|
* @param url Defaults to the URL for the API corresponding to the <b>Client</b> object being built.
|
|
86
86
|
* @return Returns <b>this</b> to accommodate method chaining.
|
|
87
87
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A candidate is a possible match for an address that was submitted.<br>
|
|
3
3
|
* A lookup can have multiple candidates if the address was ambiguous.
|
|
4
4
|
*
|
|
5
|
-
* @see "https://
|
|
5
|
+
* @see "https://www.smarty.com/docs/cloud/international-street-api#root"
|
|
6
6
|
*/
|
|
7
7
|
class Candidate {
|
|
8
8
|
constructor(responseData) {
|
|
@@ -6,7 +6,7 @@ const buildInputData = require("../util/buildInputData");
|
|
|
6
6
|
const keyTranslationFormat = require("../util/apiToSDKKeyMap").internationalStreet;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* This client sends lookups to the
|
|
9
|
+
* This client sends lookups to the Smarty International Street API, <br>
|
|
10
10
|
* and attaches the results to the appropriate Lookup objects.
|
|
11
11
|
*/
|
|
12
12
|
class Client {
|
|
@@ -13,7 +13,7 @@ const messages = {
|
|
|
13
13
|
* will contain the result of the lookup after it comes back from the API.
|
|
14
14
|
* <p><b>Note: </b><i>Lookups must have certain required fields set with non-blank values. <br>
|
|
15
15
|
* These can be found at the URL below.</i></p>
|
|
16
|
-
* @see "https://
|
|
16
|
+
* @see "https://www.smarty.com/docs/cloud/international-street-api#http-input-fields"
|
|
17
17
|
*/
|
|
18
18
|
class Lookup {
|
|
19
19
|
constructor(country, freeform) {
|
|
@@ -4,7 +4,7 @@ const Suggestion = require("./Suggestion");
|
|
|
4
4
|
const Promise = require("promise");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* This client sends lookups to the
|
|
7
|
+
* This client sends lookups to the Smarty US Autocomplete API, <br>
|
|
8
8
|
* and attaches the results to the appropriate Lookup objects.
|
|
9
9
|
*/
|
|
10
10
|
class Client {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In addition to holding all of the input data for this lookup, this class also<br>
|
|
3
3
|
* will contain the result of the lookup after it comes back from the API.
|
|
4
|
-
* @see "https://
|
|
4
|
+
* @see "https://www.smarty.com/docs/cloud/us-autocomplete-api#http-request-input-fields"
|
|
5
5
|
*/
|
|
6
6
|
class Lookup {
|
|
7
7
|
/**
|
|
@@ -4,7 +4,7 @@ const Suggestion = require("./Suggestion");
|
|
|
4
4
|
const Promise = require("promise");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* This client sends lookups to the
|
|
7
|
+
* This client sends lookups to the Smarty US Autocomplete Pro API, <br>
|
|
8
8
|
* and attaches the suggestions to the appropriate Lookup objects.
|
|
9
9
|
*/
|
|
10
10
|
class Client {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In addition to holding all of the input data for this lookup, this class also<br>
|
|
3
3
|
* will contain the result of the lookup after it comes back from the API.
|
|
4
|
-
* @see "https://
|
|
4
|
+
* @see "https://www.smarty.com/docs/cloud/us-autocomplete-api#pro-http-request-input-fields"
|
|
5
5
|
*/
|
|
6
6
|
class Lookup {
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const Candidate = require("../us_street/Candidate");
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @see <a href="https://
|
|
4
|
+
* @see <a href="https://www.smarty.com/docs/cloud/us-extract-api#http-response-status">Smarty US Extract API docs</a>
|
|
5
5
|
*/
|
|
6
6
|
class Address {
|
|
7
7
|
constructor (responseData) {
|
package/src/us_extract/Client.js
CHANGED
|
@@ -4,7 +4,7 @@ const Request = require("../Request");
|
|
|
4
4
|
const Result = require("./Result");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* This client sends lookups to the
|
|
7
|
+
* This client sends lookups to the Smarty US Extract API, <br>
|
|
8
8
|
* and attaches the results to the Lookup objects.
|
|
9
9
|
*/
|
|
10
10
|
class Client {
|
package/src/us_extract/Lookup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In addition to holding all of the input data for this lookup, this class also<br>
|
|
3
3
|
* will contain the result of the lookup after it comes back from the API.
|
|
4
|
-
* @see "https://
|
|
4
|
+
* @see "https://www.smarty.com/docs/cloud/us-extract-api#http-request-input-fields"
|
|
5
5
|
*/
|
|
6
6
|
class Lookup {
|
|
7
7
|
/**
|
package/src/us_extract/Result.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const Address = require("./Address");
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @see <a href="https://
|
|
4
|
+
* @see <a href="https://www.smarty.com/docs/cloud/us-extract-api#http-response-status">Smarty US Extract API docs</a>
|
|
5
5
|
*/
|
|
6
6
|
class Result {
|
|
7
7
|
constructor({meta, addresses}) {
|
|
@@ -5,7 +5,7 @@ const keyTranslationFormat = require("../util/apiToSDKKeyMap").usReverseGeo;
|
|
|
5
5
|
const {UndefinedLookupError} = require("../Errors.js");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* This client sends lookups to the
|
|
8
|
+
* This client sends lookups to the Smarty US Reverse Geo API, <br>
|
|
9
9
|
* and attaches the results to the appropriate Lookup objects.
|
|
10
10
|
*/
|
|
11
11
|
class Client {
|
|
@@ -3,7 +3,7 @@ const Response = require("./Response");
|
|
|
3
3
|
/**
|
|
4
4
|
* In addition to holding all of the input data for this lookup, this class also<br>
|
|
5
5
|
* will contain the result of the lookup after it comes back from the API.
|
|
6
|
-
* @see "https://
|
|
6
|
+
* @see "https://www.smarty.com/docs/cloud/us-street-api#input-fields"
|
|
7
7
|
*/
|
|
8
8
|
class Lookup {
|
|
9
9
|
constructor(latitude, longitude) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A candidate is a possible match for an address that was submitted.<br>
|
|
3
3
|
* A lookup can have multiple candidates if the address was ambiguous.
|
|
4
4
|
*
|
|
5
|
-
* @see "https://
|
|
5
|
+
* @see "https://www.smarty.com/docs/cloud/us-reverse-geo-api#result"
|
|
6
6
|
*/
|
|
7
7
|
class Result {
|
|
8
8
|
constructor(responseData) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* A lookup can have multiple candidates if the address was ambiguous, and<br>
|
|
4
4
|
* the maxCandidates field is set higher than 1.
|
|
5
5
|
*
|
|
6
|
-
* @see "https://
|
|
6
|
+
* @see "https://www.smarty.com/docs/cloud/us-street-api#root"
|
|
7
7
|
*/
|
|
8
8
|
class Candidate {
|
|
9
9
|
constructor(responseData) {
|
package/src/us_street/Client.js
CHANGED
|
@@ -6,7 +6,7 @@ const sendBatch = require("../util/sendBatch");
|
|
|
6
6
|
const keyTranslationFormat = require("../util/apiToSDKKeyMap").usStreet;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* This client sends lookups to the
|
|
9
|
+
* This client sends lookups to the Smarty US Street API, <br>
|
|
10
10
|
* and attaches the results to the appropriate Lookup objects.
|
|
11
11
|
*/
|
|
12
12
|
class Client {
|
|
@@ -28,6 +28,8 @@ class Client {
|
|
|
28
28
|
let batch;
|
|
29
29
|
|
|
30
30
|
if (dataIsLookup) {
|
|
31
|
+
if (data.maxCandidates == null && data.match == "enhanced")
|
|
32
|
+
data.maxCandidates = 5;
|
|
31
33
|
batch = new Batch();
|
|
32
34
|
batch.add(data);
|
|
33
35
|
} else {
|
package/src/us_street/Lookup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In addition to holding all of the input data for this lookup, this class also<br>
|
|
3
3
|
* will contain the result of the lookup after it comes back from the API.
|
|
4
|
-
* @see "https://
|
|
4
|
+
* @see "https://www.smarty.com/docs/cloud/us-street-api#input-fields"
|
|
5
5
|
*/
|
|
6
6
|
class Lookup {
|
|
7
7
|
constructor(street, street2, secondary, city, state, zipCode, lastLine, addressee, urbanization, match, maxCandidates, inputId) {
|
package/src/us_zipcode/Client.js
CHANGED
|
@@ -6,7 +6,7 @@ const sendBatch = require("../util/sendBatch");
|
|
|
6
6
|
const keyTranslationFormat = require("../util/apiToSDKKeyMap").usZipcode;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* This client sends lookups to the
|
|
9
|
+
* This client sends lookups to the Smarty US ZIP Code API, <br>
|
|
10
10
|
* and attaches the results to the appropriate Lookup objects.
|
|
11
11
|
*/
|
|
12
12
|
class Client {
|
package/src/us_zipcode/Lookup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In addition to holding all of the input data for this lookup, this class also<br>
|
|
3
3
|
* will contain the result of the lookup after it comes back from the API.
|
|
4
|
-
* @see "https://
|
|
4
|
+
* @see "https://www.smarty.com/docs/cloud/us-zipcode-api#http-request-input-fields"
|
|
5
5
|
*/
|
|
6
6
|
class Lookup {
|
|
7
7
|
constructor(city, state, zipCode, inputId) {
|
package/src/us_zipcode/Result.js
CHANGED
|
@@ -16,7 +16,7 @@ describe("An agent sender", function () {
|
|
|
16
16
|
let mockSender = new MockSender();
|
|
17
17
|
let agentSender = new AgentSender(mockSender);
|
|
18
18
|
let request = new Request();
|
|
19
|
-
let expectedAgentString = "
|
|
19
|
+
let expectedAgentString = "smarty (sdk:javascript@" + require("../package.json").version + ")";
|
|
20
20
|
|
|
21
21
|
agentSender.send(request);
|
|
22
22
|
|
|
@@ -52,6 +52,21 @@ describe("A US Street client", function () {
|
|
|
52
52
|
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
+
it("defaults maxCandidates to 5 when match type is enhanced.", function () {
|
|
56
|
+
let mockSender = new MockSender();
|
|
57
|
+
const client = new Client(mockSender);
|
|
58
|
+
let lookup = new Lookup();
|
|
59
|
+
lookup.match = "enhanced";
|
|
60
|
+
let expectedParameters = {
|
|
61
|
+
match: "enhanced",
|
|
62
|
+
candidates: 5,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
client.send(lookup);
|
|
66
|
+
|
|
67
|
+
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
|
|
68
|
+
});
|
|
69
|
+
|
|
55
70
|
it("doesn't send an empty batch.", function () {
|
|
56
71
|
let mockSender = new MockSender();
|
|
57
72
|
const client = new Client(mockSender);
|