module EPayCo::Request

Defines HTTP request methods

Public Instance Methods

delete(path, params={}, response_options={}) click to toggle source

Perform an HTTP DELETE request

# File lib/epayco/request.rb, line 23
def delete(path, params={}, response_options={})
  request(:delete, path, params, response_options)
end
get(path, params={}, response_options={}) click to toggle source

Perform an HTTP GET request

# File lib/epayco/request.rb, line 8
def get(path, params={}, response_options={})
  request(:get, path, params, response_options)
end
post(path, params={}, response_options={}) click to toggle source

Perform an HTTP POST request

# File lib/epayco/request.rb, line 13
def post(path, params={}, response_options={})
  request(:post, path, params, response_options)
end
put(path, params={}, response_options={}) click to toggle source

Perform an HTTP PUT request

# File lib/epayco/request.rb, line 18
def put(path, params={}, response_options={})
  request(:put, path, params, response_options)
end

Private Instance Methods

request(method, path, params, response_options) click to toggle source

Perform an HTTP request

# File lib/epayco/request.rb, line 30
def request(method, path, params, response_options)
  response = connection(response_options[:raw]).send(method) do |request|
    case method
    when :get, :delete
      request.url(URI.encode(path), params)
    when :post, :put
      request.path = URI.encode(path)
      request.body = params.to_json unless params.empty?
    end
  end
  
  return Response.create( response, response_options )
end