Sha256: bc44e422ffc3d4bfda26480b18f5c6ef0ef6b70e07fb7207a4c67f203d106b46

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

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

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

    def risk_value
      Money.new(body.dig(:policy_information, :risk_value, :@value), 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

3 entries across 3 versions & 1 rubygems

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