klevio / klevio-api
Laravel package for integrating with the Klevio API
1.0.0
2024-12-28 11:35 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.8
- lcobucci/jwt: ^4.0
Requires (Dev)
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.0
README
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
- Visit Klevio Scheduler Portal
- Complete the registration process
- Obtain your API credentials
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.