fisafe/api-client

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

The `Fisafe Api Client` is a powerful PHP client designed to integrate seamlessly with the `fisafe.cloud` API.

0.0.8 2023-09-12 11:52 UTC

This package is auto-updated.

Last update: 2024-05-12 13:11:54 UTC


README

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.

Installation

To install the Fisafe Api Client, use Composer:

composer require fisafe/api-client

Ensure you have the necessary dependencies installed and autoloaded.

Initialization

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 endpoint:

$fisafeClient = new ApiClient('https://myaddress.fisafe.cloud');

Authentication

Authenticate your client instance using your fisafe.cloud credentials:

$fisafeClient->authenticate('your_username', 'your_password');

Usage

Creating a User:

$user = $fisafeClient->createUser('my-user-identifier');
echo "User created with ID: {$user->id}" . PHP_EOL;

Creating an Identifier for a User:

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;

Listing Users:

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);

Granting User Access (assuming function and context logic exists):

$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;

Conclusion

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.