From 22f708758aec98936353288b8e0da04e48e379b9 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 23 Apr 2022 11:53:19 +0100 Subject: [PATCH] Implement getting user's name --- handler/ux/verify.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/handler/ux/verify.py b/handler/ux/verify.py index 4f0fcdb..1248010 100644 --- a/handler/ux/verify.py +++ b/handler/ux/verify.py @@ -72,6 +72,22 @@ class Verify(util.Base): rtrn = self.process_callback(content_json) return rtrn + def get_external_user_id_details(self, external_user_id): + # /resources/applicants/-;externalUserId={externalUserId}/one + url = f"{settings.Verify.Base}/resources/applicants/-;externalUserId={external_user_id}/one" + resp = self.sign_request(requests.Request("GET", url)) + s = requests.Session() + response = s.send(resp) + info = response.json() + if "info" in info: + if {"firstName", "lastName"}.issubset(set(info["info"].keys())): + first_name = info["info"]["firstName"] + last_name = info["info"]["lastName"] + if first_name.startswith("MR "): + first_name = first_name[3:] + print("info", info) + return (first_name, last_name) + def create_applicant_and_get_link(self, external_user_id): """ Create the applicant and return the authentication link.