From b07dfad37ee76a124f54f5ca11475eca25202a7c Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 20 Apr 2022 13:55:45 +0100 Subject: [PATCH] Implement getting the link --- handler/ux/verify.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/handler/ux/verify.py b/handler/ux/verify.py index 2ddd670..9ce6405 100644 --- a/handler/ux/verify.py +++ b/handler/ux/verify.py @@ -15,6 +15,14 @@ class Verify(util.Base): Class to handle user verification. """ + def create_applicant_and_get_link(self, external_user_id): + """ + Create the applicant and return the authentication link. + """ + # applicant_id = self.create_applicant(external_user_id) + auth_url = self.get_authentication_link(external_user_id) + return auth_url + def get_authentication_link(self, external_user_id): """ Get an external authentication link for a user. @@ -49,19 +57,24 @@ class Verify(util.Base): resp = self.sign_request(requests.Request("GET", url)) s = requests.Session() response = s.send(resp) - return response + response_json = response.json() + if "review" in response_json: + if "reviewResult" in response_json["review"]: + if "reviewAnswer" in response_json["review"]["reviewResult"]: + return response_json["review"]["reviewResult"]["reviewAnswer"] + return - def create_applicant(self, external_user_id, level_name): + def create_applicant(self, external_user_id): """ Create an applicant. """ body = {"externalUserId": external_user_id} - params = {"levelName": level_name} + params = {"levelName": settings.Verify.LevelName} headers = {"Content-Type": "application/json", "Content-Encoding": "utf-8"} resp = self.sign_request( requests.Request( "POST", - f"{settings.Verify.Base}/resources/applicants?levelName={level_name}", + f"{settings.Verify.Base}/resources/applicants?levelName={settings.Verify.LevelName}", params=params, data=json.dumps(body), headers=headers,