2017 © Pedro Peláez
 

library validic

Wrapper for the Validic API

image

validic/validic

Wrapper for the Validic API

  • Thursday, March 1, 2018
  • by gotun
  • Repository
  • 9 Watchers
  • 0 Stars
  • 455 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Validic PHP Wrapper

The Validic PHP Wrapper is an easy to use wrapper with many customizable options to help you get started with Validic. The Client class performs retries and returns the response and errors from Validic. The User class has many helper functions to make managing Validic users easier., (*1)

This project uses GuzzleHttp. You may use Composer to handle your dependencies., (*2)

Installation with Composer

Add the Validic/Validic package to your composer.json file., (*3)

{
    "require": {
        "validic/validic": "*"
    }
}

Installation without Composer

If you are not using composer, you must install GuzzleHTTP manually. Then copy the src folder of the Validic PHP wrapper and include the autoload.php file., (*4)

Basic Client Setup

You can configure a new client to have many default options that can be overriden by individual requests., (*5)

require __DIR__ . '/vendor/autoload.php';

use Validic\Client;

/**
 * @see Validic\ClientOptions for all options
 */
$config = [
    'organization_id' => 'ORGANIZATION_ID',
    'access_token' => 'ORGANIZATION_ACCESS_TOKEN'
];

$validic_client = new Client($config);

Routine data retrieval example

Any buildAndSend function can use options from Validic\BuildRequestOptions and SendRequest options. Using these options you can specify query parameters, a.k.a. filters, a user's id, or headers., (*6)

use Validic\Endpoint\RoutineEndpoint;
use Validic\Filter\StartDateFilter;

/**
 * @see Validic\Endpoint\Endpoints for all available endpoints
 * @see Validic\BuildRequestOptions for all available build options and
 * references to available filters and headers
 * @see Validic\SendRequestOptions for all available send options
 */
$response = $validic_client->buildAndSendRequest(
    new RoutineEndpoint(),
    [
        'filters' => [
            new StartDateFilter(date('Y-m-d'))
        ]
    ]
);

if ( $response->succeeded() ) {

    // save the data
    $routine_json = $response->getJson();

} else {

    // you can save the request and try again later
    $request = serialize($response->getRequest());

}

Paginated routine data retrieval example

$request = $validic_client->buildRequest(
    new RoutineEndpoint(),
    [
        'filters' => [
            new StartDateFilter(date('Y-m-d'))
        ]
    ]
);

do {

    $response = $validic_client->sendRequest($request);

    if ( $response->succeeded() ) {

        // save the data
        // the json response will contain the entire json response including
        // the summary
        $routine_json = $response->getJson();

    } else {

        // you can save the request and try again later
        $request = serialize($response->getRequest());

    }

} while ($request = $response->getNextPageRequest());

Create User Example

use Validic\User\User;
use Validic\User\UserOptions;

$user = new User([
    'uid' => 'phpWrapperTestUser'
]);

$response = $user->buildAndSendRequestCreate($validic_client);

if ( $response->succeeded() ) {

    // user's authentication token and validic id
    $validic_id = $user->validic_id;
    $authentication_token = $user->authentication_token;

} else {

    // you can save the request and try again later
    $request = serialize($response->getRequest());  

}

The Versions

01/03 2018

dev-master

9999999-dev https://github.com/Validic/ValidicPHP

Wrapper for the Validic API

  Sources   Download

Apache

The Requires

 

wrapper validic

24/10 2016

1.0.0

1.0.0.0 https://github.com/Validic/ValidicPHP

Wrapper for the Validic API

  Sources   Download

Apache

The Requires

 

wrapper validic