class Laximo::Request

Public Class Methods

new(soap_endpoint, soap_action) click to toggle source
# File lib/laximo/request.rb, line 19
def initialize(soap_endpoint, soap_action)

  @soap_endpoint  = soap_endpoint
  @soap_action    = soap_action

  @uri     = URI(soap_endpoint)
  @http    = ::Net::HTTP.new(@uri.host, @uri.port)
  @request = ::Net::HTTP::Post.new(@uri.request_uri)

  set_request_params
  set_http_params

end

Public Instance Methods

call(*args) click to toggle source
# File lib/laximo/request.rb, line 33
def call(*args)

  msg = args.join("\n")

  @request.body = (REQUEST_LOGIN_MSG % {
    msg:   msg,
    act:   @soap_action,
    login: ::Laximo.options.login,
    hash:  hash(msg, ::Laximo.options.password)
  })

  begin
    @http.request @request
  rescue ::Exception => ex
    ex
  end

end

Private Instance Methods

hash(command, password) click to toggle source
# File lib/laximo/request.rb, line 80
def hash(command, password)
  ::Digest::MD5::hexdigest "#{command}#{password}"
end
set_http_params() click to toggle source
# File lib/laximo/request.rb, line 54
def set_http_params

  @http.set_debug_output($stdout) if ::Laximo.options.debug?

  @http.use_ssl      = ssl?
  @http.verify_mode  = ::OpenSSL::SSL::VERIFY_NONE

  @http.open_timeout = ::Laximo.options.timeout
  @http.read_timeout = ::Laximo.options.timeout
  @http.ssl_timeout  = ::Laximo.options.timeout

  self

end
set_request_params() click to toggle source
# File lib/laximo/request.rb, line 69
def set_request_params

  @request['User-Agent']   = ::Laximo.options.user_agent
  @request['Accept']       = "*/*"
  @request['Content-Type'] = "text/xml; charset=UTF-8"
  @request['SOAPAction']   = "\"#{@soap_action}\""

  self

end
ssl?() click to toggle source
# File lib/laximo/request.rb, line 84
def ssl?
  @uri.scheme == 'https'.freeze
end