24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/botcore/sakenote_api.rb', line 24
def invest_maker(place)
sake_list = Hash.new
if place =~ /(.+)(ι½|ι|εΊ|η)/
place = $1
end
tf = Botcore::SakenoteApi::Todofuken.new
prefecture_code = tf.get_fukennum(place)
url_text = 'https://www.sakenote.com/api/v1/sakes'
uri = URI.parse(url_text)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
options = {
token: @apitoken,
prefecture_code: prefecture_code,
page: 0,
}.select{ |k, v| !v.nil? }
begin
options[:page] += 1
req = Net::HTTP::Get.new(uri.request_uri, = { 'Content-Type' => 'application/json' })
req.body = options.to_json
res = http.request(req)
body = JSON.parse(res.body)
sakes = body["sakes"]
sakes.each do |s|
sake_list[s["sake_name"]] = s["maker_name"]
end
puts options[:page]
end while options[:page] < body["num_pages"]
sake_list
end
|