Sha256: faf3920ff769f5748ec9f5dcaabd9187d4ef9d9c0a4c52dd9b7dadb009d0c4e9

Contents?: true

Size: 751 Bytes

Versions: 6

Compression:

Stored size: 751 Bytes

Contents

module AlfaInsurance
  class FindResponse < CalculateResponse
    def insurance_id
      body.dig(:policy_information, :policy_id).to_i
    end

    def cost
      Money.from_amount(body.dig(:policy_information, :rate).to_f, currency)
    end

    def risk_value
      Money.from_amount(body.dig(:policy_information, :risk_value, :@value).to_f, risk_currency)
    end

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

    def state
      body.dig(:policy_information, :policy_status)
    end

  private

    def risk_currency
      @risk_currency ||= body.dig(:policy_information, :risk_currency, :@value)
    end

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

Version data entries

6 entries across 6 versions & 1 rubygems

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