sudiptochoudhury / php-ready-theatre-systems
PHP 客户端库,用于消费 Ready Theatre Systems, LLC – Open Interface API
v1.0.10
2023-04-12 20:40 UTC
Requires
- php: ^7.1|^8.0
- sudiptochoudhury/php-api-client-forge: dev-master
Requires (Dev)
- mockery/mockery: ^1.1.0
- phpunit/phpunit: ^7.2.0
- psr/log: ^1.0@dev
- sudiptochoudhury/php-cli: dev-master
README
Ready Theatre Systems, LLC – Open Interface API 的 PHP API 客户端
use SudiptoChoudhury\Rts\Api; $rts = new Api([ 'theatre' => '<<theatre number>>' 'username' => '<<password>>', 'password' => '<<password>>', ]); $result = $rts->getShowTime(['ShowSales' => 1, 'ShowAvalTickets' => 1, 'ShowSaleLinks' => 1]); $result = $rts->checkIfSoldOut([ 'Data' => [ "Packet" => [ 'PerformanceID' => '018129000023' ] ] ]); $result = $rts->getGiftCardInformation([ 'Data' => [ "Packet" => [ 'GiftCards' => [ 'GiftCard' => '1234510813486422' ] ] ] ]);
安装
要求
- 任何 PHP 7.1+ 版本都适用
使用 Composer 安装
您可以通过向您的 composer.json 文件的 require 块中添加以下行来安装此库(用最新稳定版本替换 dev-master):
"sudiptochoudhury/php-ready-theatre-systems": "dev-master"
或者运行以下命令:
composer require sudiptochoudhury/php-ready-theatre-systems
设置
您需要做的只是将剧院 ID、用户名和密码传递给构造函数。
use SudiptoChoudhury\Rts\Api; new Api([ 'theatre' => '<<theatre number>>' 'username' => '<<password>>', 'password' => '<<password>>' ]);
此外,您还可以通过 log
属性设置记录器。
- 您可以将日志设置为
false
以禁用日志记录。 - 您还可以传递一个包含
file
和path
属性的数组。
use SudiptoChoudhury\Rts\Api; new Api([ 'theatre' => '<<theatre number>>' 'username' => '<<password>>', 'password' => '<<password>>', 'log' => ['file' => 'rts.log', 'path' => '/your/log/path'] ]);
- 您还可以传递一个
Monolog\Logger
实例。
use SudiptoChoudhury\Rts\Api; new Api([ 'theatre' => '<<theatre number>>' 'username' => '<<password>>', 'password' => '<<password>>', 'log' => ['logger' => $monologInstance] ]);
您可以使用 client
属性将其传递给 GuzzleHttp\Client
构造函数。
use SudiptoChoudhury\Rts\Api; new Api([ 'theatre' => '<<theatre number>>' 'username' => '<<password>>', 'password' => '<<password>>', 'client' => ['timeout' => 5] ]);
如果您想访问请求和响应处理程序堆栈,请使用 settings
而不是使用 client
的 handlers
属性。
'settings' => [ 'responseHandler' => function (ResponseInterface $response) { // do something return $response; }, 'requestHandler' => function (RequestInterface $request) { // some action return $request; }, ],
使用方法
接下来,调用以下表格中所示所需的方法。在大多数方法中,您可能需要传递参数。参数应以关联数组的形式传递。
例子
$rts = new Api([ 'theatre' => '<<theatre number>>' 'username' => '<<password>>', 'password' => '<<password>>', ]); $result = $rts->getShowTime(['ShowSales' => 1, 'ShowAvalTickets' => 1, 'ShowSaleLinks' => 1]); $result = $rts->checkIfSoldOut([ 'Data' => [ "Packet" => [ 'PerformanceID' => '018129000023' ] ] ]); $result = $rts->getGiftCardInformation([ 'Data' => [ "Packet" => [ 'GiftCards' => [ 'GiftCard' => '1234510813486422' ] ] ] ]);