PHP code example of irap / vida-sdk

1. Go to this page and download the library: Download irap/vida-sdk 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/ */

    

irap / vida-sdk example snippets


$api = new App(
  $app_auth_id,
  $app_api_key,
  $app_private_key
);

$api = new User(
  $app_auth_id,
  $app_api_key,
  $app_private_key,
  $user_auth_id,
  $user_api_key,
  $user_private_key
);

/*  The response body i.e. the results
 *  that are returned
 */
$response->response;

/*  The HTTP Response code,
 *  e.g. 200 for success,
 *  401 for unauthorized
 */
$response->code;

/*  Status of the response:
 *  Success or Error
 */
$response->status;

/*  The error message, if status == 'Error'
 */
$response->error;

$response->status = 'Error';
$response->code = 401;
$response->error = 'Authentication failure - You do not have permission to access this resource';

$api->requestUserPermissions($returnUrl);

$response->userAuthId;
$response->userApiKey;
$response->userPrivateKey;

$api = new User(
  $app_auth_id,
  $app_api_key,
  $app_private_key,
  $user_auth_id,
  $user_api_key,
  $user_private_key
);

$datasets = $api->getDatasets();

$response = $api->addDataset($name, 
  $project_id, 
  $manager_id,
  $country_id,
  $type,
  $assessment_date,
  $description);

$dataset_details = $api->getDatasets(1);

$response = $api->replaceDataset(
  $id, 
  $name, 
  $project_id, 
  $manager_id
);

$response = $api->deleteDataset($id);

$filter = new iRAP\VidaSDK\Filter('id', 1);

$result = $api->getUsers(null, $filter);

$filter = new iRAP\VidaSDK\Filter('id', 1, '!=');
$result = $api->getUsers(null, $filter);

$filter = new iRAP\VidaSDK\Filter('id', 1, '!=');
$filter->addFilter('is_admin', 1);
$result = $api->getUsers(null, $filter);

# Create the first filter for the first admins that were put into the system
$filter1 = new iRAP\VidaSDK\Filter('id', 10, '<=');
$filter1->addFilter('is_admin', 1);

# Create second filter for newer users that are not admins.
$filter2 = new iRAP\VidaSDK\Filter('id', 1000, '>');
$filter2->addFilter('is_admin', 1, '!=');

# Group the filters together
$filter = new iRAP\VidaSDK\FilterGroup(iRAP\VidaSDK\Conjunction::createOr(), $filter1, $filter2);

$result = $api->getUsers(null, $filter);