Functions for interacting with timesheets in Deputy.
Summary
Functions
View timesheet details by ID.
Same as get_details/2 but raises on error.
Pause or unpause an employee's timesheet (take a break/finish break).
Same as pause/2 but raises on error.
Search for timesheets using the resource API.
Same as query/3 but raises on error.
Start an employee's timesheet (clock on).
Same as start/2 but raises on error.
Stop an employee's timesheet (clock off).
Same as stop/2 but raises on error.
Functions
@spec get_details(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
View timesheet details by ID.
Parameters
client: A Deputy client.id: The ID of the timesheet to retrieve.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Timesheets.get_details(client, 123)
# => {:ok, %{"Id" => 123, "StartTime" => "2023-01-01T09:00:00"}}
Same as get_details/2 but raises on error.
@spec pause(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Pause or unpause an employee's timesheet (take a break/finish break).
Parameters
client: A Deputy client.attrs: A map containing the timesheet details.
Timesheet parameters
intTimesheetId: ID of the timesheet to pause/unpause.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
attrs = %{intTimesheetId: 123}
Deputy.Timesheets.pause(client, attrs)
# => {:ok, %{"success" => true}}
Same as pause/2 but raises on error.
@spec query(Deputy.t(), integer() | nil, map() | nil) :: {:ok, map() | [map()]} | {:error, Deputy.Error.t()}
Search for timesheets using the resource API.
Parameters
client: A Deputy client.id: Optional. The ID of a specific timesheet to retrieve.query: Optional. A map containing search criteria.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
query = %{
search: %{id: %{field: "Id", type: "eq", data: 1}},
join: ["TimesheetObject"]
}
Deputy.Timesheets.query(client, nil, query)
# => {:ok, [%{"Id" => 1, "StartTime" => "2023-01-01T09:00:00"}]}
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Timesheets.query(client, 1, nil)
# => {:ok, %{"Id" => 1, "StartTime" => "2023-01-01T09:00:00"}}
Same as query/3 but raises on error.
@spec start(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Start an employee's timesheet (clock on).
Parameters
client: A Deputy client.attrs: A map containing the timesheet details.
Timesheet parameters
intEmployeeId: ID of the employee.intCompanyId: ID of the company/location.intOperationalUnitId: Optional. ID of the operational unit.intRosterId: Optional. ID of the roster.startTime: Optional. Start time in format "YYYY-MM-DD HH:MM:SS".
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
attrs = %{
intEmployeeId: 123,
intCompanyId: 456
}
Deputy.Timesheets.start(client, attrs)
# => {:ok, %{"Id" => 789}}
Same as start/2 but raises on error.
@spec stop(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Stop an employee's timesheet (clock off).
Parameters
client: A Deputy client.attrs: A map containing the timesheet details.
Timesheet parameters
intTimesheetId: ID of the timesheet to stop.intMealbreakMinute: Optional. Duration of meal break in minutes.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
attrs = %{
intTimesheetId: 123,
intMealbreakMinute: 30
}
Deputy.Timesheets.stop(client, attrs)
# => {:ok, %{"success" => true}}
Same as stop/2 but raises on error.