smartystreets-javascript-sdk 5.2.0 → 6.0.0

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.
Files changed (243) hide show
  1. package/dist/cjs/AgentSender.cjs +1 -0
  2. package/dist/cjs/BaseUrlSender.cjs +1 -0
  3. package/dist/cjs/Batch.cjs +1 -0
  4. package/dist/cjs/ClientBuilder.cjs +1 -0
  5. package/dist/cjs/CustomHeaderSender.cjs +1 -0
  6. package/dist/cjs/Errors.cjs +1 -0
  7. package/dist/cjs/HttpSender.cjs +1 -0
  8. package/dist/cjs/InputData.cjs +1 -0
  9. package/dist/cjs/LicenseSender.cjs +1 -0
  10. package/dist/cjs/Request.cjs +1 -0
  11. package/dist/cjs/Response.cjs +1 -0
  12. package/dist/cjs/RetrySender.cjs +1 -0
  13. package/dist/cjs/SharedCredentials.cjs +1 -0
  14. package/dist/cjs/SigningSender.cjs +1 -0
  15. package/dist/cjs/StaticCredentials.cjs +1 -0
  16. package/dist/cjs/StatusCodeSender.cjs +1 -0
  17. package/dist/cjs/_virtual/Batch.cjs +1 -0
  18. package/dist/cjs/_virtual/Candidate.cjs +1 -0
  19. package/dist/cjs/_virtual/Candidate2.cjs +1 -0
  20. package/dist/cjs/_virtual/ClientBuilder.cjs +1 -0
  21. package/dist/cjs/_virtual/Errors.cjs +1 -0
  22. package/dist/cjs/_virtual/Lookup.cjs +1 -0
  23. package/dist/cjs/_virtual/Lookup2.cjs +1 -0
  24. package/dist/cjs/_virtual/Lookup3.cjs +1 -0
  25. package/dist/cjs/_virtual/Lookup4.cjs +1 -0
  26. package/dist/cjs/_virtual/Lookup5.cjs +1 -0
  27. package/dist/cjs/_virtual/Lookup6.cjs +1 -0
  28. package/dist/cjs/_virtual/Lookup7.cjs +1 -0
  29. package/dist/cjs/_virtual/Lookup8.cjs +1 -0
  30. package/dist/cjs/_virtual/Response.cjs +1 -0
  31. package/dist/cjs/_virtual/Result.cjs +1 -0
  32. package/dist/cjs/_virtual/Result2.cjs +1 -0
  33. package/dist/cjs/_virtual/SharedCredentials.cjs +1 -0
  34. package/dist/cjs/_virtual/StaticCredentials.cjs +1 -0
  35. package/dist/cjs/_virtual/Suggestion.cjs +1 -0
  36. package/dist/cjs/_virtual/Suggestion2.cjs +1 -0
  37. package/dist/cjs/_virtual/_axios.cjs +1 -0
  38. package/dist/cjs/_virtual/_commonjsHelpers.cjs +1 -0
  39. package/dist/cjs/_virtual/buildClients.cjs +1 -0
  40. package/dist/cjs/index.cjs +1 -0
  41. package/dist/cjs/international_address_autocomplete/Client.cjs +1 -0
  42. package/dist/cjs/international_address_autocomplete/Lookup.cjs +1 -0
  43. package/dist/cjs/international_address_autocomplete/Suggestion.cjs +1 -0
  44. package/dist/cjs/international_street/Candidate.cjs +1 -0
  45. package/dist/cjs/international_street/Client.cjs +1 -0
  46. package/dist/cjs/international_street/Lookup.cjs +1 -0
  47. package/dist/cjs/package.json.cjs +1 -0
  48. package/dist/cjs/us_autocomplete_pro/Client.cjs +1 -0
  49. package/dist/cjs/us_autocomplete_pro/Lookup.cjs +1 -0
  50. package/dist/cjs/us_autocomplete_pro/Suggestion.cjs +1 -0
  51. package/dist/cjs/us_enrichment/Client.cjs +1 -0
  52. package/dist/cjs/us_enrichment/Lookup.cjs +1 -0
  53. package/dist/cjs/us_enrichment/Response.cjs +1 -0
  54. package/dist/cjs/us_extract/Address.cjs +1 -0
  55. package/dist/cjs/us_extract/Client.cjs +1 -0
  56. package/dist/cjs/us_extract/Lookup.cjs +1 -0
  57. package/dist/cjs/us_extract/Result.cjs +1 -0
  58. package/dist/cjs/us_reverse_geo/Client.cjs +1 -0
  59. package/dist/cjs/us_reverse_geo/Lookup.cjs +1 -0
  60. package/dist/cjs/us_reverse_geo/Response.cjs +1 -0
  61. package/dist/cjs/us_reverse_geo/Result.cjs +1 -0
  62. package/dist/cjs/us_street/Candidate.cjs +1 -0
  63. package/dist/cjs/us_street/Client.cjs +1 -0
  64. package/dist/cjs/us_street/Lookup.cjs +1 -0
  65. package/dist/cjs/us_zipcode/Client.cjs +1 -0
  66. package/dist/cjs/us_zipcode/Lookup.cjs +1 -0
  67. package/dist/cjs/us_zipcode/Result.cjs +1 -0
  68. package/dist/cjs/util/Sleeper.cjs +1 -0
  69. package/dist/cjs/util/apiToSDKKeyMap.cjs +1 -0
  70. package/dist/cjs/util/buildClients.cjs +1 -0
  71. package/dist/cjs/util/buildInputData.cjs +1 -0
  72. package/dist/cjs/util/buildSmartyResponse.cjs +1 -0
  73. package/dist/cjs/util/sendBatch.cjs +1 -0
  74. package/dist/esm/AgentSender.mjs +1 -0
  75. package/dist/esm/BaseUrlSender.mjs +1 -0
  76. package/dist/esm/Batch.mjs +1 -0
  77. package/dist/esm/ClientBuilder.mjs +1 -0
  78. package/dist/esm/CustomHeaderSender.mjs +1 -0
  79. package/dist/esm/Errors.mjs +1 -0
  80. package/dist/esm/HttpSender.mjs +1 -0
  81. package/dist/esm/InputData.mjs +1 -0
  82. package/dist/esm/LicenseSender.mjs +1 -0
  83. package/dist/esm/Request.mjs +1 -0
  84. package/dist/esm/Response.mjs +1 -0
  85. package/dist/esm/RetrySender.mjs +1 -0
  86. package/dist/esm/SharedCredentials.mjs +1 -0
  87. package/dist/esm/SigningSender.mjs +1 -0
  88. package/dist/esm/StaticCredentials.mjs +1 -0
  89. package/dist/esm/StatusCodeSender.mjs +1 -0
  90. package/dist/esm/_virtual/Batch.mjs +1 -0
  91. package/dist/esm/_virtual/Candidate.mjs +1 -0
  92. package/dist/esm/_virtual/Candidate2.mjs +1 -0
  93. package/dist/esm/_virtual/ClientBuilder.mjs +1 -0
  94. package/dist/esm/_virtual/Errors.mjs +1 -0
  95. package/dist/esm/_virtual/Lookup.mjs +1 -0
  96. package/dist/esm/_virtual/Lookup2.mjs +1 -0
  97. package/dist/esm/_virtual/Lookup3.mjs +1 -0
  98. package/dist/esm/_virtual/Lookup4.mjs +1 -0
  99. package/dist/esm/_virtual/Lookup5.mjs +1 -0
  100. package/dist/esm/_virtual/Lookup6.mjs +1 -0
  101. package/dist/esm/_virtual/Lookup7.mjs +1 -0
  102. package/dist/esm/_virtual/Lookup8.mjs +1 -0
  103. package/dist/esm/_virtual/Response.mjs +1 -0
  104. package/dist/esm/_virtual/Result.mjs +1 -0
  105. package/dist/esm/_virtual/Result2.mjs +1 -0
  106. package/dist/esm/_virtual/SharedCredentials.mjs +1 -0
  107. package/dist/esm/_virtual/StaticCredentials.mjs +1 -0
  108. package/dist/esm/_virtual/Suggestion.mjs +1 -0
  109. package/dist/esm/_virtual/Suggestion2.mjs +1 -0
  110. package/dist/esm/_virtual/_axios.mjs +1 -0
  111. package/dist/esm/_virtual/_commonjsHelpers.mjs +1 -0
  112. package/dist/esm/_virtual/buildClients.mjs +1 -0
  113. package/dist/esm/index.mjs +1 -0
  114. package/dist/esm/international_address_autocomplete/Client.mjs +1 -0
  115. package/dist/esm/international_address_autocomplete/Lookup.mjs +1 -0
  116. package/dist/esm/international_address_autocomplete/Suggestion.mjs +1 -0
  117. package/dist/esm/international_street/Candidate.mjs +1 -0
  118. package/dist/esm/international_street/Client.mjs +1 -0
  119. package/dist/esm/international_street/Lookup.mjs +1 -0
  120. package/dist/esm/package.json.mjs +1 -0
  121. package/dist/esm/us_autocomplete_pro/Client.mjs +1 -0
  122. package/dist/esm/us_autocomplete_pro/Lookup.mjs +1 -0
  123. package/dist/esm/us_autocomplete_pro/Suggestion.mjs +1 -0
  124. package/dist/esm/us_enrichment/Client.mjs +1 -0
  125. package/dist/esm/us_enrichment/Lookup.mjs +1 -0
  126. package/dist/esm/us_enrichment/Response.mjs +1 -0
  127. package/dist/esm/us_extract/Address.mjs +1 -0
  128. package/dist/esm/us_extract/Client.mjs +1 -0
  129. package/dist/esm/us_extract/Lookup.mjs +1 -0
  130. package/dist/esm/us_extract/Result.mjs +1 -0
  131. package/dist/esm/us_reverse_geo/Client.mjs +1 -0
  132. package/dist/esm/us_reverse_geo/Lookup.mjs +1 -0
  133. package/dist/esm/us_reverse_geo/Response.mjs +1 -0
  134. package/dist/esm/us_reverse_geo/Result.mjs +1 -0
  135. package/dist/esm/us_street/Candidate.mjs +1 -0
  136. package/dist/esm/us_street/Client.mjs +1 -0
  137. package/dist/esm/us_street/Lookup.mjs +1 -0
  138. package/dist/esm/us_zipcode/Client.mjs +1 -0
  139. package/dist/esm/us_zipcode/Lookup.mjs +1 -0
  140. package/dist/esm/us_zipcode/Result.mjs +1 -0
  141. package/dist/esm/util/Sleeper.mjs +1 -0
  142. package/dist/esm/util/apiToSDKKeyMap.mjs +1 -0
  143. package/dist/esm/util/buildClients.mjs +1 -0
  144. package/dist/esm/util/buildInputData.mjs +1 -0
  145. package/dist/esm/util/buildSmartyResponse.mjs +1 -0
  146. package/dist/esm/util/sendBatch.mjs +1 -0
  147. package/package.json +26 -6
  148. package/.github/workflows/node-tests.yml +0 -27
  149. package/CHANGELOG.md +0 -5
  150. package/Makefile +0 -28
  151. package/examples/international_address_autocomplete.js +0 -58
  152. package/examples/international_street.js +0 -56
  153. package/examples/us_autocomplete_pro.js +0 -63
  154. package/examples/us_enrichment.js +0 -36
  155. package/examples/us_extract.js +0 -40
  156. package/examples/us_reverse_geo.js +0 -40
  157. package/examples/us_street.js +0 -73
  158. package/examples/us_zipcode.js +0 -57
  159. package/index.js +0 -41
  160. package/js-sdk-demo.cast +0 -95
  161. package/src/AgentSender.js +0 -16
  162. package/src/BaseUrlSender.js +0 -18
  163. package/src/Batch.js +0 -49
  164. package/src/ClientBuilder.js +0 -212
  165. package/src/CustomHeaderSender.js +0 -20
  166. package/src/Errors.js +0 -100
  167. package/src/HttpSender.js +0 -66
  168. package/src/InputData.js +0 -21
  169. package/src/LicenseSender.js +0 -20
  170. package/src/Request.js +0 -12
  171. package/src/Response.js +0 -10
  172. package/src/RetrySender.js +0 -50
  173. package/src/SharedCredentials.js +0 -13
  174. package/src/SigningSender.js +0 -26
  175. package/src/StaticCredentials.js +0 -13
  176. package/src/StatusCodeSender.js +0 -35
  177. package/src/international_address_autocomplete/Client.js +0 -41
  178. package/src/international_address_autocomplete/Lookup.js +0 -14
  179. package/src/international_address_autocomplete/Suggestion.js +0 -14
  180. package/src/international_street/Candidate.js +0 -153
  181. package/src/international_street/Client.js +0 -42
  182. package/src/international_street/Lookup.js +0 -85
  183. package/src/us_autocomplete_pro/Client.js +0 -41
  184. package/src/us_autocomplete_pro/Lookup.js +0 -29
  185. package/src/us_autocomplete_pro/Suggestion.js +0 -19
  186. package/src/us_enrichment/Client.js +0 -112
  187. package/src/us_enrichment/Lookup.js +0 -13
  188. package/src/us_enrichment/Response.js +0 -559
  189. package/src/us_extract/Address.js +0 -17
  190. package/src/us_extract/Client.js +0 -35
  191. package/src/us_extract/Lookup.js +0 -24
  192. package/src/us_extract/Result.js +0 -21
  193. package/src/us_reverse_geo/Client.js +0 -40
  194. package/src/us_reverse_geo/Lookup.js +0 -17
  195. package/src/us_reverse_geo/Response.js +0 -17
  196. package/src/us_reverse_geo/Result.js +0 -36
  197. package/src/us_street/Candidate.js +0 -89
  198. package/src/us_street/Client.js +0 -43
  199. package/src/us_street/Lookup.js +0 -25
  200. package/src/us_zipcode/Client.js +0 -39
  201. package/src/us_zipcode/Lookup.js +0 -16
  202. package/src/us_zipcode/Result.js +0 -45
  203. package/src/util/Sleeper.js +0 -8
  204. package/src/util/apiToSDKKeyMap.js +0 -75
  205. package/src/util/buildClients.js +0 -48
  206. package/src/util/buildInputData.js +0 -11
  207. package/src/util/buildSmartyResponse.js +0 -10
  208. package/src/util/sendBatch.js +0 -39
  209. package/tests/fixtures/MockSleeper.js +0 -10
  210. package/tests/fixtures/mock_senders.js +0 -43
  211. package/tests/international_address_autocomplete/test_Client.js +0 -86
  212. package/tests/international_address_autocomplete/test_Lookup.js +0 -55
  213. package/tests/international_street/test_Candidate.js +0 -268
  214. package/tests/international_street/test_Client.js +0 -70
  215. package/tests/international_street/test_Lookup.js +0 -108
  216. package/tests/test_AgentSender.js +0 -25
  217. package/tests/test_BaseUrlSender.js +0 -31
  218. package/tests/test_Batch.js +0 -73
  219. package/tests/test_CustomHeaderSender.js +0 -31
  220. package/tests/test_ExtractExample.js +0 -167
  221. package/tests/test_HttpSender.js +0 -93
  222. package/tests/test_LicenseSender.js +0 -40
  223. package/tests/test_RetrySender.js +0 -98
  224. package/tests/test_SigningSender.js +0 -56
  225. package/tests/test_StatusCodeSender.js +0 -95
  226. package/tests/us_autocomplete_pro/test_Client.js +0 -116
  227. package/tests/us_autocomplete_pro/test_Lookup.js +0 -11
  228. package/tests/us_autocomplete_pro/test_Suggestion.js +0 -24
  229. package/tests/us_enrichment/test_Client.js +0 -455
  230. package/tests/us_enrichment/test_Lookup.js +0 -22
  231. package/tests/us_enrichment/test_Response.js +0 -739
  232. package/tests/us_extract/test_Address.js +0 -67
  233. package/tests/us_extract/test_Client.js +0 -148
  234. package/tests/us_extract/test_Lookup.js +0 -19
  235. package/tests/us_extract/test_Result.js +0 -39
  236. package/tests/us_reverse_geo/test_Client.js +0 -48
  237. package/tests/us_reverse_geo/test_Lookup.js +0 -14
  238. package/tests/us_reverse_geo/test_Response.js +0 -44
  239. package/tests/us_street/test_Candidate.js +0 -133
  240. package/tests/us_street/test_Client.js +0 -150
  241. package/tests/us_street/test_Lookup.js +0 -29
  242. package/tests/us_zipcode/test_Client.js +0 -150
  243. package/tests/us_zipcode/test_Result.js +0 -81
@@ -1,21 +0,0 @@
1
- const Address = require("./Address");
2
-
3
- /**
4
- * @see <a href="https://www.smarty.com/docs/cloud/us-extract-api#http-response-status">Smarty US Extract API docs</a>
5
- */
6
- class Result {
7
- constructor({meta, addresses}) {
8
- this.meta = {
9
- lines: meta.lines,
10
- unicode: meta.unicode,
11
- addressCount: meta.address_count,
12
- verifiedCount: meta.verified_count,
13
- bytes: meta.bytes,
14
- characterCount: meta.character_count,
15
- };
16
-
17
- this.addresses = addresses.map(rawAddress => new Address(rawAddress));
18
- }
19
- }
20
-
21
- module.exports = Result;
@@ -1,40 +0,0 @@
1
- const Request = require("../Request");
2
- const Response = require("./Response");
3
- const buildInputData = require("../util/buildInputData");
4
- const keyTranslationFormat = require("../util/apiToSDKKeyMap").usReverseGeo;
5
- const {UndefinedLookupError} = require("../Errors.js");
6
-
7
- /**
8
- * This client sends lookups to the Smarty US Reverse Geo API, <br>
9
- * and attaches the results to the appropriate Lookup objects.
10
- */
11
- class Client {
12
- constructor(sender) {
13
- this.sender = sender;
14
- }
15
-
16
- send(lookup) {
17
- if (typeof lookup === "undefined") throw new UndefinedLookupError();
18
-
19
- let request = new Request();
20
- request.parameters = buildInputData(lookup, keyTranslationFormat);
21
-
22
- return new Promise((resolve, reject) => {
23
- this.sender.send(request)
24
- .then(response => {
25
- if (response.error) reject(response.error);
26
-
27
- resolve(attachLookupResults(response, lookup));
28
- })
29
- .catch(reject);
30
- });
31
-
32
- function attachLookupResults(response, lookup) {
33
- lookup.response = new Response(response.payload);
34
-
35
- return lookup;
36
- }
37
- }
38
- }
39
-
40
- module.exports = Client;
@@ -1,17 +0,0 @@
1
- const Response = require("./Response");
2
-
3
- /**
4
- * In addition to holding all of the input data for this lookup, this class also<br>
5
- * will contain the result of the lookup after it comes back from the API.
6
- * @see "https://www.smarty.com/docs/cloud/us-street-api#input-fields"
7
- */
8
- class Lookup {
9
- constructor(latitude, longitude, source="") {
10
- this.latitude = latitude.toFixed(8);
11
- this.longitude = longitude.toFixed(8);
12
- this.source = source;
13
- this.response = new Response();
14
- }
15
- }
16
-
17
- module.exports = Lookup;
@@ -1,17 +0,0 @@
1
- const Result = require("./Result");
2
-
3
- /**
4
- * The SmartyResponse contains the response from a call to the US Reverse Geo API.
5
- */
6
- class Response {
7
- constructor(responseData) {
8
- this.results = [];
9
-
10
- if (responseData)
11
- responseData.results.map(rawResult => {
12
- this.results.push(new Result(rawResult));
13
- });
14
- }
15
- }
16
-
17
- module.exports = Response;
@@ -1,36 +0,0 @@
1
- /**
2
- * A candidate is a possible match for an address that was submitted.<br>
3
- * A lookup can have multiple candidates if the address was ambiguous.
4
- *
5
- * @see "https://www.smarty.com/docs/cloud/us-reverse-geo-api#result"
6
- */
7
- class Result {
8
- constructor(responseData) {
9
- this.distance = responseData.distance;
10
-
11
- this.address = {};
12
- if (responseData.address) {
13
- this.address.street = responseData.address.street;
14
- this.address.city = responseData.address.city;
15
- this.address.state_abbreviation = responseData.address.state_abbreviation;
16
- this.address.zipcode = responseData.address.zipcode;
17
- this.address.source = responseData.address.source
18
- }
19
-
20
- this.coordinate = {};
21
- if (responseData.coordinate) {
22
- this.coordinate.latitude = responseData.coordinate.latitude;
23
- this.coordinate.longitude = responseData.coordinate.longitude;
24
- this.coordinate.accuracy = responseData.coordinate.accuracy;
25
- switch (responseData.coordinate.license) {
26
- case 1:
27
- this.coordinate.license = "SmartyStreets Proprietary";
28
- break;
29
- default:
30
- this.coordinate.license = "SmartyStreets";
31
- }
32
- }
33
- }
34
- }
35
-
36
- module.exports = Result;
@@ -1,89 +0,0 @@
1
- /**
2
- * A candidate is a possible match for an address that was submitted.<br>
3
- * A lookup can have multiple candidates if the address was ambiguous, and<br>
4
- * the maxCandidates field is set higher than 1.
5
- *
6
- * @see "https://www.smarty.com/docs/cloud/us-street-api#root"
7
- */
8
- class Candidate {
9
- constructor(responseData) {
10
- this.inputIndex = responseData.input_index;
11
- this.candidateIndex = responseData.candidate_index;
12
- this.addressee = responseData.addressee;
13
- this.deliveryLine1 = responseData.delivery_line_1;
14
- this.deliveryLine2 = responseData.delivery_line_2;
15
- this.lastLine = responseData.last_line;
16
- this.deliveryPointBarcode = responseData.delivery_point_barcode;
17
- this.smartyKey = responseData.smarty_key;
18
-
19
- this.components = {};
20
- if (responseData.components !== undefined) {
21
- this.components.urbanization = responseData.components.urbanization;
22
- this.components.primaryNumber = responseData.components.primary_number;
23
- this.components.streetName = responseData.components.street_name;
24
- this.components.streetPredirection = responseData.components.street_predirection;
25
- this.components.streetPostdirection = responseData.components.street_postdirection;
26
- this.components.streetSuffix = responseData.components.street_suffix;
27
- this.components.secondaryNumber = responseData.components.secondary_number;
28
- this.components.secondaryDesignator = responseData.components.secondary_designator;
29
- this.components.extraSecondaryNumber = responseData.components.extra_secondary_number;
30
- this.components.extraSecondaryDesignator = responseData.components.extra_secondary_designator;
31
- this.components.pmbDesignator = responseData.components.pmb_designator;
32
- this.components.pmbNumber = responseData.components.pmb_number;
33
- this.components.cityName = responseData.components.city_name;
34
- this.components.defaultCityName = responseData.components.default_city_name;
35
- this.components.state = responseData.components.state_abbreviation;
36
- this.components.zipCode = responseData.components.zipcode;
37
- this.components.plus4Code = responseData.components.plus4_code;
38
- this.components.deliveryPoint = responseData.components.delivery_point;
39
- this.components.deliveryPointCheckDigit = responseData.components.delivery_point_check_digit;
40
- }
41
-
42
- this.metadata = {};
43
- if (responseData.metadata !== undefined) {
44
- this.metadata.recordType = responseData.metadata.record_type;
45
- this.metadata.zipType = responseData.metadata.zip_type;
46
- this.metadata.countyFips = responseData.metadata.county_fips;
47
- this.metadata.countyName = responseData.metadata.county_name;
48
- this.metadata.carrierRoute = responseData.metadata.carrier_route;
49
- this.metadata.congressionalDistrict = responseData.metadata.congressional_district;
50
- this.metadata.buildingDefaultIndicator = responseData.metadata.building_default_indicator;
51
- this.metadata.rdi = responseData.metadata.rdi;
52
- this.metadata.elotSequence = responseData.metadata.elot_sequence;
53
- this.metadata.elotSort = responseData.metadata.elot_sort;
54
- this.metadata.latitude = responseData.metadata.latitude;
55
- this.metadata.longitude = responseData.metadata.longitude;
56
- switch (responseData.metadata.coordinate_license)
57
- {
58
- case 1:
59
- this.metadata.coordinateLicense = "SmartyStreets Proprietary";
60
- break;
61
- default:
62
- this.metadata.coordinateLicense = "SmartyStreets";
63
- }
64
- this.metadata.precision = responseData.metadata.precision;
65
- this.metadata.timeZone = responseData.metadata.time_zone;
66
- this.metadata.utcOffset = responseData.metadata.utc_offset;
67
- this.metadata.obeysDst = responseData.metadata.dst;
68
- this.metadata.isEwsMatch = responseData.metadata.ews_match;
69
- }
70
-
71
- this.analysis = {};
72
- if (responseData.analysis !== undefined) {
73
- this.analysis.dpvMatchCode = responseData.analysis.dpv_match_code;
74
- this.analysis.dpvFootnotes = responseData.analysis.dpv_footnotes;
75
- this.analysis.cmra = responseData.analysis.dpv_cmra;
76
- this.analysis.vacant = responseData.analysis.dpv_vacant;
77
- this.analysis.noStat = responseData.analysis.dpv_no_stat;
78
- this.analysis.active = responseData.analysis.active;
79
- this.analysis.isEwsMatch = responseData.analysis.ews_match; // Deprecated, refer to metadata.ews_match
80
- this.analysis.footnotes = responseData.analysis.footnotes;
81
- this.analysis.lacsLinkCode = responseData.analysis.lacslink_code;
82
- this.analysis.lacsLinkIndicator = responseData.analysis.lacslink_indicator;
83
- this.analysis.isSuiteLinkMatch = responseData.analysis.suitelink_match;
84
- this.analysis.enhancedMatch = responseData.analysis.enhanced_match;
85
- }
86
- }
87
- }
88
-
89
- module.exports = Candidate;
@@ -1,43 +0,0 @@
1
- const Candidate = require("./Candidate");
2
- const Lookup = require("./Lookup");
3
- const Batch = require("../Batch");
4
- const UndefinedLookupError = require("../Errors").UndefinedLookupError;
5
- const sendBatch = require("../util/sendBatch");
6
- const keyTranslationFormat = require("../util/apiToSDKKeyMap").usStreet;
7
-
8
- /**
9
- * This client sends lookups to the Smarty US Street API, <br>
10
- * and attaches the results to the appropriate Lookup objects.
11
- */
12
- class Client {
13
- constructor(sender) {
14
- this.sender = sender;
15
- }
16
-
17
- /**
18
- * Sends up to 100 lookups for validation.
19
- * @param data may be a Lookup object, or a Batch which must contain between 1 and 100 Lookup objects
20
- * @throws SmartyException
21
- */
22
- send(data) {
23
- const dataIsBatch = data instanceof Batch;
24
- const dataIsLookup = data instanceof Lookup;
25
-
26
- if (!dataIsLookup && !dataIsBatch) throw new UndefinedLookupError;
27
-
28
- let batch;
29
-
30
- if (dataIsLookup) {
31
- if (data.maxCandidates == null && data.match == "enhanced")
32
- data.maxCandidates = 5;
33
- batch = new Batch();
34
- batch.add(data);
35
- } else {
36
- batch = data;
37
- }
38
-
39
- return sendBatch(batch, this.sender, Candidate, keyTranslationFormat);
40
- }
41
- }
42
-
43
- module.exports = Client;
@@ -1,25 +0,0 @@
1
- /**
2
- * In addition to holding all of the input data for this lookup, this class also<br>
3
- * will contain the result of the lookup after it comes back from the API.
4
- * @see "https://www.smarty.com/docs/cloud/us-street-api#input-fields"
5
- */
6
- class Lookup {
7
- constructor(street, street2, secondary, city, state, zipCode, lastLine, addressee, urbanization, match, maxCandidates, inputId, format) {
8
- this.street = street;
9
- this.street2 = street2;
10
- this.secondary = secondary;
11
- this.city = city;
12
- this.state = state;
13
- this.zipCode = zipCode;
14
- this.lastLine = lastLine;
15
- this.addressee = addressee;
16
- this.urbanization = urbanization;
17
- this.match = match;
18
- this.maxCandidates = maxCandidates;
19
- this.inputId = inputId;
20
- this.format = format;
21
- this.result = [];
22
- }
23
- }
24
-
25
- module.exports = Lookup;
@@ -1,39 +0,0 @@
1
- const Lookup = require("./Lookup");
2
- const Result = require("./Result");
3
- const Batch = require("../Batch");
4
- const UndefinedLookupError = require("../Errors").UndefinedLookupError;
5
- const sendBatch = require("../util/sendBatch");
6
- const keyTranslationFormat = require("../util/apiToSDKKeyMap").usZipcode;
7
-
8
- /**
9
- * This client sends lookups to the Smarty US ZIP Code API, <br>
10
- * and attaches the results to the appropriate Lookup objects.
11
- */
12
- class Client {
13
- constructor(sender) {
14
- this.sender = sender;
15
- }
16
-
17
- /**
18
- * Sends up to 100 lookups for validation.
19
- * @param data May be a Lookup object, or a Batch which must contain between 1 and 100 Lookup objects
20
- * @throws SmartyException
21
- */
22
- send(data) {
23
- const dataIsBatch = data instanceof Batch;
24
- const dataIsLookup = data instanceof Lookup;
25
-
26
- if (!dataIsLookup && !dataIsBatch) throw new UndefinedLookupError;
27
-
28
- let batch;
29
-
30
- if (dataIsLookup) {
31
- batch = new Batch();
32
- batch.add(data);
33
- } else batch = data;
34
-
35
- return sendBatch(batch, this.sender, Result, keyTranslationFormat);
36
- }
37
- }
38
-
39
- module.exports = Client;
@@ -1,16 +0,0 @@
1
- /**
2
- * In addition to holding all of the input data for this lookup, this class also<br>
3
- * will contain the result of the lookup after it comes back from the API.
4
- * @see "https://www.smarty.com/docs/cloud/us-zipcode-api#http-request-input-fields"
5
- */
6
- class Lookup {
7
- constructor(city, state, zipCode, inputId) {
8
- this.city = city;
9
- this.state = state;
10
- this.zipCode = zipCode;
11
- this.inputId = inputId;
12
- this.result = [];
13
- }
14
- }
15
-
16
- module.exports = Lookup;
@@ -1,45 +0,0 @@
1
- /**
2
- * @see "https://www.smarty.com/docs/cloud/us-zipcode-api#root"
3
- */
4
- class Result {
5
- constructor(responseData) {
6
- this.inputIndex = responseData.input_index;
7
- this.status = responseData.status;
8
- this.reason = responseData.reason;
9
- this.valid = this.status === undefined && this.reason === undefined;
10
-
11
- this.cities = !responseData.city_states ? [] : responseData.city_states.map(city => {
12
- return {
13
- city: city.city,
14
- stateAbbreviation: city.state_abbreviation,
15
- state: city.state,
16
- mailableCity: city.mailable_city,
17
- };
18
- });
19
-
20
- this.zipcodes = !responseData.zipcodes ? [] : responseData.zipcodes.map(zipcode => {
21
- return {
22
- zipcode: zipcode.zipcode,
23
- zipcodeType: zipcode.zipcode_type,
24
- defaultCity: zipcode.default_city,
25
- countyFips: zipcode.county_fips,
26
- countyName: zipcode.county_name,
27
- latitude: zipcode.latitude,
28
- longitude: zipcode.longitude,
29
- precision: zipcode.precision,
30
- stateAbbreviation: zipcode.state_abbreviation,
31
- state: zipcode.state,
32
- alternateCounties: !zipcode.alternate_counties ? [] : zipcode.alternate_counties.map(county => {
33
- return {
34
- countyFips: county.county_fips,
35
- countyName: county.county_name,
36
- stateAbbreviation: county.state_abbreviation,
37
- state: county.state,
38
- }
39
- }),
40
- };
41
- });
42
- }
43
- }
44
-
45
- module.exports = Result;
@@ -1,8 +0,0 @@
1
- class Sleeper {
2
- constructor () {}
3
- sleep(seconds) {
4
- return new Promise(resolve => setTimeout(resolve, seconds*1000));
5
- }
6
- }
7
-
8
- module.exports = Sleeper;
@@ -1,75 +0,0 @@
1
- module.exports = {
2
- usStreet: {
3
- "street": "street",
4
- "street2": "street2",
5
- "secondary": "secondary",
6
- "city": "city",
7
- "state": "state",
8
- "zipcode": "zipCode",
9
- "lastline": "lastLine",
10
- "addressee": "addressee",
11
- "urbanization": "urbanization",
12
- "match": "match",
13
- "format": "format",
14
- "candidates": "maxCandidates",
15
- },
16
- usAutocompletePro: {
17
- search: "search",
18
- selected: "selected",
19
- max_results: "maxResults",
20
- include_only_cities: "includeOnlyCities",
21
- include_only_states: "includeOnlyStates",
22
- include_only_zip_codes: "includeOnlyZIPCodes",
23
- exclude_states: "excludeStates",
24
- prefer_cities: "preferCities",
25
- prefer_states: "preferStates",
26
- prefer_zip_codes: "preferZIPCodes",
27
- prefer_ratio: "preferRatio",
28
- prefer_geolocation: "preferGeolocation",
29
- source: "source",
30
- },
31
- usZipcode: {
32
- "city": "city",
33
- "state": "state",
34
- "zipcode": "zipCode",
35
- },
36
- internationalStreet: {
37
- "country": "country",
38
- "freeform": "freeform",
39
- "address1": "address1",
40
- "address2": "address2",
41
- "address3": "address3",
42
- "address4": "address4",
43
- "organization": "organization",
44
- "locality": "locality",
45
- "administrative_area": "administrativeArea",
46
- "postal_code": "postalCode",
47
- "geocode": "geocode",
48
- "language": "language",
49
- },
50
- internationalAddressAutocomplete: {
51
- search: "search",
52
- country: "country",
53
- max_results: "maxResults",
54
- include_only_administrative_area: "includeOnlyAdministrativeArea",
55
- include_only_locality: "includeOnlyLocality",
56
- include_only_postal_code: "includeOnlyPostalCode",
57
- },
58
- usReverseGeo: {
59
- "latitude": "latitude",
60
- "longitude": "longitude",
61
- "source": "source"
62
- },
63
- usExtract: {
64
- html: "html",
65
- aggressive: "aggressive",
66
- addr_line_breaks: "addressesHaveLineBreaks",
67
- addr_per_line: "addressesPerLine",
68
- },
69
- usEnrichment: {
70
- include: "include",
71
- exclude: "exclude",
72
- dataset: "dataset",
73
- data_subset: "dataSubset",
74
- }
75
- };
@@ -1,48 +0,0 @@
1
- const ClientBuilder = require("../ClientBuilder");
2
-
3
- function instantiateClientBuilder(credentials) {
4
- return new ClientBuilder(credentials);
5
- }
6
-
7
- function buildUsStreetApiClient(credentials) {
8
- return instantiateClientBuilder(credentials).buildUsStreetApiClient();
9
- }
10
-
11
- function buildUsAutocompleteProApiClient(credentials) {
12
- return instantiateClientBuilder(credentials).buildUsAutocompleteProClient();
13
- }
14
-
15
- function buildUsExtractApiClient(credentials) {
16
- return instantiateClientBuilder(credentials).buildUsExtractClient();
17
- }
18
-
19
- function buildUsZipcodeApiClient(credentials) {
20
- return instantiateClientBuilder(credentials).buildUsZipcodeClient();
21
- }
22
-
23
- function buildInternationalStreetApiClient(credentials) {
24
- return instantiateClientBuilder(credentials).buildInternationalStreetClient();
25
- }
26
-
27
- function buildUsReverseGeoApiClient(credentials) {
28
- return instantiateClientBuilder(credentials).buildUsReverseGeoClient();
29
- }
30
-
31
- function buildInternationalAddressAutocompleteApiClient(credentials) {
32
- return instantiateClientBuilder(credentials).buildInternationalAddressAutocompleteClient();
33
- }
34
-
35
- function buildUsEnrichmentApiClient(credentials) {
36
- return instantiateClientBuilder(credentials).buildUsEnrichmentClient();
37
- }
38
-
39
- module.exports = {
40
- usStreet: buildUsStreetApiClient,
41
- usAutocompletePro: buildUsAutocompleteProApiClient,
42
- usExtract: buildUsExtractApiClient,
43
- usZipcode: buildUsZipcodeApiClient,
44
- internationalStreet: buildInternationalStreetApiClient,
45
- usReverseGeo: buildUsReverseGeoApiClient,
46
- internationalAddressAutocomplete: buildInternationalAddressAutocompleteApiClient,
47
- usEnrichment: buildUsEnrichmentApiClient,
48
- };
@@ -1,11 +0,0 @@
1
- const InputData = require("../InputData");
2
-
3
- module.exports = (lookup, keyTranslationFormat) => {
4
- let inputData = new InputData(lookup);
5
-
6
- for (let key in keyTranslationFormat) {
7
- inputData.add(key, keyTranslationFormat[key]);
8
- }
9
-
10
- return inputData.data;
11
- };
@@ -1,10 +0,0 @@
1
- const Response = require("../Response.js");
2
-
3
- function buildSmartyResponse(response, error) {
4
- if (response) return new Response(response.status, response.data, response.error, response.headers);
5
- return new Response(undefined, undefined, error)
6
- }
7
-
8
- module.exports = {
9
- buildSmartyResponse
10
- };
@@ -1,39 +0,0 @@
1
- const Request = require("../Request");
2
- const Errors = require("../Errors");
3
- const buildInputData = require("../util/buildInputData");
4
-
5
- module.exports = (batch, sender, Result, keyTranslationFormat) => {
6
- if (batch.isEmpty()) throw new Errors.BatchEmptyError;
7
-
8
- let request = new Request();
9
-
10
- if (batch.length() === 1) request.parameters = generateRequestPayload(batch)[0];
11
- else request.payload = generateRequestPayload(batch);
12
-
13
- return new Promise((resolve, reject) => {
14
- sender.send(request)
15
- .then(response => {
16
- if (response.error) reject(response.error);
17
-
18
- resolve(assignResultsToLookups(batch, response));
19
- })
20
- .catch(reject);
21
- });
22
-
23
- function generateRequestPayload(batch) {
24
- return batch.lookups.map((lookup) => {
25
- return buildInputData(lookup, keyTranslationFormat);
26
- });
27
- }
28
-
29
- function assignResultsToLookups(batch, response) {
30
- response.payload.map(rawResult => {
31
- let result = new Result(rawResult);
32
- let lookup = batch.getByIndex(result.inputIndex);
33
-
34
- lookup.result.push(result);
35
- });
36
-
37
- return batch;
38
- }
39
- };
@@ -1,10 +0,0 @@
1
- class MockSleeper {
2
- constructor() {
3
- this.sleepDurations = [];
4
- }
5
- sleep(ms) {
6
- this.sleepDurations.push(ms);
7
- }
8
- }
9
-
10
- module.exports = MockSleeper;
@@ -1,43 +0,0 @@
1
- const {buildSmartyResponse} = require("../../src/util/buildSmartyResponse.js");
2
- const Response = require("../../src/Response");
3
-
4
- module.exports = {
5
- MockSender: function () {
6
- let request = {
7
- payload: undefined,
8
- parameters: undefined,
9
- baseUrlParam: undefined,
10
- };
11
- this.request = request;
12
-
13
- this.send = function (clientRequest) {
14
- request.payload = clientRequest.payload;
15
- request.parameters = clientRequest.parameters;
16
- request.baseUrlParam = clientRequest.baseUrlParam;
17
- }
18
- },
19
- MockSenderWithResponse: function (expectedPayload, expectedError) {
20
- this.send = function () {
21
- return new Promise((resolve, reject) => {
22
- resolve(new Response("", expectedPayload, expectedError));
23
- });
24
- }
25
- },
26
- MockSenderWithStatusCodesAndHeaders: function (statusCodes, headers = undefined, error = undefined) {
27
- this.statusCodes = statusCodes;
28
- this.headers = headers;
29
- this.error = error;
30
- this.currentStatusCodeIndex = 0;
31
-
32
- this.send = function (request) {
33
- let mockResponse = {
34
- status: this.statusCodes[this.currentStatusCodeIndex],
35
- headers: this.headers,
36
- error: this.error,
37
- };
38
- const response = buildSmartyResponse(mockResponse);
39
- this.currentStatusCodeIndex += 1;
40
- return response;
41
- }
42
- }
43
- };