Class: SigepWeb::RequestRange

Inherits:
WebServiceReverseLogisticApi show all
Defined in:
lib/sigep_web/request_range.rb

Instance Method Summary collapse

Methods inherited from WebServiceReverseLogisticApi

#process

Constructor Details

#initialize(options = {}) ⇒ RequestRange

Returns a new instance of RequestRange.



3
4
5
6
7
8
# File 'lib/sigep_web/request_range.rb', line 3

def initialize(options = {})
  @type = options[:type]
  @service = options[:service]
  @quantity = options[:quantity]
  super()
end

Instance Method Details

#requestObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sigep_web/request_range.rb', line 10

def request
  authenticate = SigepWeb.configuration.authenticate

  begin
    response = process(:solicitar_range, {
      usuario: authenticate.user,
      senha: authenticate.password,
      codAdministrativo: authenticate.administrative_code,
      contrato: authenticate.contract,
      tipo: @type,
      servico: @service,
      quantidade: @quantity
    }).to_hash[:solicitar_range_response][:return]

    {
      success: true,
      response: response
    }
  rescue Savon::SOAPFault => msg
    {
      success: false,
      error: msg
    }
  end
end