nihilsen/laravel-boxbilling

This package is abandoned and no longer maintained. No replacement package was suggested.

A BoxBilling API bridge for Laravel.

v0.2.1 2022-10-16 02:15 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.