for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace XoteliaClient;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Subscriber\Retry\RetrySubscriber;
use XoteliaClient\Endpoint\Booking;
class Xotelia
{
const BASE_URL = 'https://admin.xotelia.com/api/';
const MAX_RETRIES = 5;
/**
* @var Client
*/
protected $client;
* @param string $token
* @param int $maxRetries
public function __construct($token, $maxRetries = self::MAX_RETRIES)
$handler = new GuzzleClient([
'base_url' => self::BASE_URL,
'defaults' => [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => sprintf('Bearer %s', $token),
],
]);
$retry = new RetrySubscriber([
'filter' => RetrySubscriber::createChainFilter([
RetrySubscriber::createCurlFilter([CURLE_PARTIAL_FILE]),
RetrySubscriber::createStatusFilter([500, 502, 503, 504]),
]),
'max' => $maxRetries,
$handler->getEmitter()->attach($retry);
$this->client = new Client($handler);
}
* @return Booking
public function bookings()
return new Booking($this->client);