You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
952 B
27 lines
952 B
class UprnAddressSpikeController < ApplicationController |
|
def show |
|
if params[:uprn] || params[:address] |
|
|
|
if params[:uprn].present? |
|
uprn = params[:uprn] |
|
service = UprnClient.new(uprn) |
|
service.call |
|
if service.error.present? |
|
@error = "No match" |
|
else |
|
@address_returned = UprnDataPresenter.new(service.result) |
|
end |
|
elsif params.values_at(:address_line1, :address_line2, :town_or_city, :postcode).any?(&:present?) |
|
@address_given = params.values_at(:address_line1, :address_line2, :town_or_city, :postcode).reject { |item| item == "" }.join(", ") |
|
service = AddressClient.new(@address_given) |
|
service.call |
|
if service.error.present? |
|
@error = "No matches" |
|
else |
|
@addresses_returned = service.result&.map { |r| AddressDataPresenter.new(r) } |
|
end |
|
end |
|
end |
|
render "content/uprn_address_spike" |
|
end |
|
end
|
|
|