Deputy.Rosters (Deputy v0.5.0)

Copy Markdown View Source

Functions for interacting with rosters in Deputy.

Summary

Functions

Copy rosters from one date range to another.

Same as copy/2 but raises on error.

Create a new roster.

Same as create/2 but raises on error.

Discard rosters.

Same as discard/2 but raises on error.

Get a specific roster by ID.

Same as get/2 but raises on error.

Get rosters available for swap.

Get rosters for a specific date.

Same as get_by_date/2 but raises on error.

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.

Same as list/1 but raises on error.

Publish rosters.

Same as publish/2 but raises on error.

Functions

copy(client, attrs)

@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

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

copy!(client, attrs)

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

Same as copy/2 but raises on error.

create(client, attrs)

@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

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

create!(client, attrs)

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

Same as create/2 but raises on error.

discard(client, attrs)

@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

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

discard!(client, attrs)

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

Same as discard/2 but raises on error.

get(client, id)

@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

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

get!(client, id)

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

Same as get/2 but raises on error.

get_available_for_swap(client)

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

Get rosters available for swap.

Examples

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

get_available_for_swap!(client)

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

Same as get_available_for_swap/1 but raises on error.

get_by_date(client, date)

@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

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

get_by_date!(client, date)

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

Same as get_by_date/2 but raises on error.

get_by_date_and_location(client, date, location_id)

@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

client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
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!(client, date, location_id)

@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(client, id)

@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

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

get_recommendations!(client, id)

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

Same as get_recommendations/2 but raises on error.

list(client)

@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

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

list!(client)

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

Same as list/1 but raises on error.

publish(client, attrs)

@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

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

publish!(client, attrs)

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

Same as publish/2 but raises on error.