-
Notifications
You must be signed in to change notification settings - Fork 2
User flow
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.
-
Hotel.find(location: "Some Place, IN, The World"). This will return anArrayofHotels. 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)
-
Then, to get more information about a specific hotel, run
Hotel.find(id: hotel_id), wherehotel_idis the id attribute of aHotelfrom the above query. This will return more detailed information, i.e. more images and more than three amenities. -
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] }]). -
Set the bed types on the rooms:
room.rooms.each { |r| r[:bed_type] = room.bed_types[0] }. -
To get possible payment options for your user's currency, use the
PaymentOption.findquery, 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. -
To reserve a room, use
Room#reserve!. It takes a hash of the following options, all as symbols (italicized means optional):
- 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
- 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!