composer require jlg/php-adp-client
<?php
$config = [
'client_id' => '********-****-****-****-************',
'client_secret' => '********-****-****-****-************',
'org_name' => 'ADP Org Name',
'ssl_cert_path' => '/etc/ssl/adp/company_auth.pem',
'ssl_key_path' => '/etc/ssl/adp/company_auth.key',
'server_url' => 'https://api.adp.com/'
];
$adp = new \Jlg\ADP\Client($config);
$filter = "workers/workAssignments/assignmentStatus/statusCode/codeValue eq 'A'";
$params = [
'query' => [
'$filter' => $filter,
'$top' => 100, // amount of records to grab
'$skip' => 0 // how many records to skip.
]
];
$httpResults = $adp::getContents($adp->get('hr/v2/workers', $params));
$workers = ($httpResults) ? $httpResults->workers : [];
-
- sends a GET request to retrieve workers api meta data.
$adp->getWorkersMeta();
-
- gets a single worker based on workers AOID
- an optional select array can be passed as a secondary argument.
$adp->getWorker($aoid, $select);
-
getWorkers(array $filters = [], int $skip = 0, int $top = 100, bool $count = false, array $select = []): HttpResponse
- gets all workers, but only returns
$top
records. - You can use the
$skip
as a way of moving through all your users.
$adp->getWorkers($filters, $skip, $top, $count, $select);
- or you may need to get more than
$top
$workers = []; $filters = ["workers/workAssignments/assignmentStatus/statusCode/codeValue eq 'A'"]; // you probably want to use a filter :) $top = 100; $skip = 0; while (($results = $adp::getContents($adp->getWorkers($filters, $skip, $top))) !== null) { $workers = array_merge($workers, $results->workers); $skip += $top; } return $workers;
- gets all workers, but only returns
-
- sends a GET request to retrieve Work-Assignment api meta data.
$adp->getWorkAssignmentMeta();
-
- sends a POST request to modify a workers work assignment.
$adp->modifyWorkAssignment($params);
-
- sends a GET request to which ever ADP API endpoint you would like to use.
$adp->get($url, $requestPayload);
-
- sends a POST request to which ever ADP API endpoint you would like to use.
$adp->post($url, $requestPayload);
-
- sends an HTTP request to which ADP API endpoint specified in the
$url
parameter. $requestType
needs to be either'get'
or'put'
$adp->apiCall('get', 'hr/v2/workers', []);
- sends an HTTP request to which ADP API endpoint specified in the
-
- gets the contents from a guzzle Http Response.
$res = $adp::getContents($adp->getWorkers());
- Please refer to ADP API Documentation Explorer for additional details on request parameters and what to expect from the response.
- This is using Guzzle for the Http abstraction. You will need to call
->getBody()->getContents()
on the response from one of the methods listed above if you would like to get the contents of the ADP Api response. - If you are missing something in your config or any other type of validation, you will be met with an exception like this:
PHP Fatal error: Uncaught Jlg\ADP\Exceptions\ADPClientValidationException: [0]: Missing keys from config: server_url