View Source BambooHR.Client (bamboo_hr v0.1.0)
Client for interacting with the BambooHR API.
Configuration
To use this client, you'll need information from BambooHR:
- Your company's subdomain
- An API key
Usage
config = BambooHR.Client.new("your_company", "your_api_key")
{:ok, company_info} = BambooHR.Client.get_company_information(config)
Summary
Functions
Adds a new employee.
Records a clock-in event for an employee.
Records a clock-out event for an employee.
Retrieves company EINs (Employer Identification Numbers).
Retrieves company information.
Retrieves information about a specific employee.
Retrieves the company's employee directory.
Retrieves timesheet entries within a specified date range.
Creates a new client configuration.
Stores timesheet clock entries for employees.
Updates information for an existing employee.
Types
Functions
Adds a new employee.
Parameters
config
- Client configurationemployee_data
- Map containing the employee information (firstName and lastName are required)
Examples
iex> employee_data = %{"firstName" => "Jane", "lastName" => "Smith"}
iex> BambooHR.Client.add_employee(config, employee_data)
{:ok, %{"id" => 124}}
Records a clock-in event for an employee.
Parameters
config
- Client configurationemployee_id
- The ID of the employee to clock inclock_data
- Map containing clock-in details (date, start time, timezone, etc.)
Examples
iex> clock_data = %{
...> "date" => "2024-01-15",
...> "start" => "09:00",
...> "timezone" => "America/New_York"
...> }
iex> BambooHR.Client.clock_in_employee(config, 123, clock_data)
{:ok, %{"message" => "Successfully clocked in"}}
Records a clock-out event for an employee.
Parameters
config
- Client configurationemployee_id
- The ID of the employee to clock outclock_data
- Map containing clock-out details (date, end time, timezone)
Examples
iex> clock_data = %{
...> "date" => "2024-01-15",
...> "end" => "17:00",
...> "timezone" => "America/New_York"
...> }
iex> BambooHR.Client.clock_out_employee(config, 123, clock_data)
{:ok, %{"message" => "Successfully clocked out"}}
Retrieves company EINs (Employer Identification Numbers).
Returns a list of EINs associated with the company.
Examples
iex> BambooHR.Client.get_company_eins(config)
{:ok, %{
"eins" => [
%{"ein" => "12-3456789", "name" => "Acme Corp"},
%{"ein" => "98-7654321", "name" => "Acme Subsidiary"}
]
}}
Retrieves company information.
Returns basic company details including name, address, and employee count.
Examples
iex> BambooHR.Client.get_company_information(config)
{:ok, %{
"name" => "Acme Corp",
"employeeCount" => 100,
"city" => "San Francisco"
}}
Retrieves information about a specific employee.
Parameters
config
- Client configurationemployee_id
- The ID of the employee to retrievefields
- List of field names to retrieve (e.g., ["firstName", "lastName", "jobTitle"])
Examples
iex> BambooHR.Client.get_employee(config, 123, ["firstName", "lastName", "jobTitle"])
{:ok, %{
"firstName" => "John",
"lastName" => "Doe",
"jobTitle" => "Software Engineer"
}}
Retrieves the company's employee directory.
Returns a list of all employees with basic information like name and contact details.
Examples
iex> BambooHR.Client.get_employee_directory(config)
{:ok, %{
"employees" => [
%{
"id" => 123,
"displayName" => "John Doe",
"jobTitle" => "Developer",
"workEmail" => "john@example.com"
}
]
}}
Retrieves timesheet entries within a specified date range.
Parameters
config
- Client configurationparams
- Map containing query parameters (start, end dates, and optional employee IDs)
Examples
iex> params = %{
...> "start" => "2024-01-01",
...> "end" => "2024-01-31",
...> "employeeIds" => "123,124"
...> }
iex> BambooHR.Client.get_timesheet_entries(config, params)
{:ok, %{
"entries" => [
%{
"id" => "1",
"employeeId" => "123",
"date" => "2024-01-15",
"hours" => 8.0
}
]
}}
Creates a new client configuration.
Parameters
company_domain
- Your company's subdomainapi_key
- Your API keybase_url
- Optional custom base URL for the API (defaults to BambooHR's standard API URL)
Examples
iex> config = BambooHR.Client.new("acme", "api_key_123")
%{
company_domain: "acme",
api_key: "api_key_123",
base_url: "https://api.bamboohr.com/api/gateway.php"
}
# With custom base URL
iex> config = BambooHR.Client.new("acme", "api_key_123", "https://custom-api.example.com")
%{
company_domain: "acme",
api_key: "api_key_123",
base_url: "https://custom-api.example.com"
}
Stores timesheet clock entries for employees.
Parameters
config
- Client configurationentries
- List of clock entry maps containing employee ID, date, start and end times
Examples
iex> entries = [
...> %{
...> "employeeId" => "123",
...> "date" => "2024-01-15",
...> "start" => "09:00:00",
...> "end" => "17:00:00"
...> }
...> ]
iex> BambooHR.Client.store_timesheet_clock_entries(config, entries)
{:ok, %{"message" => "Entries stored successfully"}}
Updates information for an existing employee.
Parameters
config
- Client configurationemployee_id
- The ID of the employee to updateemployee_data
- Map containing the updated employee information
Examples
iex> update_data = %{"firstName" => "Jane", "lastName" => "Smith-Jones"}
iex> BambooHR.Client.update_employee(config, 124, update_data)
{:ok, %{}}