suitcase 1.1.7 → 1.1.8
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/.gitignore +1 -2
- data/.rspec +1 -0
- data/README.md +2 -2
- data/Rakefile +5 -1
- data/lib/suitcase.rb +3 -0
- data/lib/suitcase/core_ext/string.rb +13 -0
- data/lib/suitcase/hotel/hotel.rb +17 -6
- data/lib/suitcase/hotel/image.rb +19 -0
- data/lib/suitcase/hotel/nightly_rate.rb +11 -0
- data/lib/suitcase/hotel/room.rb +14 -3
- data/lib/suitcase/version.rb +1 -1
- data/spec/api_key.rb +1 -1
- data/spec/helpers_spec.rb +19 -0
- data/spec/hotels_spec.rb +50 -2
- data/spec/images_spec.rb +23 -0
- data/spec/rooms_spec.rb +26 -0
- metadata +23 -15
- data/spec/data_helpers_spec.rb +0 -14
data/.gitignore
CHANGED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--fail-fast -c --format d
|
data/README.md
CHANGED
|
@@ -21,8 +21,8 @@ First, include the module in your code:
|
|
|
21
21
|
Find nearby hotels:
|
|
22
22
|
|
|
23
23
|
Hotel::API_KEY = "your_api_key_here"
|
|
24
|
-
|
|
25
|
-
room =
|
|
24
|
+
hotels = Hotel.find(:location => 'Boston, MA', :results => 10) # Returns 10 closest hotels to Boston, MA
|
|
25
|
+
room = hotels.first.rooms(arrival: "2/19/2012", departure: "2/26/2012", rooms: [{ children: 1, ages: [8] }, { children: 1, ages: [12] }] # Check the availability of two rooms at that hotel with 1 child in each room of ages 8 and 9
|
|
26
26
|
room.reserve!(info) # Not yet implemented
|
|
27
27
|
Contributing
|
|
28
28
|
------------
|
data/Rakefile
CHANGED
data/lib/suitcase.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
require 'net/http'
|
|
3
|
+
require 'suitcase/core_ext/string'
|
|
3
4
|
require 'suitcase/version'
|
|
4
5
|
require 'suitcase/helpers'
|
|
6
|
+
require 'suitcase/hotel/nightly_rate'
|
|
5
7
|
require 'suitcase/hotel/room'
|
|
6
8
|
require 'suitcase/hotel/payment_option'
|
|
7
9
|
require 'suitcase/hotel/hotel'
|
|
10
|
+
require 'suitcase/hotel/image'
|
data/lib/suitcase/hotel/hotel.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Suitcase
|
|
|
18
18
|
wheelchair_accessible: 8,
|
|
19
19
|
kitchen: 9 }
|
|
20
20
|
|
|
21
|
-
attr_accessor :id, :name, :address, :city, :min_rate, :max_rate, :amenities, :country_code, :high_rate, :low_rate, :longitude, :latitude, :rating, :postal_code, :supplier_type, :
|
|
21
|
+
attr_accessor :id, :name, :address, :city, :min_rate, :max_rate, :amenities, :country_code, :high_rate, :low_rate, :longitude, :latitude, :rating, :postal_code, :supplier_type, :images
|
|
22
22
|
|
|
23
23
|
def initialize(info)
|
|
24
24
|
info.each do |k, v|
|
|
@@ -68,14 +68,13 @@ module Suitcase
|
|
|
68
68
|
handle_errors(parsed)
|
|
69
69
|
summary = parsed["hotelId"] ? parsed : parsed["HotelInformationResponse"]["HotelSummary"]
|
|
70
70
|
parsed_info = { id: summary["hotelId"], name: summary["name"], address: summary["address1"], city: summary["city"], postal_code: summary["postalCode"], country_code: summary["countryCode"], rating: summary["hotelRating"], high_rate: summary["highRate"], low_rate: summary["lowRate"], latitude: summary["latitude"].to_f, longitude: summary["longitude"].to_f }
|
|
71
|
-
if images(parsed)
|
|
72
|
-
parsed_info[:image_urls] = images(parsed)
|
|
73
|
-
end
|
|
71
|
+
parsed_info[:images] = images(parsed) if images(parsed)
|
|
74
72
|
parsed_info
|
|
75
73
|
end
|
|
76
74
|
|
|
77
75
|
def self.images(parsed)
|
|
78
|
-
return
|
|
76
|
+
return parsed["HotelInformationResponse"]["HotelImages"]["HotelImage"].map { |image_data| Suitcase::Image.new(image_data) } if parsed["HotelInformationResponse"]
|
|
77
|
+
return Suitcase::Image.new(url: parsed["thumbNailUrl"]) if parsed["thumbNailUrl"]
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
# Bleghh. so ugly. #needsfixing
|
|
@@ -110,7 +109,19 @@ module Suitcase
|
|
|
110
109
|
hotel_id = parsed["HotelRoomAvailabilityResponse"]["hotelId"]
|
|
111
110
|
rate_key = parsed["HotelRoomAvailabilityResponse"]["rateKey"]
|
|
112
111
|
supplier_type = parsed["HotelRoomAvailabilityResponse"]["HotelRoomResponse"][0]["supplierType"]
|
|
113
|
-
|
|
112
|
+
rooms = parsed["HotelRoomAvailabilityResponse"]["HotelRoomResponse"].map do |raw_data|
|
|
113
|
+
room_data = {}
|
|
114
|
+
room_data[:rate_code] = raw_data["rateCode"]
|
|
115
|
+
room_data[:room_type_code] = raw_data["roomTypeCode"]
|
|
116
|
+
room_data[:room_type_description] = raw_data["roomTypeDescription"]
|
|
117
|
+
room_data[:promo] = raw_data["RateInfo"]["@promo"].to_b
|
|
118
|
+
room_data[:price_breakdown] = raw_data["RateInfo"]["ChargeableRateInfo"]["NightlyRatesPerRoom"]["NightlyRate"].map { |raw| NightlyRate.new(raw) }
|
|
119
|
+
room_data[:total_price] = raw_data["RateInfo"]["ChargeableRateInfo"]["@total"]
|
|
120
|
+
room_data[:nightly_rate_total] = raw_data["RateInfo"]["ChargeableRateInfo"]["@nightlyRateTotal"]
|
|
121
|
+
room_data[:average_nightly_rate] = raw_data["RateInfo"]["ChargeableRateInfo"]["@averageRate"]
|
|
122
|
+
Room.new(room_data)
|
|
123
|
+
end
|
|
124
|
+
RoomGroup.new(rate_key, hotel_id, supplier_type, rooms)
|
|
114
125
|
end
|
|
115
126
|
|
|
116
127
|
def payment_options
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Suitcase
|
|
2
|
+
class Image
|
|
3
|
+
attr_accessor :id, :url, :caption, :width, :height, :thumbnail_url, :name
|
|
4
|
+
|
|
5
|
+
def initialize(data)
|
|
6
|
+
@id = data["hotelImageId"]
|
|
7
|
+
@name = data["name"]
|
|
8
|
+
@caption = data["caption"]
|
|
9
|
+
@url = data["url"]
|
|
10
|
+
@thumbnail_url = data["thumbnailURL"]
|
|
11
|
+
@width = data["width"]
|
|
12
|
+
@height = data["height"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def size
|
|
16
|
+
width.to_s + "x" + height.to_s
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/suitcase/hotel/room.rb
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
module Suitcase
|
|
2
|
-
class
|
|
3
|
-
attr_accessor :rate_key, :hotel_id, :supplier_type
|
|
2
|
+
class RoomGroup
|
|
3
|
+
attr_accessor :rate_key, :hotel_id, :supplier_type, :rooms
|
|
4
4
|
|
|
5
|
-
def initialize(rate_key, hotel_id, supplier_type)
|
|
5
|
+
def initialize(rate_key, hotel_id, supplier_type, rooms)
|
|
6
6
|
@rate_key = rate_key
|
|
7
7
|
@hotel_id = hotel_id
|
|
8
8
|
@supplier_type = supplier_type
|
|
9
|
+
@rooms = rooms
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def reserve!(info)
|
|
@@ -23,4 +24,14 @@ module Suitcase
|
|
|
23
24
|
p Hotel.shove(Hotel.url(:res, true, true, {}, :post, true), params)
|
|
24
25
|
end
|
|
25
26
|
end
|
|
27
|
+
|
|
28
|
+
class Room
|
|
29
|
+
attr_accessor :rate_code, :room_type_code, :supplier_type, :tax_rate, :non_refundable, :occupancy, :quoted_occupancy, :min_guest_age, :total, :surcharge_total, :nightly_rate_total, :average_base_rate, :average_rate, :max_nightly_rate, :currency_code, :value_adds, :room_type_description, :price_breakdown, :total_price, :average_nightly_rate, :promo
|
|
30
|
+
|
|
31
|
+
def initialize(info)
|
|
32
|
+
info.each do |k, v|
|
|
33
|
+
instance_variable_set("@" + k.to_s, v)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
26
37
|
end
|
data/lib/suitcase/version.rb
CHANGED
data/spec/api_key.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Suitcase::Hotel::API_KEY = "t3d74e8t58k2nh55gyph3cje"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Suitcase::Helpers do
|
|
4
|
+
before :each do
|
|
5
|
+
class Dummy; extend Suitcase::Helpers; end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "#url should return a URI with the correct base URL" do
|
|
9
|
+
returned = Dummy.url(:action, {})
|
|
10
|
+
returned.should be_a(URI)
|
|
11
|
+
returned.host.should match(/api.ean.com/)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "#parse_response should raise an exception when passed an invalid URI" do
|
|
15
|
+
lambda do
|
|
16
|
+
Dummy.parse_response(URI.parse "http://google.com")
|
|
17
|
+
end.should raise_error
|
|
18
|
+
end
|
|
19
|
+
end
|
data/spec/hotels_spec.rb
CHANGED
|
@@ -1,7 +1,55 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Suitcase::Hotel do
|
|
4
|
-
it "::find should
|
|
5
|
-
|
|
4
|
+
it "::find should locate a single Hotel if an id argument is passed" do
|
|
5
|
+
@hotel.should be_a(Suitcase::Hotel)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "::find should locate an Array of Hotels if an id argument is not passed" do
|
|
9
|
+
hotels = Suitcase::Hotel.find(location: "London, UK")
|
|
10
|
+
hotels.should be_an(Array)
|
|
11
|
+
hotels.first.should be_a(Suitcase::Hotel)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
before :all do
|
|
15
|
+
@hotel = Suitcase::Hotel.find(id: 123904)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
subject { @hotel }
|
|
19
|
+
|
|
20
|
+
it { should respond_to :id }
|
|
21
|
+
it { should respond_to :name }
|
|
22
|
+
it { should respond_to :address }
|
|
23
|
+
it { should respond_to :city }
|
|
24
|
+
it { should respond_to :min_rate }
|
|
25
|
+
it { should respond_to :max_rate }
|
|
26
|
+
it { should respond_to :amenities }
|
|
27
|
+
it { should respond_to :country_code }
|
|
28
|
+
it { should respond_to :high_rate }
|
|
29
|
+
it { should respond_to :low_rate }
|
|
30
|
+
it { should respond_to :longitude }
|
|
31
|
+
it { should respond_to :latitude }
|
|
32
|
+
it { should respond_to :rating }
|
|
33
|
+
it { should respond_to :postal_code }
|
|
34
|
+
it { should respond_to :images }
|
|
35
|
+
|
|
36
|
+
it "#images should return an Array of Suitcase::Image's" do
|
|
37
|
+
images = @hotel.images
|
|
38
|
+
images.should be_an(Array)
|
|
39
|
+
lambda do
|
|
40
|
+
images.map { |image| URI.parse image.url }
|
|
41
|
+
end.should_not raise_error
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "#rooms" do
|
|
45
|
+
before :all do
|
|
46
|
+
@info = { arrival: "6/23/2012", departure: "6/30/2012" }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
subject do
|
|
50
|
+
@hotel.rooms(@info)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it { should be_an(Suitcase::RoomGroup) }
|
|
6
54
|
end
|
|
7
55
|
end
|
data/spec/images_spec.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Suitcase::Image do
|
|
4
|
+
before :all do
|
|
5
|
+
@image = Suitcase::Hotel.find(id: 123904).images.first
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
subject { @image }
|
|
9
|
+
|
|
10
|
+
it { should respond_to :url }
|
|
11
|
+
it { should respond_to :id }
|
|
12
|
+
it { should respond_to :caption }
|
|
13
|
+
it { should respond_to :height }
|
|
14
|
+
it { should respond_to :width }
|
|
15
|
+
it { should respond_to :thumbnail_url }
|
|
16
|
+
it { should respond_to :name }
|
|
17
|
+
|
|
18
|
+
it "#url should return a valid URL" do
|
|
19
|
+
lambda do
|
|
20
|
+
URI.parse @image.url
|
|
21
|
+
end.should_not raise_error
|
|
22
|
+
end
|
|
23
|
+
end
|
data/spec/rooms_spec.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Suitcase::Room do
|
|
4
|
+
before :all do
|
|
5
|
+
@room = Suitcase::Hotel.find(id: 123904).rooms(arrival: "6/23/2012", departure: "6/30/2012")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
subject { @room }
|
|
9
|
+
it { should respond_to :reserve! }
|
|
10
|
+
it "#reserve! should take a Hash of options" do
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe Suitcase::RoomGroup do
|
|
16
|
+
before :all do
|
|
17
|
+
@room_group = Suitcase::Hotel.find(id: 123904).rooms(arrival: "6/23/2012", departure: "6/30/2012")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
subject { @room_group }
|
|
21
|
+
|
|
22
|
+
it { should respond_to :rooms }
|
|
23
|
+
it "#rooms should return an Array" do
|
|
24
|
+
@room_group.rooms.should be_an(Array)
|
|
25
|
+
end
|
|
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.1.
|
|
4
|
+
version: 1.1.8
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-12-
|
|
12
|
+
date: 2011-12-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &20405620 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *20405620
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: cucumber
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &20419480 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *20419480
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: rake
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &19989440 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: '0'
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *19989440
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: json
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &19987780 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
@@ -54,7 +54,7 @@ dependencies:
|
|
|
54
54
|
version: '0'
|
|
55
55
|
type: :runtime
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *19987780
|
|
58
58
|
description: Suitcase utilizes the EAN (Expedia.com) API for locating info about hotels,
|
|
59
59
|
rental cars, and flights.
|
|
60
60
|
email:
|
|
@@ -64,6 +64,7 @@ extensions: []
|
|
|
64
64
|
extra_rdoc_files: []
|
|
65
65
|
files:
|
|
66
66
|
- .gitignore
|
|
67
|
+
- .rspec
|
|
67
68
|
- Gemfile
|
|
68
69
|
- README.md
|
|
69
70
|
- Rakefile
|
|
@@ -71,15 +72,20 @@ files:
|
|
|
71
72
|
- features/step_definitions/hotels_steps.rb
|
|
72
73
|
- lib/suitcase.rb
|
|
73
74
|
- lib/suitcase/airport_codes.rb
|
|
75
|
+
- lib/suitcase/core_ext/string.rb
|
|
74
76
|
- lib/suitcase/country_codes.rb
|
|
75
77
|
- lib/suitcase/helpers.rb
|
|
76
78
|
- lib/suitcase/hotel/hotel.rb
|
|
79
|
+
- lib/suitcase/hotel/image.rb
|
|
80
|
+
- lib/suitcase/hotel/nightly_rate.rb
|
|
77
81
|
- lib/suitcase/hotel/payment_option.rb
|
|
78
82
|
- lib/suitcase/hotel/room.rb
|
|
79
83
|
- lib/suitcase/version.rb
|
|
80
84
|
- spec/api_key.rb
|
|
81
|
-
- spec/
|
|
85
|
+
- spec/helpers_spec.rb
|
|
82
86
|
- spec/hotels_spec.rb
|
|
87
|
+
- spec/images_spec.rb
|
|
88
|
+
- spec/rooms_spec.rb
|
|
83
89
|
- spec/spec_helper.rb
|
|
84
90
|
- suitcase.gemspec
|
|
85
91
|
homepage: http://github.com/thoughtfusion/suitcase
|
|
@@ -96,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
96
102
|
version: '0'
|
|
97
103
|
segments:
|
|
98
104
|
- 0
|
|
99
|
-
hash:
|
|
105
|
+
hash: 3790949770335453178
|
|
100
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
107
|
none: false
|
|
102
108
|
requirements:
|
|
@@ -105,10 +111,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
105
111
|
version: '0'
|
|
106
112
|
segments:
|
|
107
113
|
- 0
|
|
108
|
-
hash:
|
|
114
|
+
hash: 3790949770335453178
|
|
109
115
|
requirements: []
|
|
110
116
|
rubyforge_project: suitcase
|
|
111
|
-
rubygems_version: 1.8.
|
|
117
|
+
rubygems_version: 1.8.13
|
|
112
118
|
signing_key:
|
|
113
119
|
specification_version: 3
|
|
114
120
|
summary: Locates available hotels, rental cars, and flights
|
|
@@ -116,6 +122,8 @@ test_files:
|
|
|
116
122
|
- features/hotels.feature
|
|
117
123
|
- features/step_definitions/hotels_steps.rb
|
|
118
124
|
- spec/api_key.rb
|
|
119
|
-
- spec/
|
|
125
|
+
- spec/helpers_spec.rb
|
|
120
126
|
- spec/hotels_spec.rb
|
|
127
|
+
- spec/images_spec.rb
|
|
128
|
+
- spec/rooms_spec.rb
|
|
121
129
|
- spec/spec_helper.rb
|
data/spec/data_helpers_spec.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Suitcase::DataHelpers do
|
|
4
|
-
before :each do
|
|
5
|
-
class Hotel
|
|
6
|
-
API_KEY = HOTEL_API_KEY
|
|
7
|
-
extend Suitcase::DataHelpers
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "#url should return a valid url" do
|
|
12
|
-
URI.parse(Hotel.url(:hotel, :list, true, { location: "London, UK" })).should be_a(URI)
|
|
13
|
-
end
|
|
14
|
-
end
|