Skip to content

Commit

Permalink
add token into colin-api call (#1419)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick Wang <[email protected]>
  • Loading branch information
patrickpeinanw and Patrick Wang authored Sep 19, 2023
1 parent 679b1e1 commit 67153b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion solr-feeder/solr_feeder/services/colin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ def _parse_party(party: dict, legal_type: str):
return party


def get_business_info(legal_type: str, identifier: str) -> tuple[dict, dict]:
def get_business_info(legal_type: str, identifier: str, token: str) -> tuple[dict, dict]:
"""Return the basic business info of the business."""
try:
headers = {'Authorization': 'Bearer ' + token}

res = requests.get(f'{current_app.config["COLIN_API_URL"]}/businesses/{legal_type}/{identifier}',
headers=headers,
timeout=current_app.config['COLIN_API_TIMEOUT'])

if res.status_code != HTTPStatus.OK:
return None, {'message': res.json(), 'status_code': res.status_code}

Expand Down
2 changes: 1 addition & 1 deletion solr-feeder/solr_feeder/services/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def update_search_cores(identifier: str, legal_type: str):
return error

# get business data
business, error = get_business_info(legal_type, identifier)
business, error = get_business_info(legal_type, identifier, token)
if error:
logging.error('Error getting COLIN business data: %s', error)
return {'message': error['message']}, HTTPStatus.INTERNAL_SERVER_ERROR
Expand Down

0 comments on commit 67153b7

Please sign in to comment.