Functions for interacting with departments (operational units) in Deputy.
Summary
Functions
Create a department (operational unit).
Same as create/2 but raises on error.
Create multiple departments.
Same as create_multiple/2 but raises on error.
Delete an operational unit (department).
Same as delete/2 but raises on error.
Get all operational units (departments).
Same as list/1 but raises on error.
Retrieve preferred employees for a specific area/department.
Same as query/2 but raises on error.
Update an operational unit (department).
Same as update/3 but raises on error.
Functions
@spec create(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Create a department (operational unit).
Parameters
client: A Deputy client.attrs: A map containing the new department details.
Department parameters
intCompanyId: ID of the company/location.strOpunitName: Name of the department.strAddress: Address of the department.strExportName: Optional. Name to use for exports.intSortOrder: Optional. Sort order.intOpunitType: Type of operational unit.LocationId: Optional. ID of the location.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{
...> intCompanyId: 1,
...> strOpunitName: "Sales",
...> strAddress: "123 Main St",
...> intOpunitType: 1
...> }
iex> Deputy.Departments.create(client, attrs)
{:ok, %{"Id" => 123}}
Same as create/2 but raises on error.
@spec create_multiple(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Create multiple departments.
Parameters
client: A Deputy client.attrs: A map containing the array of departments to create.
Parameters
arrArea: Array of department objects.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{
...> arrArea: [
...> %{
...> intCompanyId: 1,
...> strOpunitName: "Sales",
...> strAddress: "123 Main St",
...> intOpunitType: 1
...> },
...> %{
...> intCompanyId: 1,
...> strOpunitName: "Marketing",
...> strAddress: "123 Main St",
...> intOpunitType: 1
...> }
...> ]
...> }
iex> Deputy.Departments.create_multiple(client, attrs)
{:ok, %{"success" => true}}
Same as create_multiple/2 but raises on error.
@spec delete(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Delete an operational unit (department).
Parameters
client: A Deputy client.id: The ID of the department to delete.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Departments.delete(client, 1)
{:ok, %{"success" => true}}
Same as delete/2 but raises on error.
@spec list(Deputy.t()) :: {:ok, [map()]} | {:error, Deputy.Error.t()}
Get all operational units (departments).
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Departments.list(client)
{:ok, [%{"Id" => 1, "OpunitName" => "Sales"}]}
Same as list/1 but raises on error.
@spec query(Deputy.t(), map()) :: {:ok, [map()]} | {:error, Deputy.Error.t()}
Retrieve preferred employees for a specific area/department.
Parameters
client: A Deputy client.query: A map containing the search query.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> query = %{
...> join: [],
...> assoc: ["RosterEmployeeOperationalUnit"],
...> search: %{id: %{field: "Id", type: "eq", data: 1}}
...> }
iex> Deputy.Departments.query(client, query)
{:ok, [%{"Id" => 1, "Employees" => [%{"Id" => 123, "FirstName" => "John"}]}]}
Same as query/2 but raises on error.
@spec update(Deputy.t(), integer(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Update an operational unit (department).
Parameters
client: A Deputy client.id: The ID of the department to update.attrs: A map containing the fields to update.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{
...> intCompanyId: 12,
...> strOpunitName: "Updated Department Name"
...> }
iex> Deputy.Departments.update(client, 20, attrs)
{:ok, %{"success" => true}}
Same as update/3 but raises on error.