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(type:, service:, quantity:) ⇒ RequestRange

Returns a new instance of RequestRange.



5
6
7
8
9
10
11
# File 'lib/sigep_web/request_range.rb', line 5

def initialize(type:, service:, quantity:)
  @type = type
  @service = service
  @quantity = quantity

  super()
end

Instance Method Details

#requestObject



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

def request
  authenticate = SigepWeb.configuration.authenticate

  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]

  if response[:cod_erro] == '0'
    { success: true, response: response }
  else
    { success: false, error: response[:msg_erro] }
  end
rescue Savon::SOAPFault => e
  { success: false, error: e.message }
end