Shift Management
Usage
Manage shifts:
import asyncio
import factorialhr
async def main():
auth = factorialhr.AccessTokenAuth("your_access_token")
async with factorialhr.ApiClient(auth=auth) as api:
shift_mgmt = factorialhr.ShiftManagementEndpoint(api)
response = await shift_mgmt.get(params={"page": 1})
for shift in response.data():
print(shift.employee_id, shift.starts_at, shift.ends_at)
asyncio.run(main())
- class factorialhr.ShiftManagementEndpoint(api: ApiClient)[source]
Endpoint for shift_management/shifts operations.
- async all(**kwargs) ListApiResponse[ShiftManagementShift][source]
Get all shifts records.
Official documentation: shift_management/shifts
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing the list of records.
- Return type:
- async bulk_create(data: Mapping[str, Any], **kwargs) Sequence[ShiftManagementShift][source]
Bulk create shifts.
Official documentation: shift_management/shifts
- Parameters:
data (Mapping[str, Any]) – Payload for the new record (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The created record.
- Return type:
Sequence[ShiftManagementShift]
- async bulk_delete(data: Mapping[str, Any], **kwargs) Sequence[ShiftManagementShift][source]
Bulk delete shifts.
Official documentation: shift_management/shifts
- Parameters:
data (Mapping[str, Any]) – Payload for the new record (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Result.
- Return type:
Sequence[ShiftManagementShift]
- async create(data: Mapping[str, Any], **kwargs) ShiftManagementShift[source]
Create a new shift.
Official documentation: shift_management/shifts
- Parameters:
data (Mapping[str, Any]) – Payload for the new record (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The created record.
- Return type:
- async delete(shift_id: int | str, **kwargs) ShiftManagementShift[source]
Delete a shift.
Official documentation: shift_management/shifts
- Parameters:
shift_id (int | str) – The unique identifier of the record to delete.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The deleted record.
- Return type:
- async get(**kwargs) MetaApiResponse[ShiftManagementShift][source]
Get shifts with pagination metadata.
Official documentation: shift_management/shifts
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing records and pagination metadata.
- Return type:
- async get_by_id(shift_id: int | str, **kwargs) ShiftManagementShift[source]
Get a specific shift by ID.
Official documentation: shift_management/shifts
- Parameters:
shift_id (int | str) – The unique identifier.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The record.
- Return type:
- async update(shift_id: int | str, data: Mapping[str, Any], **kwargs) ShiftManagementShift[source]
Update a shift.
Official documentation: shift_management/shifts
- Parameters:
shift_id (int | str) – The unique identifier of the record to update.
data (Mapping[str, Any]) – Payload with fields to update (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The updated record.
- Return type:
- class factorialhr.ShiftManagementShift(*, id: int, company_id: int, name: str | None = None, state: ShiftState, location_id: int | None = None, locations_work_area_id: int | None = None, employee_id: int, start_at: datetime, end_at: datetime, notes: str | None = None, extra_hours: bool | None = None, default_shift_title: str | None = None, timezone: str, local_start_at: datetime, local_end_at: datetime)[source]
Model for shift_management_shift.
- company_id: int
Company identifier
- default_shift_title: str | None
Default shift title
- employee_id: int
Employee identifier
- end_at: datetime
End date of the shift
- extra_hours: bool | None
Flag to indicate if the shift has extra hours
- id: int
Shift identifier
- local_end_at: datetime
Local end date of the shift
- local_start_at: datetime
Local start date of the shift
- location_id: int | None
Shift location identifier
- locations_work_area_id: int | None
Shift work area identifier
- name: str | None
Name of the shift, doing a fallback to the default shift title or template week name
- notes: str | None
Shift notes
- start_at: datetime
Start date of the shift
- state: ShiftState
The state of the shift
- timezone: str
Shift timezone