Functions for interacting with employees in Deputy.
Summary
Functions
Post a journal entry for an employee.
Same as add_journal/2 but raises on error.
Add leave for an employee.
Same as add_leave/2 but raises on error.
Add a location to an employee.
Same as add_location/3 but raises on error.
Add unavailability for an employee.
Same as add_unavailability/2 but raises on error.
Add a new employee.
Same as create/2 but raises on error.
Delete an employee's account in Deputy.
Same as delete/2 but raises on error.
Get employee by ID.
Same as get/2 but raises on error.
Get agreed hours for an employee.
Same as get_agreed_hours/2 but raises on error.
Get an employee's leave.
Same as get_leave/2 but raises on error.
Get an employee's current shift information.
Same as get_shift_info/2 but raises on error.
Get unavailability details for an employee.
Same as get_unavailability/2 but raises on error.
Invite an employee to Deputy.
Same as invite/2 but raises on error.
Get all employees.
Same as list/1 but raises on error.
Reactivate a terminated employee.
Same as reactivate/2 but raises on error.
Remove a location from an employee.
Same as remove_location/3 but raises on error.
Set award for an employee.
Same as set_award/3 but raises on error.
Terminate an employee.
Same as terminate/2 but raises on error.
Update an existing employee.
Same as update/3 but raises on error.
Functions
@spec add_journal(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Post a journal entry for an employee.
Parameters
client: A Deputy client.attrs: A map containing the journal details.
Journal parameters
strComment: The journal comment.intEmployeeId: ID of the employee.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.add_journal(client, %{strComment: "Employee performed well today", intEmployeeId: 1})
{:ok, %{"Id" => 123}}
Same as add_journal/2 but raises on error.
@spec add_leave(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Add leave for an employee.
Parameters
client: A Deputy client.attrs: A map containing the leave details.
Leave parameters
Status: Status code for the leave (e.g., 1 for approved).Employee: ID of the employee.DateStart: Start date in format "YYYY/MM/DD".DateEnd: End date in format "YYYY/MM/DD".ApprovalComment: Optional. Comment for the leave approval.ActionOverlappingRosters: How to handle overlapping rosters (e.g., 0 to keep).
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{
...> Status: 1,
...> Employee: 1,
...> DateStart: "2023/01/01",
...> DateEnd: "2023/01/05",
...> ApprovalComment: "Vacation",
...> ActionOverlappingRosters: 0
...> }
iex> Deputy.Employees.add_leave(client, attrs)
{:ok, %{"Id" => 123}}
Same as add_leave/2 but raises on error.
@spec add_location(Deputy.t(), integer(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Add a location to an employee.
Parameters
client: A Deputy client.employee_id: The ID of the employee.company_id: The ID of the location/company to associate with the employee.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.add_location(client, 1, 2)
{:ok, %{"success" => true}}
Same as add_location/3 but raises on error.
@spec create(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Add a new employee.
Parameters
client: A Deputy client.attrs: A map containing the new employee details.
Employee parameters
strFirstName: Employee's first name.strLastName: Employee's last name.intCompanyId: ID of the company/location where the employee works.intGender: Integer representing gender (e.g., 1 for male, 2 for female).strCountryCode: Country code (e.g., "US").strDob: Date of birth in format "YYYY-MM-DD".strStartDate: Employment start date in format "YYYY-MM-DD".strMobilePhone: Mobile phone number.strPayrollId: Optional. Payroll ID.fltWeekDayRate: Optional. Weekday pay rate.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> attrs = %{
...> strFirstName: "John",
...> strLastName: "Doe",
...> intCompanyId: 1,
...> intGender: 1,
...> strCountryCode: "US",
...> strDob: "1980-01-01",
...> strStartDate: "2023-01-01",
...> strMobilePhone: "5551234567"
...> }
iex> Deputy.Employees.create(client, attrs)
{:ok, %{"Id" => 123}}
Same as create/2 but raises on error.
@spec delete(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Delete an employee's account in Deputy.
Parameters
client: A Deputy client.id: The ID of the employee to delete.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.delete(client, 1)
{:ok, %{"success" => true}}
Same as delete/2 but raises on error.
@spec get(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Get employee by ID.
Parameters
client: A Deputy client.id: The ID of the employee to retrieve.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.get(client, 1)
{:ok, %{"Id" => 1, "FirstName" => "John", "LastName" => "Doe"}}
Same as get/2 but raises on error.
@spec get_agreed_hours(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Get agreed hours for an employee.
Parameters
client: A Deputy client.id: The ID of the employee.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.get_agreed_hours(client, 1)
{:ok, %{"AgreedHours" => 40.0}}
Same as get_agreed_hours/2 but raises on error.
@spec get_leave(Deputy.t(), integer()) :: {:ok, [map()]} | {:error, Deputy.Error.t()}
Get an employee's leave.
Parameters
client: A Deputy client.id: The ID of the employee.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.get_leave(client, 1)
{:ok, [%{"Id" => 123, "DateStart" => "2023-01-01", "DateEnd" => "2023-01-05"}]}
Same as get_leave/2 but raises on error.
@spec get_shift_info(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Get an employee's current shift information.
Parameters
client: A Deputy client.id: The ID of the employee.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.get_shift_info(client, 1)
{:ok, %{"Status" => "On Shift", "RosterID" => 123}}
Same as get_shift_info/2 but raises on error.
@spec invite(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Invite an employee to Deputy.
Parameters
client: A Deputy client.id: The ID of the employee to invite.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.invite(client, 1)
{:ok, %{"success" => true}}
Same as invite/2 but raises on error.
@spec list(Deputy.t()) :: {:ok, [map()]} | {:error, Deputy.Error.t()}
Get all employees.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.list(client)
{:ok, [%{"Id" => 1, "FirstName" => "John", "LastName" => "Doe"}]}
Same as list/1 but raises on error.
@spec reactivate(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Reactivate a terminated employee.
Parameters
client: A Deputy client.id: The ID of the employee to reactivate.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.reactivate(client, 1)
{:ok, %{"success" => true}}
Same as reactivate/2 but raises on error.
@spec remove_location(Deputy.t(), integer(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Remove a location from an employee.
Parameters
client: A Deputy client.employee_id: The ID of the employee.company_id: The ID of the location/company to remove from the employee.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.remove_location(client, 1, 2)
{:ok, %{"success" => true}}
Same as remove_location/3 but raises on error.
@spec set_award(Deputy.t(), integer(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Set award for an employee.
Parameters
client: A Deputy client.id: The ID of the employee.attrs: A map containing the award details.
Award parameters
strCountryCode: Country code (e.g., "au").strAwardCode: Award code.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.set_award(client, 1, %{strCountryCode: "au", strAwardCode: "casual-2021-11-01-aea-2"})
{:ok, %{"success" => true}}
Same as set_award/3 but raises on error.
@spec terminate(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Terminate an employee.
Parameters
client: A Deputy client.id: The ID of the employee to terminate.
Examples
iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
iex> Deputy.Employees.terminate(client, 1)
{:ok, %{"success" => true}}
Same as terminate/2 but raises on error.
@spec update(Deputy.t(), integer(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Update an existing employee.
Parameters
client: A Deputy client.id: The ID of the employee 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> Deputy.Employees.update(client, 1, %{Phone: "5559876543"})
{:ok, %{"success" => true}}
Same as update/3 but raises on error.