smartystreets-python-sdk 6.2.1__tar.gz → 7.0.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 (94) hide show
  1. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/PKG-INFO +2 -2
  2. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/README.md +1 -1
  3. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/errors.py +8 -4
  4. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/exceptions.py +8 -0
  5. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/components.py +6 -2
  6. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/rootlevel.py +1 -5
  7. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/native_serializer.py +2 -0
  8. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/status_code_sender.py +32 -15
  9. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/__init__.py +1 -0
  10. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/client.py +3 -1
  11. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/lookup.py +2 -5
  12. smartystreets_python_sdk-7.0.0/smartystreets_python_sdk/us_autocomplete_pro/source.py +6 -0
  13. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/client.py +9 -2
  14. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/lookup.py +2 -1
  15. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/__init__.py +1 -0
  16. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/client.py +3 -1
  17. smartystreets_python_sdk-7.0.0/smartystreets_python_sdk/us_reverse_geo/source.py +6 -0
  18. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/PKG-INFO +2 -2
  19. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/SOURCES.txt +2 -0
  20. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk_version/__init__.py +1 -1
  21. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/LICENSE.md +0 -0
  22. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/setup.cfg +0 -0
  23. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/setup.py +0 -0
  24. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/__init__.py +0 -0
  25. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/basic_auth_credentials.py +0 -0
  26. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/batch.py +0 -0
  27. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/client_builder.py +0 -0
  28. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/custom_header_sender.py +0 -0
  29. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/custom_query_sender.py +0 -0
  30. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/__init__.py +0 -0
  31. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/candidate.py +0 -0
  32. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/client.py +0 -0
  33. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/lookup.py +0 -0
  34. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/__init__.py +0 -0
  35. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/candidate.py +0 -0
  36. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/client.py +0 -0
  37. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/lookup.py +0 -0
  38. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/__init__.py +0 -0
  39. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/analysis.py +0 -0
  40. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/candidate.py +0 -0
  41. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/changes.py +0 -0
  42. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/client.py +0 -0
  43. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/language_mode.py +0 -0
  44. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/lookup.py +0 -0
  45. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/metadata.py +0 -0
  46. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/license_sender.py +0 -0
  47. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/proxy.py +0 -0
  48. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/request.py +0 -0
  49. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/requests_sender.py +0 -0
  50. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/response.py +0 -0
  51. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/retry_sender.py +0 -0
  52. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/shared_credentials.py +0 -0
  53. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/signing_sender.py +0 -0
  54. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/static_credentials.py +0 -0
  55. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/url_prefix_sender.py +0 -0
  56. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/geolocation_type.py +0 -0
  57. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/suggestion.py +0 -0
  58. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/__init__.py +0 -0
  59. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/business/__init__.py +0 -0
  60. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/business/detail.py +0 -0
  61. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/business/summary.py +0 -0
  62. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/response.py +0 -0
  63. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/__init__.py +0 -0
  64. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/address.py +0 -0
  65. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/client.py +0 -0
  66. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/lookup.py +0 -0
  67. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/metadata.py +0 -0
  68. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/result.py +0 -0
  69. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/address.py +0 -0
  70. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/coordinate.py +0 -0
  71. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/lookup.py +0 -0
  72. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/response.py +0 -0
  73. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/result.py +0 -0
  74. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/__init__.py +0 -0
  75. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/analysis.py +0 -0
  76. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/candidate.py +0 -0
  77. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/client.py +0 -0
  78. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/component_analysis.py +0 -0
  79. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/components.py +0 -0
  80. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/lookup.py +0 -0
  81. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/match_info.py +0 -0
  82. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/match_type.py +0 -0
  83. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/metadata.py +0 -0
  84. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/output_format.py +0 -0
  85. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/__init__.py +0 -0
  86. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/alternate_county.py +0 -0
  87. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/city.py +0 -0
  88. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/client.py +0 -0
  89. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/lookup.py +0 -0
  90. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/result.py +0 -0
  91. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/zipcode.py +0 -0
  92. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/dependency_links.txt +0 -0
  93. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/requires.txt +0 -0
  94. {smartystreets_python_sdk-6.2.1 → smartystreets_python_sdk-7.0.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.0.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.0.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
 
@@ -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
@@ -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.0.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.0.0
7
7
  Author: SmartyStreets SDK Team
8
8
  Author-email: support@smartystreets.com
9
9
  License: Apache 2
@@ -49,6 +49,7 @@ smartystreets_python_sdk/us_autocomplete_pro/__init__.py
49
49
  smartystreets_python_sdk/us_autocomplete_pro/client.py
50
50
  smartystreets_python_sdk/us_autocomplete_pro/geolocation_type.py
51
51
  smartystreets_python_sdk/us_autocomplete_pro/lookup.py
52
+ smartystreets_python_sdk/us_autocomplete_pro/source.py
52
53
  smartystreets_python_sdk/us_autocomplete_pro/suggestion.py
53
54
  smartystreets_python_sdk/us_enrichment/__init__.py
54
55
  smartystreets_python_sdk/us_enrichment/client.py
@@ -70,6 +71,7 @@ smartystreets_python_sdk/us_reverse_geo/coordinate.py
70
71
  smartystreets_python_sdk/us_reverse_geo/lookup.py
71
72
  smartystreets_python_sdk/us_reverse_geo/response.py
72
73
  smartystreets_python_sdk/us_reverse_geo/result.py
74
+ smartystreets_python_sdk/us_reverse_geo/source.py
73
75
  smartystreets_python_sdk/us_street/__init__.py
74
76
  smartystreets_python_sdk/us_street/analysis.py
75
77
  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.0.0"