Coder Social home page Coder Social logo

ean-client's Introduction

ean-client

A PHP implementation of the EAN Hotel API.

Supports all API requests and both IP and signature authentication. Internally it uses the XML request and response types.

Build Status

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.

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

<?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

$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

$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

$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' => '[email protected]',
        '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

$result = $client->getRoomCancellation([
    'itineraryId' => $reservation['itineraryId'],
    'email' => '[email protected]',
    '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.

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

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

Diffs should be clean. This means the only lines with changes should be those relevant to the commit message.

Running the tests

$ phpunit

Credits

Guzzle does most of the heavy lifting. This project is really just an elaborate Guzzle Services config.

License

MIT

ean-client's People

Contributors

indika-hotels avatar norikt avatar ryanhughes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ean-client's Issues

more parameters for search

Hello,

I need to set following params while doing ean search:

  1. show_sold_out = true
  2. number_of_results = 200 (or some large number).

How do I set?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.