floor12 / mindbox-api-client
对 MindBox API 的一般抽象
0.0.4
2020-10-08 16:43 UTC
Requires
- php: >=7.1.0
- ext-json: *
- guzzlehttp/guzzle: *
Requires (Dev)
- phpunit/phpunit: 7.*
README
对 MindBox API 的一般抽象。
要向 MindBox API 发送请求,您应该扩展 MindBoxRequest
类,并使用您的数据设置 MindBoxRequest::operationName
和 MindBoxRequest::body
。
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();