bookingcom / client
Booking.com API client.
Fund package maintenance!
rybakit
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-12-13 13:33:42 UTC
README
Usage example
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();
To send multiple requests asynchronously:
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) { // ... }
Tests
Before running tests, copy phpunit.xml.dist to phpunit.xml
and set BOOKINGCOM_API_USERNAME
and BOOKINGCOM_API_PASSWORD
environment variables.
Then run the tests:
vendor/bin/phpunit
License
The library is released under the MIT License. See the bundled LICENSE file for details.