forked from freelancer/freelancer-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_projects.py
More file actions
33 lines (27 loc) · 900 Bytes
/
search_projects.py
File metadata and controls
33 lines (27 loc) · 900 Bytes
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
from freelancersdk.session import Session
from freelancersdk.resources.projects.projects import search_projects
from freelancersdk.resources.projects.exceptions import \
ProjectsNotFoundException
import os
def sample_search_projects():
url = os.environ.get('FLN_URL')
oauth_token = os.environ.get('FLN_OAUTH_TOKEN')
session = Session(oauth_token=oauth_token, url=url)
search_data = {
'query': 'logo',
'project_types': 'fixed',
'limit': 10,
'offset': 0,
'active_only': True,
}
try:
p = search_projects(session, **search_data)
except ProjectsNotFoundException as e:
print('Error message: {}'.format(e.message))
print('Server response: {}'.format(e.error_code))
return None
else:
return p
p = sample_search_projects()
if p:
print('Found projects: {}'.format(p('total_count')))