pimssas/pims-api-client-php

Simple php client for Pims-Api

1.0.0 2018-04-17 15:31 UTC

README

Build Status

Pims Api Client

Simple php client for Pims-Api (Documentation)

Installation

composer require pimssas/pims-api-client-php:"dev-master"

Usage

We will use Pims-api as an example API endpoint.

Create the client

At a first step, we setup a Client instance.

use Pims\Api\Client;

try {
    $client = new Client('https://demo.pims.io/api/v1', 'user', 'password');
} catch (\Exception $e) {
    echo $e->getMessage();
}

Get One Events

$client = new Client('https://demo.pims.io/api/v1', 'user', 'password'); 
 
try {  
    $data = $client->getOne('/events', 2127);
} catch (ClientException $e) {
    echo $e->getMessage();
}

Get All Events

$client = new Client('https://demo.pims.io/api/v1', 'user', 'password'); 
 
try {
    $data = $client->getAll('/events');
} catch (ClientException $e) {
    echo $e->getMessage();
}

If there is a second page with more documents, we can follow the next link.

if ($data->hasLink('next')) {
    $nextResource = $data->getFirstLink('next')->get();
}

License

Copyright (c) 2010-2018 Pims SAS. Released under the MIT License.