suitcase 1.3.0 → 1.3.1
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/README.md +4 -2
- data/lib/suitcase/hotel/amenity.rb +35 -1
- data/lib/suitcase/hotel/hotel.rb +10 -4
- data/lib/suitcase/hotel/room.rb +1 -0
- data/lib/suitcase/version.rb +1 -1
- data/spec/amenity_spec.rb +25 -0
- data/spec/{hotels_spec.rb → hotels/hotels_spec.rb} +1 -0
- data/suitcase.gemspec +3 -4
- metadata +29 -26
- /data/spec/{car_rental_spec.rb → car_rentals/car_rental_spec.rb} +0 -0
- /data/spec/{caching_spec.rb → hotels/caching_spec.rb} +0 -0
- /data/spec/{helpers_spec.rb → hotels/helpers_spec.rb} +0 -0
- /data/spec/{hotel_location_spec.rb → hotels/hotel_location_spec.rb} +0 -0
- /data/spec/{images_spec.rb → hotels/images_spec.rb} +0 -0
- /data/spec/{payment_options_spec.rb → hotels/payment_options_spec.rb} +0 -0
- /data/spec/{reservation_spec.rb → hotels/reservation_spec.rb} +0 -0
- /data/spec/{rooms_spec.rb → hotels/rooms_spec.rb} +0 -0
- /data/spec/{sessions_spec.rb → hotels/sessions_spec.rb} +0 -0
data/README.md
CHANGED
@@ -43,7 +43,7 @@ room.reserve!(reservation_hash)
|
|
43
43
|
|
44
44
|
#### Caching requests
|
45
45
|
|
46
|
-
You can setup a cache to store all API requests that do not contain secure information (i.e. anything but booking requests). A cache needs to be able store deeply nested Hashes and have a method called [] to access them. An example of setting the cache is given above. Check the `examples/hash_adapter.rb` for a trivial example of the required methods. A Redis adapter
|
46
|
+
You can setup a cache to store all API requests that do not contain secure information (i.e. anything but booking requests). A cache needs to be able store deeply nested Hashes and have a method called #[] to access them. An example of setting the cache is given above. Check the `examples/hash_adapter.rb` for a trivial example of the required methods. A Redis adapter is also in the examples directory.
|
47
47
|
|
48
48
|
|
49
49
|
### Car rentals
|
@@ -66,6 +66,8 @@ rentals = Suitcase::CarRental.find(destination: "LAX", start_date: "7/14/2012",
|
|
66
66
|
# => [#<Suitcase::CarRental ...>, ...]
|
67
67
|
```
|
68
68
|
|
69
|
+
Caching is not recommended for car rentals, because they all change so quickly.
|
70
|
+
|
69
71
|
Contributing
|
70
72
|
------------
|
71
73
|
|
@@ -75,4 +77,4 @@ To set up for the specs, you need to edit the file `spec/keys.rb` with the prope
|
|
75
77
|
|
76
78
|
### Pull requests/issues
|
77
79
|
|
78
|
-
Please submit any useful pull requests through GitHub. If you find any bugs, please report them with the issue tracker! Thanks.
|
80
|
+
Please submit any useful pull requests through GitHub, preferably to the `develop` branch in the repo. If you find any bugs, please report them with the issue tracker! Thanks.
|
@@ -1,9 +1,43 @@
|
|
1
1
|
module Suitcase
|
2
2
|
class Amenity
|
3
3
|
attr_accessor :id, :description
|
4
|
-
|
4
|
+
|
5
|
+
BITS = { :business_services => 1,
|
6
|
+
:fitness_center => 2,
|
7
|
+
:hot_tub => 4,
|
8
|
+
:internet_access => 8,
|
9
|
+
:kids_activities => 16,
|
10
|
+
:kitchen => 32,
|
11
|
+
:pets_allowed => 64,
|
12
|
+
:swimming_pool => 128,
|
13
|
+
:restaurant => 256,
|
14
|
+
:whirlpool_bath => 1024,
|
15
|
+
:breakfast => 2048,
|
16
|
+
:babysitting => 4096,
|
17
|
+
:jacuzzi => 8192,
|
18
|
+
:parking => 16384,
|
19
|
+
:room_service => 32768,
|
20
|
+
:accessible_path => 65536,
|
21
|
+
:accessible_bathroom => 131072,
|
22
|
+
:roll_in_shower => 262144,
|
23
|
+
:handicapped_parking => 524288,
|
24
|
+
:in_room_accessibility => 1048576,
|
25
|
+
:deaf_accessiblity => 2097152,
|
26
|
+
:braille_or_signage => 4194304,
|
27
|
+
:free_airport_shuttle => 8388608,
|
28
|
+
:indoor_pool => 16777216,
|
29
|
+
:outdoor_pool => 33554432,
|
30
|
+
:extended_parking => 67108864,
|
31
|
+
:free_parking => 134217728 }
|
32
|
+
|
5
33
|
def initialize(info)
|
6
34
|
@id, @description = info[:id], info[:description]
|
7
35
|
end
|
36
|
+
|
37
|
+
def self.parse_mask(bitmask)
|
38
|
+
return nil unless bitmask
|
39
|
+
|
40
|
+
BITS.select {|amenity, bit| (bitmask & bit) > 0 }.keys
|
41
|
+
end
|
8
42
|
end
|
9
43
|
end
|
data/lib/suitcase/hotel/hotel.rb
CHANGED
@@ -30,8 +30,8 @@ module Suitcase
|
|
30
30
|
pets: 7,
|
31
31
|
wheelchair_accessible: 8,
|
32
32
|
kitchen: 9 }
|
33
|
-
|
34
|
-
attr_accessor :id, :name, :address, :city, :province, :amenities, :country_code, :high_rate, :low_rate, :longitude, :latitude, :rating, :postal_code, :supplier_type, :images, :nightly_rate_total, :airport_code, :property_category, :confidence_rating, :amenity_mask, :location_description, :short_description, :hotel_in_destination, :proximity_distance, :property_description, :number_of_floors, :number_of_rooms, :deep_link, :tripadvisor_rating
|
33
|
+
|
34
|
+
attr_accessor :id, :name, :address, :city, :province, :amenities, :masked_amenities, :country_code, :high_rate, :low_rate, :longitude, :latitude, :rating, :postal_code, :supplier_type, :images, :nightly_rate_total, :airport_code, :property_category, :confidence_rating, :amenity_mask, :location_description, :short_description, :hotel_in_destination, :proximity_distance, :property_description, :number_of_floors, :number_of_rooms, :deep_link, :tripadvisor_rating
|
35
35
|
|
36
36
|
# Public: Initialize a new hotel
|
37
37
|
#
|
@@ -111,10 +111,14 @@ module Suitcase
|
|
111
111
|
params.delete(:results)
|
112
112
|
params["destinationString"] = params[:location]
|
113
113
|
params.delete(:location)
|
114
|
-
|
114
|
+
|
115
|
+
amenities = params[:amenities] ? params[:amenities].map {|amenity|
|
116
|
+
AMENITIES[amenity]
|
117
|
+
}.join(",") : nil
|
118
|
+
params[:amenities] = amenities if amenities
|
119
|
+
|
115
120
|
params["minRate"] = params[:min_rate] if params[:min_rate]
|
116
121
|
params["maxRate"] = params[:max_rate] if params[:max_rate]
|
117
|
-
params[:amenities] = amenities if amenities
|
118
122
|
hotels = []
|
119
123
|
if Configuration.cache? and Configuration.cache.cached?(:list, params)
|
120
124
|
parsed = Configuration.cache.get_query(:list, params)
|
@@ -146,6 +150,8 @@ module Suitcase
|
|
146
150
|
parsed_info[:number_of_rooms] = parsed["HotelInformationResponse"]["HotelDetails"]["numberOfRooms"] if parsed["HotelInformationResponse"]
|
147
151
|
parsed_info[:number_of_floors] = parsed["HotelInformationResponse"]["HotelDetails"]["numberOfFloors"] if parsed["HotelInformationResponse"]
|
148
152
|
parsed_info[:short_description] = summary["shortDescription"]
|
153
|
+
parsed_info[:amenity_mask] = summary["amenityMask"]
|
154
|
+
parsed_info[:masked_amenities] = Amenity.parse_mask(parsed_info[:amenity_mask])
|
149
155
|
parsed_info
|
150
156
|
end
|
151
157
|
|
data/lib/suitcase/hotel/room.rb
CHANGED
@@ -52,6 +52,7 @@ module Suitcase
|
|
52
52
|
params["postalCode"] = info[:postal_code]
|
53
53
|
uri = Room.url :method => "res", :params => params, :include_key => true, :include_cid => true, :secure => true
|
54
54
|
session = Patron::Session.new
|
55
|
+
session.timeout = 30000
|
55
56
|
session.base_url = "https://" + uri.host
|
56
57
|
res = session.post uri.request_uri, {}
|
57
58
|
parsed = JSON.parse res.body
|
data/lib/suitcase/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Suitcase
|
4
|
+
describe Amenity do
|
5
|
+
describe ".parse_mask" do
|
6
|
+
context "when provided bitmask is not nil or 0" do
|
7
|
+
it "returns an array of symbols representing given amenities" do
|
8
|
+
Amenity.parse_mask(5).should == [:business_services, :hot_tub]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when provided bitmask is 0" do
|
13
|
+
it "returns an empty array" do
|
14
|
+
Amenity.parse_mask(0).should == []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when provided bitmask is nil" do
|
19
|
+
it "returns nil" do
|
20
|
+
Amenity.parse_mask(nil).should == nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -38,6 +38,7 @@ describe Suitcase::Hotel do
|
|
38
38
|
it { should respond_to :address }
|
39
39
|
it { should respond_to :city }
|
40
40
|
it { should respond_to :amenities }
|
41
|
+
it { should respond_to :masked_amenities }
|
41
42
|
it { should respond_to :country_code }
|
42
43
|
it { should respond_to :high_rate }
|
43
44
|
it { should respond_to :low_rate }
|
data/suitcase.gemspec
CHANGED
@@ -8,10 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Walter Nelson"]
|
9
9
|
s.email = ["walter.john.nelson@gmail.com"]
|
10
10
|
s.homepage = "http://github.com/thoughtfusion/suitcase"
|
11
|
-
s.summary = %q{Locates available hotels
|
12
|
-
s.description = %q{Ruby library that utilizes the EAN (Expedia.com) API for locating available hotels
|
13
|
-
|
14
|
-
s.rubyforge_project = "suitcase"
|
11
|
+
s.summary = %q{Locates available hotels and rental cars through Expedia and Hotwire}
|
12
|
+
s.description = %q{Ruby library that utilizes the EAN (Expedia.com) API for locating available hotels and the Hotwire API for rental cars.}
|
15
13
|
|
16
14
|
s.files = `git ls-files`.split("\n")
|
17
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -22,6 +20,7 @@ Gem::Specification.new do |s|
|
|
22
20
|
s.add_development_dependency "rake"
|
23
21
|
s.add_development_dependency "factory_girl"
|
24
22
|
s.add_development_dependency "pry"
|
23
|
+
|
25
24
|
s.add_runtime_dependency "json"
|
26
25
|
s.add_runtime_dependency "patron"
|
27
26
|
end
|
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.3.
|
4
|
+
version: 1.3.1
|
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-04-
|
12
|
+
date: 2012-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
description: Ruby library that utilizes the EAN (Expedia.com) API for locating available
|
111
|
-
hotels
|
111
|
+
hotels and the Hotwire API for rental cars.
|
112
112
|
email:
|
113
113
|
- walter.john.nelson@gmail.com
|
114
114
|
executables: []
|
@@ -141,17 +141,18 @@ files:
|
|
141
141
|
- lib/suitcase/hotel/room.rb
|
142
142
|
- lib/suitcase/session.rb
|
143
143
|
- lib/suitcase/version.rb
|
144
|
-
- spec/
|
145
|
-
- spec/car_rental_spec.rb
|
146
|
-
- spec/
|
147
|
-
- spec/
|
148
|
-
- spec/
|
149
|
-
- spec/
|
144
|
+
- spec/amenity_spec.rb
|
145
|
+
- spec/car_rentals/car_rental_spec.rb
|
146
|
+
- spec/hotels/caching_spec.rb
|
147
|
+
- spec/hotels/helpers_spec.rb
|
148
|
+
- spec/hotels/hotel_location_spec.rb
|
149
|
+
- spec/hotels/hotels_spec.rb
|
150
|
+
- spec/hotels/images_spec.rb
|
151
|
+
- spec/hotels/payment_options_spec.rb
|
152
|
+
- spec/hotels/reservation_spec.rb
|
153
|
+
- spec/hotels/rooms_spec.rb
|
154
|
+
- spec/hotels/sessions_spec.rb
|
150
155
|
- spec/keys.rb
|
151
|
-
- spec/payment_options_spec.rb
|
152
|
-
- spec/reservation_spec.rb
|
153
|
-
- spec/rooms_spec.rb
|
154
|
-
- spec/sessions_spec.rb
|
155
156
|
- spec/spec_helper.rb
|
156
157
|
- suitcase.gemspec
|
157
158
|
homepage: http://github.com/thoughtfusion/suitcase
|
@@ -173,21 +174,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
174
|
- !ruby/object:Gem::Version
|
174
175
|
version: '0'
|
175
176
|
requirements: []
|
176
|
-
rubyforge_project:
|
177
|
-
rubygems_version: 1.8.
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 1.8.19
|
178
179
|
signing_key:
|
179
180
|
specification_version: 3
|
180
|
-
summary: Locates available hotels
|
181
|
+
summary: Locates available hotels and rental cars through Expedia and Hotwire
|
181
182
|
test_files:
|
182
|
-
- spec/
|
183
|
-
- spec/car_rental_spec.rb
|
184
|
-
- spec/
|
185
|
-
- spec/
|
186
|
-
- spec/
|
187
|
-
- spec/
|
183
|
+
- spec/amenity_spec.rb
|
184
|
+
- spec/car_rentals/car_rental_spec.rb
|
185
|
+
- spec/hotels/caching_spec.rb
|
186
|
+
- spec/hotels/helpers_spec.rb
|
187
|
+
- spec/hotels/hotel_location_spec.rb
|
188
|
+
- spec/hotels/hotels_spec.rb
|
189
|
+
- spec/hotels/images_spec.rb
|
190
|
+
- spec/hotels/payment_options_spec.rb
|
191
|
+
- spec/hotels/reservation_spec.rb
|
192
|
+
- spec/hotels/rooms_spec.rb
|
193
|
+
- spec/hotels/sessions_spec.rb
|
188
194
|
- spec/keys.rb
|
189
|
-
- spec/payment_options_spec.rb
|
190
|
-
- spec/reservation_spec.rb
|
191
|
-
- spec/rooms_spec.rb
|
192
|
-
- spec/sessions_spec.rb
|
193
195
|
- spec/spec_helper.rb
|
196
|
+
has_rdoc:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|