Class: Evervault::Http::RequestHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/evervault/http/request_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(request:, base_url:, cage_run_url:, cert:) ⇒ RequestHandler

Returns a new instance of RequestHandler.



9
10
11
12
13
14
# File 'lib/evervault/http/request_handler.rb', line 9

def initialize(request:, base_url:, cage_run_url:, cert:)
  @request = request
  @base_url = base_url
  @cage_run_url = cage_run_url
  @cert = cert
end

Instance Method Details

#delete(path, params) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/evervault/http/request_handler.rb', line 32

def delete(path, params)
  if @cert.is_certificate_expired()
    @cert.setup()
  end
  resp = @request.execute(:delete, build_url(path), params)
  parse_json_body(resp.body)
end

#get(path, params = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/evervault/http/request_handler.rb', line 16

def get(path, params = nil)
  if @cert.is_certificate_expired()
    @cert.setup()
  end
  resp = @request.execute(:get, build_url(path), params)
  parse_json_body(resp.body)
end

#post(path, params, options: {}, cage_run: false) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/evervault/http/request_handler.rb', line 40

def post(path, params, options: {}, cage_run: false)
  if @cert.is_certificate_expired()
    @cert.setup()
  end
  resp = @request.execute(:post, build_url(path, cage_run), params, build_cage_run_headers(options, cage_run))
  parse_json_body(resp.body)
end

#put(path, params) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/evervault/http/request_handler.rb', line 24

def put(path, params)
  if @cert.is_certificate_expired()
    @cert.setup()
  end
  resp = @request.execute(:put, build_url(path), params)
  parse_json_body(resp.body)
end