PHP code example of mordisacks / priority-api

1. Go to this page and download the library: Download mordisacks/priority-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mordisacks / priority-api example snippets


$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');
        });
  });