Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields get API #109

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bamboosdk/api/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,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):
Expand Down
12 changes: 12 additions & 0 deletions bamboosdk/api/time_off.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions bamboosdk/bamboohrsdk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .api.employee import Employee
from .api.webhook import Webhook
from .api.time_off import TimeOff

class BambooHrSDK:
"""
Expand All @@ -16,6 +17,7 @@ def __init__(self, api_token: str, sub_domain: str):

self.employees = Employee()
self.webhook = Webhook()
self.time_off = TimeOff()

self.set_api_token()
self.set_sub_domain()
Expand All @@ -26,10 +28,12 @@ def set_api_token(self):
"""
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)
Loading