Deputy.Timesheets (Deputy v0.2.1)

View Source

Functions for interacting with timesheets in Deputy.

Summary

Functions

View timesheet details by ID.

Pause or unpause an employee's timesheet (take a break/finish break).

Search for timesheets using the resource API.

Start an employee's timesheet (clock on).

Stop an employee's timesheet (clock off).

Functions

get_details(client, id)

@spec get_details(Deputy.t(), integer()) :: {:ok, map()} | {:error, any()}

View timesheet details by ID.

Parameters

  • client: A Deputy client.
  • id: The ID of the timesheet to retrieve.

Examples

iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Timesheets.get_details(client, 123)
{:ok, %{"Id" => 123, "StartTime" => "2023-01-01T09:00:00"}}

pause(client, attrs)

@spec pause(Deputy.t(), map()) :: {:ok, map()} | {:error, any()}

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

iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{intTimesheetId: 123}
iex> Deputy.Timesheets.pause(client, attrs)
{:ok, %{"success" => true}}

query(client, id, query \\ nil)

@spec query(Deputy.t(), integer() | nil, map() | nil) ::
  {:ok, map() | [map()]} | {:error, any()}

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

iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> query = %{
...>   search: %{id: %{field: "Id", type: "eq", data: 1}},
...>   join: ["TimesheetObject"]
...> }
iex> Deputy.Timesheets.query(client, nil, query)
{:ok, [%{"Id" => 1, "StartTime" => "2023-01-01T09:00:00"}]}

iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Timesheets.query(client, 1, nil)
{:ok, %{"Id" => 1, "StartTime" => "2023-01-01T09:00:00"}}

start(client, attrs)

@spec start(Deputy.t(), map()) :: {:ok, map()} | {:error, any()}

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

iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{
...>   intEmployeeId: 123,
...>   intCompanyId: 456
...> }
iex> Deputy.Timesheets.start(client, attrs)
{:ok, %{"Id" => 789}}

stop(client, attrs)

@spec stop(Deputy.t(), map()) :: {:ok, map()} | {:error, any()}

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

iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{
...>   intTimesheetId: 123,
...>   intMealbreakMinute: 30
...> }
iex> Deputy.Timesheets.stop(client, attrs)
{:ok, %{"success" => true}}