suitcase 1.6.6 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/suitcase/hotel/room.rb +30 -9
- data/lib/suitcase/hotel.rb +10 -4
- data/lib/suitcase/version.rb +1 -1
- data/test/hotels/room_test.rb +0 -1
- metadata +9 -4
data/lib/suitcase/hotel/room.rb
CHANGED
@@ -9,7 +9,8 @@ module Suitcase
|
|
9
9
|
:room_type_description, :price_breakdown, :total_price,
|
10
10
|
:average_nightly_rate, :promo, :arrival, :departure, :rooms,
|
11
11
|
:bed_types, :cancellation_policy, :non_refundable,
|
12
|
-
:deposit_required, :surcharges,
|
12
|
+
:guarantee_required, :deposit_required, :surcharges,
|
13
|
+
:rate_description, :raw
|
13
14
|
|
14
15
|
extend Helpers
|
15
16
|
|
@@ -35,7 +36,8 @@ module Suitcase
|
|
35
36
|
params["arrivalDate"] = @arrival
|
36
37
|
params["departureDate"] = @departure
|
37
38
|
params["supplierType"] = @supplier_type
|
38
|
-
|
39
|
+
# Only submit the rateKey if it is a merchant hotel
|
40
|
+
params["rateKey"] = @rate_key if @supplier_type == "E"
|
39
41
|
params["rateTypeCode"] = @room_type_code
|
40
42
|
params["rateCode"] = @rate_code
|
41
43
|
params["roomTypeCode"] = @room_type_code
|
@@ -64,8 +66,8 @@ module Suitcase
|
|
64
66
|
params["room#{index}"] = "#{room[:adults].to_s},#{room[:children_ages].join(",")}"
|
65
67
|
params["room#{index}FirstName"] = room[:first_name] || params["firstName"] # defaults to the billing
|
66
68
|
params["room#{index}LastName"] = room[:last_name] || params["lastName"] # person's name
|
67
|
-
params["room#{index}BedTypeId"] = room[:bed_type].id
|
68
|
-
params["room#{index}SmokingPreference"] = room[:smoking_preference]
|
69
|
+
params["room#{index}BedTypeId"] = room[:bed_type].id if @supplier_type == "E"
|
70
|
+
params["room#{index}SmokingPreference"] = room[:smoking_preference] || "E"
|
69
71
|
end
|
70
72
|
params["stateProvinceCode"] = info[:province]
|
71
73
|
params["countryCode"] = info[:country]
|
@@ -78,11 +80,18 @@ module Suitcase
|
|
78
80
|
res = session.post uri.request_uri, {}
|
79
81
|
parsed = JSON.parse res.body
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
reservation_res = parsed["HotelRoomReservationResponse"]
|
84
|
+
surcharges = if @supplier_type == "E"
|
85
|
+
[reservation_res["RateInfo"]["ChargeableRateInfo"]["Surcharges"]["Surcharge"]].
|
86
|
+
flatten.map { |s| Surcharge.parse(s) }
|
87
|
+
else
|
88
|
+
[]
|
89
|
+
end
|
90
|
+
r = Reservation.new(
|
91
|
+
itinerary_id: reservation_res["itineraryId"],
|
92
|
+
confirmation_numbers: reservation_res["confirmationNumbers"],
|
93
|
+
surcharges: surcharges
|
94
|
+
)
|
86
95
|
r.raw = parsed
|
87
96
|
r
|
88
97
|
end
|
@@ -97,6 +106,18 @@ module Suitcase
|
|
97
106
|
@max_nightly_rate
|
98
107
|
end
|
99
108
|
end
|
109
|
+
|
110
|
+
# Public: The description of the displayed rate.
|
111
|
+
#
|
112
|
+
# Returns the rate description based on the `rate_change` attribute.
|
113
|
+
def room_rate_description
|
114
|
+
if @rate_change
|
115
|
+
"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."
|
116
|
+
else
|
117
|
+
"highest single night rate during the dates selected without taxes or fees"
|
118
|
+
end
|
119
|
+
end
|
100
120
|
end
|
101
121
|
end
|
102
122
|
end
|
123
|
+
|
data/lib/suitcase/hotel.rb
CHANGED
@@ -323,24 +323,30 @@ module Suitcase
|
|
323
323
|
Configuration.cache.save_query(:avail, params, parsed)
|
324
324
|
end
|
325
325
|
end
|
326
|
-
|
327
|
-
|
328
|
-
|
326
|
+
res = parsed["HotelRoomAvailabilityResponse"]
|
327
|
+
hotel_room_res = [res["HotelRoomResponse"]].flatten
|
328
|
+
hotel_id = res["hotelId"]
|
329
|
+
rate_key = res["rateKey"]
|
330
|
+
supplier_type = hotel_room_res[0]["supplierType"]
|
329
331
|
Hotel.update_session(parsed, info[:session])
|
330
332
|
|
331
|
-
|
333
|
+
hotel_room_res.map do |raw_data|
|
332
334
|
room_data = {}
|
333
335
|
room_data[:non_refundable] = raw_data["nonRefundable"]
|
334
336
|
room_data[:deposit_required] = raw_data["depositRequired"]
|
337
|
+
room_data[:guarantee_only] = raw_data["guaranteeRequired"]
|
335
338
|
room_data[:cancellation_policy] = raw_data["cancellationPolicy"]
|
336
339
|
room_data[:rate_code] = raw_data["rateCode"]
|
337
340
|
room_data[:room_type_code] = raw_data["roomTypeCode"]
|
338
341
|
room_data[:room_type_description] = raw_data["roomTypeDescription"]
|
342
|
+
room_data[:rate_description] = raw_data["rateDescription"]
|
339
343
|
room_data[:promo] = raw_data["RateInfo"]["@promo"].to_b
|
340
344
|
room_data[:price_breakdown] = raw_data["RateInfo"]["ChargeableRateInfo"]["NightlyRatesPerRoom"]["NightlyRate"].map do |raw|
|
341
345
|
NightlyRate.new(raw)
|
342
346
|
end if raw_data["RateInfo"]["ChargeableRateInfo"] && raw_data["RateInfo"]["ChargeableRateInfo"]["NightlyRatesPerRoom"] && raw_data["RateInfo"]["ChargeableRateInfo"]["NightlyRatesPerRoom"]["NightlyRate"].is_a?(Array)
|
343
347
|
room_data[:total_price] = raw_data["RateInfo"]["ChargeableRateInfo"]["@total"]
|
348
|
+
room_data[:max_nightly_rate] = raw_data["RateInfo"]["ChargeableRateInfo"]["@maxNightlyRate"]
|
349
|
+
room_data[:rate_change] = raw_data["rateChange"]
|
344
350
|
room_data[:nightly_rate_total] = raw_data["RateInfo"]["ChargeableRateInfo"]["@nightlyRateTotal"]
|
345
351
|
room_data[:average_nightly_rate] = raw_data["RateInfo"]["ChargeableRateInfo"]["@averageRate"]
|
346
352
|
room_data[:arrival] = info[:arrival]
|
data/lib/suitcase/version.rb
CHANGED
data/test/hotels/room_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: suitcase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -203,15 +203,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- - ! '>='
|
204
204
|
- !ruby/object:Gem::Version
|
205
205
|
version: '0'
|
206
|
+
segments:
|
207
|
+
- 0
|
208
|
+
hash: 1258883948376164129
|
206
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
210
|
none: false
|
208
211
|
requirements:
|
209
212
|
- - ! '>='
|
210
213
|
- !ruby/object:Gem::Version
|
211
214
|
version: '0'
|
215
|
+
segments:
|
216
|
+
- 0
|
217
|
+
hash: 1258883948376164129
|
212
218
|
requirements: []
|
213
219
|
rubyforge_project:
|
214
|
-
rubygems_version: 1.8.
|
220
|
+
rubygems_version: 1.8.24
|
215
221
|
signing_key:
|
216
222
|
specification_version: 3
|
217
223
|
summary: Locates available hotels and rental cars through Expedia and Hotwire
|
@@ -231,4 +237,3 @@ test_files:
|
|
231
237
|
- test/keys.rb
|
232
238
|
- test/minitest_helper.rb
|
233
239
|
- test/support/fake_response.rb
|
234
|
-
has_rdoc:
|