amara/onehydra

A library for working with the OneHydra API

v0.4.1 2017-12-08 14:12 UTC

This package is not auto-updated.

Last update: 2024-12-17 19:19:22 UTC


README

Build Status Coverage Status

Purpose

amara/onehydra is a library for working with the OneHydra API from PHP, it's still in development so will change often.

Installation

Use composer:

composer require amara/onehydra

Example usage

The library should be extensible for you:

use Amara\OneHydra\Api;
use Amara\OneHydra\Http\HttpRequestBuilder;
use Amara\OneHydra\Http\Transport\GuzzleTransport;
use Amara\OneHydra\ResultBuilder\ResultBuilderEngine;
use GuzzleHttp\Client;

$isUat = false;
$authToken = 'your auth token';

// Use the standard request builder
$httpRequestBuilder = new HttpRequestBuilder($isUat, $authToken);

// Create a Guzzle transport, in UAT you'll need to ignore the OneHydra SSL cert
$guzzleClient = new Client();
$transport = new GuzzleTransport($guzzleClient);

// Create the result builder engine, which will create result objects 
// for our requests
$resultBuilderEngine = new ResultBuilderEngine();

$api = new Api($httpRequestBuilder, $transport, $resultBuilderEngine);

Once we have the API, the interface makes it easy to work with:

$pagesResult = $api->getPagesResult();
    
// Print the urls of the pages we will need to fetch details for
foreach ($pagesResult->getPageUrls() as $pageUrl) {
    echo $pageUrl;
}

We can then fetch the details for a particular page:

$pageResult = $api->getPageResult('/my/page');
$pageLinks = $pageResult->getPage()->getLinks();

Versioning

The library will be following Semantic Versioning, although we don't have a 1.0.0 release yet!

http://semver.org/spec/v2.0.0.html