2017 © Pedro Peláez
 

library ean-client

Client for consuming the EAN Hotel API, based on Guzzle - forked for Guzzle 6.0

image

smokymountains/ean-client

Client for consuming the EAN Hotel API, based on Guzzle - forked for Guzzle 6.0

  • Thursday, July 27, 2017
  • by titani0us
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 19 Versions
  • 0 % Grown

The README.md

ean-client

A PHP implementation of the EAN Hotel API., (*1)

Supports all API requests and both IP and signature authentication. Internally it uses the XML request and response types., (*2)

Build Status, (*3)

Usage

Each of the API services are represented by a method on the HotelClient object. Each API method takes parameters in a single array argument and returns the results as an array. The parameter names and structure match those of the API spec., (*4)

A HotelClient object is instantiated using the HotelClient::factory() method, (*5)

<?php
require 'vendor/autoload.php';

use Otg\Ean\HotelClient;

$client = HotelClient::factory([
    'auth' => [
        'cid' => YOUR_CID,
        'apiKey' => YOUR_API_KEY,
        'secret' => YOUR_API_SECRET, // optional, omit if using IP authentication
    ],
    'defaults' => [
        'bookingEndpoint' => 'http://dev.api.ean.com',
        'generalEndpoint' => 'http://dev.api.ean.com',
        'customerIpAddress' => getenv('REMOTE_ADDR'),
        'customerUserAgent' => getenv('HTTP_USER_AGENT'),
    ]
]);

Examples

Hotel List

http://developer.ean.com/docs/hotel-list, (*6)

$hotels = $client->getHotelList([
    'destinationString' => 'Montpellier France',
    'arrivalDate' => '2016-06-13',
    'departureDate' => '2016-06-27',
    'RoomGroup' => [
       ['numberOfAdults' => 2]
    ]
]);

Room Availability

http://developer.ean.com/docs/room-avail, (*7)

$rooms = $client->getRoomAvailability([
    'hotelId' => $hotels['HotelList'][0]['hotelId'],
    'arrivalDate' => '2016-06-13',
    'departureDate' => '2016-06-27',
    'RoomGroup' => [
        ['numberOfAdults' => 2]
    ]
]);

Book Reservation

http://developer.ean.com/docs/book-reservation, (*8)

$bedTypes = $rooms['Rooms'][0]['BedTypes'];
$smokingPreferences = explode(',', $rooms['Rooms'][0]['smokingPreferences']);

$reservation = $client->postReservation([
    'RoomGroup' => [[
        'numberOfAdults' => 2,
        'firstName' => 'Test',
        'lastName' => 'Test',
        'bedTypeId' => key($bedTypes),
        'smokingPreference' => $smokingPreferences[0],
    ]],
    'ReservationInfo' => [
        'email' => 'user@example.org',
        'firstName' => 'Test',
        'lastName' => 'Test',
        'homePhone' => '0312345678',
        'creditCardType' => 'CA',
        'creditCardNumber' => '5401999999999999',
        'creditCardIdentifier' => '123',
        'creditCardExpirationMonth' => '12',
        'creditCardExpirationYear' => '2099'
    ],
    'AddressInfo' => [
        'address1' => 'travelnow',
        'city' => 'travelnow',
        'stateProvinceCode' => 'VC',
        'countryCode' => 'AU',
        'postalCode' => '3000'
    ],
    'hotelId' => $rooms['hotelId'],
    'arrivalDate' => $rooms['arrivalDate'],
    'departureDate' => $rooms['departureDate'],
    'supplierType' => $rooms['Rooms'][0]['supplierType'],
    'rateKey' => $rooms['Rooms'][0]['RateInfos'][0]['RoomGroup'][0]['rateKey'],
    'roomTypeCode' => isset($rooms['Rooms'][0]['roomTypeCode']) ? $rooms['Rooms'][0]['roomTypeCode'] : $rooms['Rooms'][0]['RoomType']['roomCode'],
    'rateCode' => $rooms['Rooms'][0]['rateCode'],
    'chargeableRate' => $rooms['Rooms'][0]['RateInfos'][0]['ChargeableRateInfo']['total'],
    'currencyCode' => $rooms['Rooms'][0]['RateInfos'][0]['ChargeableRateInfo']['currencyCode']
]);

Cancel Reservation

http://developer.ean.com/docs/cancel-reservation, (*9)

$result = $client->getRoomCancellation([
    'itineraryId' => $reservation['itineraryId'],
    'email' => 'user@example.org',
    'confirmationNumber' => $reservation['confirmationNumbers'][0]
]);

if (isset($result['cancellationNumber'])) {
    printf("Room cancelled: %s", $result['cancellationNumber']);
}

Installation

$ composer require onlinetravelgroup/ean-client

Requirements

  • PHP 5.4
  • php5-curl (suggested, unless you want to use a custom adapter)

Contributing

Pull requests are welcome. Just be sure to follow the PSR-1/2 coding standards and don't make a mess., (*10)

Commit messages should follow the advice at http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html, (*11)

Messy commits should be squashed until it looks like it was programmed perfectly the first time. This does not necessarily mean a single commit., (*12)

Diffs should be clean. This means the only lines with changes should be those relevant to the commit message., (*13)

Running the tests

$ phpunit

Credits

Guzzle does most of the heavy lifting. This project is really just an elaborate Guzzle Services config., (*14)

License

MIT, (*15)

The Versions

27/07 2017

dev-master

9999999-dev

Client for consuming the EAN Hotel API, based on Guzzle - forked for Guzzle 6.0

  Sources   Download

MIT

The Requires

 

by Ryan Hughes

20/07 2017

0.7.5

0.7.5.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

21/06 2017

0.7.4

0.7.4.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

30/08 2016

0.7.3

0.7.3.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

04/06 2016

0.7.2

0.7.2.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

04/12 2015

0.7.1

0.7.1.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

06/08 2015

0.7.0

0.7.0.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

18/06 2015

0.6.0

0.6.0.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

25/04 2015

0.5.0

0.5.0.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

26/02 2015

0.4.2

0.4.2.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

28/01 2015

0.4.1

0.4.1.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

27/01 2015

0.4.0

0.4.0.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

24/10 2014

0.3.1

0.3.1.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

10/10 2014

0.3.0

0.3.0.0

Client for consuming the EAN Hotel API, based on Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Hughes

06/03 2014

v0.2.1

0.2.1.0

Client for consuming the EAN API, based on Guzzle

  Sources   Download

MIT

The Requires

 

by Ryan Hughes

05/03 2014

v0.2.0

0.2.0.0

Client for consuming the EAN API, based on Guzzle

  Sources   Download

MIT

The Requires

 

by Ryan Hughes

06/12 2013

v0.1.2

0.1.2.0

Client for consuming the EAN API, based on Guzzle

  Sources   Download

MIT

The Requires

 

by Ryan Hughes

15/11 2013

v0.1.1

0.1.1.0

Client for consuming the EAN API, based on Guzzle

  Sources   Download

MIT

The Requires

 

by Ryan Hughes

03/11 2013

v0.1.0

0.1.0.0

Client for consuming the EAN API, based on Guzzle

  Sources   Download

MIT

The Requires

 

by Ryan Hughes