class ApiMaxmindRequestsController < ApiController

  respond_to :json

  def countries
    countries = MaxMindManager.countries()
    render :json => { :countries => countries }, :status => 200
  end

  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