bc-automotive/master-api-client

bFlash Master Api Client

v1.0.0 2021-05-28 15:59 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:21:32 UTC


README

The bc-automotive/master-api-client package is a library that eases integration of the bFlash Master API in your site.

Installation

Install the package via composer:

composer require bc-automotive/master-api-client

Usage

The api uses authentication using a bearer token. Contact bFlash support to request your authentication token.

Encrypt a slave file:

use \BcAutomotive\MasterApiClient\MasterApiClient;

$client = new MasterApiClient($apiKey);

$data = file_get_contents('/path/to/data.bdc');
$encrypted = $client->encrypt($data, $slaveName);
file_put_contents('/path/to/data.sbdc', $encrypted['data']);

Decrypt a slave file:

use \BcAutomotive\MasterApiClient\MasterApiClient;

$client = new MasterApiClient($apiKey);

$data = file_get_contents('/path/to/data.sbdc');
$decrypted = $client->decrypt($data);
file_put_contents('/path/to/data.sbdc', $decrypted['data']);

Laravel Integration

The package has a laravel service provider and facade to ease integration, so after including the package inside your laravel project, you can add the key to the .env file

MASTER_API_KEY=your_key_here

And use the facade:

use MasterApiClient;

$encrypted = MasterApiClient::encrypt($data, $slaveName);
$decrypted = MasterApiClient::decrypt($data);

Exceptions

The MasterApiClient class is a small wrapper around the Guzzle http client library, so this class can throw all regular Guzzle exceptions as well. You can file the Guzzle docs here.

License

MIT