-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathget_self.py
32 lines (27 loc) · 918 Bytes
/
get_self.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from freelancersdk.session import Session
from freelancersdk.resources.users.users import get_self
from freelancersdk.resources.users.exceptions import \
SelfNotRetrievedException
from freelancersdk.resources.users.helpers import (
create_get_users_details_object
)
import os
def sample_get_self():
url = os.environ.get('FLN_URL')
oauth_token = os.environ.get('FLN_OAUTH_TOKEN')
session = Session(oauth_token=oauth_token, url=url)
user_details = create_get_users_details_object(
country=True,
profile_description=True
)
try:
result = get_self(session, user_details)
except SelfNotRetrievedException as e:
print('Error message: {}'.format(e.message))
print('Server response: {}'.format(e.error_code))
return None
else:
return result
result = sample_get_self()
if result:
print('Found self user: {}'.format(result))