smartystreets-python-sdk 6.2.1__tar.gz → 7.1.0__tar.gz

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 (100) hide show
  1. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/PKG-INFO +2 -2
  2. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/README.md +1 -1
  3. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/client_builder.py +6 -0
  4. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/errors.py +8 -4
  5. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/exceptions.py +8 -0
  6. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/components.py +6 -2
  7. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/rootlevel.py +1 -5
  8. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/native_serializer.py +2 -0
  9. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/status_code_sender.py +32 -15
  10. {smartystreets_python_sdk-6.2.1/smartystreets_python_sdk/us_autocomplete_pro → smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete}/__init__.py +1 -0
  11. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete/client.py +70 -0
  12. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete/lookup.py +83 -0
  13. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete/source.py +6 -0
  14. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete/suggestion.py +14 -0
  15. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete_pro/__init__.py +4 -0
  16. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_autocomplete_pro/client.py +3 -1
  17. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete_pro/geolocation_type.py +3 -0
  18. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_autocomplete_pro/lookup.py +2 -5
  19. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete_pro/source.py +6 -0
  20. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_enrichment/client.py +9 -2
  21. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_enrichment/lookup.py +2 -1
  22. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_reverse_geo/__init__.py +1 -0
  23. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_reverse_geo/client.py +3 -1
  24. smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_reverse_geo/source.py +6 -0
  25. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk.egg-info/PKG-INFO +2 -2
  26. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk.egg-info/SOURCES.txt +8 -0
  27. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk_version/__init__.py +1 -1
  28. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/LICENSE.md +0 -0
  29. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/setup.cfg +0 -0
  30. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/setup.py +0 -0
  31. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/__init__.py +0 -0
  32. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/basic_auth_credentials.py +0 -0
  33. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/batch.py +0 -0
  34. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/custom_header_sender.py +0 -0
  35. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/custom_query_sender.py +0 -0
  36. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_autocomplete/__init__.py +0 -0
  37. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_autocomplete/candidate.py +0 -0
  38. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_autocomplete/client.py +0 -0
  39. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_autocomplete/lookup.py +0 -0
  40. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_postal_code/__init__.py +0 -0
  41. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_postal_code/candidate.py +0 -0
  42. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_postal_code/client.py +0 -0
  43. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_postal_code/lookup.py +0 -0
  44. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/__init__.py +0 -0
  45. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/analysis.py +0 -0
  46. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/candidate.py +0 -0
  47. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/changes.py +0 -0
  48. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/client.py +0 -0
  49. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/language_mode.py +0 -0
  50. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/lookup.py +0 -0
  51. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/international_street/metadata.py +0 -0
  52. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/license_sender.py +0 -0
  53. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/proxy.py +0 -0
  54. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/request.py +0 -0
  55. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/requests_sender.py +0 -0
  56. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/response.py +0 -0
  57. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/retry_sender.py +0 -0
  58. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/shared_credentials.py +0 -0
  59. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/signing_sender.py +0 -0
  60. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/static_credentials.py +0 -0
  61. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/url_prefix_sender.py +0 -0
  62. {smartystreets_python_sdk-6.2.1/smartystreets_python_sdk/us_autocomplete_pro → smartystreets_python_sdk-7.1.0/smartystreets_python_sdk/us_autocomplete}/geolocation_type.py +0 -0
  63. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_autocomplete_pro/suggestion.py +0 -0
  64. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_enrichment/__init__.py +0 -0
  65. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_enrichment/business/__init__.py +0 -0
  66. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_enrichment/business/detail.py +0 -0
  67. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_enrichment/business/summary.py +0 -0
  68. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_enrichment/response.py +0 -0
  69. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_extract/__init__.py +0 -0
  70. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_extract/address.py +0 -0
  71. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_extract/client.py +0 -0
  72. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_extract/lookup.py +0 -0
  73. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_extract/metadata.py +0 -0
  74. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_extract/result.py +0 -0
  75. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_reverse_geo/address.py +0 -0
  76. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_reverse_geo/coordinate.py +0 -0
  77. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_reverse_geo/lookup.py +0 -0
  78. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_reverse_geo/response.py +0 -0
  79. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_reverse_geo/result.py +0 -0
  80. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/__init__.py +0 -0
  81. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/analysis.py +0 -0
  82. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/candidate.py +0 -0
  83. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/client.py +0 -0
  84. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/component_analysis.py +0 -0
  85. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/components.py +0 -0
  86. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/lookup.py +0 -0
  87. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/match_info.py +0 -0
  88. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/match_type.py +0 -0
  89. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/metadata.py +0 -0
  90. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_street/output_format.py +0 -0
  91. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_zipcode/__init__.py +0 -0
  92. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_zipcode/alternate_county.py +0 -0
  93. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_zipcode/city.py +0 -0
  94. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_zipcode/client.py +0 -0
  95. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_zipcode/lookup.py +0 -0
  96. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_zipcode/result.py +0 -0
  97. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk/us_zipcode/zipcode.py +0 -0
  98. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk.egg-info/dependency_links.txt +0 -0
  99. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk.egg-info/requires.txt +0 -0
  100. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.1.0}/smartystreets_python_sdk.egg-info/top_level.txt +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smartystreets_python_sdk
3
- Version: 6.2.1
3
+ Version: 7.1.0
4
4
  Summary: An official library to help Python developers easily access the SmartyStreets APIs
5
5
  Home-page: https://github.com/smartystreets/smartystreets-python-sdk
6
- Download-URL: https://github.com/smartystreets/smartystreets-python-sdk/tarball/6.2.1
6
+ Download-URL: https://github.com/smartystreets/smartystreets-python-sdk/tarball/7.1.0
7
7
  Author: SmartyStreets SDK Team
8
8
  Author-email: support@smartystreets.com
9
9
  License: Apache 2
@@ -2,7 +2,7 @@
2
2
 
3
3
  # SmartyStreets Python SDK
4
4
 
5
- The official client libraries for accessing SmartyStreets APIs from Python 2.7 and 3.5
5
+ The official client libraries for accessing SmartyStreets APIs from Python 3.10 and later.
6
6
 
7
7
  You may have noticed this page is curiously sparse. Don't panic, there's [documentation](https://smartystreets.com/docs/sdk/python) and [examples](examples).
8
8
 
@@ -3,6 +3,7 @@ from smartystreets_python_sdk.us_street import Client as USStreetClient
3
3
  from smartystreets_python_sdk.us_zipcode import Client as USZIPClient
4
4
  from smartystreets_python_sdk.us_extract import Client as USExtractClient
5
5
  from smartystreets_python_sdk.us_autocomplete_pro import Client as USAutocompleteProClient
6
+ from smartystreets_python_sdk.us_autocomplete import Client as USAutocompleteClient
6
7
  from smartystreets_python_sdk.us_reverse_geo import Client as USReverseGeoClient
7
8
  from smartystreets_python_sdk.international_street import Client as InternationalStreetClient
8
9
  from smartystreets_python_sdk.international_autocomplete import Client as InternationalAutocompleteClient
@@ -34,6 +35,7 @@ class ClientBuilder:
34
35
  self.INTERNATIONAL_STREET_API_URL = "https://international-street.api.smarty.com/verify"
35
36
  self.INTERNATIONAL_AUTOCOMPLETE_API_URL = "https://international-autocomplete.api.smarty.com/v2/lookup"
36
37
  self.US_AUTOCOMPLETE_PRO_API_URL = "https://us-autocomplete-pro.api.smarty.com/lookup"
38
+ self.US_AUTOCOMPLETE_API_URL = "https://us-autocomplete.api.smarty.com/v2/lookup"
37
39
  self.US_EXTRACT_API_URL = "https://us-extract.api.smarty.com"
38
40
  self.US_STREET_API_URL = "https://us-street.api.smarty.com/street-address"
39
41
  self.US_ZIP_CODE_API_URL = "https://us-zipcode.api.smarty.com/lookup"
@@ -229,6 +231,10 @@ class ClientBuilder:
229
231
  self.ensure_url_prefix_not_null(self.US_AUTOCOMPLETE_PRO_API_URL)
230
232
  return USAutocompleteProClient(self.build_sender(), self.serializer)
231
233
 
234
+ def build_us_autocomplete_api_client(self):
235
+ self.ensure_url_prefix_not_null(self.US_AUTOCOMPLETE_API_URL)
236
+ return USAutocompleteClient(self.build_sender(), self.serializer)
237
+
232
238
  def build_us_extract_api_client(self):
233
239
  self.ensure_url_prefix_not_null(self.US_EXTRACT_API_URL)
234
240
  return USExtractClient(self.build_sender(), self.serializer)
@@ -4,20 +4,24 @@ BAD_CREDENTIALS = "Unauthorized: The credentials were provided incorrectly or di
4
4
  PAYMENT_REQUIRED = "Payment Required: There is no active subscription\
5
5
  for the account associated with the credentials submitted with the request."
6
6
 
7
- FORBIDDEN = "Because the international service is currently in a limited release phase, only approved accounts" \
8
- " may access the service."
7
+ FORBIDDEN = "Forbidden: The request contained valid data and was understood by the server, but the server is\
8
+ refusing action."
9
+
10
+ REQUEST_TIMEOUT = "Request timeout error."
9
11
 
10
12
  REQUEST_ENTITY_TOO_LARGE = "Request Entity Too Large: The request body has exceeded the maximum size."
11
13
 
12
- BAD_REQUEST = "Bad Request (Malformed Payload): A GET request lacked a street field or the request body of a\
14
+ BAD_REQUEST = "Bad Request (Malformed Payload): A GET request lacked a required field or the request body of a\
13
15
  POST request contained malformed JSON."
14
16
 
15
17
  UNPROCESSABLE_ENTITY = "GET request lacked required fields."
16
18
 
17
- TOO_MANY_REQUESTS = "The rate limit has been exceeded."
19
+ TOO_MANY_REQUESTS = "Too Many Requests: The rate limit for your account has been exceeded."
18
20
 
19
21
  INTERNAL_SERVER_ERROR = "Internal Server Error."
20
22
 
23
+ BAD_GATEWAY = "Bad Gateway error."
24
+
21
25
  SERVICE_UNAVAILABLE = "Service Unavailable. Try again later."
22
26
 
23
27
  GATEWAY_TIMEOUT = "The upstream data provider did not respond in a timely fashion and the request failed. " \
@@ -22,6 +22,14 @@ class BadRequestError(SmartyException):
22
22
  pass
23
23
 
24
24
 
25
+ class RequestTimeoutError(SmartyException):
26
+ pass
27
+
28
+
29
+ class BadGatewayError(SmartyException):
30
+ pass
31
+
32
+
25
33
  class UnprocessableEntityError(SmartyException):
26
34
  pass
27
35
 
@@ -7,8 +7,7 @@ class Components:
7
7
  self.super_administrative_area = obj.get("super_administrative_area", None)
8
8
  self.administrative_area = obj.get("administrative_area", None)
9
9
  self.administrative_area_iso2 = obj.get("administrative_area_iso2", None)
10
- self.administrative_area_short = obj.get("administrative_area_short", None)
11
- self.administrative_area_long = obj.get("administrative_area_long", None)
10
+ self.attention = obj.get("attention", None)
12
11
  self.sub_administrative_area = obj.get("sub_administrative_area", None)
13
12
  self.dependent_locality= obj.get("dependent_locality", None)
14
13
  self.dependent_locality_name = obj.get("dependent_locality_name", None)
@@ -22,6 +21,11 @@ class Components:
22
21
  self.premise_number = obj.get("premise_number", None)
23
22
  self.premise_prefix_number = obj.get("premise_prefix_number", None)
24
23
  self.premise_type = obj.get("premise_type", None)
24
+ self.short_address_code = obj.get("short_address_code", None)
25
+ self.sub_building_leading_type = obj.get("sub_building_leading_type", None)
26
+ self.sub_building_block = obj.get("sub_building_block", None)
27
+ self.sub_building_door = obj.get("sub_building_door", None)
28
+ self.sub_building_staircase = obj.get("sub_building_staircase", None)
25
29
  self.thoroughfare = obj.get("thoroughfare", None)
26
30
  self.thoroughfare_predirection = obj.get("thoroughfare_predirection", None)
27
31
  self.thoroughfare_postdirection = obj.get("thoroughfare_postdirection", None)
@@ -9,8 +9,4 @@ class RootLevel:
9
9
  self.address5 = obj.get("address5", None)
10
10
  self.address6 = obj.get("address6", None)
11
11
  self.address7 = obj.get("address7", None)
12
- self.address8 = obj.get("address8", None)
13
- self.address9 = obj.get("address9", None)
14
- self.address10 = obj.get("address10", None)
15
- self.address11 = obj.get("address11", None)
16
- self.address12 = obj.get("address12", None)
12
+ self.address8 = obj.get("address8", None)
@@ -9,4 +9,6 @@ class NativeSerializer:
9
9
  return json.dumps(obj).encode("UTF-8")
10
10
 
11
11
  def deserialize(self, payload):
12
+ if not payload:
13
+ return {}
12
14
  return json.loads(payload)
@@ -14,23 +14,35 @@ class StatusCodeSender:
14
14
  response = self.inner.send(request)
15
15
 
16
16
  if not response.error:
17
- if response.status_code == 304:
18
- response.error = exceptions.NotModifiedError(errors.NOT_MODIFIED, response.find_header('etag'))
19
- elif response.status_code == 429:
17
+ if response.status_code == 429:
20
18
  response.error = self.parse_rate_limit_response(response)
21
- elif response.status_code in [400, 401, 402, 403, 413, 422]:
22
- response.error = messageFrom(response, statuses.get(response.status_code))
23
- else:
24
- response.error = statuses.get(response.status_code)
19
+ elif response.status_code not in (200, 304):
20
+ response.error = messageFrom(response, fallback_error(response.status_code))
25
21
 
26
22
  return response
27
23
 
24
+ def fallback_error(status_code):
25
+ error = statuses.get(status_code)
26
+ if error is None:
27
+ error = exceptions.SmartyException(
28
+ 'The server returned an unexpected HTTP status code: {}'.format(status_code))
29
+ return error
30
+
31
+
28
32
  def messageFrom(response, fallback):
29
33
  message = extract_message(response)
30
34
  if message:
31
35
  return type(fallback)(message)
32
- else:
33
- return fallback
36
+ return type(fallback)('{} Body: {}'.format(fallback, unused_body(response)).rstrip())
37
+
38
+
39
+ def unused_body(response):
40
+ payload = response.payload
41
+ if payload is None:
42
+ return ''
43
+ if isinstance(payload, bytes):
44
+ payload = payload.decode('utf-8', 'replace')
45
+ return str(payload).strip()
34
46
 
35
47
 
36
48
  def extract_message(response):
@@ -51,10 +63,6 @@ def extract_message(response):
51
63
  return message.rstrip()
52
64
 
53
65
 
54
- def ok():
55
- return None
56
-
57
-
58
66
  def bad_credentials():
59
67
  return exceptions.BadCredentialsError(errors.BAD_CREDENTIALS)
60
68
 
@@ -67,6 +75,10 @@ def forbidden():
67
75
  return exceptions.ForbiddenError(errors.FORBIDDEN)
68
76
 
69
77
 
78
+ def request_timeout():
79
+ return exceptions.RequestTimeoutError(errors.REQUEST_TIMEOUT)
80
+
81
+
70
82
  def request_entity_too_large():
71
83
  return exceptions.RequestEntityTooLargeError(errors.REQUEST_ENTITY_TOO_LARGE)
72
84
 
@@ -83,6 +95,10 @@ def internal_server_error():
83
95
  return exceptions.InternalServerError(errors.INTERNAL_SERVER_ERROR)
84
96
 
85
97
 
98
+ def bad_gateway():
99
+ return exceptions.BadGatewayError(errors.BAD_GATEWAY)
100
+
101
+
86
102
  def service_unavailable():
87
103
  return exceptions.ServiceUnavailableError(errors.SERVICE_UNAVAILABLE)
88
104
 
@@ -91,14 +107,15 @@ def gateway_timeout():
91
107
  return exceptions.GatewayTimeoutError(errors.GATEWAY_TIMEOUT)
92
108
 
93
109
 
94
- statuses = {200: ok(),
95
- 401: bad_credentials(),
110
+ statuses = {401: bad_credentials(),
96
111
  402: payment_required(),
97
112
  403: forbidden(),
113
+ 408: request_timeout(),
98
114
  413: request_entity_too_large(),
99
115
  400: bad_request(),
100
116
  422: unprocessable_entity(),
101
117
  500: internal_server_error(),
118
+ 502: bad_gateway(),
102
119
  503: service_unavailable(),
103
120
  504: gateway_timeout()
104
121
  }
@@ -1,3 +1,4 @@
1
1
  from .suggestion import Suggestion
2
2
  from .lookup import Lookup
3
3
  from .client import Client
4
+ from .source import Source
@@ -0,0 +1,70 @@
1
+ from enum import Enum
2
+
3
+ from smartystreets_python_sdk import Request
4
+ from smartystreets_python_sdk.exceptions import SmartyException
5
+ from smartystreets_python_sdk.us_autocomplete import Suggestion, geolocation_type
6
+
7
+
8
+ class Client:
9
+ def __init__(self, sender, serializer):
10
+ """
11
+ It is recommended to instantiate this class using ClientBuilder.build_us_autocomplete_api_client()
12
+ """
13
+ self.sender = sender
14
+ self.serializer = serializer
15
+
16
+ def send(self, lookup):
17
+ """
18
+ Sends a Lookup object to the US Autocomplete API and stores the result in the Lookup's result field.
19
+ """
20
+ if not lookup or not lookup.search:
21
+ raise SmartyException('Send() must be passed a Lookup with the search field set.')
22
+
23
+ request = self.build_request(lookup)
24
+
25
+ response = self.sender.send(request)
26
+
27
+ if response.error:
28
+ raise response.error
29
+
30
+ result = self.serializer.deserialize(response.payload)
31
+ suggestions = self.convert_suggestions(result.get('suggestions') or [])
32
+ lookup.result = suggestions
33
+
34
+ return suggestions
35
+
36
+ def build_request(self, lookup):
37
+ request = Request()
38
+
39
+ self.add_parameter(request, 'search', lookup.search)
40
+ self.add_parameter(request, 'max_results', lookup.max_results)
41
+ self.add_parameter(request, 'include_only_cities', self.build_filter_string(lookup.city_filter))
42
+ self.add_parameter(request, 'include_only_states', self.build_filter_string(lookup.state_filter))
43
+ self.add_parameter(request, 'include_only_zip_codes', self.build_filter_string(lookup.zip_filter))
44
+ self.add_parameter(request, 'exclude_states', self.build_filter_string(lookup.exclude_states))
45
+ self.add_parameter(request, 'prefer_cities', self.build_filter_string(lookup.prefer_cities))
46
+ self.add_parameter(request, 'prefer_states', self.build_filter_string(lookup.prefer_states))
47
+ self.add_parameter(request, 'prefer_zip_codes', self.build_filter_string(lookup.prefer_zips))
48
+ self.add_parameter(request, 'prefer_ratio', lookup.prefer_ratio)
49
+ self.add_parameter(request, 'prefer_geolocation', lookup.prefer_geolocation)
50
+ self.add_parameter(request, 'source', lookup.source)
51
+ self.add_parameter(request, 'selected', lookup.selected)
52
+ self.add_parameter(request, 'exclude', self.build_filter_string(lookup.exclude, ','))
53
+
54
+ for parameter in lookup.custom_parameter_array:
55
+ self.add_parameter(request, parameter, lookup.custom_parameter_array[parameter])
56
+
57
+ return request
58
+
59
+ @staticmethod
60
+ def build_filter_string(filter_list, separator=';'):
61
+ return separator.join(filter_list or []) or None
62
+
63
+ @staticmethod
64
+ def convert_suggestions(suggestion_dictionaries):
65
+ return [Suggestion(suggestion) for suggestion in suggestion_dictionaries]
66
+
67
+ @staticmethod
68
+ def add_parameter(request, key, value):
69
+ if value and value != 'none':
70
+ request.parameters[key] = value.value if isinstance(value, Enum) else value
@@ -0,0 +1,83 @@
1
+ from smartystreets_python_sdk.us_autocomplete import geolocation_type
2
+
3
+
4
+ class Lookup:
5
+ def __init__(self, search=None, max_results=None, city_filter=None, state_filter=None, zip_filter=None,
6
+ exclude_states=None, prefer_cities=None, prefer_states=None, prefer_zips=None, prefer_ratio=None,
7
+ prefer_geolocation=None, selected=None, exclude=None, source=None):
8
+
9
+ """
10
+ In addition to holding all of the input data for this lookup, this class also will contain the result
11
+ of the lookup after it comes back from the API.
12
+
13
+ See "https://www.smarty.com/docs/apis/us-autocomplete-v2/reference#http-request-input-fields"
14
+
15
+ :param search: The part of the address that has already been typed (required)
16
+ :param max_results: Maximum number of address suggestions to return
17
+ :param city_filter: Limit the results to only those cities listed, as well as those in state_filter
18
+ :param state_filter: Limit the results to only those states listed, as well as those in city_filter
19
+ :param zip_filter: Limit the result to only those ZIP Codes listed. When this parameter is used,
20
+ no other _cities, _states parameters can be used
21
+ :param exclude_states: Exclude the following states from the results. When this parameter is used,
22
+ no other include_ parameters can be used
23
+ :param prefer_cities: Display suggestions with the listed cities and states at the top of the suggestion list
24
+ :param prefer_states: Display suggestions with the listed states at the top of the suggestion list
25
+ :param prefer_zips: Display suggestions with the listed ZIP Codes at the top of the suggestion list.
26
+ When this parameter is used, no other _cities or _state parameters can be used
27
+ :param prefer_ratio: Specifies the percentage of address suggestions that should be preferred
28
+ and will appear at the top of the suggestion list
29
+ :param prefer_geolocation: If omitted or set to city it uses the sender's IP address to determine location,
30
+ then automatically adds the city and state to the prefer_cities value.
31
+ This parameter takes precedence over other _include or exclude parameters,
32
+ meaning that if it is not set to none, you may see addresses from the customer's area
33
+ when you may not desire it
34
+ :param selected: Used by UI components to request a list of secondaries (up to 100) for the specified address
35
+ :param exclude: Removes the given partial address from the suggestion results
36
+ :param source: Include results from alternate data sources. Defaults to None (API default: postal).
37
+ Use Source.ALL to include non-postal addresses, Source.POSTAL to limit to postal only.
38
+ """
39
+ self.result = []
40
+ self.custom_parameter_array = {}
41
+ self.search = search
42
+ self.max_results = max_results
43
+ self.city_filter = city_filter or []
44
+ self.state_filter = state_filter or []
45
+ self.zip_filter = zip_filter or []
46
+ self.exclude_states = exclude_states or []
47
+ self.prefer_cities = prefer_cities or []
48
+ self.prefer_states = prefer_states or []
49
+ self.prefer_zips = prefer_zips or []
50
+ self.prefer_ratio = prefer_ratio
51
+ self.prefer_geolocation = prefer_geolocation
52
+ self.selected = selected
53
+ self.exclude = exclude or []
54
+ self.source = source
55
+
56
+ def add_city_filter(self, city):
57
+ self.city_filter.append(city)
58
+
59
+ def add_state_filter(self, state):
60
+ self.state_filter.append(state)
61
+
62
+ def add_zip_filter(self, zipcode):
63
+ self.prefer_geolocation = geolocation_type.NONE
64
+ self.zip_filter.append(zipcode)
65
+
66
+ def add_state_exclusion(self, state):
67
+ self.exclude_states.append(state)
68
+
69
+ def add_city_preference(self, city):
70
+ self.prefer_cities.append(city)
71
+
72
+ def add_state_preference(self, state):
73
+ self.prefer_states.append(state)
74
+
75
+ def add_zip_preference(self, zipcode):
76
+ self.prefer_geolocation = geolocation_type.NONE
77
+ self.prefer_zips.append(zipcode)
78
+
79
+ def add_exclude(self, exclude_type):
80
+ self.exclude.append(exclude_type)
81
+
82
+ def add_custom_parameter(self, parameter, value):
83
+ self.custom_parameter_array[parameter] = value
@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Source(str, Enum):
5
+ ALL = "all"
6
+ POSTAL = "postal"
@@ -0,0 +1,14 @@
1
+ class Suggestion:
2
+ def __init__(self, obj=None):
3
+ """
4
+ See "https://www.smarty.com/docs/apis/us-autocomplete-v2/reference#http-response-status"
5
+ """
6
+ self.smarty_key = obj.get('smarty_key', None)
7
+ self.entry_id = obj.get('entry_id', None)
8
+ self.street_line = obj.get('street_line', None)
9
+ self.secondary = obj.get('secondary', None)
10
+ self.city = obj.get('city', None)
11
+ self.state = obj.get('state', None)
12
+ self.zipcode = obj.get('zipcode', None)
13
+ self.entries = obj.get('entries', None)
14
+ self.source = obj.get('source', None)
@@ -0,0 +1,4 @@
1
+ from .suggestion import Suggestion
2
+ from .lookup import Lookup
3
+ from .client import Client
4
+ from .source import Source
@@ -1,3 +1,5 @@
1
+ from enum import Enum
2
+
1
3
  from smartystreets_python_sdk import Request
2
4
  from smartystreets_python_sdk.exceptions import SmartyException
3
5
  from smartystreets_python_sdk.us_autocomplete_pro import Suggestion, geolocation_type
@@ -64,4 +66,4 @@ class Client:
64
66
  @staticmethod
65
67
  def add_parameter(request, key, value):
66
68
  if value and value != 'none':
67
- request.parameters[key] = value
69
+ request.parameters[key] = value.value if isinstance(value, Enum) else value
@@ -1,6 +1,5 @@
1
1
  from smartystreets_python_sdk.us_autocomplete_pro import geolocation_type
2
2
 
3
-
4
3
  class Lookup:
5
4
  def __init__(self, search=None, max_results=None, city_filter=None, state_filter=None, zip_filter=None,
6
5
  exclude=None, prefer_cities=None, prefer_states=None, prefer_zips=None, prefer_ratio=None,
@@ -32,10 +31,8 @@ class Lookup:
32
31
  meaning that if it is not set to none, you may see addresses from the customer's area
33
32
  when you may not desire it
34
33
  :param selected: Used by UI components to request a list of secondaries (up to 100) for the specified address
35
- :param source: Include results from alternate data sources. If no value is passed, the default will be `postal`.
36
- Allowed values are:
37
- all - will include non-postal addresses in the results
38
- postal - will limit the results to postal addresses only
34
+ :param source: Include results from alternate data sources. Defaults to None (API default: postal).
35
+ Use Source.ALL to include non-postal addresses, Source.POSTAL to limit to postal only.
39
36
  """
40
37
  self.result = []
41
38
  self.custom_parameter_array = {}
@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Source(str, Enum):
5
+ ALL = "all"
6
+ POSTAL = "postal"
@@ -107,11 +107,14 @@ def send_lookup(client: Client, lookup, response_class=Response):
107
107
  _is_blank(getattr(lookup, 'smartykey', None))
108
108
  and _is_blank(getattr(lookup, 'street', None))
109
109
  and _is_blank(getattr(lookup, 'freeform', None))
110
+ and _is_blank(getattr(lookup, 'business_name', None))
110
111
  ):
111
- raise SmartyException("Lookup requires one of 'smartykey', 'street', or 'freeform' to be set")
112
+ raise SmartyException("Lookup requires one of 'smartykey', 'street', 'freeform', or 'business_name' to be set")
112
113
 
113
114
  request = build_request(lookup)
114
115
  raw = _dispatch(client, request, lookup)
116
+ if raw is None:
117
+ return lookup.result
115
118
  lookup.result = [response_class(candidate) for candidate in raw]
116
119
  return lookup.result
117
120
 
@@ -126,6 +129,8 @@ def send_business_detail_lookup(client: Client, lookup):
126
129
  _apply_etag_header(request, lookup)
127
130
 
128
131
  raw = _dispatch(client, request, lookup)
132
+ if raw is None:
133
+ return lookup.result
129
134
  if not raw:
130
135
  lookup.result = None
131
136
  elif len(raw) > 1:
@@ -158,7 +163,7 @@ def _url_components(lookup):
158
163
 
159
164
  def _address_parameters(lookup):
160
165
  params = {}
161
- for key in ('freeform', 'street', 'city', 'state', 'zipcode', 'features'):
166
+ for key in ('freeform', 'street', 'city', 'state', 'zipcode', 'features', 'business_name'):
162
167
  value = getattr(lookup, key, None)
163
168
  if value:
164
169
  params[key] = value
@@ -184,6 +189,8 @@ def _apply_etag_header(request, lookup):
184
189
  def _dispatch(client, request, lookup):
185
190
  response = client.sender.send(request)
186
191
  lookup.response_etag = response.find_header('etag')
192
+ if response.status_code == 304:
193
+ return None
187
194
  if response.error:
188
195
  raise response.error
189
196
  raw = client.serializer.deserialize(response.payload)
@@ -28,7 +28,7 @@ class LookupBase:
28
28
 
29
29
 
30
30
  class Lookup(LookupBase):
31
- def __init__(self, smartykey=None, dataset=None, dataSubset=None, features=None, freeform=None, street=None, city=None, state=None, zipcode=None):
31
+ def __init__(self, smartykey=None, dataset=None, dataSubset=None, features=None, freeform=None, street=None, city=None, state=None, zipcode=None, business_name=None):
32
32
  super().__init__()
33
33
  self.smartykey = smartykey
34
34
  self.dataset = dataset
@@ -40,6 +40,7 @@ class Lookup(LookupBase):
40
40
  self.state = state
41
41
  self.zipcode = zipcode
42
42
  self.result = []
43
+ self.business_name = business_name
43
44
 
44
45
 
45
46
  class PrincipalLookup(Lookup):
@@ -4,3 +4,4 @@ from .result import Result
4
4
  from .address import Address
5
5
  from .coordinate import Coordinate
6
6
  from .client import Client
7
+ from .source import Source
@@ -1,3 +1,5 @@
1
+ from enum import Enum
2
+
1
3
  from smartystreets_python_sdk import Request
2
4
  from smartystreets_python_sdk.us_reverse_geo import Response
3
5
 
@@ -41,4 +43,4 @@ class Client:
41
43
  @staticmethod
42
44
  def add_parameter(request, key, value):
43
45
  if value and value != 'none':
44
- request.parameters[key] = value
46
+ request.parameters[key] = value.value if isinstance(value, Enum) else value
@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Source(str, Enum):
5
+ ALL = "all"
6
+ POSTAL = "postal"
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smartystreets_python_sdk
3
- Version: 6.2.1
3
+ Version: 7.1.0
4
4
  Summary: An official library to help Python developers easily access the SmartyStreets APIs
5
5
  Home-page: https://github.com/smartystreets/smartystreets-python-sdk
6
- Download-URL: https://github.com/smartystreets/smartystreets-python-sdk/tarball/6.2.1
6
+ Download-URL: https://github.com/smartystreets/smartystreets-python-sdk/tarball/7.1.0
7
7
  Author: SmartyStreets SDK Team
8
8
  Author-email: support@smartystreets.com
9
9
  License: Apache 2
@@ -45,10 +45,17 @@ smartystreets_python_sdk/international_street/language_mode.py
45
45
  smartystreets_python_sdk/international_street/lookup.py
46
46
  smartystreets_python_sdk/international_street/metadata.py
47
47
  smartystreets_python_sdk/international_street/rootlevel.py
48
+ smartystreets_python_sdk/us_autocomplete/__init__.py
49
+ smartystreets_python_sdk/us_autocomplete/client.py
50
+ smartystreets_python_sdk/us_autocomplete/geolocation_type.py
51
+ smartystreets_python_sdk/us_autocomplete/lookup.py
52
+ smartystreets_python_sdk/us_autocomplete/source.py
53
+ smartystreets_python_sdk/us_autocomplete/suggestion.py
48
54
  smartystreets_python_sdk/us_autocomplete_pro/__init__.py
49
55
  smartystreets_python_sdk/us_autocomplete_pro/client.py
50
56
  smartystreets_python_sdk/us_autocomplete_pro/geolocation_type.py
51
57
  smartystreets_python_sdk/us_autocomplete_pro/lookup.py
58
+ smartystreets_python_sdk/us_autocomplete_pro/source.py
52
59
  smartystreets_python_sdk/us_autocomplete_pro/suggestion.py
53
60
  smartystreets_python_sdk/us_enrichment/__init__.py
54
61
  smartystreets_python_sdk/us_enrichment/client.py
@@ -70,6 +77,7 @@ smartystreets_python_sdk/us_reverse_geo/coordinate.py
70
77
  smartystreets_python_sdk/us_reverse_geo/lookup.py
71
78
  smartystreets_python_sdk/us_reverse_geo/response.py
72
79
  smartystreets_python_sdk/us_reverse_geo/result.py
80
+ smartystreets_python_sdk/us_reverse_geo/source.py
73
81
  smartystreets_python_sdk/us_street/__init__.py
74
82
  smartystreets_python_sdk/us_street/analysis.py
75
83
  smartystreets_python_sdk/us_street/candidate.py
@@ -1,2 +1,2 @@
1
1
  __version__ = '0.0.0' # DO NOT EDIT (this is updated by a build job when a new release is published)
2
- __version__="6.2.1"
2
+ __version__="7.1.0"