Module: Pinnacle
- Defined in:
- lib/pinnacle.rb,
lib/pinnacle/api.rb,
lib/pinnacle/error.rb,
lib/pinnacle/version.rb
Defined Under Namespace
Classes: DatumModel
Constant Summary collapse
- BASE_URI =
'https://api.pinnaclesports.com/v1/'
- Error =
Class.new(StandardError)
- RequestError =
Class.new(Error)
- InvalidObject =
Class.new(Error)
- VERSION =
'0.0.1'
Class Method Summary collapse
- .encode_basic(id, password) ⇒ Object
- .generate_url(endpoint, parameters) ⇒ Object
- .request(endpoint, parameters) ⇒ Object
- .reset_connection ⇒ Object
Instance Method Summary collapse
Class Method Details
.encode_basic(id, password) ⇒ Object
8 9 10 11 |
# File 'lib/pinnacle/api.rb', line 8 def self.encode_basic(id, password) str = "#{id}:#{password}" Base64.encode(str) end |
.generate_url(endpoint, parameters) ⇒ Object
17 18 19 |
# File 'lib/pinnacle/api.rb', line 17 def self.generate_url(endpoint, parameters) BASE_URI + endpoint + '?' + format_parameters(parameters) end |
.request(endpoint, parameters) ⇒ Object
21 22 23 24 |
# File 'lib/pinnacle/api.rb', line 21 def self.request(endpoint, parameters) url = generate_url(endpoint, parameters) HTTParty.get(url) end |
.reset_connection ⇒ Object
13 14 15 |
# File 'lib/pinnacle/api.rb', line 13 def self.reset_connection @__api_connection = nil end |
Instance Method Details
#format_parameters(parameters) ⇒ Object
26 27 28 29 30 |
# File 'lib/pinnacle/api.rb', line 26 def format_parameters(parameters) uri = Addressable::URI.new uri.query_values = parameters uri.query end |