2013-03-15 04:23:37 +00:00
|
|
|
class ApiMaxmindRequestsController < ApiController
|
2012-12-15 20:17:41 +00:00
|
|
|
|
|
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
|
|
def regions
|
|
|
|
|
regions = MaxMindManager.regions(params[:country])
|
|
|
|
|
if regions && regions.length > 0
|
|
|
|
|
render :json => { :regions => regions }, :status => 200
|
|
|
|
|
else
|
2013-05-17 03:54:33 +00:00
|
|
|
render :json => { :message => "Unrecognized Country" }, :status => 422
|
2012-12-15 20:17:41 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def cities
|
|
|
|
|
cities = MaxMindManager.cities(params[:country], params[:region])
|
|
|
|
|
if cities && cities.length > 0
|
|
|
|
|
render :json => { :cities => cities }, :status => 200
|
|
|
|
|
else
|
2013-05-17 03:54:33 +00:00
|
|
|
render :json => { :message => "Unrecognzied country or region" }, :status => 422
|
2012-12-15 20:17:41 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2013-05-16 17:45:10 +00:00
|
|
|
def isps
|
|
|
|
|
isps = MaxMindManager.isps(params[:country])
|
|
|
|
|
if isps && isps.length > 0
|
|
|
|
|
render :json => { :isps => isps }, :status => 200
|
|
|
|
|
else
|
2013-05-17 03:54:33 +00:00
|
|
|
render :json => { :message => "Unrecognzied Country" }, :status => 422
|
2013-05-16 17:45:10 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2012-12-15 20:17:41 +00:00
|
|
|
end
|