BambooHR PHP SDK


  • An overview of this library/SDK. What it’s used for, etc.
  • Disclaimers and waivers of liability and disassociation
  • Links to similar packages (e.g. Laravel package that implements this SDK)
  • Link to BambooHR and the BambooHR API docs

Installation


Via Composer

$ composer require jeffreyhyer/bamboohr


Or add the following to your composer.json file:

{
    "require": {
        "jeffreyhyer/bamboohr": "^0.1.2"
    }
}


Then execute the following command to install the package:

$ composer update

Usage


From within your PHP application you can access the BambooHR API with just a couple lines:

<?php

require "./vendor/autoload.php";

$bamboo = new BambooHR\BambooHR("BAMBOO COMPANY SUBDOMAIN", "BAMBOO API TOKEN");

// Get the employee directory
$employees = $bamboo->employees->directory();

API Reference


Employees


See the BambooHR documentation relating to employees here: https://www.bamboohr.com/api/documentation/employees.php

Can be accessed via any of the following aliases:

  • employee
  • employees

me($fields = null)


Returns the current user as determined by the API key used for the request.

This is an alias/shortcut for calling: $bamboo->employees->byId(0, $fields)

Request

<?php

// Defaults to all fields
$bamboo->employees->me();

// -OR-

// Specify which fields to return
$bamboo->employees->me(['firstName', 'lastName']);

Response

<?php

BambooHR\Api\Response Object
(
    [code:protected] => 200
    [reason:protected] => OK
    [errors:protected] => Array
        (
        )

    [response:protected] => stdClass Object
        (
            [id] => 123
            [address1] => 123 North Main St
            [address2] => 
            [age] => 25
            [bestEmail] => test@yourcompany.com
            [birthday] => 12-25
            [city] => Lindon
            [country] => 
            [dateOfBirth] => 1901-01-01
            [department] => 
            [division] => 
            [eeo] => 
            [employeeNumber] => 123456
            [employmentHistoryStatus] => Full-Time
            [ethnicity] => 
            [flsaCode] => Exempt
            [firstName] => John
            [fullName1] => John Doe
            [fullName2] => Doe, John
            [fullName3] => Doe, John B 
            [fullName4] => Doe, John B
            [fullName5] => John B Doe
            [displayName] => John Doe
            [gender] => Male
            [hireDate] => 2000-01-01
            [originalHireDate] => 0000-00-00
            [homeEmail] => john@yourcompany.com
            [homePhone] => 555-123-4567
            [jobTitle] => Job Title
            [lastChanged] => 2001-01-01T12:34:56+00:00
            [lastName] => Doe
            [location] => Utah
            [maritalStatus] => Married
            [middleName] => B
            [mobilePhone] => 
            [payChangeReason] => 
            [payGroupId] => 
            [payRate] => 123456.00 USD
            [payRateEffectiveDate] => 2000-01-01
            [payType] => Salary
            [payPer] => Year
            [payPeriod] => Every other week
            [preferredName] => 
            [ssn] => 
            [state] => UT
            [stateCode] => UT
            [status] => Active
            [supervisor] => Jane Doe
            [supervisorId] => 123457
            [supervisorEId] => 124
            [terminationDate] => 0000-00-00
            [workEmail] => 
            [workPhone] => 
            [workPhonePlusExtension] => 
            [workPhoneExtension] => 
            [zipcode] => 12345
            [isPhotoUploaded] => false
        )

)

byId($id, $fields = null)


Returns the user identified by $id

Request

<?php

// Defaults to all fields
$bamboo->employees->byId(123);

// -OR-

// Specify which fields to return
$bamboo->employees->byId(123, ['firstName', 'lastName']);

Response

<?php

