Skip to content

Commit f6cee74

Browse files
Merge branch 'master' into comp-analysis
2 parents ecfa420 + bd18eea commit f6cee74

44 files changed

Lines changed: 951 additions & 86 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,31 @@ package: test
1616
echo "__version__=\"${VERSION}\"" >> "$(VERSION_FILE)" \
1717
&& python3 setup.py sdist
1818

19-
.PHONY: clean test dependencies package
19+
international_autocomplete_api:
20+
PYTHONPATH=. python3 examples/international_autocomplete_example.py
21+
22+
international_street_api:
23+
PYTHONPATH=. python3 examples/international_example.py
24+
25+
us_autocomplete_pro_api:
26+
PYTHONPATH=. python3 examples/us_autocomplete_pro_example.py
27+
28+
us_enrichment_api:
29+
PYTHONPATH=. python3 examples/us_enrichment_example.py
30+
31+
us_extract_api:
32+
PYTHONPATH=. python3 examples/us_extract_example.py
33+
34+
us_reverse_geo_api:
35+
PYTHONPATH=. python3 examples/us_reverse_geo_example.py
36+
37+
us_street_api:
38+
PYTHONPATH=. python3 examples/us_street_single_address_example.py && PYTHONPATH=. python3 examples/us_street_multiple_addresses_example.py
39+
40+
us_zipcode_api:
41+
PYTHONPATH=. python3 examples/us_zipcode_single_lookup_example.py && PYTHONPATH=. python3 examples/us_zipcode_multiple_lookups_example.py
42+
43+
examples: international_autocomplete_api international_street_api us_autocomplete_pro_api us_enrichment_api us_extract_api us_reverse_geo_api us_street_api us_zipcode_api
44+
45+
46+
.PHONY: clean test dependencies package examples international_autocomplete_api international_street_api us_autocomplete_pro_api us_enrichment_api us_extract_api us_reverse_geo_api us_street_api us_zipcode_api

examples/international_autocomplete_example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ def run():
2121
#
2222
# credentials = StaticCredentials(auth_id, auth_token)
2323

24-
# The appropriate license values to be used for your subscriptions
25-
# can be found on the Subscriptions page of the account dashboard.
26-
# https://www.smartystreets.com/docs/cloud/licensing
27-
client = ClientBuilder(credentials).with_licenses(["international-autocomplete-v2-cloud"]) \
28-
.build_international_autocomplete_api_client()
24+
client = ClientBuilder(credentials).build_international_autocomplete_api_client()
25+
2926
lookup = InternationalAutocompleteLookup('Louis')
3027
lookup.country = "FRA"
3128

29+
# Uncomment the below line to add a custom parameter
30+
# lookup.add_custom_parameter("parameter", "value")
31+
3232
client.send(lookup)
3333

3434
print('*** Result with no filter ***')

examples/international_example.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ def run():
2121
#
2222
# credentials = StaticCredentials(auth_id, auth_token)
2323

24-
# The appropriate license values to be used for your subscriptions
25-
# can be found on the Subscription page of the account dashboard.
26-
# https://www.smartystreets.com/docs/cloud/licensing
27-
client = ClientBuilder(credentials).with_licenses(['international-global-plus-cloud'])\
28-
.build_international_street_api_client()
24+
client = ClientBuilder(credentials).build_international_street_api_client()
2925

3026
# Documentation for input fields can be found at:
3127
# https://smartystreets.com/docs/cloud/international-street-api#http-input-fields
@@ -41,6 +37,9 @@ def run():
4137
lookup.country = "Brazil"
4238
lookup.postal_code = "02516-050"
4339

40+
# Uncomment the below line to add a custom parameter
41+
# lookup.add_custom_parameter("parameter", "value")
42+
4443
candidates = client.send(lookup) # The candidates are also stored in the lookup's 'result' field.
4544

4645
first_candidate = candidates[0]

examples/us_autocomplete_pro_example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ def run():
2727
#
2828
# credentials = StaticCredentials(auth_id, auth_token)
2929

30-
# The appropriate license values to be used for your subscriptions
31-
# can be found on the Subscriptions page of the account dashboard.
32-
# https://www.smartystreets.com/docs/cloud/licensing
33-
client = ClientBuilder(credentials).with_licenses(["us-autocomplete-pro-cloud"]).build_us_autocomplete_pro_api_client()
30+
client = ClientBuilder(credentials).build_us_autocomplete_pro_api_client()
31+
3432
lookup = AutocompleteProLookup('1042 W Center')
3533

34+
# Uncomment the below line to add a custom parameter
35+
# lookup.add_custom_parameter("parameter", "value")
36+
3637
client.send(lookup)
3738

3839
print('*** Result with no filter ***')

examples/us_enrichment_example.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,53 @@ def run():
1212

