Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from nihilsen/boxbilling
Browse files Browse the repository at this point in the history
Rename to "laravel-boxbilling"
  • Loading branch information
Persaeus authored Oct 11, 2022
2 parents 6985764 + 95f51ea commit fd805b8
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 112 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/nihilsen/laravel-fossbilling/discussions/new?category=q-a
url: https://github.com/nihilsen/laravel-boxbilling/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/nihilsen/laravel-fossbilling/discussions/new?category=ideas
url: https://github.com/nihilsen/laravel-boxbilling/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/nihilsen/laravel-fossbilling/security/policy
url: https://github.com/nihilsen/laravel-boxbilling/security/policy
about: Learn how to notify us for sensitive bugs
- name: Report a bug
url: https://github.com/nihilsen/laravel-fossbilling/issues/new
url: https://github.com/nihilsen/laravel-boxbilling/issues/new
about: Report a reproducible bug
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changelog

All notable changes to `laravel-fossbilling` will be documented in this file.
All notable changes to `laravel-boxbilling` will be documented in this file.
54 changes: 25 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# A minimalist FOSSBilling API bridge for Laravel.
# A minimalist BoxBilling API bridge for Laravel.

[![Latest Version on Packagist](https://img.shields.io/packagist/v/nihilsen/laravel-fossbilling.svg?style=flat-square)](https://packagist.org/packages/nihilsen/laravel-fossbilling)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/nihilsen/laravel-fossbilling/run-tests?label=tests)](https://github.com/nihilsen/laravel-fossbilling/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/nihilsen/laravel-fossbilling/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/nihilsen/laravel-fossbilling/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/nihilsen/laravel-fossbilling.svg?style=flat-square)](https://packagist.org/packages/nihilsen/laravel-fossbilling)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/nihilsen/laravel-boxbilling.svg?style=flat-square)](https://packagist.org/packages/nihilsen/laravel-boxbilling)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/nihilsen/laravel-boxbilling/run-tests?label=tests)](https://github.com/nihilsen/laravel-boxbilling/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/nihilsen/laravel-boxbilling/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/nihilsen/laravel-boxbilling/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/nihilsen/laravel-boxbilling.svg?style=flat-square)](https://packagist.org/packages/nihilsen/laravel-boxbilling)

This package adds a simple interface for interacting with the API of a [FOSSBilling](https://github.com/FOSSBilling/FOSSBilling) instance.
This package adds a simple interface for interacting with the API of a [BoxBilling](https://github.com/BoxBilling/BoxBilling) instance.

Basic authentication via a token is supported for `Client` and `Admin` endpoints.

> **Warning**
> *FOSSBilling* is under active development but is currenly available as beta software. As such, parts of the API may still be subject to change.
## Installation

You can install the package via composer:

```bash
composer require nihilsen/laravel-fossbilling
composer require nihilsen/laravel-boxbilling
```


If you wish, you may publish the config file with:

```bash
php artisan vendor:publish --tag="laravel-fossbilling-config"
php artisan vendor:publish --tag="laravel-boxbilling-config"
```

In the published config file, you may configure the `url` for the FOSSBilling instance as well as the `token` for authenticated requests:
In the published config file, you may configure the `url` for the BoxBilling instance as well as the `token` for authenticated requests:

```php
return [
Expand All @@ -37,11 +33,11 @@ return [
| Url
|--------------------------------------------------------------------------
|
| The base url for all FOSSBilling API requests.
| The base url for all BoxBilling API requests.
|
*/

'url' => env('FOSSBILLING_API_URL'),
'url' => env('BOXBILLING_API_URL'),

/*
|--------------------------------------------------------------------------
Expand All @@ -52,7 +48,7 @@ return [
|
*/

'token' => env('FOSSBILLING_API_TOKEN'),
'token' => env('BOXBILLING_API_TOKEN'),

];
```
Expand All @@ -61,31 +57,31 @@ Alternatively, you may configure these options via your `.env` enviroment file:

```env
FOSSBILLING_API_URL='https://fossbilling.tld/api'
FOSSBILLING_API_TOKEN='your_secret_fossbilling_token'
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 FOSSBilling.
API calls follow a format similar to that used internally in BoxBilling.

The starting point should always be the `FOSSBilling` facade.
The starting point should always be the `BoxBilling` facade.

Request parameters **MUST** be passed as *named parameters*.
Request parameters **MUST** be passed as _named parameters_.

```php

use Nihilsen\FOSSBilling\Facades\FOSSBilling;
use Nihilsen\BoxBilling\Facades\BoxBilling;

# Determine FOSSBilling version (endpoint: guest/system/version)
$version = FOSSBilling::guest()->system_version();
# Determine BoxBilling version (endpoint: guest/system/version)
$version = BoxBilling::guest()->system_version();

# Get client by id (endpoint: admin/client/get)
$client = FOSSBilling::admin()->client_get(id: 42);
$client = BoxBilling::admin()->client_get(id: 42);

# Get client profile (endpoint: client/profile/get)
$profile = FOSSBilling::client(id: 42)->profile_get();
# Get profile of client by id (endpoint: client/profile/get)
$profile = BoxBilling::client(id: 42)->profile_get();

```

Expand All @@ -105,8 +101,8 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Credits

- [nihilsen](https://github.com/nihilsen)
- [All Contributors](../../contributors)
- [nihilsen](https://github.com/nihilsen)
- [All Contributors](../../contributors)

## License

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "nihilsen/laravel-fossbilling",
"description": "A FOSSBilling API bridge for Laravel.",
"name": "nihilsen/laravel-boxbilling",
"description": "A BoxBilling API bridge for Laravel.",
"keywords": [
"nihilsen",
"laravel",
"laravel-fossbilling"
"laravel-boxbilling"
],
"homepage": "https://github.com/nihilsen/laravel-fossbilling",
"homepage": "https://github.com/nihilsen/laravel-boxbilling",
"license": "MIT",
"authors": [
{
Expand All @@ -31,12 +31,12 @@
},
"autoload": {
"psr-4": {
"Nihilsen\\FOSSBilling\\": "src"
"Nihilsen\\BoxBilling\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Nihilsen\\FOSSBilling\\Tests\\": "tests"
"Nihilsen\\BoxBilling\\Tests\\": "tests"
}
},
"scripts": {
Expand All @@ -55,10 +55,10 @@
"extra": {
"laravel": {
"providers": [
"Nihilsen\\FOSSBilling\\ServiceProvider"
"Nihilsen\\BoxBilling\\ServiceProvider"
],
"aliases": {
"FOSSBilling": "Nihilsen\\FOSSBilling\\Facades\\FOSSBilling"
"BoxBilling": "Nihilsen\\BoxBilling\\Facades\\BoxBilling"
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions config/fossbilling.php → config/boxbilling.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
| Url
|--------------------------------------------------------------------------
|
| The base url for all FOSSBilling API requests.
| The base url for all BoxBilling API requests.
|
*/

'url' => env('FOSSBILLING_API_URL'),
'url' => env('BOXBILLING_API_URL'),

/*
|--------------------------------------------------------------------------
Expand All @@ -22,6 +22,6 @@
|
*/

'token' => env('FOSSBILLING_API_TOKEN'),
'token' => env('BOXBILLING_API_TOKEN'),

];
14 changes: 7 additions & 7 deletions src/API/API.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Nihilsen\FOSSBilling\API;
namespace Nihilsen\BoxBilling\API;

use GuzzleHttp\Cookie\CookieJar;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Nihilsen\FOSSBilling\Exceptions\APIErrorException;
use Nihilsen\FOSSBilling\Facades\FOSSBilling;
use Nihilsen\FOSSBilling\Role;
use Nihilsen\BoxBilling\Exceptions\APIErrorException;
use Nihilsen\BoxBilling\Facades\BoxBilling;
use Nihilsen\BoxBilling\Role;

abstract class API
{
Expand All @@ -22,7 +22,7 @@ abstract class API
/**
* The Role corresponding to this subset of the API endpoints.
*
* @var \Nihilsen\FOSSBilling\Role
* @var \Nihilsen\BoxBilling\Role
*/
public readonly Role $role;

Expand Down Expand Up @@ -50,7 +50,7 @@ public function cookies(?string $key = null, ?CookieJar $set = null): ?CookieJar
return $this->cookies($this->cookieKey(), $set);
}

$cacheKey = 'fossbilling.cookies:'.$key;
$cacheKey = 'boxbilling.cookies:'.$key;

if (
$set &&
Expand Down Expand Up @@ -113,7 +113,7 @@ protected function query(string $method, ?array $parameters)
*/
public function request(): PendingRequest
{
$request = Http::acceptJson()->baseUrl(FOSSBilling::url());
$request = Http::acceptJson()->baseUrl(BoxBilling::url());

if ($cookies = $this->cookies()?->toArray()) {
return $request->withCookies(
Expand Down
2 changes: 1 addition & 1 deletion src/API/Admin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Nihilsen\FOSSBilling\API;
namespace Nihilsen\BoxBilling\API;

/**
* @method mixed client_login(int $id)
Expand Down
6 changes: 3 additions & 3 deletions src/API/AuthenticatedAPI.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Nihilsen\FOSSBilling\API;
namespace Nihilsen\BoxBilling\API;

use Illuminate\Http\Client\PendingRequest;
use Nihilsen\FOSSBilling\Facades\FOSSBilling;
use Nihilsen\BoxBilling\Facades\BoxBilling;

abstract class AuthenticatedAPI extends API
{
Expand All @@ -27,6 +27,6 @@ public function request(): PendingRequest

protected function token(): string
{
return FOSSBilling::token();
return BoxBilling::token();
}
}
8 changes: 4 additions & 4 deletions src/API/Client.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Nihilsen\FOSSBilling\API;
namespace Nihilsen\BoxBilling\API;

use Illuminate\Http\Client\PendingRequest;
use Nihilsen\FOSSBilling\Exceptions\APIErrorException;
use Nihilsen\FOSSBilling\Facades\FOSSBilling;
use Nihilsen\BoxBilling\Exceptions\APIErrorException;
use Nihilsen\BoxBilling\Facades\BoxBilling;

class Client extends AuthenticatedAPI
{
Expand Down Expand Up @@ -33,7 +33,7 @@ protected function cookieKey(): string
*/
protected function logIn()
{
$adminAPI = FOSSBilling::admin();
$adminAPI = BoxBilling::admin();

$adminAPI->client_login(id: $this->id);

Expand Down
4 changes: 2 additions & 2 deletions src/API/Guest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Nihilsen\FOSSBilling\API;
namespace Nihilsen\BoxBilling\API;

/**
* @method string system_version() Get FOSSBilling version
* @method string system_version() Get BoxBilling version
*/
class Guest extends API
{
Expand Down
10 changes: 5 additions & 5 deletions src/Accessor.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Nihilsen\FOSSBilling;
namespace Nihilsen\BoxBilling;

use Nihilsen\FOSSBilling\Exceptions\UnexpectedAPIRoleException;
use Nihilsen\BoxBilling\Exceptions\UnexpectedAPIRoleException;

class Accessor
{
Expand All @@ -22,7 +22,7 @@ public function __call($method, $_)

public function client(?int $id = null)
{
/** @var \Nihilsen\FOSSBilling\API\Client */
/** @var \Nihilsen\BoxBilling\API\Client */
$api = Role::Client->api();

if (is_null($id)) {
Expand All @@ -37,14 +37,14 @@ public function client(?int $id = null)
*/
public function token()
{
return config('fossbilling.token');
return config('boxbilling.token');
}

/**
* Get the base url for API requests.
*/
public function url()
{
return config('fossbilling.url');
return config('boxbilling.url');
}
}
2 changes: 1 addition & 1 deletion src/Exceptions/APIErrorException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Nihilsen\FOSSBilling\Exceptions;
namespace Nihilsen\BoxBilling\Exceptions;

class APIErrorException extends \RuntimeException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/UnexpectedAPIRoleException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Nihilsen\FOSSBilling\Exceptions;
namespace Nihilsen\BoxBilling\Exceptions;

class UnexpectedAPIRoleException extends \UnexpectedValueException
{
Expand Down
22 changes: 22 additions & 0 deletions src/Facades/BoxBilling.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Nihilsen\BoxBilling\Facades;

use Illuminate\Support\Facades\Facade;

/**
* @method static \Nihilsen\BoxBilling\API\Admin admin()
* @method static \Nihilsen\BoxBilling\API\Client client(int|null $id = null)
* @method static \Nihilsen\BoxBilling\API\Guest guest()
* @method static string token()
* @method static string url()
*
* @see \Nihilsen\BoxBilling\Accessor
*/
class BoxBilling extends Facade
{
protected static function getFacadeAccessor()
{
return \Nihilsen\BoxBilling\Accessor::class;
}
}
Loading

0 comments on commit fd805b8

Please sign in to comment.