Sha256: 072c3b404906155357f08fa45011313e2abef235afde3d9305bfe6a7495e7b19

Contents?: true

Size: 535 Bytes

Versions: 6

Compression:

Stored size: 535 Bytes

Contents

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

    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/create_response.rb
alfa_insurance-0.1.7 lib/alfa_insurance/create_response.rb
alfa_insurance-0.1.6 lib/alfa_insurance/create_response.rb
alfa_insurance-0.1.5 lib/alfa_insurance/create_response.rb
alfa_insurance-0.1.4 lib/alfa_insurance/create_response.rb
alfa_insurance-0.1.3 lib/alfa_insurance/create_response.rb