Sha256: 6fb9627d79a1fce883969432762ede709c0b7ef4c4105eb00816389c6ca65a0c

Contents?: true

Size: 471 Bytes

Versions: 6

Compression:

Stored size: 471 Bytes

Contents

module AlfaInsurance
  class CalculateResponse < Response
    def cost
      Money.from_amount(body.dig(:calculation_result, :premium).to_f, currency)
    end

    def risk_value
      Money.from_amount(body.dig(:calculation_result, :risk_value_sum).to_f, currency)
    end

    def risk_type
      body.dig(:calculation_result, :risk_value, :@risk_type)
    end

  private

    def currency
      @currency ||= body.dig(:calculation_result, :currency)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alfa_insurance-0.1.8 lib/alfa_insurance/calculate_response.rb
alfa_insurance-0.1.7 lib/alfa_insurance/calculate_response.rb
alfa_insurance-0.1.6 lib/alfa_insurance/calculate_response.rb
alfa_insurance-0.1.5 lib/alfa_insurance/calculate_response.rb
alfa_insurance-0.1.4 lib/alfa_insurance/calculate_response.rb
alfa_insurance-0.1.3 lib/alfa_insurance/calculate_response.rb