User Holiday

class moco_wrapper.models.UserHoliday(moco)

Class for handling users holiday/vacation credits.

Every user that can take vacation has a number of vacation credits. These can be manged with this model.

Example usage:

from moco_wrapper import Moco

m = Moco()

# this user gets extra vacation in 2020
m.UserHoliday.create(
    year = 2020,
    title = "extra vacation day",
    user_id = 22,
    hours = 8
)

Note

Please not that the base unit for holiday credits is hours. So if your typical workday contains 8 hours, 8 holiday credits means one day off.

create(year: int, title: str, user_id: int, hours: float = None, days: float = None)

Create an users entitlement for holidays/vacation (either by hours or days).

Parameters:
  • year (int) – Year the holiday credits are for
  • title (str) – Title
  • user_id (int) – Id of the user these holiday credits belongs to
  • hours (float) – Hours (specify either hours or days) (default None)
  • days (float) – Days (specify either hours or days) (default None)
Returns:

The created holiday object

Return type:

moco_wrapper.util.response.ObjectResponse

delete(holiday_id: int)

Delete a holiday entry

Parameters:holiday_id (int) – Id of the holiday entry to delete
Returns:Empty response on success
Return type:moco_wrapper.util.response.EmptyResponse
static endpoints() → List[moco_wrapper.util.endpoint.endpoint.Endpoint]

Returns all endpoints associated with the model

Returns:List of Endpoint objects
Return type:moco_wrapper.util.endpoint.Endpoint
get(holiday_id: int)

Retrieve single holiday entry

Parameters:holiday_id (int) – Id of the holiday
Returns:The holiday object
Return type:moco_wrapper.util.response.ObjectResponse
getlist(year: int = None, user_id: int = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)

Retrieve a list of holiday entries.

Parameters:
  • year (int) – Show only this year (e.g. 2019) (default None)
  • user_id (int) – Show only holidays from this user (e.g. 5) (default None)
  • sort_by (str) – field to sort results by (default None)
  • sort_order (str) – asc or desc (default "asc")
  • page (int) – Page number (default 1)
Returns:

List of holiday entries

Return type:

moco_wrapper.util.response.PagedListResponse

update(holiday_id: int, year: int = None, title: str = None, user_id: int = None, hours: float = None, days: float = None)

Update a holiday entry

Parameters:
  • holiday_id (int) – Id of the holiday entry
  • year (int) – Year the holiday credits are for (default None)
  • title (str) – Title (default None)
  • user_id (int) – User this holiday entry belongs to (default None)
  • hours (float) – Hours (specify either hours or days) (default None)
  • days (float) – Days (specify either hours or days) (default None)
Returns:

The updated holiday object

Return type:

moco_wrapper.util.response.ObjectResponse