nihilsen / laravel-boxbilling
A BoxBilling API bridge for Laravel.
Requires
- php: ^8.1
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.5
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2023-11-09 18:43:10 UTC
README
This package adds a simple interface for interacting with the API of a BoxBilling instance.
Basic authentication via a token is supported for Client
and Admin
endpoints.
Installation
You can install the package via composer:
composer require nihilsen/laravel-boxbilling
If you wish, you may publish the config file with:
php artisan vendor:publish --tag="laravel-boxbilling-config"
In the published config file, you may configure the url
for the BoxBilling instance as well as the token
for authenticated requests:
return [ /* |-------------------------------------------------------------------------- | Url |-------------------------------------------------------------------------- | | The base url for all BoxBilling API requests. | */ 'url' => env('BOXBILLING_API_URL'), /* |-------------------------------------------------------------------------- | Token |-------------------------------------------------------------------------- | | The authentication token for authenticated API requests. | */ 'token' => env('BOXBILLING_API_TOKEN'), ];
Alternatively, you may configure these options via your .env
enviroment file:
BOXBILLING_API_URL='https://boxbilling.tld/api' BOXBILLING_API_TOKEN='your_secret_boxbilling_token'
Usage
API calls follow a format similar to that used internally in BoxBilling.
The starting point should always be the BoxBilling
facade.
Request parameters MUST be passed as named parameters.
use Nihilsen\BoxBilling\Facades\BoxBilling; # Determine BoxBilling version (endpoint: guest/system/version) $version = BoxBilling::guest()->system_version(); # Get client by id (endpoint: admin/client/get) $client = BoxBilling::admin()->client_get(id: 42); # Get profile of client by id (endpoint: client/profile/get) $profile = BoxBilling::client(id: 42)->profile_get();
Paginated results
Paginated results are collected into a Nihilsen\BoxBilling\Collection
instance, which is subclass of Illuminate\Support\LazyCollection
.
use Nihilsen\BoxBilling\Facades\BoxBilling; /** @var Nihilsen\BoxBilling\Collection **/ $tickets = BoxBilling::admin()->support_ticket_get_list(page: 1, per_page: 10); # Select a random ticket $ticket = $tickets->random();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.