Sha256: e36d93dd9e2101daba57e3f601ae889558c8cdeb293c8ca18d42cda54ff8c35a

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 Bytes

Contents

module AlfaInsurance
  class FindResponse < CalculateResponse
    def insurance_id
      policy[:policy_id].to_i
    end

    def state
      policy[:policy_status]
    end

    def cost
      @cost ||= to_money(policy[:rate], policy[: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_value
      @risk_value ||= risk_values.values.inject(&:+)
    end

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

  private

    def risk_currency
      policy.dig(:risk_currency, :@value)
    end

    def policy
      @policy ||= body[:policy_information] || {}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alfa_insurance-0.2.0 lib/alfa_insurance/find_response.rb