lib/gamelocker_api.rb in gamelocker_api-0.1.1 vs lib/gamelocker_api.rb in gamelocker_api-0.1.2
- old
+ new
@@ -1,9 +1,10 @@
require "rest-client"
require "oj"
require_relative "gamelocker_api/abstract_parser"
require_relative "gamelocker_api/match"
+require_relative "gamelocker_api/telemetry"
require_relative "gamelocker_api/player"
require_relative "gamelocker_api/roster"
require_relative "gamelocker_api/participant"
class GameLockerAPI
@@ -34,10 +35,14 @@
def matches(match_params = {})
request("matches", match_params)
end
+ # def samples(samples_params = {})
+ # request("samples", samples_params)
+ # end
+
private
def request(end_point, params = nil)
api_headers = {
"X-TITLE-ID": "semc-vainglory",
"Authorization": @api_key,
@@ -50,13 +55,11 @@
response = RestClient.get(@base_url+@region+"/"+end_point+"?"+URI.encode_www_form(params), api_headers)
else
response = RestClient.get(@base_url+@region+"/"+end_point, api_headers)
end
@headers = response.headers
- open(Dir.pwd+"/response.dat", "w") do |file|
- file.write(Oj.load(response.body))
- end
parser(response, end_point)
+
rescue RestClient::ExceptionWithResponse => e
response = VirtualResponse.new(e.response, e.response)
@headers = e.response.headers
parser(response, end_point, false)
end