Deputy.Rosters (Deputy v0.2.1)
View SourceFunctions for interacting with rosters in Deputy.
Summary
Functions
Copy rosters from one date range to another.
Create a new roster.
Discard rosters.
Get a specific roster by ID.
Get rosters available for swap.
Get rosters for a specific date.
Get rosters for a specific date and location.
Get recommendations for a roster.
Get a list of rosters from the last 12 hours and forward 36 hours.
Publish rosters.
Functions
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}}
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}}
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}}
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 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 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"}]}
@spec get_by_date_and_location(Deputy.t(), String.t(), integer()) :: {:ok, [map()]} | {:error, any()}
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 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 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"}]}
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}}