added ratelimit exception
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
require 'sightstone/modules/sightstone_base_module'
|
||||
require 'sightstone/summoner'
|
||||
require 'sightstone/player_stats_summary'
|
||||
require 'sightstone/ranked_stats'
|
||||
|
||||
class StatsModule
|
||||
class StatsModule < SightstoneBaseModule
|
||||
def initialize(sightstone)
|
||||
@sightstone = sightstone
|
||||
end
|
||||
@@ -46,29 +47,4 @@ class StatsModule
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
def _get_api_response(uri, header={})
|
||||
params = {'api_key' => @sightstone.api_key}.merge header
|
||||
RestClient.get(uri, headers={:params => params}) {|response, request, result| response }
|
||||
rescue SocketError => e
|
||||
nil
|
||||
|
||||
end
|
||||
|
||||
def _parse_response(response, &block)
|
||||
response_code = if response.nil?
|
||||
500
|
||||
else
|
||||
response.code
|
||||
end
|
||||
|
||||
if response_code == 200
|
||||
block.call(response.body)
|
||||
elsif response_code == 404
|
||||
raise Sightstone::SummonerNotFoundException
|
||||
elsif response_code == 500
|
||||
raise Sightstone::SightstoneConnectionException
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user