spinbits/baselinker-sdk

PHP integration with Baselinker https://api.baselinker.com/

1.0.2 2022-02-01 08:36 UTC

This package is auto-updated.

Last update: 2024-10-23 16:25:52 UTC


README

Latest Version on Packagist Software License Build Status Total Downloads

Need help ?

Drop us a message hello@spinbits.io

Description

This package is implementation of communication with BaseLinker Connector ("integration file"). For further details please refer to https://connectors.baselinker.com/exec/docs/index.php .

This package provides only core action handler. It's ready to be extended with your own ecommerce (Sylius, or other php-based products) action handlers.

For integration with Sylius, please go to https://github.com/spinbits/sylius-baselinker-plugin

Install

Via Composer

$ composer require spinbits/baselinker-sdk

Usage

In order to use this package, instantiate your Baselinker handler:

$baselinkerPassword = 'secret-password';
$baselinkerHandler = new Spinbits\BaselinkerSdk\RequestHandler($baselinkerPassword);

Register example handlers with $actionName from BaseLinker API:

$fileVersionHandler = new Spinbits\BaselinkerSdk\Handler\Common\FileVersionActionHandler();
$baselinkerHandler->registerHandler('FileVersion', $fileVersionHandler);

You can register handler with some depending parameter also:

$supportedMethods = new Spinbits\BaselinkerSdk\Handler\Common\SupportedMethodsActionHandler($baselinkerHandler);
$baselinkerHandler->registerHandler('SupportedMethodsActionHandler', $supportedMethods);

Before your handle request you should create Input object which receives array passed in POST request as a parameter. Let's assumer that $request is for example Symfony\Component\HttpFoundation\Request object. We can use:

$input = new Spinbits\BaselinkerSdk\Rest\Input($request->request->all());

In order to process incoming request you can just run:

$response = $baselinkerHandler->handle($input);

The result to return controller response is:

$response->getContent();
/* returns example response:
[
    'platform' => "Common spinbits baslinker plugin",
    'version' => "4.0.0",
    'standard' => 4,
]
*/

Example handlers, common for all implementations can be found in src\Handler\Common.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email office@spinbits.io instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.