bookingcom/client

Booking.com API client.

dev-master 2021-05-21 22:09 UTC

This package is auto-updated.

Last update: 2024-10-13 13:08:05 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.