Wego Hotels API

Build
Status Code
Climate Gem
Version

The Wego Hotels API allows developers to interact with the Hotels product of Wego.com programmatically via HTTP requests. This is the interface to the Wego Hotels API and responses are parsed to OpenStruct object.

Installation

Add this line to your application's Gemfile:

gem "wego"

And then execute:

$ bundle install

Configure

Once you are approved and you got your API key from Wego.com, then you can add an initializer to set your API keys

Wego.configure do |config|
  config.api_key  = "WEGO_API_KEY"
  config.api_code = "WEGO_TS_CODE"
end

Usages

Locations

Use this to map user location queries to Wego location IDs. E.g. you will probably provide your users with a text field for entering the location when searching for hotels. The Locations API allows you to lookup text queries like "sydney" to get a list of matching locations and their IDs.

Wego::Location.find(
  "sydney", lang: "en", page: 1, per_page: 10
)

Complete list of options: Wego Location API.

To perform a real-time search on Wego's partners' sites for rates in a given location and date range, you need to pass the search terms with the user's ip. For example: create new search for hotels in Sydney (location ID 7046)

Wego::Search.create(
  location_id: "7046",
  rooms: 1,
  guests: 2,
  check_in: "2016-07-15",
  check_out: "2016-07-20",
  user_ip: end_user_ip
)

Complete list of parameters: Wego Search API.

Results

Once user created a new search and they have the search_id then they can retrieve that search results very easily. Wego suggests to wait at least 10 seconds after starting the search

Wego::Result.find(
  search_id,
  lang: "en",
  page: 1,
  per_page: 20,
  order: "asc",
  sort: "popularity",
  currency_code: "USD"
)

Complete list of options: Wego Search Results API.

Hotel Details

Get details of a hotel, like its address, amenities, photos.

Wego::Result.find(
  search_id, hotel_id: hotel_id, lang: "en", currency: "USD"
)

Complete list of parameters: Wego Search Result API.

Booking

The Wego API doesn't support the shopping cart or e-commerce process either, but using the API you can take users to continue the booking process at one of their partners' sites.

Wego::Booking.url_for(
  search_id, hotel_id: hotel_id, room_rate_id: room_rate_id, locale: "en"
)

Development

We are following Sandi Metz's Rules for this gem, you can read the description of the rules here. All new code should follow these rules. If you make changes in a pre-existing file that violates these rules you should fix the violations as part of your contribution.

Setup

  • Clone the repository.
git clone https://github.com/abunashir/wego.git
  • Setup your environment.
bin/setup
  • Run the test suite
bin/rake

PlayBox

  • Setup API keys.
cp .sample.pryrc .pryrc
vim .pryrc
  • Start your console.
bin/console
  • Start playing with it.
Wego::Location.find "sydney"

Testing

RSpec

This gem provides an easier way to test Wego API Responses. Simply include the following line in your spec_helper and you should have access to all of the test helpers.

require "wego/rspec"
Find a location
stub_get_location_api(q: location_name, lang: 1, page: 1, per_page: 10)
stub_new_search_api(search_term_as_hash)
Search results
stub_search_results_api(search_id, additional_option_hash)
Search result (Hotel)
stub_search_result_api(search_id: search_id, hotel_id: hotel_id, **options)
Invalid search result
stub_invalid_search_result_api(option_hash)
Invalid API response
stub_invalid_api_response(status: status_code)

Contributing

First, thank you for contributing! We love pull requests from everyone. By participating in this project, you hereby grant the right to grant or transfer an unlimited number of non exclusive licenses or sub-licenses to third parties, under the copyright covering the contribution to use the contribution by all means.

Here are a few technical guidelines to follow:

  1. Open an issue to discuss a new feature.
  2. Write tests to support your new feature.
  3. Make sure the entire test suite passes locally and on CI.
  4. Open a Pull Request.
  5. Squash your commits after receiving feedback.
  6. Party!

License

The gem is available as open source under the terms of the MIT License.