Skip to content
thoughtfusion edited this page Jul 31, 2012 · 15 revisions

Grab the gem, so you can try the following at the prompt. The following is a basic sequence of events for your app to follow.

  1. Hotel.find(location: "Some Place, IN, The World"). This will return an Array of Hotels. Each of these Hotel object's will have the following attributes:
  • name
  • id
  • address
  • amenities
  • city
  • country_code
  • postal_code
  • rating
  • high_rate
  • low_rate
  • max_rate - Might not be used
  • min_rate - Might not be used
  • nightly_rate_total
  • images
  • longitude
  • latitude
  • supplier_type
  • thumbnail_url (a helper method for returning a thumbnail image)
  1. Then, to get more information about a specific hotel, run Hotel.find(id: hotel_id), where hotel_id is the id attribute of a Hotel from the above query. This will return more detailed information, i.e. more images and more than three amenities.

  2. To list rooms available at a hotel, use the query Hotel#rooms. For example, this particular query searches for the availability of two rooms, one for one adult and two children ages 2 and 3, and the other for one adult and one child of age 4: room = @hotel.rooms(arrival: "somedate", departure: "someotherdate", rooms: [{ adults: 1, children_ages: [2, 3] }, { adults: 1, children_ages: [4] }]).

  3. Set the bed types on the rooms: room.rooms.each { |r| r[:bed_type] = room.bed_types[0] }.

  4. To get possible payment options for your user's currency, use the PaymentOption.find query, with the user's preferred currency passed in as an option. For example, PaymentOption.find(currency_code: "USD") returns all payment options which are compatible with USDs.

  5. To reserve a room, use Room#reserve!. It takes a hash of the following options, all as symbols (italicized means optional):

  • email
  • first_name
  • last_name
  • home_phone
  • work_phone
  • work_phone_extension
  • fax_phone
  • company_name
  • additional_emails (an array of string email addresses that the reservation confirmation should be sent to)
  • payment_option (the selected payment type object from [4])
  • credit_card_number
  • credit_card_verification_code
  • credit_card_expiration_date (a string, eg. "YYYY-MM-DD", the day is required)
  • address1
  • address2, address3
  • city
  • province
  • country
  • postal_code
  1. The item returned from that will be a reservation. Store this in the database for future use, or whatever.

Any questions about this please ask via issues!

Clone this wiki locally