2017 © Pedro Peláez
 

library humanity-php-sdk

Humanity PHP SDK

image

shiftplanning/humanity-php-sdk

Humanity PHP SDK

  • Sunday, May 8, 2016
  • by humanity
  • Repository
  • 4 Watchers
  • 0 Stars
  • 770 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 11 Versions
  • 1 % Grown

The README.md

Humanity SDK for PHP

Installation

Install the latest version with, (*1)

$ composer require shiftplanning/humanity-php-sdk

Usage

Initialize

Make sure to loade composer autoload file., (*2)

<?php
use \Humanity\Entity\Company;
use \Humanity\Entity\Employee;
use \Humanity\Humanity;

// Load Humanity SDK for PHP via composer

$config = [
    'provider' => [
        'clientId' => '...',
        'clientSecret' => '...',
        'redirectUri' => '...',
        'scopes' => [
            Company::SCOPE_VIEW,
            Employee::SCOPE_VIEW
        ],
    ],
];

// Create new instance of humanity class
$humanity = new Humanity($config);

Obtain access token

Obtained access token will be saved for you in _SESSION variable., (*3)

// Obtain access token
$humanity->obtainAccessToken();
// Get access token instance
$accessToken = $humanity->getAccessToken();
printf('Access token: %s<br/>', $accessToken->accessToken);

Retrive logged employee data

Invoking Humanity::me() will return Employee entity instance, (*4)

$me = $humanity->me();
printf('Hello, %s<br/>', $me->display_name);

Working with entities

Retrieve data, (*5)

// Get Company repository instance
$companyRepository = $humanity->getCompanyRepository();
// Retrieve company data for current logged employee
$company = $companyRepository->get($me->company_id);
printf('Company: %s<br/>', $company->name);

// Get Employee repository instance
$employeeRepository = $humanity->getEmployeeRepository();
// Retrieve employees data for company.
$employees = $employeeRepository->getByCompany($company->company_id);

echo 'Employees: ';
echo '

    '; // Iterating employees collection foreach ($employees as $employee) { printf('
  • %s
  • ', $employee->display_name); } echo '
';

The Versions

08/05 2016

dev-master

9999999-dev

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

08/05 2016

1.1.8

1.1.8.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

02/11 2015

1.1.7

1.1.7.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

25/08 2015

1.1.6

1.1.6.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

25/08 2015

1.1.5

1.1.5.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

25/08 2015

1.1.4

1.1.4.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

28/07 2015

1.1.3

1.1.3.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

22/06 2015

1.1.2

1.1.2.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

21/06 2015

1.1.1

1.1.1.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

21/06 2015

1.1.0

1.1.0.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity

19/06 2015

1.0.0

1.0.0.0

Humanity PHP SDK

  Sources   Download

MIT

The Requires

 

authorization oauth sdk client oauth2 humanity