diff --git a/setup.py b/setup.py index afd4c37..d896206 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = "0.12" +version = "0.13" setup(name="staffjoy", packages=find_packages(), version=version, diff --git a/staffjoy/resource.py b/staffjoy/resource.py index 8fafb3a..87438c5 100644 --- a/staffjoy/resource.py +++ b/staffjoy/resource.py @@ -81,7 +81,8 @@ def get_all(cls, parent=None, **params): for data in objects_data: # Note that this approach does not get meta data return_objects.append(cls.get(parent=parent, - id=data.get(cls.ID_NAME), + id=data.get(cls.ID_NAME, data.get( + "id")), data=data)) return return_objects diff --git a/staffjoy/resources/role.py b/staffjoy/resources/role.py index 0119cb4..456aa68 100644 --- a/staffjoy/resources/role.py +++ b/staffjoy/resources/role.py @@ -8,8 +8,8 @@ class Role(Resource): PATH = "organizations/{organization_id}/locations/{location_id}/roles/{role_id}" ID_NAME = "role_id" - def get_workers(self): - return Worker.get_all(parent=self) + def get_workers(self, **kwargs): + return Worker.get_all(parent=self, **kwargs) def get_worker(self, id=id): return Worker.get(parent=self, id=id) diff --git a/staffjoy/resources/schedule.py b/staffjoy/resources/schedule.py index 741ccff..d95f7d6 100644 --- a/staffjoy/resources/schedule.py +++ b/staffjoy/resources/schedule.py @@ -2,6 +2,7 @@ from .preference import Preference from .schedule_shift import ScheduleShift from .schedule_timeclock import ScheduleTimeclock +from .schedule_time_off_request import ScheduleTimeOffRequest class Schedule(Resource): @@ -23,3 +24,6 @@ def get_schedule_shifts(self, **kwargs): def get_schedule_timeclocks(self, **kwargs): return ScheduleTimeclock.get_all(parent=self, **kwargs) + + def get_schedule_time_off_requests(self, **kwargs): + return ScheduleTimeOffRequest.get_all(parent=self, **kwargs) diff --git a/staffjoy/resources/schedule_time_off_request.py b/staffjoy/resources/schedule_time_off_request.py new file mode 100644 index 0000000..1ebb21c --- /dev/null +++ b/staffjoy/resources/schedule_time_off_request.py @@ -0,0 +1,6 @@ +from ..resource import Resource + + +class ScheduleTimeOffRequest(Resource): + """this is only a get collection endpoint""" + PATH = "organizations/{organization_id}/locations/{location_id}/roles/{role_id}/schedules/{schedule_id}/timeoffrequests/" diff --git a/staffjoy/resources/time_off_request.py b/staffjoy/resources/time_off_request.py new file mode 100644 index 0000000..f983c23 --- /dev/null +++ b/staffjoy/resources/time_off_request.py @@ -0,0 +1,6 @@ +from ..resource import Resource + + +class TimeOffRequest(Resource): + PATH = "organizations/{organization_id}/locations/{location_id}/roles/{role_id}/users/{user_id}/timeoffrequests/{time_off_request_id}" + ID_NAME = "time_off_request_id" diff --git a/staffjoy/resources/worker.py b/staffjoy/resources/worker.py index d04caf8..9eea8d3 100644 --- a/staffjoy/resources/worker.py +++ b/staffjoy/resources/worker.py @@ -1,5 +1,6 @@ from ..resource import Resource from .timeclock import Timeclock +from .time_off_request import TimeOffRequest class Worker(Resource): @@ -15,3 +16,12 @@ def get_timeclock(self, id): def create_timeclock(self, **kwargs): return Timeclock.create(parent=self, **kwargs) + + def get_time_off_requests(self, **kwargs): + return TimeOffRequest.get_all(parent=self, **kwargs) + + def get_time_off_request(self, id): + return TimeOffRequest.get(parent=self, id=id) + + def create_time_off_request(self, **kwargs): + return TimeOffRequest.create(parent=self, **kwargs)