Class: Api::V1::GeoZonesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/v1/geo_zones_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/api/v1/geo_zones_controller.rb', line 7

def index
  GeoZone.include_root_in_json = false

  if params[:geo_country_iso_code_2].present?
    geo_country = GeoCountry.find_by_iso_code_2(params[:geo_country_iso_code_2])
    if geo_country
      render json: {success: true, geo_zones: GeoZone.where('geo_country_id = ?', geo_country.id).all}
    else
      render json: {success: false, message: 'Invalid Geo Country'}
    end

  else
    render json: {success: true, geo_zones: GeoZone.all}
  end
end