floor12/mindbox-api-client

General abstraction over the MindBox API

0.0.4 2020-10-08 16:43 UTC

This package is auto-updated.

Last update: 2024-11-12 10:03:51 UTC


README

Scrutinizer Code Quality Code Coverage Build Status

General abstraction over the Mindbox API.

To send requests to the Mindbox API you should extend the MindBoxRequest class, set MindBoxRequest::operationName and MindBoxRequest::body with your data.

use floor12\MindBox\MindBoxClient;
use floor12\MindBox\MindBoxRequest;

class SomeMindboxRequest extends MindBoxRequest
{
    /** @var string */
    protected $operationName = 'Website.CheckCustomer';
    protected $mode = MindBoxClient::MODE_SYNCHRONOUS;

    /**
     * @param $userId int
     */
    public function __construct(int $userId)
    {
        $this->body = [
            'customer' => [
                'ids' =>
                    ['externalId' => $userId]
            ]
        ];
    }
}



$apiKey = '4a942bc1';
$apiEndPoint = 'Website.ExampleEndPoint';

$client = new MindBoxClient($apiKey, $apiEndPoint);
$request = new SomeMindboxRequest(10);
$client->sendData($request);
$response = $client->getResponse();