hotel_price 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/hotel_price/rakuten/rakuten_api.rb +54 -29
- data/lib/hotel_price/rakuten/rakuten_console.rb +1 -1
- data/lib/hotel_price/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f785c18b6a55388aa61ae8580d92e2ad24c5eee8edf6f996bb5b188b16af1d0
|
4
|
+
data.tar.gz: fc8915c693cde72347f71461deb09bd7ef54e89574d928b9220ca1a7f59ae1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce184e34ebc4394c1ff7f6f27d951afa5cc0f3b7bb1c78de35a029e14ebf01a50b16256cbae16c1579fc91f1ce3f36f077a9fc352be4f7ede01bde517f137710
|
7
|
+
data.tar.gz: 4b61029941a79252166d53ad2015e55ecddc0dc26396cae1616397a14de39544d685eaea17577634434ef339e60cde9d0b202cdb42743dd77569879579630b92
|
data/Gemfile.lock
CHANGED
@@ -15,10 +15,10 @@ module HotelPrice::Rakuten
|
|
15
15
|
if result["error"] == "not_found"
|
16
16
|
{
|
17
17
|
date: DateTime.now.strftime("%Y-%m-%d"),
|
18
|
-
checkin_date:
|
19
|
-
rakuten_hotel_id:
|
20
|
-
adult_num:
|
21
|
-
breakfast:
|
18
|
+
checkin_date: checkin_date,
|
19
|
+
rakuten_hotel_id: @config[:rakuten_hotel_id],
|
20
|
+
adult_num: num_adults,
|
21
|
+
breakfast: "",
|
22
22
|
plan_num: 0,
|
23
23
|
min_price: 0
|
24
24
|
}
|
@@ -27,11 +27,11 @@ module HotelPrice::Rakuten
|
|
27
27
|
else
|
28
28
|
{
|
29
29
|
date: DateTime.now.strftime("%Y-%m-%d"),
|
30
|
-
checkin_date:
|
31
|
-
rakuten_hotel_id:
|
30
|
+
checkin_date: checkin_date,
|
31
|
+
rakuten_hotel_id: rakuten_hotel_id,
|
32
32
|
hotel_name: result["hotels"][0]["hotel"][0]["hotelBasicInfo"]["hotelName"],
|
33
|
-
adult_num:
|
34
|
-
breakfast:
|
33
|
+
adult_num: num_adults,
|
34
|
+
breakfast: "",
|
35
35
|
plan_num: result["pagingInfo"]["recordCount"],
|
36
36
|
room_name: result["hotels"][0]["hotel"][1]["roomInfo"][0]["roomBasicInfo"]["roomName"],
|
37
37
|
plan_name: result["hotels"][0]["hotel"][1]["roomInfo"][0]["roomBasicInfo"]["planName"],
|
@@ -41,8 +41,8 @@ module HotelPrice::Rakuten
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def make_query_string(rakuten_hotel_id, checkin_date, num_adults)
|
44
|
-
checkout_date = (Date.parse(checkin_date) +
|
45
|
-
"format=json&sort=%2BroomCharge&searchPattern=1&applicationId=#{@config[:rakuten_api_key]}&adultNum=#{num_adults}&checkinDate=#{checkin_date}&checkoutDate=#{checkout_date}&squeezeCondition="
|
44
|
+
checkout_date = (Date.parse(checkin_date) + 1).strftime("%Y-%m-%d")
|
45
|
+
"format=json&sort=%2BroomCharge&searchPattern=1&applicationId=#{@config[:rakuten_api_key]}&hotelNo=#{rakuten_hotel_id}&adultNum=#{num_adults}&checkinDate=#{checkin_date}&checkoutDate=#{checkout_date}&squeezeCondition="
|
46
46
|
end
|
47
47
|
|
48
48
|
def get_min_price params
|
@@ -103,7 +103,7 @@ module HotelPrice::Rakuten
|
|
103
103
|
return result["error_description"] if result["error"] == "wrong_parameter"
|
104
104
|
result["hotels"][0].each do |_key, field|
|
105
105
|
field[0].each do |_, value|
|
106
|
-
data_hash = {
|
106
|
+
@data_hash = {
|
107
107
|
rakuten_hotel_id: value["hotelNo"],
|
108
108
|
hotel_name: value["hotelName"],
|
109
109
|
room_price_min: value["hotelMinCharge"],
|
@@ -125,42 +125,67 @@ module HotelPrice::Rakuten
|
|
125
125
|
end
|
126
126
|
result["hotels"][0].each do |_key, field|
|
127
127
|
field[1].each do |_, value|
|
128
|
-
data_hash["rakuten_service_review"] = value["serviceAverage"].to_f
|
129
|
-
data_hash["rakuten_location_review"] = value["locationAverage"].to_f
|
130
|
-
data_hash["rakuten_room_review"] = value["roomAverage"].to_f
|
131
|
-
data_hash["rakuten_equipment_review"] = value["equipmentAverage"].to_f
|
132
|
-
data_hash["rakuten_bath_review"] = value["bathAverage"].to_f
|
133
|
-
data_hash["rakuten_meal_review"] = value["mealAverage"].to_f
|
128
|
+
@data_hash["rakuten_service_review"] = value["serviceAverage"].to_f
|
129
|
+
@data_hash["rakuten_location_review"] = value["locationAverage"].to_f
|
130
|
+
@data_hash["rakuten_room_review"] = value["roomAverage"].to_f
|
131
|
+
@data_hash["rakuten_equipment_review"] = value["equipmentAverage"].to_f
|
132
|
+
@data_hash["rakuten_bath_review"] = value["bathAverage"].to_f
|
133
|
+
@data_hash["rakuten_meal_review"] = value["mealAverage"].to_f
|
134
134
|
end
|
135
135
|
end
|
136
136
|
result["hotels"][0].each do |_key, field|
|
137
137
|
field[2].each do |_, value|
|
138
|
-
data_hash["middle_class_code"] = value["middleClassCode"].to_s
|
139
|
-
data_hash["small_class_code"] = value["smallClassCode"].to_s
|
140
|
-
data_hash["area_name"] = value["areaName"].to_s
|
141
|
-
data_hash["hotel_class_code"] = value["hotelClassCode"].to_s
|
142
|
-
data_hash["checkin_time"] = value["checkinTime"].to_s
|
143
|
-
data_hash["checkout_time"] = value["checkoutTime"].to_s
|
144
|
-
data_hash["last_checkin_time"] = value["lastCheckinTime"].to_s
|
138
|
+
@data_hash["middle_class_code"] = value["middleClassCode"].to_s
|
139
|
+
@data_hash["small_class_code"] = value["smallClassCode"].to_s
|
140
|
+
@data_hash["area_name"] = value["areaName"].to_s
|
141
|
+
@data_hash["hotel_class_code"] = value["hotelClassCode"].to_s
|
142
|
+
@data_hash["checkin_time"] = value["checkinTime"].to_s
|
143
|
+
@data_hash["checkout_time"] = value["checkoutTime"].to_s
|
144
|
+
@data_hash["last_checkin_time"] = value["lastCheckinTime"].to_s
|
145
145
|
end
|
146
146
|
end
|
147
147
|
result["hotels"][0].each do |_key, field|
|
148
148
|
field[3].each do |_, value|
|
149
|
-
data_hash["total_room_num"] = value["hotelRoomNum"].to_s
|
149
|
+
@data_hash["total_room_num"] = value["hotelRoomNum"].to_s
|
150
150
|
room_facilities = []
|
151
151
|
value["roomFacilities"].each_with_index do |f, i|
|
152
152
|
room_facilities[i] = f["item"]
|
153
153
|
end
|
154
|
-
data_hash["room_facilities"] = room_facilities
|
154
|
+
@data_hash["room_facilities"] = room_facilities
|
155
155
|
end
|
156
156
|
end
|
157
157
|
result["hotels"][0].each do |_key, field|
|
158
158
|
field[4].each do |_, value|
|
159
|
-
data_hash["hotel_policy_note"] = value["note"].to_s
|
160
|
-
data_hash["cancel_policy"] = value["cancelPolicy"].to_s
|
159
|
+
@data_hash["hotel_policy_note"] = value["note"].to_s
|
160
|
+
@data_hash["cancel_policy"] = value["cancelPolicy"].to_s
|
161
161
|
end
|
162
162
|
end
|
163
|
-
data_hash
|
163
|
+
@data_hash
|
164
|
+
end
|
165
|
+
|
166
|
+
def search_ranking(params = {})
|
167
|
+
body = {
|
168
|
+
middle_class_code: params[:middle_class_code],
|
169
|
+
small_class_code: params[:small_class_code],
|
170
|
+
detail_class_code: params[:detail_class_code],
|
171
|
+
page_num: params[:page_num]
|
172
|
+
}
|
173
|
+
url = "https://app.rakuten.co.jp/services/api/Travel/SimpleHotelSearch/20170426?applicationId=#{@config[:rakuten_api_key]}&largeClassCode=japan&middleClassCode=#{body[:middle_class_code]}&smallClassCode=#{body[:small_class_code]}&detailClassCode=#{body[:detail_class_code]}&page=#{body[:page_num]}"
|
174
|
+
uri = URI.parse(url)
|
175
|
+
json = Net::HTTP.get(uri)
|
176
|
+
result = JSON.parse(json)
|
177
|
+
@i = 1
|
178
|
+
result["hotels"].each do |key, _value|
|
179
|
+
if @config[:rakuten_hotel_id] == key["hotel"][0]["hotelBasicInfo"]["hotelNo"].to_s
|
180
|
+
return {
|
181
|
+
area_rank: @i.to_i + ((body[:page_num].to_i - 1) * 30),
|
182
|
+
hotel_name: key["hotel"][0]["hotelBasicInfo"]["hotelName"],
|
183
|
+
status: "found"
|
184
|
+
}
|
185
|
+
end
|
186
|
+
@i += 1
|
187
|
+
end
|
188
|
+
{ status: "no" }
|
164
189
|
end
|
165
190
|
end
|
166
191
|
end
|
@@ -10,7 +10,7 @@ module HotelPrice::Rakuten
|
|
10
10
|
options = Selenium::WebDriver::Firefox::Options.new
|
11
11
|
options.add_argument("-headless")
|
12
12
|
@wait = Selenium::WebDriver::Wait.new(:timeout => 100)
|
13
|
-
@driver = Selenium::WebDriver.for :firefox
|
13
|
+
@driver = Selenium::WebDriver.for :firefox#, options: options
|
14
14
|
if @config[:chain]
|
15
15
|
go_to_management_page_chain
|
16
16
|
else
|
data/lib/hotel_price/version.rb
CHANGED