class Maxipago::RequestBuilder::Request

Public Class Methods

new(maxipagoId, apiKey) click to toggle source
# File lib/maxipago/request_builder/request.rb, line 8
def initialize(maxipagoId, apiKey)
  @maxipagoId = maxipagoId
  @apiKey = apiKey
  @apiVersion = Maxipago::Client::APIVERSION
  @header = { "Content-Type" => 'text/xml' }
end

Public Instance Methods

send_command(opts) click to toggle source
# File lib/maxipago/request_builder/request.rb, line 15
def send_command(opts)
  xml = build_xml(opts)
  send_request(xml)
end

Private Instance Methods

build_xml(opts) click to toggle source
# File lib/maxipago/request_builder/request.rb, line 36
def build_xml(opts)
  raise "This is an abstract method"
end
send_request(xml) click to toggle source
# File lib/maxipago/request_builder/request.rb, line 22
def send_request(xml)
  set_uri
  set_http_session

  @http_session.start { |http|
    response = http.post(@uri.path, xml, @header)
    { header: response, body: response.body, message: response.message }
  }
end
set_http_session() click to toggle source
# File lib/maxipago/request_builder/request.rb, line 40
def set_http_session
  @http_session = Net::HTTP.new(@uri.host, @uri.port)
  @http_session.use_ssl = true if @uri.scheme == "https"
  set_ssl_mode if @http_session.use_ssl?
end
set_ssl_mode() click to toggle source
# File lib/maxipago/request_builder/request.rb, line 46
def set_ssl_mode
  @http_session.verify_mode = OpenSSL::SSL::VERIFY_NONE
  @http_session.ssl_timeout = 30
end
set_uri() click to toggle source
# File lib/maxipago/request_builder/request.rb, line 32
def set_uri
  raise "This is an abstract method"
end