hotel_price 0.4.1 → 0.4.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/hotel_price/rakuten/rakuten_api.rb +30 -14
- 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: 8271fc1ad3a22ae3308a9a9fc6e4b71e2b75bbc04b27e9f9fb380dcba14d6d5f
|
|
4
|
+
data.tar.gz: 57f8bb20af2a5b0b8024b1c341060da9c03f5b99070be2b45ffe8502b5025988
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b895ba6069ad8042362ad936ad0b4275ca2034a57e3d07159041e915181fa6a99acf8096b1ab582697c7294ad45f466403a031d3119a2b13679b7ae1f77e613
|
|
7
|
+
data.tar.gz: 0e006edc3409af3fe1e00b6f8cb0acfb95e63ef91bd60b7438e86848639d3703bef32fbb5f54b1c7ffc918cfeecdd578d5357c84be5bb80aac4c1d52d22e7870
|
data/Gemfile.lock
CHANGED
|
@@ -99,7 +99,6 @@ module HotelPrice::Rakuten
|
|
|
99
99
|
uri = URI.parse("https://app.rakuten.co.jp/services/api/Travel/HotelDetailSearch/20131024?hotelNo=" + @config[:rakuten_hotel_id].to_s + "&applicationId=" + @config[:rakuten_api_key].to_s + "&datumType=1&responseType=large")
|
|
100
100
|
json = Net::HTTP.get(uri)
|
|
101
101
|
result = JSON.parse(json)
|
|
102
|
-
puts uri
|
|
103
102
|
return "ホテル情報がありませんでした。" if result["error"] == "not_found"
|
|
104
103
|
return result["error_description"] if result["error"] == "wrong_parameter"
|
|
105
104
|
result["hotels"][0].each do |_key, field|
|
|
@@ -164,12 +163,23 @@ module HotelPrice::Rakuten
|
|
|
164
163
|
@data_hash
|
|
165
164
|
end
|
|
166
165
|
|
|
167
|
-
def
|
|
166
|
+
def get_area_rank
|
|
167
|
+
body = get_page_num
|
|
168
|
+
(1..body[:page_num]).each do |i|
|
|
169
|
+
body[:page_num] = i
|
|
170
|
+
rank = search_ranking(body)
|
|
171
|
+
return rank if rank[:status] == "found"
|
|
172
|
+
end
|
|
173
|
+
{ status: "not_found" }
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def search_ranking params
|
|
168
177
|
body = {
|
|
169
178
|
middle_class_code: params[:middle_class_code],
|
|
170
179
|
small_class_code: params[:small_class_code],
|
|
171
180
|
detail_class_code: params[:detail_class_code],
|
|
172
|
-
page_num: params[:page_num]
|
|
181
|
+
page_num: params[:page_num],
|
|
182
|
+
area_name: params[:area_name]
|
|
173
183
|
}
|
|
174
184
|
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]}"
|
|
175
185
|
uri = URI.parse(url)
|
|
@@ -179,9 +189,13 @@ module HotelPrice::Rakuten
|
|
|
179
189
|
result["hotels"].each do |key, _value|
|
|
180
190
|
if @config[:rakuten_hotel_id] == key["hotel"][0]["hotelBasicInfo"]["hotelNo"].to_s
|
|
181
191
|
return {
|
|
182
|
-
|
|
192
|
+
status: "found",
|
|
183
193
|
hotel_name: key["hotel"][0]["hotelBasicInfo"]["hotelName"],
|
|
184
|
-
|
|
194
|
+
area_name: body[:area_name],
|
|
195
|
+
area_rank: i.to_i + ((body[:page_num].to_i - 1) * 30),
|
|
196
|
+
middle_class_code: body[:middle_class_code],
|
|
197
|
+
small_class_code: body[:small_class_code],
|
|
198
|
+
detail_class_code: body[:detail_class_code]
|
|
185
199
|
}
|
|
186
200
|
end
|
|
187
201
|
i += 1
|
|
@@ -189,18 +203,20 @@ module HotelPrice::Rakuten
|
|
|
189
203
|
{ status: "not_found" }
|
|
190
204
|
end
|
|
191
205
|
|
|
192
|
-
def get_page_num
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
detail_class_code: hotel.detail_class_code
|
|
197
|
-
}
|
|
198
|
-
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]}"
|
|
199
|
-
puts url
|
|
206
|
+
def get_page_num
|
|
207
|
+
detail_class_code = HotelPrice::Rakuten::RakutenScraper.get_detail_class_code(@config[:rakuten_hotel_id])[:detail_class_code]
|
|
208
|
+
hotel = hotel_info
|
|
209
|
+
url = "https://app.rakuten.co.jp/services/api/Travel/SimpleHotelSearch/20170426?applicationId=#{@config[:rakuten_api_key]}&largeClassCode=japan&middleClassCode=#{hotel[:middle_class_code]}&smallClassCode=#{hotel[:small_class_code]}&detailClassCode=#{detail_class_code}"
|
|
200
210
|
uri = URI.parse(url)
|
|
201
211
|
json = Net::HTTP.get(uri)
|
|
202
212
|
result = JSON.parse(json)
|
|
203
|
-
|
|
213
|
+
{
|
|
214
|
+
small_class_code: hotel[:small_class_code],
|
|
215
|
+
middle_class_code: hotel[:middle_class_code],
|
|
216
|
+
detail_class_code: detail_class_code,
|
|
217
|
+
area_name: hotel[:area_name].to_s,
|
|
218
|
+
page_num: result["pagingInfo"]["pageCount"].to_i
|
|
219
|
+
}
|
|
204
220
|
end
|
|
205
221
|
end
|
|
206
222
|
end
|
data/lib/hotel_price/version.rb
CHANGED