require_relative 'config'
apartment = PriceHubble::Property.new(
location: {
address: {
post_code: '22769',
city: 'Hamburg',
street: 'Stresemannstr.',
house_number: '29'
}
},
property_type: { code: :apartment },
building_year: 1990,
living_area: 200,
balcony_Area: 30,
floor_number: 5,
has_lift: true,
is_furnished: false,
is_new: false,
renovation_year: 2014,
condition: {
bathrooms: :well_maintained,
kitchen: :well_maintained,
flooring: :well_maintained,
windows: :well_maintained,
masonry: :well_maintained
},
quality: {
bathrooms: :normal,
kitchen: :normal,
flooring: :normal,
windows: :normal,
masonry: :normal
}
)
house = PriceHubble::Property.new(
location: {
address: {
post_code: '22769',
city: 'Hamburg',
street: 'Stresemannstr.',
house_number: '29'
}
},
property_type: { code: :house },
building_year: 1990,
land_area: 100,
living_area: 500,
number_of_floors_in_building: 5
)
request = PriceHubble::ValuationRequest.new(
deal_type: :sale,
properties: [apartment, house],
valuation_dates: [
1.year.ago,
Date.current,
1.year.from_now
]
)
valuations = request.perform!
require 'terminal-table'
table = Terminal::Table.new do |tab|
tab << ['Deal Type', 'Property Type', *request.valuation_dates.map(&:year)]
tab << :separator
valuations.group_by(&:property).each do |property, valuations|
tab << [request.deal_type, property.property_type.code,
*valuations.map { |val| "#{val.value} #{val.currency}" }]
end
end
puts table