1313
# We recommend storing your secret keys in environment variables instead---it's safer!
1414
# for client-side requests (browser/mobile), use this code:
15-
key = os.environ['SMARTY_AUTH_WEB']
16-
hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15+
#key = os.environ['SMARTY_AUTH_WEB']
16+
#hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
1717

18-
credentials = SharedCredentials(key, hostname)
18+
#credentials = SharedCredentials(key, hostname)
1919

2020
# for server-to-server requests, use this code:
21-
# auth_id = os.environ['SMARTY_AUTH_ID']
22-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
21+
auth_id = os.environ['SMARTY_AUTH_ID']
22+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
2323
#
24-
# credentials = StaticCredentials(auth_id, auth_token)
24+
credentials = StaticCredentials(auth_id, auth_token)
25+
26+
client = ClientBuilder(credentials).build_us_enrichment_api_client()
2527

26-
# The appropriate license values to be used for your subscriptions
27-
# can be found on the Subscriptions page of the account dashboard.
28-
# https://www.smartystreets.com/docs/cloud/licensing
29-
client = ClientBuilder(credentials).with_licenses(["us-property-data-principal-cloud"]).build_us_enrichment_api_client()
3028
# client = ClientBuilder(credentials).with_custom_header({'User-Agent': 'smartystreets (python@0.0.0)', 'Content-Type': 'application/json'}).build_us_enrichment_api_client()
3129
# client = ClientBuilder(credentials).with_http_proxy('localhost:8080', 'user', 'password').build_us_street_api_client()
3230
# Uncomment the line above to try it with a proxy instead
3331

34-
smarty_key = "325023201"
32+
smarty_key = "87844267"
3533

3634
lookup = EnrichmentLookup()
3735
freeform_lookup = EnrichmentLookup()
3836

39-
lookup.street = "56 Union Ave"
40-
lookup.city = "Somerville"
41-
lookup.state = "NJ"
42-
lookup.zipcode = "08876"
37+
lookup.smartykey = smarty_key
38+
# lookup.street = "56 Union Ave"
39+
# lookup.city = "Somerville"
40+
# lookup.state = "NJ"
41+
# lookup.zipcode = "08876"
42+
lookup.features = "financial"
43+
44+
# Uncomment the below lines to add attributes to the "include" parameter
45+
# lookup.add_include_attribute('assessed_improvement_percent')
46+
# lookup.add_include_attribute('assessed_improvement_value')
47+
48+
# Uncomment the below lines to add attributes to the "exclude" parameter
49+
# lookup.add_exclude_attribute('assessed_land_value')
50+
# lookup.add_exclude_attribute('assessed_value')
51+
52+
# Uncomment the below line to add a custom parameter
53+
# lookup.add_custom_parameter("parameter", "value")
4354

4455
freeform_lookup.freeform = "56 Union Ave Somerville NJ 08876"
4556

4657
try:
4758
# use the below line to send a lookup with a smarty key
48-
results = client.send_property_principal_lookup(smarty_key)
59+
# results = client.send_property_principal_lookup(smarty_key)
4960
# Or, uncomment the below line to send a lookup with an address in components
50-
# results = client.send_property_principal_lookup(lookup)
61+
results = client.send_property_principal_lookup(lookup)
5162
# Or, uncomment the below line to send a lookup with an address in freeform
5263
# results = client.send_property_principal_lookup(freeform_lookup)
5364

examples/us_extract_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def run():
4040
lookup.addresses_per_line = 1
4141
lookup.match = MatchType.ENHANCED
4242

43+
# Uncomment the below line to add a custom parameter
44+
# lookup.add_custom_parameter("parameter", "value")
45+
4346
result = client.send(lookup)
4447

4548
metadata = result.metadata

examples/us_reverse_geo_example.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ def run():
2121
#
2222
# credentials = StaticCredentials(auth_id, auth_token)
2323

24-
# The appropriate license values to be used for your subscriptions
25-
# can be found on the Subscriptions page of the account dashboard.
26-
# https://www.smartystreets.com/docs/cloud/licensing
27-
client = ClientBuilder(credentials).with_licenses(["us-reverse-geocoding-cloud"]).build_us_reverse_geo_api_client()
28-
24+
client = ClientBuilder(credentials).build_us_reverse_geo_api_client()
25+
2926
# Documentation for input fields can be found at:
3027
# https://smartystreets.com/docs/cloud/us-reverse-geo-api#http-input-fields
3128

3229
lookup = Lookup(40.111111, -111.111111)
3330

31+
# Uncomment the below line to add a custom parameter
32+
# lookup.add_custom_parameter("parameter", "value")
33+
3434
results = client.send(lookup)
3535

3636
for result in results:
@@ -46,6 +46,7 @@ def run():
4646
print("State Abbreviation: {}".format(address.state_abbreviation))
4747
print("ZIP Code: {}".format(address.zipcode))
4848
print("License: {}".format(coordinate.get_license()))
49+
print("Smartykey: {}".format(address.smartykey))
4950
print()
5051

