diff --git a/bamboosdk/api/api_base.py b/bamboosdk/api/api_base.py index 50523d70..dcba2457 100644 --- a/bamboosdk/api/api_base.py +++ b/bamboosdk/api/api_base.py @@ -124,8 +124,9 @@ def set_api_token(self, api_token): self.__api_token = api_token self.headers = { - "content-type": "application/json", - "authorization": f"Basic {self.__encode_username_password()}" + 'Accept': 'application/json', + 'content-type': 'application/json', + 'authorization': f'Basic {self.__encode_username_password()}' } def set_sub_domain(self, sub_domain): diff --git a/bamboosdk/api/time_off.py b/bamboosdk/api/time_off.py new file mode 100644 index 00000000..c616e79b --- /dev/null +++ b/bamboosdk/api/time_off.py @@ -0,0 +1,12 @@ +from .api_base import ApiBase + +class TimeOff(ApiBase): + CHECK_URL = '/v1/meta/time_off/types/' + + def get(self): + """ + Get method to get the different fields, + used here for checking connection. + Returns: + """ + return self._get_request(self.CHECK_URL) diff --git a/bamboosdk/api/webhook.py b/bamboosdk/api/webhook.py new file mode 100644 index 00000000..7dbe7e04 --- /dev/null +++ b/bamboosdk/api/webhook.py @@ -0,0 +1,22 @@ +from .api_base import ApiBase + + +class Webhook(ApiBase): + """ Class for webhook APIs for bamboohr """ + + POST_WEBHOOK = '/v1/webhooks/' + DELETE_WEBHOOK = '/v1/webhooks/{}' + + def post(self, payload): + """ + Post webhook url to bamboohr for employee update or create + Returns: + """ + return self._post_request(self.POST_WEBHOOK, payload) + + def delete(self, id): + """ + Delete Webhook + Returns: + """ + return self._delete_request(self.DELETE_WEBHOOK.format(id)) diff --git a/bamboosdk/bamboohrsdk.py b/bamboosdk/bamboohrsdk.py index 49b51ac4..7b92468f 100644 --- a/bamboosdk/bamboohrsdk.py +++ b/bamboosdk/bamboohrsdk.py @@ -1,4 +1,6 @@ from .api.employee import Employee +from .api.webhook import Webhook +from .api.time_off import TimeOff class BambooHrSDK: """ @@ -14,5 +16,24 @@ def __init__(self, api_token: str, sub_domain: str): self.__sub_domain = sub_domain self.employees = Employee() + self.webhook = Webhook() + self.time_off = TimeOff() + + self.set_api_token() + self.set_sub_domain() + + def set_api_token(self): + """ + Set the api token for all the APIs + """ self.employees.set_api_token(self.__api_token) + self.webhook.set_api_token(self.__api_token) + self.time_off.set_api_token(self.__api_token) + + def set_sub_domain(self): + """ + Set sub domain for all the APIs + """ self.employees.set_sub_domain(self.__sub_domain) + self.webhook.set_sub_domain(self.__sub_domain) + self.time_off.set_sub_domain(self.__sub_domain)