Class: Probasketball::Api
- Inherits:
-
Object
- Object
- Probasketball::Api
- Defined in:
- lib/probasketball/api.rb
Defined Under Namespace
Modules: Response
Constant Summary collapse
- BASE_URLS =
{ :v1 => 'https://probasketballapi.com/', :v2 => 'http://api.probasketballapi.com/' }
Instance Method Summary collapse
-
#initialize(api_key, options = {}) ⇒ Api
constructor
A new instance of Api.
- #post(url, params = {}) ⇒ Object
Constructor Details
#initialize(api_key, options = {}) ⇒ Api
Returns a new instance of Api.
5 6 7 8 |
# File 'lib/probasketball/api.rb', line 5 def initialize(api_key, = {}) @api_key = api_key @options = end |
Instance Method Details
#post(url, params = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/probasketball/api.rb', line 15 def post(url, params = {}) response = RestClient.post build_url(url), build_params(params), headers Response::Success.new(JSON.parse(response), response.code) rescue RestClient::ExceptionWithResponse => e Response::Error.new(e.) rescue JSON::ParserError => e Response::Error.new(response.body) end |