Class: Moneybookers::Request
- Inherits:
-
Object
- Object
- Moneybookers::Request
- Defined in:
- lib/moneybookers/request.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #headers ⇒ Object
- #http ⇒ Object
- #post(to, params = {}) ⇒ Object
- #prepare_params(params) ⇒ Object
- #uri ⇒ Object
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/moneybookers/request.rb', line 7 def path @path end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/moneybookers/request.rb', line 7 def response @response end |
Instance Method Details
#headers ⇒ Object
29 30 31 |
# File 'lib/moneybookers/request.rb', line 29 def headers {"User-Agent" => "ruby-moneybookers-gem"} end |
#http ⇒ Object
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 |
#uri ⇒ Object
16 17 18 |
# File 'lib/moneybookers/request.rb', line 16 def uri @uri ||= URI.parse(Moneybookers::HOST) end |