rthbound-suitcase 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -151,6 +151,16 @@ module Suitcase
151
151
  end
152
152
  end
153
153
 
154
+ if info[:arrival] && info[:departure]
155
+ params["arrivalDate"] = info[:arrival]
156
+ params["departureDate"] = info[:departure]
157
+ params.delete(:arrival)
158
+ params.delete(:departure)
159
+
160
+ params.merge!(parameterize_rooms(info[:rooms] || [{ adults: 1 }]))
161
+ params.delete(:rooms)
162
+ end
163
+
154
164
  amenities = params[:amenities] ? params[:amenities].map {|amenity|
155
165
  AMENITIES[amenity]
156
166
  }.join(",") : nil
@@ -281,9 +291,8 @@ module Suitcase
281
291
  # Returns an Array of Rooms.
282
292
  def rooms(info)
283
293
  params = { rooms: [{adults: 1, children_ages: []}] }.merge(info)
284
- params[:rooms].each_with_index do |room, n|
285
- params["room#{n+1}"] = room[:adults].to_s + "," + (room[:children_ages].join(",") if room[:children_ages])
286
- end
294
+ params.merge!(Hotel.parameterize_rooms(params[:rooms]))
295
+ params.delete(:rooms)
287
296
  params["arrivalDate"] = info[:arrival]
288
297
  params["departureDate"] = info[:departure]
289
298
  params["includeDetails"] = true
@@ -193,6 +193,18 @@ module Suitcase
193
193
  Configuration.hotel_shared_secret +
194
194
  Time.now.to_i.to_s)
195
195
  end
196
+
197
+ # Internal: Build a rooms parameter given an array of hashes
198
+ #
199
+ # Returns the rooms parameters hash
200
+ def parameterize_rooms(rooms)
201
+ params = {}
202
+ rooms.each_with_index do |room, n|
203
+ params["room#{n+1}"] = room[:adults].to_s
204
+ params["room#{n+1}"] += "," + room[:children_ages].join(",") if room[:children_ages]
205
+ end
206
+ params
207
+ end
196
208
  end
197
209
  end
198
210
  end
@@ -7,8 +7,9 @@ module Suitcase
7
7
  :surcharge_total, :nightly_rate_total, :average_base_rate,
8
8
  :average_rate, :max_nightly_rate, :currency_code, :value_adds,
9
9
  :room_type_description, :price_breakdown, :total_price,
10
- :average_nightly_rate, :promo, :arrival, :departure, :rooms,
11
- :bed_types, :cancellation_policy, :non_refundable,
10
+ :average_nightly_rate, :promo, :promo_description,
11
+ :arrival, :departure, :rooms, :bed_types,
12
+ :cancellation_policy, :non_refundable,
12
13
  :guarantee_required, :deposit_required, :surcharges,
13
14
  :rate_description, :raw, :rate_change, :guarantee_only
14
15
 
@@ -68,9 +69,9 @@ module Suitcase
68
69
  params["address2"] = info[:address2] if info[:address2]
69
70
  params["address3"] = info[:address3] if info[:address3]
70
71
  params["city"] = info[:city]
72
+ params.merge!(parameterize_rooms(@rooms))
71
73
  @rooms.each_with_index do |room, index|
72
74
  index += 1
73
- params["room#{index}"] = "#{room[:adults].to_s},#{room[:children_ages].join(",")}"
74
75
  params["room#{index}FirstName"] = room[:first_name] || params["firstName"] # defaults to the billing
75
76
  params["room#{index}LastName"] = room[:last_name] || params["lastName"] # person's name
76
77
  params["room#{index}BedTypeId"] = room[:bed_type].id if @supplier_type == "E"
@@ -1,3 +1,3 @@
1
1
  module Suitcase
2
- VERSION = "1.7.1"
2
+ VERSION = "1.7.2"
3
3
  end
@@ -49,4 +49,12 @@ describe Suitcase::Hotel::Helpers do
49
49
  signature.must_equal(Digest::MD5.hexdigest("abc12310"))
50
50
  end
51
51
  end
52
+
53
+ describe "#parameterize_rooms" do
54
+ it "returns a hash of room parameters" do
55
+ rooms = [{adults: 1}, {adults: 2, children_ages: [3, 5]}]
56
+ params = Dummy.parameterize_rooms(rooms)
57
+ params.must_equal({ "room1" => "1", "room2" => "2,3,5" })
58
+ end
59
+ end
52
60
  end
@@ -20,6 +20,16 @@ describe Suitcase::Hotel do
20
20
  @hotel.must_be_kind_of(Suitcase::Hotel)
21
21
  end
22
22
 
23
+ it "returns available hotels if arrival and departure are passed in" do
24
+ hotels = Suitcase::Hotel.find(location: "London, UK",
25
+ arrival: "10/13/2013",
26
+ departure: "10/15/2013",
27
+ results: 1)
28
+ hotels.must_be_kind_of(Array)
29
+ hotels.first.must_be_kind_of(Suitcase::Hotel)
30
+ hotels.first.raw["HotelListResponse"]["moreResultsAvailable"].must_equal(true)
31
+ end
32
+
23
33
  it "returns multiple Hotels if a location is passed in" do
24
34
  hotels = Suitcase::Hotel.find(location: "London, UK")
25
35
  hotels.must_be_kind_of(Array)
@@ -9,8 +9,8 @@ describe Suitcase::Hotel::Room do
9
9
  non_refundable occupancy quoted_occupancy min_guest_age total surcharge_total
10
10
  average_base_rate average_base_rate average_rate max_nightly_rate
11
11
  currency_code value_adds room_type_description price_breakdown total_price
12
- average_nightly_rate promo rate_key hotel_id supplier_type bed_types
13
- rooms).each do |attribute|
12
+ average_nightly_rate promo promo_description rate_key hotel_id
13
+ supplier_type bed_types rooms).each do |attribute|
14
14
  it "has an attr_accessor for #{attribute}" do
15
15
  @room.must_respond_to attribute.to_sym
16
16
  @room.must_respond_to (attribute + "=").to_sym
@@ -33,7 +33,10 @@ describe Suitcase::Hotel::Room do
33
33
  province: "MA",
34
34
  country: "US",
35
35
  postal_code: "02111" }
36
- @room.rooms[0][:bed_type] = @room.bed_types[0]
36
+ @room.rooms = [{}]
37
+ @room.rooms[0][:adults] = 1
38
+ @room.rooms[0][:children_ages] = [5, 3]
39
+ # @room.rooms[0][:bed_type] = @room.bed_types[0]
37
40
  @room.rooms[0][:smoking_preference] = "NS"
38
41
  end
39
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rthbound-suitcase
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -204,12 +204,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
204
  - - ! '>='
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
+ segments:
208
+ - 0
209
+ hash: -1478877458648309527
207
210
  required_rubygems_version: !ruby/object:Gem::Requirement
208
211
  none: false
209
212
  requirements:
210
213
  - - ! '>='
211
214
  - !ruby/object:Gem::Version
212
215
  version: '0'
216
+ segments:
217
+ - 0
218
+ hash: -1478877458648309527
213
219
  requirements: []
214
220
  rubyforge_project:
215
221
  rubygems_version: 1.8.24