smartystreets-javascript-sdk 3.1.0 → 3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/make -f
2
2
 
3
- VERSION := $(shell tagit -m --dry-run)
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 -m
14
+ tagit -p
15
15
  git push origin --tags
16
16
 
17
17
  upload:
@@ -18,12 +18,12 @@ let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["us-
18
18
  // .withBaseUrl("");
19
19
  let client = clientBuilder.buildUsReverseGeoClient();
20
20
 
21
- let lookup1 = new Lookup(40.27644, -111.65747);
21
+ let lookup1 = new Lookup(40.27644, -111.65747, "all");
22
22
 
23
23
  await handleResponse(lookup1);
24
24
 
25
25
  function displayResult(result) {
26
- console.log(result.result[0].address);
26
+ console.log(result.response.results[0].address);
27
27
  }
28
28
 
29
29
  function handleError(error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartystreets-javascript-sdk",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "Quick and easy Smarty address validation.",
5
5
  "keywords": [
6
6
  "smarty",
@@ -9,6 +9,10 @@ class Suggestion {
9
9
  this.state = responseData.state;
10
10
  this.zipcode = responseData.zipcode;
11
11
  this.entries = responseData.entries;
12
+
13
+ if (responseData.source) {
14
+ this.source = responseData.source;
15
+ }
12
16
  }
13
17
  }
14
18
 
@@ -6,9 +6,10 @@ const Response = require("./Response");
6
6
  * @see "https://www.smarty.com/docs/cloud/us-street-api#input-fields"
7
7
  */
8
8
  class Lookup {
9
- constructor(latitude, longitude) {
9
+ constructor(latitude, longitude, source="") {
10
10
  this.latitude = latitude.toFixed(8);
11
11
  this.longitude = longitude.toFixed(8);
12
+ this.source = source;
12
13
  this.response = new Response();
13
14
  }
14
15
  }
@@ -14,6 +14,7 @@ class Result {
14
14
  this.address.city = responseData.address.city;
15
15
  this.address.state_abbreviation = responseData.address.state_abbreviation;
16
16
  this.address.zipcode = responseData.address.zipcode;
17
+ this.address.source = responseData.address.source
17
18
  }
18
19
 
19
20
  this.coordinate = {};
@@ -34,5 +34,6 @@ module.exports = {
34
34
  usReverseGeo: {
35
35
  "latitude": "latitude",
36
36
  "longitude": "longitude",
37
+ "source": "source"
37
38
  }
38
39
  };
@@ -30,14 +30,15 @@ describe("A US Reverse Geo client", function () {
30
30
  "street": "2335 S State St",
31
31
  "city": "Provo",
32
32
  "state_abbreviation": "UT",
33
- "zipcode": "84606"
33
+ "zipcode": "84606",
34
+ "source": "postal"
34
35
  }
35
36
  },
36
37
  ]
37
38
  };
38
39
  let mockSender = new MockSenderWithResponse(expectedMockPayload);
39
40
  const client = new Client(mockSender);
40
- let lookup = new Lookup(44.888888888, -111.111111111);
41
+ let lookup = new Lookup(44.888888888, -111.111111111, "postal");
41
42
 
42
43
  return client.send(lookup).then(() => {
43
44
  expect(lookup.response).to.deep.equal(expectedMockPayload);
@@ -4,8 +4,9 @@ const Lookup = require("../../src/us_reverse_geo/Lookup");
4
4
 
5
5
  describe("A US Reverse Geo lookup", function () {
6
6
  it("correctly populates fields.", function () {
7
- let lookup = new Lookup(44.888888888, -111.111111111);
7
+ let lookup = new Lookup(44.888888888, -111.111111111, "postal");
8
8
 
9
+ expect(lookup.source).to.equal("postal")
9
10
  expect(lookup.latitude).to.equal("44.88888889");
10
11
  expect(lookup.longitude).to.equal("-111.11111111");
11
12
  expect(lookup.response.results).to.deep.equal([]);
@@ -18,7 +18,8 @@ describe("A US Reverse Geo match response", function () {
18
18
  street: "5",
19
19
  city: "6",
20
20
  state_abbreviation: "7",
21
- zipcode: "8"
21
+ zipcode: "8",
22
+ source: "postal"
22
23
  }
23
24
  },
24
25
  ]
@@ -33,6 +34,7 @@ describe("A US Reverse Geo match response", function () {
33
34
  expect(address.city).to.equal("6");
34
35
  expect(address.state_abbreviation).to.equal("7");
35
36
  expect(address.zipcode).to.equal("8");
37
+ expect(address.source).to.equal("postal");
36
38
  let coordinate = result.coordinate;
37
39
  expect(coordinate.latitude).to.equal(1.1);
38
40
  expect(coordinate.longitude).to.equal(2.2);