Class: Hula::ServiceBroker::HttpJsonClient

Inherits:
Object
  • Object
show all
Defined in:
lib/hula/service_broker/http_json_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_proxy: HttpProxyNull.new) ⇒ HttpJsonClient

Returns a new instance of HttpJsonClient.



28
29
30
# File 'lib/hula/service_broker/http_json_client.rb', line 28

def initialize(http_proxy: HttpProxyNull.new)
  @http_proxy = http_proxy
end

Instance Method Details

#delete(uri, auth: nil) ⇒ Object



45
46
47
48
49
# File 'lib/hula/service_broker/http_json_client.rb', line 45

def delete(uri, auth: nil)
  request = Net::HTTP::Delete.new(uri)
  request.basic_auth auth.fetch(:username), auth.fetch(:password) unless auth.nil?
  send_request(request)
end

#get(uri, auth: nil) ⇒ Object



32
33
34
35
36
# File 'lib/hula/service_broker/http_json_client.rb', line 32

def get(uri, auth: nil)
  request = Net::HTTP::Get.new(uri)
  request.basic_auth auth.fetch(:username), auth.fetch(:password) unless auth.nil?
  send_request(request)
end

#put(uri, body: nil, auth: nil) ⇒ Object



38
39
40
41
42
43
# File 'lib/hula/service_broker/http_json_client.rb', line 38

def put(uri, body: nil, auth: nil)
  request = Net::HTTP::Put.new(uri)
  request.body = JSON.generate(body) if body
  request.basic_auth auth.fetch(:username), auth.fetch(:password) unless auth.nil?
  send_request(request)
end