Sha256: f72d76dfd48a7ff9890316ceb97a78b7a7d391b2b86e8927fd8da8f3f8f99ea7

Contents?: true

Size: 509 Bytes

Versions: 3

Compression:

Stored size: 509 Bytes

Contents

module AlfaInsurance
  class CreateResponse < CalculateResponse
    def insurance_id
      body[:policy_id].to_i
    end

    def cost
      Money.new(body.dig(:calculation_result, :premium), currency)
    end

    def risk_value
      Money.new(body.dig(:calculation_result, :risk_value_sum), 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

3 entries across 3 versions & 1 rubygems

Version Path
alfa_insurance-0.1.2 lib/alfa_insurance/create_response.rb
alfa_insurance-0.1.1 lib/alfa_insurance/create_response.rb
alfa_insurance-0.1.0 lib/alfa_insurance/create_response.rb