Skip to content

Commit 212be77

Browse files
authored
Merge pull request #63 from smartystreets/eric/add-custom-parameter
- Added add_custom_parameter functionality for all APIs
2 parents af56ea7 + 69bf151 commit 212be77

35 files changed

+244
-39
lines changed

examples/international_autocomplete_example.py

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

24+
client = ClientBuilder(credentials).build_international_autocomplete_api_client()
25+
26+
# (Advanced) Uncomment the below line to explicitly specify a license value
27+
# client = ClientBuilder(credentials).with_licenses(["international-autocomplete-v2-cloud"]).build_international_autocomplete_api_client()
28+
2429
# The appropriate license values to be used for your subscriptions
2530
# can be found on the Subscriptions page of the account dashboard.
2631
# https://www.smartystreets.com/docs/cloud/licensing
27-
client = ClientBuilder(credentials).with_licenses(["international-autocomplete-v2-cloud"]) \
28-
.build_international_autocomplete_api_client()
32+
2933
lookup = InternationalAutocompleteLookup('Louis')
3034
lookup.country = "FRA"
3135

36+
# Uncomment the below line to add a custom parameter
37+
# lookup.add_custom_parameter("parameter", "value")
38+
3239
client.send(lookup)
3340

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

examples/international_example.py

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

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

3033
# Documentation for input fields can be found at:
3134
# https://smartystreets.com/docs/cloud/international-street-api#http-input-fields
@@ -41,6 +44,9 @@ def run():
4144
lookup.country = "Brazil"
4245
lookup.postal_code = "02516-050"
4346

47+
# Uncomment the below line to add a custom parameter
48+
# lookup.add_custom_parameter("parameter", "value")
49+
4450
candidates = client.send(lookup) # The candidates are also stored in the lookup's 'result' field.
4551

4652
first_candidate = candidates[0]

examples/us_autocomplete_pro_example.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,20 @@ def run():
2727
#
2828
# credentials = StaticCredentials(auth_id, auth_token)
2929

30+
client = ClientBuilder(credentials).build_us_autocomplete_pro_api_client()
31+
32+
# (Advanced) Uncomment the below line to explicitly specify a license value
33+
# client = ClientBuilder(credentials).with_licenses(["us-autocomplete-pro-cloud"]).build_us_autocomplete_pro_api_client()
34+
3035
# The appropriate license values to be used for your subscriptions
3136
# can be found on the Subscriptions page of the account dashboard.
3237
# https://www.smartystreets.com/docs/cloud/licensing
33-
client = ClientBuilder(credentials).with_licenses(["us-autocomplete-pro-cloud"]).build_us_autocomplete_pro_api_client()
38+
3439
lookup = AutocompleteProLookup('1042 W Center')
3540

41+
# Uncomment the below line to add a custom parameter
42+
# lookup.add_custom_parameter("parameter", "value")
43+
3644
client.send(lookup)
3745

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

examples/us_enrichment_example.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ def run():
2323
#
2424
# credentials = StaticCredentials(auth_id, auth_token)
2525

26+
client = ClientBuilder(credentials).build_us_enrichment_api_client()
27+
28+
# (Advanced) Uncomment the below line to explicitly specify a license value
29+
# client = ClientBuilder(credentials).with_licenses(["us-property-data-principal-cloud"]).build_us_enrichment_api_client()
30+
2631
# The appropriate license values to be used for your subscriptions
2732
# can be found on the Subscriptions page of the account dashboard.
2833
# https://www.smartystreets.com/docs/cloud/licensing
29-
client = ClientBuilder(credentials).with_licenses(["us-property-data-principal-cloud"]).build_us_enrichment_api_client()
34+
3035
# client = ClientBuilder(credentials).with_custom_header({'User-Agent': 'smartystreets ([email protected])', 'Content-Type': 'application/json'}).build_us_enrichment_api_client()
3136
# client = ClientBuilder(credentials).with_http_proxy('localhost:8080', 'user', 'password').build_us_street_api_client()
3237
# Uncomment the line above to try it with a proxy instead
@@ -41,6 +46,17 @@ def run():
4146
lookup.state = "NJ"
4247
lookup.zipcode = "08876"
4348

49+
# Uncomment the below lines to add attributes to the "include" parameter
50+
# lookup.add_include_attribute('assessed_improvement_percent')
51+
# lookup.add_include_attribute('assessed_improvement_value')
52+
53+
# Uncomment the below lines to add attributes to the "exclude" parameter
54+
# lookup.add_exclude_attribute('assessed_land_value')
55+
# lookup.add_exclude_attribute('assessed_value')
56+
57+
# Uncomment the below line to add a custom parameter
58+
# lookup.add_custom_parameter("parameter", "value")
59+
4460
freeform_lookup.freeform = "56 Union Ave Somerville NJ 08876"
4561

