class PayU::HttpClient

Constants

DEFAULT_HEADER

Public Class Methods

new(host) click to toggle source
# File lib/pay_u/http_client.rb, line 9
def initialize(host)
  @host = formatted_url(host)
end

Public Instance Methods

delete(path, request) click to toggle source
# File lib/pay_u/http_client.rb, line 22
def delete(path, request)
  NET::HTTP.delete(path, DEFAULT_HEADER.merge(request.headers))
end
post(path, request) click to toggle source
# File lib/pay_u/http_client.rb, line 18
def post(path, request)
  Net::HTTP.post(uri(path), request.to_json, DEFAULT_HEADER.merge(request.headers))
end
post_form(path, params) click to toggle source
# File lib/pay_u/http_client.rb, line 13
def post_form(path, params)
  response = Net::HTTP.post_form(uri(path), params)
  parse_json(response.body)
end

Private Instance Methods

formatted_url(url) click to toggle source
# File lib/pay_u/http_client.rb, line 36
def formatted_url(url)
  url.chomp('/')
end
parse_json(json_string) click to toggle source
# File lib/pay_u/http_client.rb, line 28
def parse_json(json_string)
  JSON.parse(json_string)
end
uri(path) click to toggle source
# File lib/pay_u/http_client.rb, line 32
def uri(path)
  URI(@host + path)
end