https://github.com/communityds/deputy-api-wrapper
PHP library that abstracts interactions with the Deputy API.
https://github.com/communityds/deputy-api-wrapper
deputy deputy-api php
Last synced: 6 months ago
JSON representation
PHP library that abstracts interactions with the Deputy API.
- Host: GitHub
- URL: https://github.com/communityds/deputy-api-wrapper
- Owner: communityds
- License: mit
- Created: 2019-05-22T04:00:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-13T01:20:14.000Z (over 1 year ago)
- Last Synced: 2025-10-05T10:32:18.337Z (9 months ago)
- Topics: deputy, deputy-api, php
- Language: PHP
- Homepage:
- Size: 198 KB
- Stars: 5
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Deputy API Wrapper
[](https://packagist.org/packages/communityds/deputy-api-wrapper)
[](https://packagist.org/packages/communityds/deputy-api-wrapper)

[](LICENSE)
Allows interaction with the [Deputy API (Version 1)](https://www.deputy.com/api-doc/Welcome) using an object based interface that abstracts sending and receiving content from the REST API.
[View the documentation](docs/index.md) on how to use the wrapper.
[Use the CLI tool](https://github.com/communityds/deputy-api-console) to explore the wrapper.
## Installation
This package can be installed via Composer:
```bash
composer require communityds/deputy-api-wrapper
```
By default, this package uses the Guzzle library to send the API requests.
Install the package via Composer:
```bash
composer require guzzlehttp/guzzle ^6.0
```
See the [HTTP Clients documentation](docs/http_clients.md) to see what other libraries can be used instead.
## Usage
Create a singleton instance of the wrapper and provide at a minimum the authentication and target component configurations:
```php
use CommunityDS\Deputy\Api\Wrapper;
$wrapper = Wrapper::setInstance(
[
'auth' => [
'class' => 'CommunityDS\Deputy\Api\Adapter\Config\PermanentToken',
'token' => '',
],
'target' => [
'class' => 'CommunityDS\Deputy\Api\Adapter\Config\TargetConfig',
'domain' => '',
],
]
);
```
Use the [helper functions](docs/resources.md) to get the records you are after.
The example below returns all of today's schedules/rosters:
```php
$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](docs/index.md).