Class: Kongfigure::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/kongfigure/http_client.rb

Constant Summary collapse

HTTP_HEADERS =
{
  accept: "application/json; charset=UTF-8",
  content_type: "application/json; charset=UTF-8",
  accept_encoding: "gzip"
}

Instance Method Summary collapse

Constructor Details

#initialize(parser, url) ⇒ HTTPClient

Returns a new instance of HTTPClient.



12
13
14
15
16
17
18
19
# File 'lib/kongfigure/http_client.rb', line 12

def initialize(parser, url)
  @configuration = {
    ssl_ca_path: nil,
    verify_ssl:  OpenSSL::SSL::VERIFY_NONE,
    url:         url || parser.parse!.url
  }
  @inflector = Dry::Inflector.new
end

Instance Method Details

#delete(path) ⇒ Object



38
39
40
# File 'lib/kongfigure/http_client.rb', line 38

def delete(path)
   execute(request_options(:delete, path, nil))
end

#get(path, size = nil) ⇒ Object



33
34
35
36
# File 'lib/kongfigure/http_client.rb', line 33

def get(path, size=nil)
  size = size = 1000
  execute(request_options(:get, path, size))
end

#patch(path, payload) ⇒ Object



29
30
31
# File 'lib/kongfigure/http_client.rb', line 29

def patch(path, payload)
  execute(request_options(:patch, path, nil, payload))
end

#post(path, payload) ⇒ Object



21
22
23
# File 'lib/kongfigure/http_client.rb', line 21

def post(path, payload)
  execute(request_options(:post, path, nil, payload))
end

#put(path, payload) ⇒ Object



25
26
27
# File 'lib/kongfigure/http_client.rb', line 25

def put(path, payload)
  execute(request_options(:put, path, nil, payload))
end