Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 2.34 KB

README.md

File metadata and controls

50 lines (37 loc) · 2.34 KB

Simple PHP ADP Client

Latest Stable Version Total Downloads License

Getting started

composer require jlg/php-adp-client

Basic usage

<?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 =  json_decode($adp->get('hr/v2/workers', $params));
$workers = ($httpResults) ? $httpResults->workers : [];

Methods

  • $adp->get($url, $requestPayload);: sends a GET request to which ever ADP API endpoint you would like to use.
  • $adp->post($url, $requestPayload);: sends a POST request to which ever ADP API endpoint you would like to use.
  • $adp->apiCall($requestType, $url, $requestPayload);: sends an HTTP request to which ADP API endpoint specified in the $url parameter.

Additional Information

  • 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