PHP code example of communityds / deputy-api-wrapper

1. Go to this page and download the library: Download communityds/deputy-api-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

communityds / deputy-api-wrapper example snippets


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>',
        ],
    ]
);

$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;
}