Class: SigepWeb::CalculateDigitChecker

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

Instance Method Summary collapse

Methods inherited from WebServiceReverseLogisticApi

#process

Constructor Details

#initialize(options = {}) ⇒ CalculateDigitChecker



3
4
5
6
# File 'lib/sigep_web/calculate_digit_checker.rb', line 3

def initialize(options = {})
  @number = options[:number]
  super()
end

Instance Method Details

#requestObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sigep_web/calculate_digit_checker.rb', line 8

def request
  authenticate = SigepWeb.configuration.authenticate

  begin
    response = process(:calcular_digito_verificador, {
      usuario: authenticate.user,
      senha: authenticate.password,
      codAdministrativo: authenticate.administrative_code,
      numero: @number
    }).to_hash[:calcular_digito_verificador_response][:return]

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