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

Functions for interacting with rosters in Deputy.

# `copy`

```elixir
@spec copy(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Copy rosters from one date range to another.

## Parameters

- `client`: A Deputy client.
- `attrs`: A map containing the copy parameters.

## Copy parameters

- `strFromDate`: Start date of the source rosters in format "YYYY-MM-DD".
- `strToDate`: Start date for the destination rosters in format "YYYY-MM-DD".
- `intOperationalUnitArray`: Array of operational unit IDs to copy rosters for.
- `blnRequireErrorDetails`: Optional. Whether to return detailed error information (1 for true, 0 for false).

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> attrs = %{
    ...>   strFromDate: "2023-01-01",
    ...>   strToDate: "2023-01-08",
    ...>   intOperationalUnitArray: [1, 2],
    ...>   blnRequireErrorDetails: 1
    ...> }
    iex> Deputy.Rosters.copy(client, attrs)
    {:ok, %{"success" => true}}

# `copy!`

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

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

# `create`

```elixir
@spec create(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Create a new roster.

## Parameters

- `client`: A Deputy client.
- `attrs`: A map containing the roster details.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> attrs = %{
    ...>   intEmployeeId: 1,
    ...>   intOperationalUnitId: 2,
    ...>   intCompanyId: 3,
    ...>   dtmStartTime: "2023-01-01 09:00:00",
    ...>   dtmEndTime: "2023-01-01 17:00:00"
    ...> }
    iex> Deputy.Rosters.create(client, attrs)
    {:ok, %{"Id" => 123}}

# `create!`

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

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

# `discard`

```elixir
@spec discard(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Discard rosters.

## Parameters

- `client`: A Deputy client.
- `attrs`: A map containing the discard parameters.

## Discard parameters

- `intRosterArray`: Array of roster IDs to discard.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> attrs = %{intRosterArray: [400]}
    iex> Deputy.Rosters.discard(client, attrs)
    {:ok, %{"success" => true}}

# `discard!`

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

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

# `get`

```elixir
@spec get(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Get a specific roster by ID.

## Parameters

- `client`: A Deputy client.
- `id`: The ID of the roster to retrieve.

## Examples

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

# `get!`

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

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

# `get_available_for_swap`

```elixir
@spec get_available_for_swap(Deputy.t()) ::
  {:ok, [map()]} | {:error, Deputy.Error.t()}
```

Get rosters available for swap.

## Examples

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

# `get_available_for_swap!`

```elixir
@spec get_available_for_swap!(Deputy.t()) :: [map()]
```

Same as `get_available_for_swap/1` but raises on error.

# `get_by_date`

```elixir
@spec get_by_date(Deputy.t(), String.t()) ::
  {:ok, [map()]} | {:error, Deputy.Error.t()}
```

Get rosters for a specific date.

## Parameters

- `client`: A Deputy client.
- `date`: The date to retrieve rosters for, in format "YYYY-MM-DD".

## Examples

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

# `get_by_date!`

```elixir
@spec get_by_date!(Deputy.t(), String.t()) :: [map()]
```

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

# `get_by_date_and_location`

```elixir
@spec get_by_date_and_location(Deputy.t(), String.t(), integer()) ::
  {:ok, [map()]} | {:error, Deputy.Error.t()}
```

Get rosters for a specific date and location.

## Parameters

- `client`: A Deputy client.
- `date`: The date to retrieve rosters for, in format "YYYY-MM-DD".
- `location_id`: The ID of the location.

## Examples

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

# `get_by_date_and_location!`

```elixir
@spec get_by_date_and_location!(Deputy.t(), String.t(), integer()) :: [map()]
```

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

# `get_recommendations`

```elixir
@spec get_recommendations(Deputy.t(), integer()) ::
  {:ok, [map()]} | {:error, Deputy.Error.t()}
```

Get recommendations for a roster.

## Parameters

- `client`: A Deputy client.
- `id`: The ID of the roster to get recommendations for.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.Rosters.get_recommendations(client, 1)
    {:ok, [%{"EmployeeId" => 123, "Score" => 85}]}

# `get_recommendations!`

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

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

# `list`

```elixir
@spec list(Deputy.t()) :: {:ok, [map()]} | {:error, Deputy.Error.t()}
```

Get a list of rosters from the last 12 hours and forward 36 hours.

## Examples

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

# `list!`

```elixir
@spec list!(Deputy.t()) :: [map()]
```

Same as `list/1` but raises on error.

# `publish`

```elixir
@spec publish(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Publish rosters.

## Parameters

- `client`: A Deputy client.
- `attrs`: A map containing the publish parameters.

## Publish parameters

- `intMode`: Mode for publishing (e.g., 1).
- `blnAllLocationsMode`: Whether to publish for all locations (1 for true, 0 for false).
- `intRosterArray`: Array of roster IDs to publish.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> attrs = %{
    ...>   intMode: 1,
    ...>   blnAllLocationsMode: 1,
    ...>   intRosterArray: [400]
    ...> }
    iex> Deputy.Rosters.publish(client, attrs)
    {:ok, %{"success" => true}}

# `publish!`

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

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

---

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