amara / onehydra
A library for working with the OneHydra API
Installs: 9 365
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 6
Forks: 0
Open Issues: 1
Requires
- php: >=5.5.0,<8.0
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2024-12-17 19:19:22 UTC
README
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!