Module: Payzilla::Transports::HTTP
- Included in:
- Gateways::Akado, Gateways::Cyberplat, Gateways::Gorod, Gateways::Matrix, Gateways::Megafon, Gateways::Mts, Gateways::Rapida
- Defined in:
- lib/payzilla/transports/http.rb
Instance Method Summary collapse
-
#get(url, params, attributes = {}) ⇒ String
Send data via GET method.
-
#post(url, params, attributes = {}, headers = {}) ⇒ String
Send data via POST method.
-
#resource(url, attributes) ⇒ RestClient::Resource
Generate new RestClient resource.
-
#ssl(cert, key, password, ca = false) ⇒ Object
Prepare SSL data to be sent.
Instance Method Details
#get(url, params, attributes = {}) ⇒ String
Send data via GET method
21 22 23 24 25 |
# File 'lib/payzilla/transports/http.rb', line 21 def get(url, params, attributes={}) logger.info "GET #{url}: #{params.inspect}" unless logger.blank? logger.debug attributes.inspect unless logger.blank? resource(url, attributes).get(:params => params).to_s end |
#post(url, params, attributes = {}, headers = {}) ⇒ String
Send data via POST method
33 34 35 36 37 |
# File 'lib/payzilla/transports/http.rb', line 33 def post(url, params, attributes={}, headers={}) logger.info "POST #{url}: #{params.inspect}" unless logger.blank? logger.debug attributes.inspect unless logger.blank? resource(url, attributes).post(params, headers).to_s end |
#resource(url, attributes) ⇒ RestClient::Resource
Generate new RestClient resource
11 12 13 |
# File 'lib/payzilla/transports/http.rb', line 11 def resource(url, attributes) RestClient::Resource.new url, attributes end |
#ssl(cert, key, password, ca = false) ⇒ Object
Prepare SSL data to be sent
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/payzilla/transports/http.rb', line 45 def ssl(cert, key, password, ca=false) ssl = { :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read cert.path), :verify_ssl => OpenSSL::SSL::VERIFY_NONE } unless password.blank? ssl[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(key.path), password) else ssl[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(key.path)) end ssl[:ssl_ca_file] = ca.path unless ca.blank? ssl end |