5152

examples/us_street_multiple_addresses_example.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,19 @@ def run():
1111

1212
# We recommend storing your secret keys in environment variables instead---it's safer!
1313
# for client-side requests (browser/mobile), use this code:
14-
key = os.environ['SMARTY_AUTH_WEB']
15-
hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
14+
# key = os.environ['SMARTY_AUTH_WEB']
15+
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
1616

17-
credentials = SharedCredentials(key, hostname)
17+
# credentials = SharedCredentials(key, hostname)
1818

1919
# for server-to-server requests, use this code:
20-
# auth_id = os.environ['SMARTY_AUTH_ID']
21-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
22-
#
23-
# credentials = StaticCredentials(auth_id, auth_token)
24-
25-
# The appropriate license values to be used for your subscriptions
26-
# can be found on the Subscription page of the account dashboard.
27-
# https://www.smartystreets.com/docs/cloud/licensing
28-
client = ClientBuilder(credentials).with_licenses(['us-core-cloud']).build_us_street_api_client()
20+
auth_id = os.environ['SMARTY_AUTH_ID']
21+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
22+
23+
credentials = StaticCredentials(auth_id, auth_token)
24+
25+
client = ClientBuilder(credentials).build_us_street_api_client()
26+
2927
batch = Batch()
3028

3129
# Documentation for input fields can be found at:
@@ -44,6 +42,9 @@ def run():
4442
# this will always return at least one result even if the address is invalid.
4543
# Refer to the documentation for additional Match Strategy options.
4644

45+
# Uncomment the below line to add a custom parameter
46+
# batch[0].add_custom_parameter("parameter", "value")
47+
4748
batch.add(StreetLookup("1 Rosedale, Baltimore, Maryland")) # Freeform addresses work too.
4849
batch[1].candidates = 10 # Allows up to ten possible matches to be returned (default is 1).
4950

examples/us_street_single_address_example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ def run():
2323

2424
# credentials = StaticCredentials(auth_id, auth_token)
2525

26-
# The appropriate license values to be used for your subscriptions
27-
# can be found on the Subscriptions page of the account dashboard.
28-
# https://www.smartystreets.com/docs/cloud/licensing
29-
client = ClientBuilder(credentials).with_licenses(["us-core-cloud"]).build_us_street_api_client()
26+
client = ClientBuilder(credentials).build_us_street_api_client()
27+
3028
# client = ClientBuilder(credentials).with_custom_header({'User-Agent': 'smartystreets (python@0.0.0)', 'Content-Type': 'application/json'}).build_us_street_api_client()
3129
# client = ClientBuilder(credentials).with_http_proxy('localhost:8080', 'user', 'password').build_us_street_api_client()
3230
# Uncomment the line above to try it with a proxy instead
@@ -49,6 +47,9 @@ def run():
4947
# this will always return at least one result even if the address is invalid.
5048
# Refer to the documentation for additional Match Strategy options.
5149

50+
# Uncomment the below line to add a custom parameter
51+
# lookup.add_custom_parameter("parameter", "value")
52+
5253
try:
5354
client.send_lookup(lookup)
5455
except exceptions.SmartyException as err:

examples/us_zipcode_multiple_lookups_example.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ def run():
1010

1111
# We recommend storing your secret keys in environment variables instead---it's safer!
1212
# for client-side requests (browser/mobile), use this code:
13-
key = os.environ['SMARTY_AUTH_WEB']
14-
hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
13+
# key = os.environ['SMARTY_AUTH_WEB']
14+
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
1515

16-
credentials = SharedCredentials(key, hostname)
16+
# credentials = SharedCredentials(key, hostname)
1717

1818
# for server-to-server requests, use this code:
19-
# auth_id = os.environ['SMARTY_AUTH_ID']
20-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
21-
#
22-
# credentials = StaticCredentials(auth_id, auth_token)
19+
auth_id = os.environ['SMARTY_AUTH_ID']
20+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
21+
22+
credentials = StaticCredentials(auth_id, auth_token)
2323

2424
client = ClientBuilder(credentials).build_us_zipcode_api_client()
2525
batch = Batch()
@@ -31,6 +31,9 @@ def run():
3131
batch[0].input_id = "011889998819991197253" # Optional ID from your system
3232
batch[0].zipcode = "12345" # A Lookup may have a ZIP Code, city and state, or city, state, and ZIP Code
3333

34+
# Uncomment the below line to add a custom parameter
35+
# batch[0].add_custom_parameter("parameter", "value")
36+
3437
batch.add(ZIPCodeLookup())
3538
batch[1].city = "Phoenix"
3639
batch[1].state = "Arizona"

0 commit comments

Comments
 (0)