BambooHR.Client (BambooHR v0.3.0)

View Source

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

client = BambooHR.Client.new(company_domain: "your_company", api_key: "your_api_key")
{:ok, company_info} = BambooHR.Company.get_information(client)

Summary

Functions

Makes a GET request to the BambooHR API.

Creates a new client configuration.

Makes a POST request to the BambooHR API.

Types

response()

@type response() :: {:ok, map()} | {:error, any()}

t()

@type t() :: %BambooHR.Client{
  api_key: String.t(),
  base_url: String.t(),
  company_domain: String.t(),
  http_client: module()
}

Functions

get(path, client, opts \\ [])

@spec get(String.t(), t(), keyword()) :: response()

Makes a GET request to the BambooHR API.

This function is meant to be used by resource modules.

new(opts)

@spec new(Keyword.t()) :: t()

Creates a new client configuration.

Options

  • :company_domain - Your company's subdomain
  • :api_key - Your API key
  • :base_url - Optional. Custom base URL for the API (defaults to BambooHR's standard API URL)
  • :http_client - Optional. Module that implements the HTTPClient behavior. Defaults to BambooHR.HTTPClient.Req.

Examples

iex> client = BambooHR.Client.new(company_domain: "acme", api_key: "api_key_123")
%{
  company_domain: "acme",
  api_key: "api_key_123",
  base_url: "https://api.bamboohr.com/api/gateway.php",
  http_client: BambooHR.HTTPClient.Req
}

# With custom base URL
iex> client = BambooHR.Client.new(company_domain: "acme", api_key: "api_key_123", base_url: "https://custom-api.example.com")
%{
  company_domain: "acme",
  api_key: "api_key_123",
  base_url: "https://custom-api.example.com",
  http_client: BambooHR.HTTPClient.Req
}

post(path, client, opts)

@spec post(String.t(), t(), keyword()) :: response()

Makes a POST request to the BambooHR API.

This function is meant to be used by resource modules.