-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathget_milestones.py
More file actions
42 lines (35 loc) · 1.13 KB
/
get_milestones.py
File metadata and controls
42 lines (35 loc) · 1.13 KB
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
33
34
35
36
37
38
39
40
41
42
from freelancersdk.session import Session
from freelancersdk.resources.projects.projects import get_milestones
from freelancersdk.resources.projects.exceptions import \
MilestonesNotFoundException
from freelancersdk.resources.users.helpers import (
create_get_users_details_object
)
import os
def sample_get_milestones():
url = os.environ.get('FLN_URL')
oauth_token = os.environ.get('FLN_OAUTH_TOKEN')
session = Session(oauth_token=oauth_token, url=url)
get_milestones_data = {
'project_ids': [
101,
102,
],
'limit': 10,
'offset': 0,
'user_details': create_get_users_details_object(
country=True,
profile_description=True
)
}
try:
milestones = get_milestones(session, **get_milestones_data)
except MilestonesNotFoundException as e:
print('Error message: {}'.format(e.message))
print('Server response: {}'.format(e.error_code))
return None
else:
return milestones
result = sample_get_milestones()
if result:
print('Found milestones: {}'.format(len(result['milestones'])))