Class: BitsOnTheRun::API

Inherits:
Object
  • Object
show all
Defined in:
lib/bitsontherun/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter) ⇒ API

Returns a new instance of API.



3
4
5
# File 'lib/bitsontherun/api.rb', line 3

def initialize(adapter)
  @adapter = BitsOnTheRun.const_get(adapter.to_s.capitalize).new
end

Instance Method Details

#executeObject



24
25
26
# File 'lib/bitsontherun/api.rb', line 24

def execute
  @adapter.execute
end

#file(file) ⇒ Object



20
21
22
# File 'lib/bitsontherun/api.rb', line 20

def file(file)
  @adapter.file(file)
end

#method(method, params = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bitsontherun/api.rb', line 7

def method(method, params = {})
  if params.include?(:api_format)
    raise ArgumentError("Params hash should not include :api_format")
  end
  if params.include?(:api_key)
    raise ArgumentError("Params hash should not include :api_key, use BitsOnTheRun.key instead")
  end
  if params.include?(:api_secret)
    raise ArgumentError("Params hash should not include :api_secret, use BitsOnTheRun.secret instead")
  end
  @adapter.method(method, params)
end