lib/pagarme/request.rb in pagarme-1.0 vs lib/pagarme/request.rb in pagarme-1.1
- old
+ new
@@ -4,16 +4,15 @@
require File.join(File.dirname(__FILE__), '.', 'util')
require File.join(File.dirname(__FILE__), '.', 'errors')
module PagarMe
class Request
- attr_accessor :path, :method, :parameters, :headers, :live
+ attr_accessor :path, :method, :parameters, :headers
- def initialize(path, method, live=PagarMe.live)
+ def initialize(path, method)
self.path = path
self.method = method
- self.live = live
self.parameters = {}
self.headers = {}
end
def self.encode(params)
@@ -23,15 +22,18 @@
def run
unless PagarMe.api_key
raise PagarMeError.new("You need to configure a API key before performing requests.")
end
- self.headers = self.live ? { 'X-Live' => '1' } : {}
+ self.headers = {}
parameters = self.parameters.merge({
:api_key => PagarMe.api_key
})
error = nil
+
+ puts self.class.encode(parameters)
+
begin
response = RestClient::Request.execute({
:method => self.method,
:url => PagarMe.full_api_url(self.path),