GithubHelp home page GithubHelp logo

zaidakram / expedia Goto Github PK

View Code? Open in Web Editor NEW
48.0 9.0 29.0 397 KB

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

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

License: MIT License

Ruby 100.00%

expedia's Introduction

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 => "[email protected]", :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

expedia's People

Contributors

benjamincorey avatar bradtheappguy avatar digitaltom avatar jordelver avatar kellymahan avatar tombruijn avatar veekram avatar vitalim avatar zaidakram avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expedia's Issues

Issue with get_static_reservation method

When I try to use this method call, I receive the following failing message:

Faraday::Error::ConnectionFailed:
hostname "dev.api.ean.com" does not match the server certificate

All my other method calls test fine. Is there someplace we are suppose to set the url?

formatting room group object

I have been trying to figure out how to format the number of rooms/ guests section using this gem for some time and simply cannot figure it out. The api docs say :

"Room format for REST
The REST format compacts the values from the previous elements into a comma-delimited list. To declare a room and its occupants, use the following format:

&room[room number, starting with 1]=
[number of adults],
[comma-delimited list of children's ages]

For example, to declare that a room has one adult and two children ages 5 and 12, you would send &room1=1,5,12 . There is no separate declaration for the number of children - each age value is assumed to belong to a child."

I feel like I have tried every combination under the sun and I can't get a number of rooms to show up in my get request. Would it be possible to get an example of the format?

dev mode url

Kept getting a 403 response in dev mode.. I had to change the DEVELOPMENT_SERVER to api.ean.com from dev.api.ean.com in http_service.rb, once I did I started getting response 200 in development mode..

Is there a way to get the current price?

What is the syntax to retrieve the current price for a given date? Sorry I am just a bit confused as to how to use the "expeosed" methods. I cant call them on the object or the response. Thanks for your time

sig value for authentication

Lines 83-98 of the same file (https://github.com/zaidakram/expedia/blob/master/lib/expedia/http_service.rb ) is where sig is put together and since Ruby sets variables when the service is started the timestamp is static which makes the sig static which causes authentication failures after about 5 minutes of the service being started.

This is because EAN's service will only authenticate a sig value for 5 minutes based on the EAN server time. To get the EAN server time, use EAN's ping request. Always generate a new sig value for each request to ensure your requests are authenticated.

Code not working

For me, even copying the exact code written on this repository's home page in to my program gives me an error. It says: "in add_timeouts': undefined methodpresent?' for nil:NilClass (NoMethodError)". Any ideas why? Or what I'm doing wrong.

#<Expedia::APIError: Expedia::APIError>

After upgrading to version to 0.0.5, I am getting the above mentioned error. The status response is 400.
I am simply making request as:

list_api = Expedia.Api.new
response = list_api.get_payment_info( {:hotelID => 172396)

Am not I supposed to get the response.body?

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.