logotel / logobot-php-integration
A package to integrate with LogoBot
Requires
- php: ^7.4||^8.0
- firebase/php-jwt: ^6.10
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.50
- mockery/mockery: ^1.6
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^5.0||^6.0||^7.0
README
Logobot PHP integration
This package aim to provide the integration with Logobot
Installation
Install via composer:
composer require logotel/logobot-php-integration
Generating JWT
Generate your JWT with:
use Logotel\Logobot\Manager; $jwt = Manager::jwt() ->setKey(file_get_contents('/path/to/private_key.pem')) ->setLicense($license) ->setEmail($email) ->setIdentifier($identifier) ->setPermissions($permissions) ->setExpiration($expiration) ->generate();
The key can be retrieved by a file path:
use Logotel\Logobot\Manager; $jwt = Manager::jwt() ->setKeyFromFile('/path/to/private_key.pem') ->setLicense($license) ->setEmail($email) ->setIdentifier($identifier) ->setPermissions($permissions) ->setExpiration($expiration) ->generate();
Token expiration
The token default lifetime is 24 hours. You can edit it with ->setExpiration(int $expiration)
. The expiration time is in seconds (deafult 60 * 60 * 24)
User payload
Parameter | Type | Description |
---|---|---|
String | The email address of the user | |
identifier | String | The user identifier |
license | String | The bot license |
permissions | Array(String) | The user's permissions |
Uploading text (with link)
use Logotel\Logobot\Manager; Manager::textUpload() ->setApiKey($api_key) ->setIdentifier($identifier) ->setTitle($title) ->setContent($content) ->setLink($link) ->setPermissions($permissions) ->setLanguage($language) ->upload();
If you want to change the endpoint base url you can change it by:
Manager::textUpload()->setApiUrl("https://something.test");
You can also set a custom http client
Manager::textUpload()->setClient(new \GuzzleHttp\Client(...));
Bulk importer
The bulk importer functionality will take care of processing multiple file at once. The file uploaded must by a zip file, containing:
- n files in pdf or txt format
- a json file named
details.json
with this structure, with one entry for each file:
[ { "name": "name_of_the_file.pdf", "permissions": [ "a", "list", "of", "permissions", ], "language": "selected_language" }, { ... }, ... ]
The number of the entries in the array must be total files in zip - 1
(the json file).
Usage
use Logotel\Logobot\Manager; Manager::bulkImporter() ->setApiKey($api_key) ->setFilePath($file_path) ->upload();
If you want to change the endpoint base url you can change it by:
Manager::textUpload()->setApiUrl("https://something.test");
You can also set a custom http client
Manager::textUpload()->setClient(new \GuzzleHttp\Client(...));
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
History
Version 1.00 (2024-02-27) - first commit
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email giagara@yahoo.it instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.