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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a22861f4708dba324ef8f028527961fefb087435821d853e95f88dbe9083ebd5
4
- data.tar.gz: 28dbdcad4bef039222ca579cb4bb4a2cb8e111aad37653991666b65287ca6517
3
+ metadata.gz: 0f785c18b6a55388aa61ae8580d92e2ad24c5eee8edf6f996bb5b188b16af1d0
4
+ data.tar.gz: fc8915c693cde72347f71461deb09bd7ef54e89574d928b9220ca1a7f59ae1b2
5
5
  SHA512:
6
- metadata.gz: 4c415172a89791a5ab6f469b0ef9c726333d065c411abae4a8490c2edfddd4356f4f38765f3024be89d9e3298d60de5117370503331c51b963176608cb941a77
7
- data.tar.gz: 8f177c1d244c7557b0f64533d66a092b864394586388df5f00048b63ce60899c074e36ed11077f7ff5e15e968fb4bdb1496a7584424c8beba072dfb9bb4efb5a
6
+ metadata.gz: ce184e34ebc4394c1ff7f6f27d951afa5cc0f3b7bb1c78de35a029e14ebf01a50b16256cbae16c1579fc91f1ce3f36f077a9fc352be4f7ede01bde517f137710
7
+ data.tar.gz: 4b61029941a79252166d53ad2015e55ecddc0dc26396cae1616397a14de39544d685eaea17577634434ef339e60cde9d0b202cdb42743dd77569879579630b92
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hotel_price (0.3.7)
4
+ hotel_price (0.3.8)
5
5
  activesupport (~> 6.0.2.1)
6
6
  json (~> 2.3.0)
7
7
  nokogiri (~> 1.10.9)
@@ -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: params[:checkin_date],
19
- rakuten_hotel_id: params[:rakuten_hotel_id],
20
- adult_num: params[:adult_num],
21
- breakfast: params[: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: result["hotels"][0]["hotel"][1]["roomInfo"][1]["dailyCharge"]["stayDate"],
31
- rakuten_hotel_id: params[: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: params[:adult_num],
34
- breakfast: params[: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) + 2).strftime("%Y-%m-%d")
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, options: options
13
+ @driver = Selenium::WebDriver.for :firefox#, options: options
14
14
  if @config[:chain]
15
15
  go_to_management_page_chain
16
16
  else
@@ -1,3 +1,3 @@
1
1
  module HotelPrice
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotel_price
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumitake Kawasaki