Sha256: eae1f5f9f8c53609bbdb68ab0d42770130f76eeb28c85eabc9fa01bbb0e333a5
Contents?: true
Size: 896 Bytes
Versions: 1
Compression:
Stored size: 896 Bytes
Contents
module AlfaInsurance class Response def initialize(soap_response) @raw_response = soap_response end def success? body.dig(:return_code, :code) == 'OK' end def error_code body.dig(:return_code, :code) unless success? end def error_description body.dig(:return_code, :error_message) unless success? end def body @body ||= @raw_response.body.values.first end private def risk_values_from(data, currency:) raw_values = data[:risk_value] raw_values = [raw_values] unless raw_values.is_a?(Array) raw_values.each_with_object({}) do |item, result| risk_type = item[:@risk_type] risk_value = item[:@value] result[risk_type] = to_money(risk_value, currency) end end def to_money(amount, currency) Money.from_amount(amount.to_f, currency) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alfa_insurance-0.2.0 | lib/alfa_insurance/response.rb |