openpublicmedia / roisolutions-php
PHP client for ROI Solutions APIs.
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^6.0 || ^7.0
Requires (Dev)
- phpcompatibility/php-compatibility: ^9.3
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.4
- tochka-developers/array-file-cache: ^3.1
README
This library abstracts interactions with ROI Solutions APIs.
Implemented APIs:
Installation
Install via composer:
composer require openpublicmedia/roisolutions-php
Use
REST API
The OpenPublicMedia\RoiSolutions\Rest\Client
queries the REST API.
Examples
Creating a client
use OpenPublicMedia\RoiSolutions\Rest\Client; $userId = 'USER_ID'; $password = 'pAsSw0rD'; $clientCode = 'CLIENTCODE'; $client = new Client($userId, $password, $clientCode);
Providing a cache service is also supported (and recommended) when creating the client. If the client has a cache service it will be used to cache the authentication token provided by the API across multiple requests for the lifetime of the token.
A PSR-16 compliant interface is preferred but any class providing
set($key, $value)
and get($key, $default)
methods will suffice.
use OpenPublicMedia\RoiSolutions\Rest\Client; use Tochka\Cache\ArrayFileCache; $userId = 'USER_ID'; $password = 'pAsSw0rD'; $clientCode = 'CLIENTCODE'; $cache = new ArrayFileCache('.', 'my_awesome_cache'); $client = new Client($userId, $password, $clientCode, cache: $cache);
Handling exceptions
Custom exceptions are provided for 404 response and general errors. Additional information from the API response is captured in these exceptions.
use OpenPublicMedia\RoiSolutions\Rest\Exception\RequestException; try { $results = $client->request('get', 'donors'); } catch (RequestException $e) { var_dump(get_class($e)); var_dump($e->getMessage()); var_dump($e->getCode()); var_dump($e->getStatusCodeReported()); var_dump($e->getTitle()); var_dump($e->getDetail()); var_dump($e->getInstanceCode()); var_dump($e->getHelpLink()); }
Development goals
See CONTRIBUTING for information about contributing to this project.
v1
- REST API client (
\OpenPublicMedia\RoiSolutions\Rest\Client
) - API direct querying (
$client->request()
) - Result/error handling
- System
- Donors
- Search donors
- Account flags support
- Sub-resources support
- Get donor
- Support for advanced query parameters (
include
,summary.*
,donations.*
) - Get flags (BETA)
- Get emails
- Get Passport memberships (BETA)
- Membership ID property
- Other properties (once finalized)
- Support for advanced query parameters (
- Create donor (BETA)
- Update donor (BETA)
- Search donors