-
Notifications
You must be signed in to change notification settings - Fork 44
/
place_project_bid.py
36 lines (30 loc) · 1.05 KB
/
place_project_bid.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
33
34
35
36
from freelancersdk.resources.projects import place_project_bid
from freelancersdk.session import Session
from freelancersdk.resources.users \
import get_self_user_id
from freelancersdk.exceptions import BidNotPlacedException
import os
# https://www.freelancer.com/api/docs/cases/creating_a_bid
def sample_place_project_bid():
url = os.environ.get('FLN_URL')
oauth_token = os.environ.get('FLN_OAUTH_TOKEN')
project_id = os.environ.get('PROJECT_ID')
session = Session(oauth_token=oauth_token, url=url)
my_user_id = get_self_user_id(session)
bid_data = {
'project_id': int(project_id),
'bidder_id': my_user_id,
'amount': 10,
'period': 2,
'milestone_percentage': 100,
'description': 'This is my bid',
}
try:
return place_project_bid(session, **bid_data)
except BidNotPlacedException as e:
print(('Error message: %s' % e.message))
print(('Error code: %s' % e.error_code))
return None
b = sample_place_project_bid()
if b:
print(("Bid placed: %s" % b))