Class: Quovo::Api::Base

Inherits:
Object
  • Object
show all
Includes:
Models, Request
Defined in:
lib/quovo/api/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Request

#request

Constructor Details

#initialize(token = Quovo::Token.new) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/quovo/api/base.rb', line 7

def initialize(token = Quovo::Token.new)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



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

def token
  @token
end

Instance Method Details

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



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/quovo/api/base.rb', line 11

def api(method, path, params = {})
  format = case method
           when :delete
             :plain
           else
             :json
           end

  request(method, path, params, format) do |req|
    req['Authorization'] = "Bearer #{token.get}"
  end || {}
end