Implement getting the link

This commit is contained in:
Mark Veidemanis 2022-04-20 13:55:45 +01:00
parent ae08955d6b
commit b07dfad37e
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 17 additions and 4 deletions

View File

@ -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,