BambooHR\Api\Response Object
(
    [code:protected] => 200
    [reason:protected] => OK
    [errors:protected] => Array
        (
        )

    [response:protected] => stdClass Object
        (
            [id] => 123
            [address1] => 123 North Main St
            [address2] => 
            [age] => 25
            [bestEmail] => test@yourcompany.com
            [birthday] => 12-25
            [city] => Lindon
            [country] => 
            [dateOfBirth] => 1901-01-01
            [department] => 
            [division] => 
            [eeo] => 
            [employeeNumber] => 123456
            [employmentHistoryStatus] => Full-Time
            [ethnicity] => 
            [flsaCode] => Exempt
            [firstName] => John
            [fullName1] => John Doe
            [fullName2] => Doe, John
            [fullName3] => Doe, John B 
            [fullName4] => Doe, John B
            [fullName5] => John B Doe
            [displayName] => John Doe
            [gender] => Male
            [hireDate] => 2000-01-01
            [originalHireDate] => 0000-00-00
            [homeEmail] => john@yourcompany.com
            [homePhone] => 555-123-4567
            [jobTitle] => Job Title
            [lastChanged] => 2001-01-01T12:34:56+00:00
            [lastName] => Doe
            [location] => Utah
            [maritalStatus] => Married
            [middleName] => B
            [mobilePhone] => 
            [payChangeReason] => 
            [payGroupId] => 
            [payRate] => 123456.00 USD
            [payRateEffectiveDate] => 2000-01-01
            [payType] => Salary
            [payPer] => Year
            [payPeriod] => Every other week
            [preferredName] => 
            [ssn] => 
            [state] => UT
            [stateCode] => UT
            [status] => Active
            [supervisor] => Jane Doe
            [supervisorId] => 123457
            [supervisorEId] => 124
            [terminationDate] => 0000-00-00
            [workEmail] => 
            [workPhone] => 
            [workPhonePlusExtension] => 
            [workPhoneExtension] => 
            [zipcode] => 12345
            [isPhotoUploaded] => false
        )

)

directory()


Returns the employee directory

Request

<?php

$bamboo->employees->directory();

Response

<?php

// TODO
BambooHR\Api\Response Object
(
    [code:protected] => 200
    [reason:protected] => OK
    [errors:protected] => Array
        (
        )

    [response:protected] => stdClass Object
        (
        )

)

add(array $data)


Add a new employee

See: https://www.bamboohr.com/api/documentation/employees.php#addEmployee

Parameters

Parameter Type Required Description

$data

Array

Data describing the employee to be created. firstName and lastName are the only required fields.

Request

<?php

$data = [
    'firstName' => 'John',
    'lastName'  => 'Doe'
];

$bamboo->employees->add($data);

Response

<?php

// TODO
BambooHR\Api\Response Object
(
    [code:protected] => 200
    [reason:protected] => OK
    [errors:protected] => Array
        (
        )

    [response:protected] => stdClass Object
        (
        )

)

update(string $id, array $data)


Edit/update an existing employee

See: https://www.bamboohr.com/api/documentation/employees.php#updateEmployee

Parameters

Parameter Type Required Description

$id

Mixed (String)

The employee ID to update

$data

Array

The data to set on the employee

Request

<?php

$data = [
    'firstName' => 'Joe',
    'lastName'  => 'Schmo',
];

$bamboo->employees->update('123', $data);

Response

<?php

// TODO
BambooHR\Api\Response Object
(
    [code:protected] => 200
    [reason:protected] => OK
    [errors:protected] => Array
        (
        )

    [response:protected] => stdClass Object
        (
        )

)

files(string $id)


Get a list of files associated with the given employee

See: https://www.bamboohr.com/api/documentation/employees.php#listEmployeeFiles

Parameters

Parameter Type Required Description

$id

Mixed (String)

An employee ID

Request

<?php

$bamboo->employee->files(123);

Response

<?php

// TODO
BambooHR\Api\Response Object
(
    [code:protected] => 200
    [reason:protected] => OK
    [errors:protected] => Array
        (
        )

    [response:protected] => stdClass Object
        (
        )

)