|
|
@ -5,7 +5,9 @@ class AddressSearchController < ApplicationController |
|
|
|
def index |
|
|
|
def index |
|
|
|
query = params[:query] |
|
|
|
query = params[:query] |
|
|
|
|
|
|
|
|
|
|
|
if query.match?(/\A\d+\z/) && query.length > 5 |
|
|
|
if query.nil? |
|
|
|
|
|
|
|
render json: { error: "Query cannot be blank." }, status: :bad_request |
|
|
|
|
|
|
|
elsif query.match?(/\A\d+\z/) && query.length > 5 |
|
|
|
# Query is all numbers and greater than 5 digits, assume it's a UPRN |
|
|
|
# Query is all numbers and greater than 5 digits, assume it's a UPRN |
|
|
|
service = UprnClient.new(query) |
|
|
|
service = UprnClient.new(query) |
|
|
|
service.call |
|
|
|
service.call |
|
|
|