Class: Moneybookers::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/moneybookers/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/moneybookers/request.rb', line 7

def path
  @path
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/moneybookers/request.rb', line 7

def response
  @response
end

Instance Method Details

#headersObject



29
30
31
# File 'lib/moneybookers/request.rb', line 29

def headers
  {"User-Agent" => "ruby-moneybookers-gem"}
end

#httpObject



9
10
11
12
13
14
# File 'lib/moneybookers/request.rb', line 9

def http
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  http
end

#post(to, params = {}) ⇒ Object



20
21
22
23
# File 'lib/moneybookers/request.rb', line 20

def post(to, params={})
  @path = URI.parse(to).path
  @response = http.post(path, prepare_params(params), headers)
end

#prepare_params(params) ⇒ Object



25
26
27
# File 'lib/moneybookers/request.rb', line 25

def prepare_params(params)
  params.map { |k, v| "#{k}=#{v}" }.join("&")
end

#uriObject



16
17
18
# File 'lib/moneybookers/request.rb', line 16

def uri
  @uri ||= URI.parse(Moneybookers::HOST)
end