32 lines
913 B
Ruby
32 lines
913 B
Ruby
class ApiMaxmindRequestsController < ApiController
|
|
|
|
respond_to :json
|
|
|
|
def regions
|
|
regions = MaxMindManager.regions(params[:country])
|
|
if regions && regions.length > 0
|
|
render :json => { :regions => regions }, :status => 200
|
|
else
|
|
render :json => { :message => "Unrecognized Country" }, :status => 422
|
|
end
|
|
end
|
|
|
|
def cities
|
|
cities = MaxMindManager.cities(params[:country], params[:region])
|
|
if cities && cities.length > 0
|
|
render :json => { :cities => cities }, :status => 200
|
|
else
|
|
render :json => { :message => "Unrecognized country or region" }, :status => 422
|
|
end
|
|
end
|
|
|
|
def isps
|
|
isps = MaxMindManager.isps(params[:country])
|
|
if isps && isps.length > 0
|
|
render :json => { :isps => isps }, :status => 200
|
|
else
|
|
render :json => { :message => "Unrecognized Country" }, :status => 422
|
|
end
|
|
end
|
|
|
|
end |