Class: Suitcase::Hotel::Room
- Inherits:
-
Object
- Object
- Suitcase::Hotel::Room
- Extended by:
- Helpers
- Includes:
- Helpers
- Defined in:
- lib/suitcase/hotel/room.rb
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#arrival ⇒ Object
Returns the value of attribute arrival.
-
#average_base_rate ⇒ Object
Returns the value of attribute average_base_rate.
-
#average_nightly_rate ⇒ Object
Returns the value of attribute average_nightly_rate.
-
#average_rate ⇒ Object
Returns the value of attribute average_rate.
-
#bed_types ⇒ Object
Returns the value of attribute bed_types.
-
#cancellation_policy ⇒ Object
Returns the value of attribute cancellation_policy.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#departure ⇒ Object
Returns the value of attribute departure.
-
#deposit_required ⇒ Object
Returns the value of attribute deposit_required.
-
#guarantee_only ⇒ Object
Returns the value of attribute guarantee_only.
-
#guarantee_required ⇒ Object
Returns the value of attribute guarantee_required.
-
#hotel_id ⇒ Object
Returns the value of attribute hotel_id.
-
#max_nightly_rate ⇒ Object
Returns the value of attribute max_nightly_rate.
-
#min_guest_age ⇒ Object
Returns the value of attribute min_guest_age.
-
#nightly_rate_total ⇒ Object
Returns the value of attribute nightly_rate_total.
-
#non_refundable ⇒ Object
Returns the value of attribute non_refundable.
-
#occupancy ⇒ Object
Returns the value of attribute occupancy.
-
#price_breakdown ⇒ Object
Returns the value of attribute price_breakdown.
-
#promo ⇒ Object
Returns the value of attribute promo.
-
#quoted_occupancy ⇒ Object
Returns the value of attribute quoted_occupancy.
-
#rate_change ⇒ Object
Returns the value of attribute rate_change.
-
#rate_code ⇒ Object
Returns the value of attribute rate_code.
-
#rate_description ⇒ Object
Returns the value of attribute rate_description.
-
#rate_key ⇒ Object
Returns the value of attribute rate_key.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#room_type_code ⇒ Object
Returns the value of attribute room_type_code.
-
#room_type_description ⇒ Object
Returns the value of attribute room_type_description.
-
#rooms ⇒ Object
Returns the value of attribute rooms.
-
#supplier_type ⇒ Object
Returns the value of attribute supplier_type.
-
#surcharge_total ⇒ Object
Returns the value of attribute surcharge_total.
-
#surcharges ⇒ Object
Returns the value of attribute surcharges.
-
#tax_rate ⇒ Object
Returns the value of attribute tax_rate.
-
#total ⇒ Object
Returns the value of attribute total.
-
#total_price ⇒ Object
Returns the value of attribute total_price.
-
#value_adds ⇒ Object
Returns the value of attribute value_adds.
Instance Method Summary collapse
-
#chargeable_rate ⇒ Object
Public: The chargeable rate for the Hotel room.
-
#initialize(info) ⇒ Room
constructor
Internal: Create a new Room from within a Room search query.
-
#reserve!(info) ⇒ Object
Public: Reserve a room.
-
#room_rate_description ⇒ Object
Public: The description of the displayed rate.
Methods included from Helpers
base_url, build_session_params, generate_signature, handle_errors, main_url, parameterize, parse_response, update_session, url
Constructor Details
#initialize(info) ⇒ Room
Internal: Create a new Room from within a Room search query.
info - A Hash of parsed information from the API, with any of the keys
from the attr_accessor's list.
22 23 24 25 26 |
# File 'lib/suitcase/hotel/room.rb', line 22 def initialize(info) info.each do |k, v| instance_variable_set("@" + k.to_s, v) end end |
Instance Attribute Details
#arrival ⇒ Object
Returns the value of attribute arrival.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def arrival @arrival end |
#average_base_rate ⇒ Object
Returns the value of attribute average_base_rate.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def average_base_rate @average_base_rate end |
#average_nightly_rate ⇒ Object
Returns the value of attribute average_nightly_rate.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def average_nightly_rate @average_nightly_rate end |
#average_rate ⇒ Object
Returns the value of attribute average_rate.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def average_rate @average_rate end |
#bed_types ⇒ Object
Returns the value of attribute bed_types.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def bed_types @bed_types end |
#cancellation_policy ⇒ Object
Returns the value of attribute cancellation_policy.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def cancellation_policy @cancellation_policy end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def currency_code @currency_code end |
#departure ⇒ Object
Returns the value of attribute departure.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def departure @departure end |
#deposit_required ⇒ Object
Returns the value of attribute deposit_required.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def deposit_required @deposit_required end |
#guarantee_only ⇒ Object
Returns the value of attribute guarantee_only.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def guarantee_only @guarantee_only end |
#guarantee_required ⇒ Object
Returns the value of attribute guarantee_required.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def guarantee_required @guarantee_required end |
#hotel_id ⇒ Object
Returns the value of attribute hotel_id.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def hotel_id @hotel_id end |
#max_nightly_rate ⇒ Object
Returns the value of attribute max_nightly_rate.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def max_nightly_rate @max_nightly_rate end |
#min_guest_age ⇒ Object
Returns the value of attribute min_guest_age.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def min_guest_age @min_guest_age end |
#nightly_rate_total ⇒ Object
Returns the value of attribute nightly_rate_total.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def nightly_rate_total @nightly_rate_total end |
#non_refundable ⇒ Object
Returns the value of attribute non_refundable.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def non_refundable @non_refundable end |
#occupancy ⇒ Object
Returns the value of attribute occupancy.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def occupancy @occupancy end |
#price_breakdown ⇒ Object
Returns the value of attribute price_breakdown.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def price_breakdown @price_breakdown end |
#promo ⇒ Object
Returns the value of attribute promo.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def promo @promo end |
#quoted_occupancy ⇒ Object
Returns the value of attribute quoted_occupancy.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def quoted_occupancy @quoted_occupancy end |
#rate_change ⇒ Object
Returns the value of attribute rate_change.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def rate_change @rate_change end |
#rate_code ⇒ Object
Returns the value of attribute rate_code.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def rate_code @rate_code end |
#rate_description ⇒ Object
Returns the value of attribute rate_description.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def rate_description @rate_description end |
#rate_key ⇒ Object
Returns the value of attribute rate_key.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def rate_key @rate_key end |
#raw ⇒ Object
Returns the value of attribute raw.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def raw @raw end |
#room_type_code ⇒ Object
Returns the value of attribute room_type_code.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def room_type_code @room_type_code end |
#room_type_description ⇒ Object
Returns the value of attribute room_type_description.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def room_type_description @room_type_description end |
#rooms ⇒ Object
Returns the value of attribute rooms.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def rooms @rooms end |
#supplier_type ⇒ Object
Returns the value of attribute supplier_type.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def supplier_type @supplier_type end |
#surcharge_total ⇒ Object
Returns the value of attribute surcharge_total.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def surcharge_total @surcharge_total end |
#surcharges ⇒ Object
Returns the value of attribute surcharges.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def surcharges @surcharges end |
#tax_rate ⇒ Object
Returns the value of attribute tax_rate.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def tax_rate @tax_rate end |
#total ⇒ Object
Returns the value of attribute total.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def total @total end |
#total_price ⇒ Object
Returns the value of attribute total_price.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def total_price @total_price end |
#value_adds ⇒ Object
Returns the value of attribute value_adds.
4 5 6 |
# File 'lib/suitcase/hotel/room.rb', line 4 def value_adds @value_adds end |
Instance Method Details
#chargeable_rate ⇒ Object
Public: The chargeable rate for the Hotel room.
Returns the chargeable rate for the Room.
116 117 118 119 120 121 122 |
# File 'lib/suitcase/hotel/room.rb', line 116 def chargeable_rate if @supplier_type == "E" @total_price else @max_nightly_rate end end |
#reserve!(info) ⇒ Object
Public: Reserve a room.
info - A Hash of the information described on the Suitcase
[wiki](http://github.com/thoughtfusion/suitcase/wiki/User-flow).
Returns a Suitcase::Reservation.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/suitcase/hotel/room.rb', line 34 def reserve!(info) params = {} params["hotelId"] = @hotel_id params["arrivalDate"] = @arrival params["departureDate"] = @departure params["supplierType"] = @supplier_type # Only submit the rateKey if it is a merchant hotel params["rateKey"] = @rate_key if @supplier_type == "E" params["rateTypeCode"] = @room_type_code params["rateCode"] = @rate_code params["roomTypeCode"] = @room_type_code params["chargeableRate"] = chargeable_rate params["email"] = info[:email] params["firstName"] = info[:first_name] params["lastName"] = info[:last_name] params["homePhone"] = info[:home_phone] params["workPhone"] = info[:work_phone] if info[:work_phone] params["extension"] = info[:work_phone_extension] if info[:work_phone_extension] params["faxPhone"] = info[:fax_phone] if info[:fax_phone] params["companyName"] = info[:company_name] if info[:company_name] if info[:additional_emails] params["emailIntineraryList"] = info[:additional_emails].join(",") end params["creditCardType"] = info[:payment_option].code params["creditCardNumber"] = info[:credit_card_number] params["creditCardIdentifier"] = info[:credit_card_verification_code] expiration_date = Date._parse(info[:credit_card_expiration_date]) params["creditCardExpirationMonth"] = if expiration_date[:mon] < 10 "0" + expiration_date[:mon].to_s else expiration_date[:mon].to_s end params["creditCardExpirationYear"] = expiration_date[:year].to_s params["address1"] = info[:address1] params["address2"] = info[:address2] if info[:address2] params["address3"] = info[:address3] if info[:address3] params["city"] = info[:city] @rooms.each_with_index do |room, index| index += 1 params["room#{index}"] = "#{room[:adults].to_s},#{room[:children_ages].join(",")}" params["room#{index}FirstName"] = room[:first_name] || params["firstName"] # defaults to the billing params["room#{index}LastName"] = room[:last_name] || params["lastName"] # person's name params["room#{index}BedTypeId"] = room[:bed_type].id if @supplier_type == "E" params["room#{index}SmokingPreference"] = room[:smoking_preference] || "E" end params["stateProvinceCode"] = info[:province] params["countryCode"] = info[:country] params["postalCode"] = info[:postal_code] uri = Room.url( method: "res", params: params, include_key: true, include_cid: true, secure: true ) session = Patron::Session.new session.timeout = 30000 session.base_url = "https://" + uri.host res = session.post uri.request_uri, {} parsed = JSON.parse res.body reservation_res = parsed["HotelRoomReservationResponse"] handle_errors(parsed) surcharges = if @supplier_type == "E" && reservation_res["RateInfo"]["ChargeableRateInfo"]["Surcharges"] [reservation_res["RateInfo"]["ChargeableRateInfo"]["Surcharges"]["Surcharge"]]. flatten.map { |s| Surcharge.parse(s) } else [] end r = Reservation.new( itinerary_id: reservation_res["itineraryId"], confirmation_numbers: reservation_res["confirmationNumbers"], surcharges: surcharges ) r.raw = parsed r end |
#room_rate_description ⇒ Object
Public: The description of the displayed rate.
Returns the rate description based on the ‘rate_change` attribute.
127 128 129 130 131 132 133 |
# File 'lib/suitcase/hotel/room.rb', line 127 def room_rate_description if @rate_change "rate changes during the dates requested and the single nightly rate displayed is the highest nightly rate of the dates requested without taxes and fees." else "highest single night rate during the dates selected without taxes or fees" end end |