-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RAS-1400 Extend party enrolment to include business and survey details
- Loading branch information
Showing
14 changed files
with
317 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,31 @@ | ||
import logging | ||
|
||
import requests | ||
import structlog | ||
from flask import current_app | ||
from requests.exceptions import ConnectionError, HTTPError, Timeout | ||
|
||
from ras_party.exceptions import ServiceUnavailableException | ||
|
||
logger = structlog.wrap_logger(logging.getLogger(__name__)) | ||
|
||
|
||
def get_surveys_details() -> dict: | ||
url = f'{current_app.config["SURVEY_URL"]}/surveys' | ||
try: | ||
response = requests.get( | ||
url, auth=(current_app.config["SECURITY_USER_NAME"], current_app.config["SECURITY_USER_PASSWORD"]) | ||
) | ||
response.raise_for_status() | ||
except HTTPError: | ||
logger.error("Survey returned a HTTPError") | ||
raise | ||
except ConnectionError: | ||
raise ServiceUnavailableException("Survey service returned a connection error", 503) | ||
except Timeout: | ||
raise ServiceUnavailableException("Survey service has timed out", 504) | ||
|
||
return { | ||
survey["id"]: {"short_name": survey["shortName"], "long_name": survey["longName"], "ref": survey["surveyRef"]} | ||
for survey in response.json() | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.