Commit 37ad6257 authored by Jo Sama's avatar Jo Sama 😱
Browse files

Return None when no person found

parent f2913fe4
......@@ -166,14 +166,20 @@ class TopDeskClient:
return None
else:
url = self.urls.get_persons()
persons = [Person.from_dict(x) for x in
self.get(url,
params={'ssp_login_name': identity})]
f = filter(lambda x: x.user_name.lower() == identity,
persons)
try:
return next(f)
except StopIteration:
r = self.get(url,
params={'ssp_login_name': identity},
return_response=True)
if r.status_code == 200:
persons = [Person.from_dict(x) for x in r.json()]
f = filter(lambda x: x.user_name.lower() == identity,
persons)
try:
return next(f)
except StopIteration:
return None
else:
r.raise_for_status()
return None
def create_person(self, person):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment