All Projects → onlinetravelgroup → Ean Client

onlinetravelgroup / Ean Client

Licence: mit
PHP client for consuming the EAN Hotel API, based on Guzzle

Labels

Projects that are alternatives of or similar to Ean Client

guzzle-oauth2-subscriber
OAuth 2.0 Client for Guzzle 4, 5, 6 and 7 with PHP 5.4 - PHP 8.0 - no more dependency hell!
Stars: ✭ 112 (+761.54%)
Mutual labels:  guzzle
mastodon-api-php
PHP wrapper for the Mastodon API.
Stars: ✭ 12 (-7.69%)
Mutual labels:  guzzle
Guzzle Cache Middleware
A HTTP Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack.
Stars: ✭ 325 (+2400%)
Mutual labels:  guzzle
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+369.23%)
Mutual labels:  guzzle
eventbrite
A lightweight PHP library for interacting with version 3 of the Eventbrite API.
Stars: ✭ 20 (+53.85%)
Mutual labels:  guzzle
http-constants
The missing PHP constants for HTTP header fields
Stars: ✭ 19 (+46.15%)
Mutual labels:  guzzle
twitter-stream-api
🐤 Another Twitter stream PHP library to retrieve filtered tweets on hot.
Stars: ✭ 11 (-15.38%)
Mutual labels:  guzzle
Guzzle
Guzzle, an extensible PHP HTTP client
Stars: ✭ 21,384 (+164392.31%)
Mutual labels:  guzzle
guzzle6-bundle
Integrates Guzzle 6 into your Symfony application
Stars: ✭ 11 (-15.38%)
Mutual labels:  guzzle
Sapient
Secure API Toolkit
Stars: ✭ 308 (+2269.23%)
Mutual labels:  guzzle
jacky
🐄 HTTP JSON API Client for Laravel & Lumen
Stars: ✭ 17 (+30.77%)
Mutual labels:  guzzle
GuzzleBundleOAuth2Plugin
OAuth2 Plugin for GuzzleBundle
Stars: ✭ 13 (+0%)
Mutual labels:  guzzle
guzzlehttp-cloudflare
Guzzle middleware to pass through Cloudflare protection
Stars: ✭ 31 (+138.46%)
Mutual labels:  guzzle
behat-3-kickstart
Behat 3/Mink and Guzzle for API testing. Code follows PageObjects approach. Saucelabs integration.
Stars: ✭ 13 (+0%)
Mutual labels:  guzzle
Ganesha
🐘 A Circuit Breaker pattern implementation for PHP applications.
Stars: ✭ 384 (+2853.85%)
Mutual labels:  guzzle
php-curl-cookbook
PHP CURL Cookbook 📖
Stars: ✭ 83 (+538.46%)
Mutual labels:  guzzle
AkamaiOPEN-edgegrid-php-client
PHP client library for Akamai {OPEN} EdgeGrid Authentication scheme (based on Guzzle)
Stars: ✭ 38 (+192.31%)
Mutual labels:  guzzle
Guzzlette
🌀 Guzzle integration into Nette Framework (@nette)
Stars: ✭ 19 (+46.15%)
Mutual labels:  guzzle
Eightpointsguzzlebundle
⛽️ Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony
Stars: ✭ 407 (+3030.77%)
Mutual labels:  guzzle
The-PHP-Workshop
A New, Interactive Approach to Learning PHP
Stars: ✭ 30 (+130.77%)
Mutual labels:  guzzle

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].