require 'base64' require 'httparty' require 'addressable/uri' module Pinnacle BASE_URI = 'https://api.pinnaclesports.com/v1/' def self.encode_basic(id, password) str = "#{id}:#{password}" Base64.encode(str) end def self.reset_connection @__api_connection = nil end def self.generate_url(endpoint, parameters) BASE_URI + endpoint + '?' + format_parameters(parameters) end def self.request(endpoint, parameters) url = generate_url(endpoint, parameters) HTTParty.get(url) end def format_parameters(parameters) uri = Addressable::URI.new uri.query_values = parameters uri.query end end