# `Deputy.Timesheets`
[🔗](https://github.com/sgerrand/ex_deputy/blob/v0.4.0/lib/deputy/timesheets.ex#L1)

Functions for interacting with timesheets in Deputy.

# `get_details`

```elixir
@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

    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"}}

# `get_details!`

```elixir
@spec get_details!(Deputy.t(), integer()) :: map()
```

Same as `get_details/2` but raises on error.

# `pause`

```elixir
@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

    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}}

# `pause!`

```elixir
@spec pause!(Deputy.t(), map()) :: map()
```

Same as `pause/2` but raises on error.

# `query`

```elixir
@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

    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"}}

# `query!`

```elixir
@spec query!(Deputy.t(), integer() | nil, map() | nil) :: map() | [map()]
```

Same as `query/3` but raises on error.

# `start`

```elixir
@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

    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}}

# `start!`

```elixir
@spec start!(Deputy.t(), map()) :: map()
```

Same as `start/2` but raises on error.

# `stop`

```elixir
@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

    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}}

# `stop!`

```elixir
@spec stop!(Deputy.t(), map()) :: map()
```

Same as `stop/2` but raises on error.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