4662
try:

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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,23 @@ def run():
2121
#
2222
# credentials = StaticCredentials(auth_id, auth_token)
2323

24+
client = ClientBuilder(credentials).build_us_reverse_geo_api_client()
25+
26+
# (Advanced) Uncomment the below line to explicitly specify a license value
27+
# client = ClientBuilder(credentials).with_licenses(["us-reverse-geocoding-cloud"]).build_us_reverse_geo_api_client()
28+
2429
# The appropriate license values to be used for your subscriptions
2530
# can be found on the Subscriptions page of the account dashboard.
2631
# https://www.smartystreets.com/docs/cloud/licensing
27-
client = ClientBuilder(credentials).with_licenses(["us-reverse-geocoding-cloud"]).build_us_reverse_geo_api_client()
2832

2933
# Documentation for input fields can be found at:
3034
# https://smartystreets.com/docs/cloud/us-reverse-geo-api#http-input-fields
3135

3236
lookup = Lookup(40.111111, -111.111111)
3337

38+
# Uncomment the below line to add a custom parameter
39+
# lookup.add_custom_parameter("parameter", "value")
40+
3441
results = client.send(lookup)
3542

3643
for result in results:

examples/us_street_multiple_addresses_example.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@ 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)
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+
27+
# (Advanced) Uncomment the below line to explicitly specify a license value
28+
# client = ClientBuilder(credentials).with_licenses(['us-core-cloud']).build_us_street_api_client()
2429

2530
# The appropriate license values to be used for your subscriptions
2631
# can be found on the Subscription page of the account dashboard.
2732
# https://www.smartystreets.com/docs/cloud/licensing
28-
client = ClientBuilder(credentials).with_licenses(['us-core-cloud']).build_us_street_api_client()
33+
2934
batch = Batch()
3035

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

52+
# Uncomment the below line to add a custom parameter
53+
# batch[0].add_custom_parameter("parameter", "value")
54+
4755
batch.add(StreetLookup("1 Rosedale, Baltimore, Maryland")) # Freeform addresses work too.
4856
batch[1].candidates = 10 # Allows up to ten possible matches to be returned (default is 1).
4957

examples/us_street_single_address_example.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ def run():
2323

2424
# credentials = StaticCredentials(auth_id, auth_token)
2525

26+
client = ClientBuilder(credentials).build_us_street_api_client()
27+
28+
# (Advanced) Uncomment the below line to explicitly specify a license value
29+
# client = ClientBuilder(credentials).with_licenses(["us-core-cloud"]).build_us_street_api_client()
30+
2631
# The appropriate license values to be used for your subscriptions
2732
# can be found on the Subscriptions page of the account dashboard.
2833
# https://www.smartystreets.com/docs/cloud/licensing
29-
client = ClientBuilder(credentials).with_licenses(["us-core-cloud"]).build_us_street_api_client()
34+
3035
# client = ClientBuilder(credentials).with_custom_header({'User-Agent': 'smartystreets ([email protected])', 'Content-Type': 'application/json'}).build_us_street_api_client()
3136
# client = ClientBuilder(credentials).with_http_proxy('localhost:8080', 'user', 'password').build_us_street_api_client()
3237
# Uncomment the line above to try it with a proxy instead
@@ -49,6 +54,9 @@ def run():
4954
# this will always return at least one result even if the address is invalid.
5055
# Refer to the documentation for additional Match Strategy options.
5156

57+
# Uncomment the below line to add a custom parameter
58+
# lookup.add_custom_parameter("parameter", "value")
59+
5260
try:
5361
client.send_lookup(lookup)
5462
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"

examples/us_zipcode_single_lookup_example.py

Lines changed: 10 additions & 6 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']
19+
auth_id = os.environ['SMARTY_AUTH_ID']
20+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
2121
#
22-
# credentials = StaticCredentials(auth_id, auth_token)
22+
credentials = StaticCredentials(auth_id, auth_token)
2323

2424
# Documentation for input fields can be found at:
2525
# https://smartystreet.com/docs/us-zipcode-api#input-fields
@@ -32,6 +32,9 @@ def run():
3232
lookup.state = "California"
3333
lookup.zipcode = "94043"
3434

35+
# Uncomment the below line to add a custom parameter
36+
# lookup.add_custom_parameter("parameter", "value")
37+
3538
try:
3639
client.send_lookup(lookup)
3740
except exceptions.SmartyException as err:
@@ -51,6 +54,7 @@ def run():
5154
print("\nZIP Code: " + zipcode.zipcode)
5255
print("Latitude: {}".format(zipcode.latitude))
5356
print("Longitude: {}".format(zipcode.longitude))
57+
print("County: {}".format(zipcode.county_name))
5458

5559

5660
if __name__ == "__main__":

0 commit comments

Comments
 (0)