Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
it-bott-integrasjoner
topdesk-client
Commits
37ad6257
Commit
37ad6257
authored
Oct 28, 2019
by
Jo Sama
😱
Browse files
Return None when no person found
parent
f2913fe4
Changes
1
Hide whitespace changes
Inline
Side-by-side
topdesk_client/client.py
View file @
37ad6257
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment