regalii/regaliator

There is no license information available for the latest version (1.0.1) of this package.

PHP client library for connecting to the Regalii API

1.0.1 2017-02-01 22:47 UTC

This package is not auto-updated.

Last update: 2024-04-22 11:09:24 UTC


README

A PHP client for connecting to the Regalii API.

Usage

After requiring regalii/regaliator in your composer.json file, you can use the class like so:

$configuration = new Regaliator\Configuration([
  'version' => '3.1',
  'api_host' => 'api.casiregalii.com',
  'api_key' => getenv('REGALII_API_KEY'),
  'secret_key' => getenv('REGALII_SECRET')
]);
$regaliator = new Regaliator\Regaliator($configuration);

$response = $regaliator->account();

if ($response->success) {
  $data = json_decode($response->body, true);
} else {
  echo "Failed with status code {$response->status_code}";
}

The $response will be a Response object from the Requests library.

Examples

Examples of some common use-cases:

Creating a credential bill

$response = $regaliator->create_credentials_bill(12376, 'login', 'challengeme');
$bill = json_decode($response->body, true);
echo "Created bill {$bill['id']}\n";

Polling for while bill fetching

function poll_while_updating($regaliator, $id) {
  for($i = 0; $i < 60; $i++) {
    echo "Checking status for bill {$id} after sleeping 1 second\n";
    sleep(1);

    $response = $regaliator->show_bill($id);
    $bill = json_decode($response->body, true);

    if ($bill['status'] !== 'fetching') {
      return $bill;
    }
  }
  // raise exception because bill is still fetching
}

$bill = poll_while_updating($regaliator, $bill['id']);

Answering MFA Challenge

$response = $regaliator->update_bill_mfas($bill['id'], ['mfa_challenges' => [
  [
    'id' => $bill['mfa_challenges'][0]['id'],
    'type' => $bill['mfa_challenges'][0]['type'],
    'response' => '8'
  ]
]]);