klevio/klevio-api

Laravel package for integrating with the Klevio API

1.0.0 2024-12-28 11:35 UTC

This package is auto-updated.

Last update: 2025-05-28 12:37:26 UTC


README

Latest Version on Packagist Total Downloads License

A powerful Laravel package for seamless integration with Klevio's smart access control system. Manage digital keys, access rights, and smart locks with enterprise-grade security.

Documentation โ€ข Installation โ€ข Usage Examples โ€ข Contributing

โœจ Features

  • ๐Ÿ”’ Secure Authentication - JWT-based API authentication
  • ๐Ÿ”‘ Key Management - Grant and revoke access rights
  • ๐Ÿข Property Control - Manage multiple properties
  • ๐Ÿ“ฑ Smart Lock Integration - Remote lock/unlock capabilities
  • ๐Ÿ”„ Real-time Operations - Instant access management
  • ๐Ÿ›ก๏ธ Enterprise Security - ES256 encryption

๐Ÿ“š Documentation

Comprehensive documentation is available:

๐Ÿš€ Quick Start

Installation

composer require klevio/klevio-api

Getting Started

1๏ธโƒฃ Sign Up for API Access

2๏ธโƒฃ Generate Security Keys

# Generate ES256 Private Key
openssl ecparam -genkey -name secp256k1 -out private_key.pem

# Extract Public Key
openssl ec -in private_key.pem -pubout -out public_key.pem

3๏ธโƒฃ Configure Environment

Add to your .env file:

KLEVIO_CLIENT_ID="your_client_id"
KLEVIO_API_KEY="your_api_key"
KLEVIO_API_URL="https://api.klevio.com/v2"

# Keys should be properly formatted with escaped newlines
KLEVIO_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----\nMIGHAgEA...\n-----END EC PRIVATE KEY-----"
KLEVIO_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMFkwEwYH...\n-----END PUBLIC KEY-----"

๐Ÿ’ก Usage Examples

Managing Access Keys

use Klevio\KlevioApi\Facades\KlevioApi;

// Grant Access with Metadata
$response = KlevioApi::grantKey(
    propertyId: 'property-123',
    email: 'guest@example.com',
    from: '2024-01-01T00:00:00Z',
    to: '2024-01-07T23:59:59Z',
    metadata: [
        'reservationId' => 'booking-123',
        'guestName' => 'John Doe',
        'roomNumber' => '101'
    ]
);

// List Property Keys
$keys = KlevioApi::getKeys('property-123');

// Control Lock
$response = KlevioApi::useKey('key-123');

Error Handling

use GuzzleHttp\Exception\RequestException;

try {
    $response = KlevioApi::useKey('key-123');
} catch (RequestException $e) {
    Log::error('Klevio API Error', [
        'message' => $e->getMessage(),
        'code' => $e->getCode()
    ]);
}

๐Ÿ›ก๏ธ Security Best Practices

  • Store credentials securely using environment variables
  • Never commit sensitive keys to version control
  • Regularly rotate API keys
  • Monitor API access logs
  • Use HTTPS for all API communications

๐Ÿงช Testing

composer test

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“ License

The MIT License (MIT). Please see License File for more information.

๐Ÿ”— Links

Made with โค๏ธ by Mehedi Hasan Sagor