Class: Qube::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/qube/transport/http.rb

Defined Under Namespace

Classes: Response

Constant Summary collapse

VERBS =
{
  get:    Net::HTTP::Get,
  post:   Net::HTTP::Post,
  put:    Net::HTTP::Put,
  delete: Net::HTTP::Delete
}

Instance Method Summary collapse

Constructor Details

#initializeHTTP

Returns a new instance of HTTP.



18
19
20
21
22
23
24
25
26
# File 'lib/qube/transport/http.rb', line 18

def initialize
  @config     = Qube.config
  @connection = Net::HTTP::Persistent.new

  @api_uri    = @config.api_uri
  @api_token  = @config.api_token
  @user_agent = @config.user_agent
  @logger     = @config.logger
end

Instance Method Details

#base_headersObject



28
29
30
31
32
33
34
# File 'lib/qube/transport/http.rb', line 28

def base_headers
  {
    'X-Auth-Token' => @api_token,
    'User-Agent'   => @user_agent,
    'Content-Type' => 'application/json'
  }
end

#delete(path, options = {}) ⇒ Object



48
49
50
# File 'lib/qube/transport/http.rb', line 48

def delete(path, options = {})
  execute(path, :delete, options)
end

#get(path, options = {}) ⇒ Object



36
37
38
# File 'lib/qube/transport/http.rb', line 36

def get(path, options = {})
  execute(path, :get, options)
end

#post(path, options = {}) ⇒ Object



40
41
42
# File 'lib/qube/transport/http.rb', line 40

def post(path, options = {})
  execute(path, :post, options)
end

#put(path, options = {}) ⇒ Object



44
45
46
# File 'lib/qube/transport/http.rb', line 44

def put(path, options = {})
  execute(path, :put, options)
end