-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbamboo_hr_api.py
40 lines (25 loc) · 1.15 KB
/
bamboo_hr_api.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
37
38
39
40
from base_api import BaseApi
BAMBOO_HR_API_URL = "https://api.bamboohr.com/api/gateway.php/{}/v1"
class BambooHRApi(BaseApi):
def __init__(self, sub_domain, api_key):
if not sub_domain:
raise ValueError("Please pass a valid 'subdomain'")
if not api_key:
raise ValueError("Please pass a valid 'apikey'")
super().__init__(BAMBOO_HR_API_URL.format(sub_domain), api_key=api_key)
def get_list_of_employees(self):
data = self.get("/employees/directory")
return data['employees']
def get_employee(self, employee_id):
return self.get("/employees/{}".format(employee_id))
def get_employee_time_offs(self, employee_id, start_date=None, end_date=None, status=None):
if not employee_id:
raise ValueError("Please pass an employee id")
params = {'employeeId': employee_id}
if start_date:
params['start'] = start_date.strftime("%Y-%m-%d")
if end_date:
params['end'] = end_date.strftime("%Y-%m-%d")
if status:
params['status'] = ','.join(status)
return self.get("/time_off/requests", params=params)