Skip to content

Commit

Permalink
Merge pull request #7 from Staffjoy/pto
Browse files Browse the repository at this point in the history
adding time off requests to library
  • Loading branch information
philipithomas committed Mar 1, 2016
2 parents 38220ca + 0cc5714 commit ea6619d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = "0.12"
version = "0.13"
setup(name="staffjoy",
packages=find_packages(),
version=version,
Expand Down
3 changes: 2 additions & 1 deletion staffjoy/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions staffjoy/resources/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions staffjoy/resources/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
6 changes: 6 additions & 0 deletions staffjoy/resources/schedule_time_off_request.py
Original file line number Diff line number Diff line change
@@ -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/"
6 changes: 6 additions & 0 deletions staffjoy/resources/time_off_request.py
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions staffjoy/resources/worker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..resource import Resource
from .timeclock import Timeclock
from .time_off_request import TimeOffRequest


class Worker(Resource):
Expand All @@ -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)

0 comments on commit ea6619d

Please sign in to comment.