A PHP client for priority software API
based on this documentation
https://prioritysoftware.github.io/restapi/
composer require mordisacks/priority-api
$client = new PriorityClient($serviceRootUrl);// Basic auth
$client->withBasicAuth('username', 'password');
// App auth
$client->withAppAuth('app_id', 'app_key');$query = new Builder();
$query->setClient($client);$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(); // Returns a single ORDER with the id of AA123456
$query->from('ORDERS')->find('AA123456');$query->filter(function (Filter $filter) {
$filter->filter('B', 'something');
$filter->filter('C', 'something');
});$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