Class: Laximo::Request

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

Instance Method Summary collapse

Constructor Details

#initialize(soap_endpoint, soap_action) ⇒ Request

Returns a new instance of Request.



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/laximo/request.rb', line 30

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

Instance Method Details

#call(msg) ⇒ Object

initialize



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/laximo/request.rb', line 44

def call(msg)

  if ::Laximo.options.use_ssl
    @request.body = REQUEST_MSG % {
      msg: msg,
      act: @soap_action
    }
  else
    @request.body =  % {
      msg:   msg,
      act:   @soap_action,
      login: ::Laximo.options.,
      hash:  hash(msg, ::Laximo.options.password)
    }
  end

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

end