smartystreets-python-sdk 6.2.0__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.
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/PKG-INFO +2 -2
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/README.md +1 -1
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/errors.py +8 -4
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/exceptions.py +8 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/components.py +6 -2
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/rootlevel.py +1 -5
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/native_serializer.py +2 -0
- smartystreets_python_sdk-7.0.0/smartystreets_python_sdk/status_code_sender.py +121 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/__init__.py +1 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/client.py +3 -1
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/lookup.py +2 -5
- smartystreets_python_sdk-7.0.0/smartystreets_python_sdk/us_autocomplete_pro/source.py +6 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/client.py +9 -2
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/lookup.py +2 -1
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/__init__.py +1 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/client.py +3 -1
- smartystreets_python_sdk-7.0.0/smartystreets_python_sdk/us_reverse_geo/source.py +6 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/PKG-INFO +2 -2
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/SOURCES.txt +2 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk_version/__init__.py +1 -1
- smartystreets_python_sdk-6.2.0/smartystreets_python_sdk/status_code_sender.py +0 -88
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/LICENSE.md +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/setup.cfg +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/setup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/basic_auth_credentials.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/batch.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/client_builder.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/custom_header_sender.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/custom_query_sender.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/candidate.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/client.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_autocomplete/lookup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/candidate.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/client.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_postal_code/lookup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/analysis.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/candidate.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/changes.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/client.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/language_mode.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/lookup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/international_street/metadata.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/license_sender.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/proxy.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/request.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/requests_sender.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/response.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/retry_sender.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/shared_credentials.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/signing_sender.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/static_credentials.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/url_prefix_sender.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/geolocation_type.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_autocomplete_pro/suggestion.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/business/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/business/detail.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/business/summary.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_enrichment/response.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/address.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/client.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/lookup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/metadata.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_extract/result.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/address.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/coordinate.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/lookup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/response.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_reverse_geo/result.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/analysis.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/candidate.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/client.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/component_analysis.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/components.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/lookup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/match_info.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/match_type.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/metadata.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_street/output_format.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/__init__.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/alternate_county.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/city.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/client.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/lookup.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/result.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/us_zipcode/zipcode.py +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/dependency_links.txt +0 -0
- {smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk.egg-info/requires.txt +0 -0
- {smartystreets_python_sdk-6.2.0 → 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:
|
|
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
|
+
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
|
|
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
|
|
{smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/errors.py
RENAMED
|
@@ -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 = "
|
|
8
|
-
|
|
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
|
|
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. " \
|
|
@@ -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.
|
|
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)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from smartystreets_python_sdk import errors, exceptions
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StatusCodeSender:
|
|
7
|
+
def __init__(self, inner):
|
|
8
|
+
self.inner = inner
|
|
9
|
+
|
|
10
|
+
def parse_rate_limit_response(self, response):
|
|
11
|
+
return messageFrom(response, exceptions.TooManyRequestsError(errors.TOO_MANY_REQUESTS))
|
|
12
|
+
|
|
13
|
+
def send(self, request):
|
|
14
|
+
response = self.inner.send(request)
|
|
15
|
+
|
|
16
|
+
if not response.error:
|
|
17
|
+
if response.status_code == 429:
|
|
18
|
+
response.error = self.parse_rate_limit_response(response)
|
|
19
|
+
elif response.status_code not in (200, 304):
|
|
20
|
+
response.error = messageFrom(response, fallback_error(response.status_code))
|
|
21
|
+
|
|
22
|
+
return response
|
|
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
|
+
|
|
32
|
+
def messageFrom(response, fallback):
|
|
33
|
+
message = extract_message(response)
|
|
34
|
+
if message:
|
|
35
|
+
return type(fallback)(message)
|
|
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()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def extract_message(response):
|
|
49
|
+
try:
|
|
50
|
+
response_json = json.loads(response.payload)
|
|
51
|
+
except (ValueError, TypeError):
|
|
52
|
+
return ''
|
|
53
|
+
if response_json is None:
|
|
54
|
+
return ''
|
|
55
|
+
errors_json = response_json.get('errors')
|
|
56
|
+
if errors_json is None:
|
|
57
|
+
return ''
|
|
58
|
+
message = ''
|
|
59
|
+
for current_error in errors_json:
|
|
60
|
+
current_message = current_error.get('message')
|
|
61
|
+
if current_message is not None:
|
|
62
|
+
message = message + current_message + ' '
|
|
63
|
+
return message.rstrip()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def bad_credentials():
|
|
67
|
+
return exceptions.BadCredentialsError(errors.BAD_CREDENTIALS)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def payment_required():
|
|
71
|
+
return exceptions.PaymentRequiredError(errors.PAYMENT_REQUIRED)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def forbidden():
|
|
75
|
+
return exceptions.ForbiddenError(errors.FORBIDDEN)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def request_timeout():
|
|
79
|
+
return exceptions.RequestTimeoutError(errors.REQUEST_TIMEOUT)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def request_entity_too_large():
|
|
83
|
+
return exceptions.RequestEntityTooLargeError(errors.REQUEST_ENTITY_TOO_LARGE)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def bad_request():
|
|
87
|
+
return exceptions.BadRequestError(errors.BAD_REQUEST)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def unprocessable_entity():
|
|
91
|
+
return exceptions.UnprocessableEntityError(errors.UNPROCESSABLE_ENTITY)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def internal_server_error():
|
|
95
|
+
return exceptions.InternalServerError(errors.INTERNAL_SERVER_ERROR)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def bad_gateway():
|
|
99
|
+
return exceptions.BadGatewayError(errors.BAD_GATEWAY)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def service_unavailable():
|
|
103
|
+
return exceptions.ServiceUnavailableError(errors.SERVICE_UNAVAILABLE)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def gateway_timeout():
|
|
107
|
+
return exceptions.GatewayTimeoutError(errors.GATEWAY_TIMEOUT)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
statuses = {401: bad_credentials(),
|
|
111
|
+
402: payment_required(),
|
|
112
|
+
403: forbidden(),
|
|
113
|
+
408: request_timeout(),
|
|
114
|
+
413: request_entity_too_large(),
|
|
115
|
+
400: bad_request(),
|
|
116
|
+
422: unprocessable_entity(),
|
|
117
|
+
500: internal_server_error(),
|
|
118
|
+
502: bad_gateway(),
|
|
119
|
+
503: service_unavailable(),
|
|
120
|
+
504: gateway_timeout()
|
|
121
|
+
}
|
|
@@ -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.
|
|
36
|
-
|
|
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 = {}
|
|
@@ -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 '
|
|
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):
|
|
@@ -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
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: smartystreets_python_sdk
|
|
3
|
-
Version:
|
|
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
|
+
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__="
|
|
2
|
+
__version__="7.0.0"
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
|
|
3
|
-
from smartystreets_python_sdk import errors, exceptions
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class StatusCodeSender:
|
|
7
|
-
def __init__(self, inner):
|
|
8
|
-
self.inner = inner
|
|
9
|
-
|
|
10
|
-
def parse_rate_limit_response(self, response):
|
|
11
|
-
error_message = exceptions.TooManyRequestsError(errors.TOO_MANY_REQUESTS)
|
|
12
|
-
response_json = json.loads(response.payload)
|
|
13
|
-
if response_json is not None:
|
|
14
|
-
errors_json = response_json.get('errors')
|
|
15
|
-
if errors_json is not None:
|
|
16
|
-
message = ''
|
|
17
|
-
for current_error in errors_json:
|
|
18
|
-
current_message = current_error.get('message')
|
|
19
|
-
if current_message is not None:
|
|
20
|
-
message = message + current_message + ' '
|
|
21
|
-
error_message = exceptions.TooManyRequestsError(message.rstrip())
|
|
22
|
-
return error_message
|
|
23
|
-
|
|
24
|
-
def send(self, request):
|
|
25
|
-
response = self.inner.send(request)
|
|
26
|
-
|
|
27
|
-
if not response.error:
|
|
28
|
-
if response.status_code == 304:
|
|
29
|
-
response.error = exceptions.NotModifiedError(errors.NOT_MODIFIED, response.find_header('etag'))
|
|
30
|
-
elif response.status_code == 429:
|
|
31
|
-
response.error = self.parse_rate_limit_response(response)
|
|
32
|
-
else:
|
|
33
|
-
response.error = statuses.get(response.status_code)
|
|
34
|
-
|
|
35
|
-
return response
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def ok():
|
|
39
|
-
return None
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def bad_credentials():
|
|
43
|
-
return exceptions.BadCredentialsError(errors.BAD_CREDENTIALS)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def payment_required():
|
|
47
|
-
return exceptions.PaymentRequiredError(errors.PAYMENT_REQUIRED)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def forbidden():
|
|
51
|
-
return exceptions.ForbiddenError(errors.FORBIDDEN)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def request_entity_too_large():
|
|
55
|
-
return exceptions.RequestEntityTooLargeError(errors.REQUEST_ENTITY_TOO_LARGE)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def bad_request():
|
|
59
|
-
return exceptions.BadRequestError(errors.BAD_REQUEST)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def unprocessable_entity():
|
|
63
|
-
return exceptions.UnprocessableEntityError(errors.UNPROCESSABLE_ENTITY)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def internal_server_error():
|
|
67
|
-
return exceptions.InternalServerError(errors.INTERNAL_SERVER_ERROR)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def service_unavailable():
|
|
71
|
-
return exceptions.ServiceUnavailableError(errors.SERVICE_UNAVAILABLE)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def gateway_timeout():
|
|
75
|
-
return exceptions.GatewayTimeoutError(errors.GATEWAY_TIMEOUT)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
statuses = {200: ok(),
|
|
79
|
-
401: bad_credentials(),
|
|
80
|
-
402: payment_required(),
|
|
81
|
-
403: forbidden(),
|
|
82
|
-
413: request_entity_too_large(),
|
|
83
|
-
400: bad_request(),
|
|
84
|
-
422: unprocessable_entity(),
|
|
85
|
-
500: internal_server_error(),
|
|
86
|
-
503: service_unavailable(),
|
|
87
|
-
504: gateway_timeout()
|
|
88
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/batch.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{smartystreets_python_sdk-6.2.0 → smartystreets_python_sdk-7.0.0}/smartystreets_python_sdk/proxy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|