Class: AlfaInsurance::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/alfa_insurance/response.rb

Direct Known Subclasses

CalculateResponse

Instance Method Summary collapse

Constructor Details

#initialize(soap_response) ⇒ Response

Returns a new instance of Response.



3
4
5
# File 'lib/alfa_insurance/response.rb', line 3

def initialize(soap_response)
  @raw_response = soap_response
end

Instance Method Details

#bodyObject



19
20
21
# File 'lib/alfa_insurance/response.rb', line 19

def body
  @body ||= @raw_response.body.values.first
end

#error_codeObject



11
12
13
# File 'lib/alfa_insurance/response.rb', line 11

def error_code
  body.dig(:return_code, :code) unless success?
end

#error_descriptionObject



15
16
17
# File 'lib/alfa_insurance/response.rb', line 15

def error_description
  body.dig(:return_code, :error_message) unless success?
end

#success?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/alfa_insurance/response.rb', line 7

def success?
  body.dig(:return_code, :code) == 'OK'
end