Sha256: 0730cf7b996c4caea5e84a172a4edf7a59b41974c819455f9361fb7288749123

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pinnacle-0.0.1 lib/pinnacle/api.rb