From 3cfa09e45de28934351475178c99bd829a1e08d8 Mon Sep 17 00:00:00 2001 From: andhess Date: Tue, 1 Mar 2016 13:54:52 -0800 Subject: [PATCH 1/2] @philipithomas committing an inheritance bug fix --- staffjoy/resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staffjoy/resource.py b/staffjoy/resource.py index 8fafb3a..fe8c88b 100644 --- a/staffjoy/resource.py +++ b/staffjoy/resource.py @@ -81,7 +81,7 @@ 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 From 0cc57147cd3d23b7caba1eb1f3ae4242af73cdcf Mon Sep 17 00:00:00 2001 From: andhess Date: Tue, 1 Mar 2016 14:13:31 -0800 Subject: [PATCH 2/2] adding time off requests to library --- setup.py | 2 +- staffjoy/resource.py | 3 ++- staffjoy/resources/role.py | 4 ++-- staffjoy/resources/schedule.py | 4 ++++ staffjoy/resources/schedule_time_off_request.py | 6 ++++++ staffjoy/resources/time_off_request.py | 6 ++++++ staffjoy/resources/worker.py | 10 ++++++++++ 7 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 staffjoy/resources/schedule_time_off_request.py create mode 100644 staffjoy/resources/time_off_request.py 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 fe8c88b..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, data.get("id")), + 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)