Class: Proxima::Api

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri, opts = {}) ⇒ Api

Returns a new instance of Api.



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

def initialize(base_uri, opts = {})
  begin
    @base_uri = URI.parse base_uri
    @http     = HTTP.persistent URI.join @base_uri, "/"
  rescue => e
    raise "'#{base_uri}' is not a valid base_uri: #{e.message}"
  end
  @headers     = opts[:headers] || {}
  @ssl_context = opts[:ssl_context]
end

Instance Attribute Details

#base_uriObject (readonly)

Returns the value of attribute base_uri.



5
6
7
# File 'lib/proxima/api.rb', line 5

def base_uri
  @base_uri
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/proxima/api.rb', line 5

def headers
  @headers
end

#httpObject (readonly)

Returns the value of attribute http.



5
6
7
# File 'lib/proxima/api.rb', line 5

def http
  @http
end

#ssl_contextObject (readonly)

Returns the value of attribute ssl_context.



5
6
7
# File 'lib/proxima/api.rb', line 5

def ssl_context
  @ssl_context
end

Instance Method Details

#request(method, path, opts = {}, &block) ⇒ Object



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

def request(method, path, opts = {}, &block)
  Proxima::Request.new(self, method, path, opts, &block).response
end