Евгений Горяев
Разработка, поддержка и развитие сайтов

floor12/mindbox-api-client Общая абстракция над апи MindBox

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();