Deputy.Employees (Deputy v0.2.1)
View SourceFunctions for interacting with employees in Deputy.
Summary
Functions
Post a journal entry for an employee.
Add leave for an employee.
Add a location to an employee.
Add unavailability for an employee.
Add a new employee.
Delete an employee's account in Deputy.
Get employee by ID.
Get agreed hours for an employee.
Get an employee's leave.
Get an employee's current shift information.
Get unavailability details for an employee.
Invite an employee to Deputy.
Get all employees.
Reactivate a terminated employee.
Remove a location from an employee.
Set award for an employee.
Terminate an employee.
Update an existing employee.
Functions
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}}
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}}
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}}
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}}
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}}
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"}}
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}}
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"}]}
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}}
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}}
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"}]}
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}}
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}}
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}}
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}}
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}}