xotelia/xotelia-php-client

Xotelia PHP client

v1.0.3 2016-10-31 16:11 UTC

This package is not auto-updated.

Last update: 2019-10-27 13:52:22 UTC


README

Build Status Latest Stable Version Total Downloads License Scrutinizer Code Quality

Simple PHP client for Xotelia API

Installation

$ composer require xotelia/xotelia-php-client

Usage:

API Booking Getter

<?php

use XoteliaClient\Model\Booking;
use XoteliaClient\Xotelia;

$oAuthToken = 'your_token';
$otaName = 'your_ota_name';

$xoteliaClient = new Xotelia($oAuthToken);
$bookings = $xoteliaClient->bookings()->findAll(new \DateTime('-1 day'), new \DateTime('+1 day'));

/** @var Booking $booking */
foreach ($bookings as $booking) {
    try {
        $bookingId = $booking->getCode();
        //Save has you want
        //...
    } catch (\Exception $ex) {
        //Do something
    }
    
    //Acknowledge that everything went fine during the retrieval and save.
    $xoteliaClient->bookings()->confirm($booking->getInternalId());
}

API Booking Setter

<?php

use XoteliaClient\Model\Booking;
use XoteliaClient\Model\Currency;
use XoteliaClient\Model\Customer;
use XoteliaClient\Model\Room;
use XoteliaClient\Xotelia;

$oAuthToken = 'your_token';
$otaName = 'your_ota_name';

$xoteliaClient = new Xotelia($oAuthToken);

$currency = new Currency();
$currency
    ->setCode('EUR');

$room = new Room();
$room
    ->setRoomId('your_room_id')
    ->setQuantity(1)
    ->setStartDate(new \DateTime('2017-01-15'))
    ->setEndDate(new \DateTime('2017-01-18'))
    ->setCurrency($currency)
    ->setPrice(222.222)
    ->setTravelerCount(3)
;

$customer = new Customer();
$customer
    ->setLastName('Parker')
    ->setFirstName('Peter')
    ->setEmail('peter.parker@mail.com')
;

$booking = new Booking();
$booking
    ->setHotelId('your_hotel_id')
    ->setStatus(Booking::STATUS_NEW) //Booking::STATUS_NEW or Booking::STATUS_MODIFIED or Booking::STATUS_CANCELLED
    ->setOta($otaName)
    ->setCode('unique-code-test-remy-1')
    ->setRooms([$room])
    ->setCurrency($currency)
    ->setCustomer($customer)
;

$xoteliaBookingId = $xoteliaClient->bookings()->set($booking);
//If it possible save them