bookingcom / client
Booking.com API 客户端。
dev-master
2021-05-21 22:09 UTC
Requires
- php: ^7.4|^8
- caseyamcl/guzzle_retry_middleware: ^2.2
- guzzlehttp/guzzle: ^6.3
- pcrov/jsonreader: ^1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- phpunit/phpunit: ^9.1
- psr/log: ^1.1
This package is auto-updated.
Last update: 2024-09-13 12:56:51 UTC
README
使用示例
use Bookingcom\Client\Client; use Bookingcom\Client\Result\ChangedHotels; $client = new Client('<username>', '<password>'); $client->getChangedHotels('-2 hours')->then(function (ChangedHotels $changedHotels) { foreach ($changedHotels->getClosedHotelIds() as $hotelId) { // do something } // or foreach ($changedHotels->getChanges() as $hotelId => $changes) { // do something } })->wait();
要异步发送多个请求
use GuzzleHttp\Promise; use Bookingcom\Client\Client; $client = new Client('<username>', '<password>'); $results = Promise\all([ 'descriptions' => $client->getHotelDescriptions(42, ['en', 'nl']), 'facilities' => $client->getHotelFacilities(42, ['en', 'nl']), ])->wait(); foreach ($results as $type => $result) { // ... }
测试
在运行测试之前,将 phpunit.xml.dist 复制到 phpunit.xml
并设置 BOOKINGCOM_API_USERNAME
和 BOOKINGCOM_API_PASSWORD
环境变量。
然后运行测试
vendor/bin/phpunit
许可证
该库以 MIT 许可证发布。有关详细信息,请参阅附带的 LICENSE 文件。