xotelia / xotelia-php-client
Xotelia PHP client
Installs: 2 756
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- guzzlehttp/guzzle: ~5.0
- guzzlehttp/retry-subscriber: ~2.0
- jms/serializer: ^1.0.0
Requires (Dev)
- phpspec/phpspec: ~2.0
- psr/http-message: ^1.0
This package is not auto-updated.
Last update: 2019-10-27 13:52:22 UTC
README
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