-
Notifications
You must be signed in to change notification settings - Fork 44
/
get_portfolios.py
32 lines (27 loc) · 1005 Bytes
/
get_portfolios.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_portfolios
from freelancersdk.resources.users.exceptions import \
PortfoliosNotFoundException
import os
def sample_get_portfolios():
url = os.environ.get('FLN_URL')
oauth_token = os.environ.get('FLN_OAUTH_TOKEN')
session = Session(oauth_token=oauth_token, url=url)
user_ids = [ 7344704]
# 3112780
try:
portfolios = get_portfolios(session, user_ids=user_ids)
except PortfoliosNotFoundException as e:
print('Error message: {}'.format(e.message))
print('Server: response: {}'.format(e.error_code))
return None
else:
return portfolios
result = sample_get_portfolios()
if result:
portfolios = []
users = result['users'].keys()
for k in users:
portfolios+=(result['portfolios'][k])
print('Got {} portfolios from {} users.'.format(len(portfolios), len(users)))
print('Portfolios:\n {}'.format(portfolios))