The Fisafe Api Client
is a powerful PHP client designed to integrate seamlessly with the fisafe.cloud
API. This README provides a concise guide on setting up and using the client.
To install the Fisafe Api Client, use Composer:
composer require fisafe/api-client
Ensure you have the necessary dependencies installed and autoloaded.
First, include the required files and use the necessary classes:
<?php
use Fisafe\ApiClient;
require('vendor/autoload.php');
Initialize the client by passing the desired authentication details with your fisafe.cloud
credentials:
$fisafeClient = new ApiClient(
'https://auth.fisafe.cloud',
'used_realm',
'used_client_id',
'your_username'
'your_password'
);
Specify used organization (tenant) domain
$fisafeClient->setApiUrl('https://organization-domain.fisplay.cloud/v1/api/');
You can also change the url (organization context) if needed, but the user must be related to the organization.
$user = $fisafeClient->createUser('my-user-identifier');
echo "User created with ID: {$user->id}" . PHP_EOL;
You can associate a user with identifiers such as 'pin', 'rfid-tag', or 'licence-plate':
$identifierType = 'rfid-tag'; // Choose from 'pin', 'rfid-tag', or 'licence-plate'
$identifierValue = '121212121';
$identifier = $fisafeClient->createIdentifer($user->id, $identifierValue, $identifierType);
echo "Identifier {$identifierValue} of type {$identifierType} created for User ID: {$user->id}" . PHP_EOL;
Retrieve a list of users with a specific identifier:
$filteredUsers = $fisafeClient->listUsers(['identifier' => 'my-user-identifier']);
echo "List of users with identifier 'my-user-identifier':" . PHP_EOL;
var_dump($filteredUsers);
$contextId = 12345; // Example context ID
$fromDate = new DateTime('now');
$toDate = new DateTime('+1 month');
$access = $fisafeClient->createGrantedAccess($contextId, $user->id, $fromDate, $toDate);
echo "Access granted to context {$contextId} from {$fromDate->format('Y-m-d')} to {$toDate->format('Y-m-d')}" . PHP_EOL;
The Fisafe Api Client
provides a streamlined approach to interacting with the fisafe.cloud
API, simplifying the management of users, identifiers, and access rights. For more in-depth details, please refer to the full documentation or the official API documentation.
Note: Always handle exceptions and check return values appropriately in production code.