-
Notifications
You must be signed in to change notification settings - Fork 36
Mae/business name #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dd9555c
Integrated the business_name input field
mae-smarty f17d050
Merge branch 'master' of github.com:smartystreets/smartystreets-pytho…
mae-smarty 914c78b
Further testing updates
mae-smarty 3582b76
Move business_name to end of input list and wire up enrichment examples
mae-smarty 6595ca9
Merge remote-tracking branch 'origin/master' into mae/business-name
andyjohnsonsmarty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import os | ||
|
|
||
| from smartystreets_python_sdk import BasicAuthCredentials, ClientBuilder | ||
| from smartystreets_python_sdk.us_enrichment import BusinessLookup | ||
|
|
||
|
|
||
| def run(): | ||
| auth_id = os.environ['SMARTY_AUTH_ID'] | ||
| auth_token = os.environ['SMARTY_AUTH_TOKEN'] | ||
|
|
||
| credentials = BasicAuthCredentials(auth_id, auth_token) | ||
| client = ClientBuilder(credentials).build_us_enrichment_api_client() | ||
|
|
||
| lookup = BusinessLookup() | ||
| lookup.business_name = "delta air" | ||
| lookup.city = "atlanta" | ||
|
|
||
| try: | ||
| summary_results = client.send_business_lookup(lookup) | ||
| except Exception as err: | ||
| print(err) | ||
| return | ||
|
|
||
| if not summary_results: | ||
| print("No response returned for business name {}".format(lookup.business_name)) | ||
| return | ||
|
|
||
| summary = summary_results[0] | ||
| if not summary.businesses: | ||
| print("Business name {} has no business tenants".format(lookup.business_name)) | ||
| return | ||
|
|
||
| print("Matching businesses for business_name '{}':".format(lookup.business_name)) | ||
| for biz in summary.businesses: | ||
| print(" - {} (ID: {})".format(biz.company_name, biz.business_id)) | ||
|
|
||
| first = summary.businesses[0] | ||
| print("\nFetching details for business: {} (ID: {})".format(first.company_name, first.business_id)) | ||
|
|
||
| try: | ||
| detail_result = client.send_business_detail_lookup(first.business_id) | ||
| except Exception as err: | ||
| print(err) | ||
| return | ||
|
|
||
| if detail_result is None: | ||
| print("\nNo detail result returned") | ||
| return | ||
|
|
||
| print("\nDetail result:") | ||
| print_result(detail_result) | ||
|
|
||
|
|
||
| def print_result(obj): | ||
| for key, value in vars(obj).items(): | ||
| if value is None: | ||
| continue | ||
| if key == 'attributes': | ||
| print_result(value) | ||
| continue | ||
| print("{}: {}".format(key, value)) | ||
| print() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.