Class: Suitcase::Room
- Inherits:
-
Object
- Object
- Suitcase::Room
- Extended by:
- Helpers
- Defined in:
- lib/suitcase/hotel/room.rb
Instance Attribute Summary (collapse)
-
- (Object) arrival
Returns the value of attribute arrival.
-
- (Object) average_base_rate
Returns the value of attribute average_base_rate.
-
- (Object) average_nightly_rate
Returns the value of attribute average_nightly_rate.
-
- (Object) average_rate
Returns the value of attribute average_rate.
-
- (Object) bed_types
Returns the value of attribute bed_types.
-
- (Object) currency_code
Returns the value of attribute currency_code.
-
- (Object) departure
Returns the value of attribute departure.
-
- (Object) hotel_id
Returns the value of attribute hotel_id.
-
- (Object) max_nightly_rate
Returns the value of attribute max_nightly_rate.
-
- (Object) min_guest_age
Returns the value of attribute min_guest_age.
-
- (Object) nightly_rate_total
Returns the value of attribute nightly_rate_total.
-
- (Object) non_refundable
Returns the value of attribute non_refundable.
-
- (Object) occupancy
Returns the value of attribute occupancy.
-
- (Object) price_breakdown
Returns the value of attribute price_breakdown.
-
- (Object) promo
Returns the value of attribute promo.
-
- (Object) quoted_occupancy
Returns the value of attribute quoted_occupancy.
-
- (Object) rate_code
Returns the value of attribute rate_code.
-
- (Object) rate_key
Returns the value of attribute rate_key.
-
- (Object) room_type_code
Returns the value of attribute room_type_code.
-
- (Object) room_type_description
Returns the value of attribute room_type_description.
-
- (Object) rooms
Returns the value of attribute rooms.
-
- (Object) supplier_type
Returns the value of attribute supplier_type.
-
- (Object) surcharge_total
Returns the value of attribute surcharge_total.
-
- (Object) tax_rate
Returns the value of attribute tax_rate.
-
- (Object) total
Returns the value of attribute total.
-
- (Object) total_price
Returns the value of attribute total_price.
-
- (Object) value_adds
Returns the value of attribute value_adds.
Instance Method Summary (collapse)
- - (Object) chargeable_rate
-
- (Room) initialize(info)
constructor
A new instance of Room.
- - (Object) reserve!(info)
Methods included from Helpers
base_url, main_url, parse_response, update_session, url
Constructor Details
- (Room) initialize(info)
A new instance of Room
6 7 8 9 10 |
# File 'lib/suitcase/hotel/room.rb', line 6 def initialize(info) info.each do |k, v| instance_variable_set("@" + k.to_s, v) end end |
Instance Attribute Details
- (Object) arrival
Returns the value of attribute arrival
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def arrival @arrival end |
- (Object) average_base_rate
Returns the value of attribute average_base_rate
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def average_base_rate @average_base_rate end |
- (Object) average_nightly_rate
Returns the value of attribute average_nightly_rate
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def average_nightly_rate @average_nightly_rate end |
- (Object) average_rate
Returns the value of attribute average_rate
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def average_rate @average_rate end |
- (Object) bed_types
Returns the value of attribute bed_types
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def bed_types @bed_types end |
- (Object) currency_code
Returns the value of attribute currency_code
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def currency_code @currency_code end |
- (Object) departure
Returns the value of attribute departure
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def departure @departure end |
- (Object) hotel_id
Returns the value of attribute hotel_id
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def hotel_id @hotel_id end |
- (Object) max_nightly_rate
Returns the value of attribute max_nightly_rate
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def max_nightly_rate @max_nightly_rate end |
- (Object) min_guest_age
Returns the value of attribute min_guest_age
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def min_guest_age @min_guest_age end |
- (Object) nightly_rate_total
Returns the value of attribute nightly_rate_total
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def nightly_rate_total @nightly_rate_total end |
- (Object) non_refundable
Returns the value of attribute non_refundable
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def non_refundable @non_refundable end |
- (Object) occupancy
Returns the value of attribute occupancy
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def occupancy @occupancy end |
- (Object) price_breakdown
Returns the value of attribute price_breakdown
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def price_breakdown @price_breakdown end |
- (Object) promo
Returns the value of attribute promo
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def promo @promo end |
- (Object) quoted_occupancy
Returns the value of attribute quoted_occupancy
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def quoted_occupancy @quoted_occupancy end |
- (Object) rate_code
Returns the value of attribute rate_code
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def rate_code @rate_code end |
- (Object) rate_key
Returns the value of attribute rate_key
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def rate_key @rate_key end |
- (Object) room_type_code
Returns the value of attribute room_type_code
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def room_type_code @room_type_code end |
- (Object) room_type_description
Returns the value of attribute room_type_description
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def room_type_description @room_type_description end |
- (Object) rooms
Returns the value of attribute rooms
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def rooms @rooms end |
- (Object) supplier_type
Returns the value of attribute supplier_type
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def supplier_type @supplier_type end |
- (Object) surcharge_total
Returns the value of attribute surcharge_total
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def surcharge_total @surcharge_total end |
- (Object) tax_rate
Returns the value of attribute tax_rate
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def tax_rate @tax_rate end |
- (Object) total
Returns the value of attribute total
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def total @total end |
- (Object) total_price
Returns the value of attribute total_price
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def total_price @total_price end |
- (Object) value_adds
Returns the value of attribute value_adds
3 4 5 |
# File 'lib/suitcase/hotel/room.rb', line 3 def value_adds @value_adds end |
Instance Method Details
- (Object) chargeable_rate
61 62 63 64 65 66 67 |
# File 'lib/suitcase/hotel/room.rb', line 61 def chargeable_rate if @supplier_type == "E" @total_price else @max_nightly_rate end end |
- (Object) reserve!(info)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 |
# File 'lib/suitcase/hotel/room.rb', line 12 def reserve!(info) params = {} params["hotelId"] = @hotel_id params["arrivalDate"] = @arrival params["departureDate"] = @departure params["supplierType"] = @supplier_type params["rateKey"] = @rate_key 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] params["emailIntineraryList"] = info[:additional_emails].join(",") if info[:additional_emails] 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"] = (expiration_date[:mon].to_s.length == 1 ? "0" + expiration_date[:mon].to_s : expiration_date[:mon].to_s) 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 params["room#{index}SmokingPreference"] = room[:smoking_preference] or "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.base_url = "https://" + uri.host res = session.post uri.request_uri, {} parsed = JSON.parse res.body Reservation.new(itinerary_id: parsed["HotelRoomReservationResponse"]["itineraryId"], confirmation_numbers: parsed["HotelRoomReservationResponse"]["confirmationNumbers"]) end |