BambooHR.TimeTracking (BambooHR v0.3.0)
View SourceFunctions for interacting with time tracking resources in the BambooHR API.
Summary
Functions
Records a clock-in event for an employee.
Records a clock-out event for an employee.
Retrieves timesheet entries within a specified date range.
Stores timesheet clock entries for employees.
Functions
@spec clock_in(BambooHR.Client.t(), integer(), map()) :: BambooHR.Client.response()
Records a clock-in event for an employee.
Parameters
client
- Client configuration created withBambooHR.Client.new/1
employee_id
- The ID of the employee to clock inclock_data
- Map containing clock-in details (date, start time, timezone, etc.)
Examples
iex> clock_data = %{
...> "date" => "2024-01-15",
...> "start" => "09:00",
...> "timezone" => "America/New_York"
...> }
iex> BambooHR.TimeTracking.clock_in(client, 123, clock_data)
{:ok, %{"message" => "Successfully clocked in"}}
@spec clock_out(BambooHR.Client.t(), integer(), map()) :: BambooHR.Client.response()
Records a clock-out event for an employee.
Parameters
client
- Client configuration created withBambooHR.Client.new/1
employee_id
- The ID of the employee to clock outclock_data
- Map containing clock-out details (date, end time, timezone)
Examples
iex> clock_data = %{
...> "date" => "2024-01-15",
...> "end" => "17:00",
...> "timezone" => "America/New_York"
...> }
iex> BambooHR.TimeTracking.clock_out(client, 123, clock_data)
{:ok, %{"message" => "Successfully clocked out"}}
@spec get_timesheet_entries(BambooHR.Client.t(), map()) :: BambooHR.Client.response()
Retrieves timesheet entries within a specified date range.
Parameters
client
- Client configuration created withBambooHR.Client.new/1
params
- Map containing query parameters (start, end dates, and optional employee IDs)
Examples
iex> params = %{
...> "start" => "2024-01-01",
...> "end" => "2024-01-31",
...> "employeeIds" => "123,124"
...> }
iex> BambooHR.TimeTracking.get_timesheet_entries(client, params)
{:ok, %{
"entries" => [
%{
"id" => "1",
"employeeId" => "123",
"date" => "2024-01-15",
"hours" => 8.0
}
]
}}
@spec store_clock_entries(BambooHR.Client.t(), [map()]) :: BambooHR.Client.response()
Stores timesheet clock entries for employees.
Parameters
client
- Client configuration created withBambooHR.Client.new/1
entries
- List of clock entry maps containing employee ID, date, start and end times
Examples
iex> entries = [
...> %{
...> "employeeId" => "123",
...> "date" => "2024-01-15",
...> "start" => "09:00:00",
...> "end" => "17:00:00"
...> }
...> ]
iex> BambooHR.TimeTracking.store_clock_entries(client, entries)
{:ok, %{"message" => "Entries stored successfully"}}