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.
Add this line to your application's Gemfile:
gem "wego"
And then execute:
$ bundle install
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
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.
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.
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.
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"
)
We are following Sandi Metz's Rules for this gem, you can read the [description of the rules here] (http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers). 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.
- Clone the repository.
git clone https://github.com/abunashir/wego.git
- Setup your environment.
bin/setup
- Run the test suite
bin/rake
- Setup API keys.
cp .sample.pryrc .pryrc
vim .pryrc
- Start your console.
bin/console
- Start playing with it.
Wego::Location.find "sydney"
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"
stub_get_location_api(q: location_name, lang: 1, page: 1, per_page: 10)
stub_new_search_api(search_term_as_hash)
stub_search_results_api(search_id, additional_option_hash)
stub_search_result_api(search_id: search_id, hotel_id: hotel_id, **options)
stub_invalid_search_result_api(option_hash)
stub_invalid_api_response(status: status_code)
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:
- Open an issue to discuss a new feature.
- Write tests to support your new feature.
- Make sure the entire test suite passes locally and on CI.
- Open a Pull Request.
- Squash your commits after receiving feedback.
- Party!
The gem is available as open source under the terms of the MIT License.