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(number:) ⇒ CalculateDigitChecker

Returns a new instance of CalculateDigitChecker.



5
6
7
8
9
# File 'lib/sigep_web/calculate_digit_checker.rb', line 5

def initialize(number:)
  @number = number

  super()
end

Instance Method Details

#requestObject



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

def request
  authenticate = SigepWeb.configuration.authenticate

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

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