zaidakram/expedia


Expedia is a ruby wrapper for EAN (Expedia Affiliate Network)

http://zaidakram.github.io/expedia/

License: MIT

Language: Ruby


Expedia Expedia

Expedia is a ruby wrapper for EAN – Expedia Affiliate Network APIs.

Other details of this gem are:

Installation

For Rails Add this line to your application’s Gemfile:

gem 'expedia'

And then execute:

$ bundle

Or install it yourself as:

$ gem install expedia

Either you can configure Expedia in code on run-time

Expedia.cid = 55505
Expedia.api_key = 'your_api_key'
Expedia.shared_secret = 'your_shared_secret'
Expedia.locale = 'en_US'
Expedia.currency_code = 'USD'
Expedia.minor_rev = 13
Expedia.use_signature = true # must be false if using ip whitelisting instead of signature
# Optional configuration...
Expedia.timeout = 1 # read timeout in sec
Expedia.open_timeout = 1 # connection timeout in sec

Or you can execute the following command to create an intializer (if you are using rails)

$ rails g expedia:initialize

Usage

After configuring keys, default locale, currency and minor_rev for EAN use

# Instentiate api object
api = Expedia::Api.new

# Method to search for a hotel. see http://developer.ean.com/docs/hotel-list/
response = api.get_list({:propertyName => 'Hotel Moa', :destinationString => 'berlin'})

# execute this method to know if there is any exception
response.exception? # false if success

Following methods are expeosed by Expedia::API object

get_list({})
geo_search({})
get_availability({})
get_room_images({})
get_information({})
get_rules({})
get_itinerary({})
get_alternate_properties({})
get_reservation({})
get_payment_info({})
get_cancel({})
get_ping({})
get_static_reservation({}) # To test Reservation (Static Reservation)

Success

if request is successfull you will get a Expedia::HTTPService::Response object in response.
and you can use

response.status
response.body # Returns Parsed body of response.
response.headers

Error

In case of any error a Expedia::APIError object is returned.

Note: Expedia responds with status of 200 even if there is an exception (most of the times). So no Exception is raised!

# See http://developer.ean.com/docs/error-handling/hotel-v3-exception-details/

response.status # Response status
response.error_body # Complete error body
response.category # Value indicating the nature of the exception or the reason it occurred
response.presentation_message # Presentation error message returned
response.verbose_message # More specific detailed error message
response.handling # value indicating the severity of the exception and how it may be handled

Test Booking (Static Reservation)

For Static reservation use get_static_reservation() method.

CAUTION: Do Not send adress and booking information (creditCardNumber, creditCardIdentifier, creditCardExpirationMonth, creditCardExpirationYear, address1) in parameters to the method. Especially do not pass address1 parameter They are already been taken care of. For more on Static booking see Static Test Booking Credit Card Information

A static Booking example.

response = api.get_static_reservation({	:arrivalDate => "10/10/2013", :departureDate => "10/12/2013",
                                        :hotelID => 359433, :supplierType => "E", :rateKey => "084eab14-335e-46d6-aa2e-766fce6be32c",
                                        :roomTypeCode => 200007964, :rateCode => 200865704, :chargeableRate => "142.8",
                                        :room1 => "1", :room1FirstName => "test", :room1LastName => "testers", :room1BedTypeId => "15",
                                        :room1SmokingPreference => "NS", :email => "test@tesing.com", :city => 'Bellevue',
                                        :stateProvinceCode => 'WA', :countryCode => 'US', :postalCode => 98004 })

Logging

Expedia::Utils.logger points to STDOUT by default. You can use it to Log in Rails applications.

Expedia::Utils.logger = Rails.logger

# And loggig methods available
[:debug, :info, :warn, :error, :fatal]

# Default logger level is Logger::ERROR. You can change it by setting
Expedia.logger.level = Logger::DEBUG # Or whatever level you want...

Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am ‘Added some feature’`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Project Statistics

Sourcerank 7
Repository Size 388 KB
Stars 46
Forks 31
Watchers 7
Open issues 2
Dependencies 4
Contributors 11
Tags 4
Created
Last updated
Last pushed

Top Contributors See all

Zaid Akram shanys8 Kelly Mahan Brad Anderson Smith Benjamin Corey Wilkins Martijn Bleeker Thomas Schmidt vitalim Tom de Bruijn Bikram Suwal Jordan Elver

Packages Referencing this Repo

expedia
Expedia is a lightweight, flexible Ruby SDK for EAN. It allows read/write access to the EAN APIs.
Latest release 0.0.7 - Updated - 46 stars

Recent Tags See all

v0.0.7 August 03, 2015
v0.0.6 July 06, 2015
v0.0.5 June 07, 2015
v0.0.4 January 10, 2015

Interesting Forks See all

goto-satoru/expedia
Expedia is a ruby wrapper for EAN (Expedia Affiliate Network)
This repository is no longer available - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2017-04-17 12:22:53 UTC

Login to resync this repository