Sha256: 0d1eb6afa2a28324461d044236bfdd8b48d8d8f9613fbfaa5a71b1f9f36cd0c1
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
module Sportradar module Api class Request include HTTParty attr_reader :url, :headers, :timeout, :api_key def base_setup(path, options={}) @url = set_base(path) @headers = set_headers @api_key = options[:api_key] @timeout = options.delete(:api_timeout) || Sportradar::Api.config.api_timeout end def get(path, options={}) base_setup(path, options) results = 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 private def set_base(path) protocol = !!Sportradar::Api.config.use_ssl ? "https://" : "http://" url = "#{protocol}api.sportradar.us" url += path url += ".#{Sportradar::Api.config.format}" end def set_headers {'Content-Type' => "application/#{Sportradar::Api.config.format}", 'Accept' => "application/#{Sportradar::Api.config.format}"} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sportradar-api-0.1.0 | lib/sportradar/api/request.rb |