Allows interaction with the Deputy API (Version 1) using an object based interface that abstracts sending and receiving content from the REST API.
View the documentation on how to use the wrapper.
Use the CLI tool to explore the wrapper.
This package can be installed via Composer:
composer require communityds/deputy-api-wrapper
By default, this package uses the Guzzle library to send the API requests. Install the package via Composer:
composer require guzzlehttp/guzzle ^6.0
See the HTTP Clients documentation to see what other libraries can be used instead.
Create a singleton instance of the wrapper and provide at a minimum the authentication and target component configurations:
use CommunityDS\Deputy\Api\Wrapper;
$wrapper = Wrapper::setInstance(
[
'auth' => [
'class' => 'CommunityDS\Deputy\Api\Adapter\Config\PermanentToken',
'token' => '<YOUR_OAUTH_TOKEN_HERE>',
],
'target' => [
'class' => 'CommunityDS\Deputy\Api\Adapter\Config\TargetConfig',
'domain' => '<YOUR_DOMAIN_HERE>',
],
]
);
Use the helper functions to get the records you are after. The example below returns all of today's schedules/rosters:
$today = mktime(0, 0, 0);
$shifts = $wrapper->findRosters()
->andWhere(['>=', 'startTime', $today])
->andWhere(['<', 'endTime', strtotime('+1 day', $today)])
->joinWith('employeeObject')
->joinWith('operationalUnitObject')
->all();
foreach ($shifts as $shift) {
echo date('h:ia', $shift->startTime)
. ' to ' . date('h:ia', $shift->endTime)
. ' for ' . $shift->employeeObject->displayName
. ' at ' . $shift->operationalUnitObject->displayName
. PHP_EOL;
}
More details and examples can be found in the documentation.