yaro / gamstop
GAMSTOP 包
0.1.0
2018-04-25 14:30 UTC
Requires
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-09-23 01:25:29 UTC
README
为检查用户在线赌博自我排除的 Gamstop API 提供的包。
安装
您可以通过 Composer 安装此包。
composer require yaro/gamstop
用法
Laravel
只需将以下内容放入您的 services
配置文件中
'gamstop' => [ 'key' => env('GAMSTOP_API_KEY'), ],
对于 Laravel <5.5,请将其添加到您的 app
配置中
'providers' => [ Yaro\Gamstop\ServiceProvider::class, //... ]; 'aliases' => [ 'Gamstop' => Yaro\Gamstop\Facade::class, //... ];
然后使用如下
Gamstop::checkParams($firstName, $lastName, $dateOfBirth, $email, $postcode, $xTraceId);
或在其模型中实现 GamstopCheckableInterface
接口以传递模型。
$user = User::first(); $isUserAllowedToPlay = Gamstop::check($user)->isAllowed();
其他
$gamstop = new \Yaro\Gamstop\Gamstop\Api($apiKey); $response = $gamstop->checkParams($firstName, $lastName, $dateOfBirth, $email, $postcode, $xTraceId); var_dump($response->isBlocked());
您应该捕获所有异常
try { $response = Gamstop::check($user); // ... } catch (\Yaro\Gamstop\ExceptionsMissingParametersException $e) { // if missing parameters } catch (\Yaro\Gamstop\ExceptionsApiKeyInvalidException $e) { // if API key invalid or IP address not in range } catch (\Yaro\Gamstop\ExceptionsNonPostCallException $e) { // for non-POST calls } catch (\Yaro\Gamstop\ExceptionsRateLimitedException $e) { // if rate limited } catch (\Yaro\Gamstop\NetworkingErrorException $e) { // in case of networking error (connection timeout, DNS errors, etc.) }
捕获此异常将捕获任何可能抛出的异常
try { $response = Gamstop::check($user); // ... } catch (\Yaro\Gamstop\GamstopBaseException $e) { }
许可证
MIT 许可证 (MIT)。请参阅 LICENSE 以获取更多信息。