lib/sportradar/api/request.rb in sportradar-api-0.10.55 vs lib/sportradar/api/request.rb in sportradar-api-0.11.0
- old
+ new
@@ -4,21 +4,38 @@
include HTTParty
# attr_reader :url, :headers, :timeout, :api_key
+ def get_data(url)
+ data = get request_url(url)
+ if data.is_a?(::Sportradar::Api::Error)
+ puts request_url(url)
+ puts
+ puts data.inspect
+ raise 'Sportradar error'
+ end
+ data
+ end
+
def get(path, options={})
url, headers, options, timeout = base_setup(path, options)
begin
# puts url + "?api_key=#{api_key[:api_key]}" # uncomment for debugging
response = self.class.get(url, headers: headers, query: options, timeout: timeout)
rescue Net::ReadTimeout, Net::OpenTimeout
raise Sportradar::Api::Error::Timeout
rescue EOFError
raise Sportradar::Api::Error::NoData
end
- return Sportradar::Api::Error.new(response.code, response.message, response) unless response.success?
- response
+ unless response.success?
+ puts url + "?api_key=#{api_key[:api_key]}" # uncomment for debugging
+ puts
+ puts response.inspect
+ Sportradar::Api::Error.new(response.code, response.message, response)
+ else
+ response
+ end
end
def get_request_info(url)
base_setup(request_url(url))
end