Sha256: 6cad02ffbb8b732166bd21877fbe5c9948e28e975b923f569d0aa43181869e61

Contents?: true

Size: 657 Bytes

Versions: 2

Compression:

Stored size: 657 Bytes

Contents

module AlfaInsurance
  class CalculateResponse < Response
    def cost
      @cost ||= to_money(result[:premium], currency)
    end

    def risk_value
      @risk_value ||= to_money(result[:risk_value_sum], currency)
    end

    def risk_type
      warn "[DEPRECATION] `risk_type` is deprecated.  Please use `risk_types` instead."
      risk_types.first
    end

    def risk_types
      risk_values.keys
    end

    def risk_values
      @risk_values ||= risk_values_from(result, currency: currency)
    end

  private

    def currency
      result[:currency]
    end

    def result
      @result ||= body[:calculation_result] || {}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alfa_insurance-0.2.1 lib/alfa_insurance/calculate_response.rb
alfa_insurance-0.2.0 lib/alfa_insurance/calculate_response.rb