mordisacks / priority-api
A PHP client for priority software API
0.2.2
2020-12-14 21:41 UTC
Requires
- ext-json: *
- ext-simplexml: *
- guzzlehttp/guzzle: ^6.5
- illuminate/support: ~5|~6|~7|~8
Requires (Dev)
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2024-11-19 22:54:21 UTC
README
A PHP client for priority software API
based on this documentation
https://prioritysoftware.github.io/restapi/
Instellation
composer require mordisacks/priority-api
Usage
Setup
$client = new PriorityClient($serviceRootUrl);
Authentication
// Basic auth $client->withBasicAuth('username', 'password'); // App auth $client->withAppAuth('app_id', 'app_key');
$query = new Builder(); $query->setClient($client);
Getting a collection
$query->from('ORDER') ->select('A', 'B', 'C') ->filter('FOO', 'bar') ->orFilter('FOO', '!=', 'BAZ') ->expand('ITEMS_SUBFORM') ->top(3); // Outputs the raw query: ORDER?$select=A,B,C&$filter=FOO eq 'bar' or FOO ne 'BAZ'&$expand=ITEMS_SUBFORM&$top=3 $query->toQuery(); // Returns a collection of ORDERS $query->get();
Gettign a single Entity
// Returns a single ORDER with the id of AA123456 $query->from('ORDERS')->find('AA123456');
Filter Group
$query->filter(function (Filter $filter) { $filter->filter('B', 'something'); $filter->filter('C', 'something'); });
Expand sub query
$query->expand('ITEMS', function (Builder $q) { $q->select('FIELD1', 'FIELD2', 'FIELD3') ->filter('FIELD1', 'Y') ->filter(function (Filter $filter) { $filter->filter('FIELD2', 'Y') ->orFilter('FIELD3', 'Y'); }); });
Inspired by Laravel Eloquant builder