Class: Api::V1::LocationsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::V1::LocationsController
- Defined in:
- app/controllers/api/v1/locations_controller.rb
Overview
adapter: :json_api, include: params[:include]
Instance Method Summary collapse
-
#by_lat_lng ⇒ Object
Get location data by lat/lng GET https://api.warmlyyours.me:3000/en-US/v1/locations/by_lat_lng?lat=42.1779737&lng=-88.06782100000001.
-
#by_postal_code ⇒ Object
Get location data by zip/postal code GET https://api.warmlyyours.me:3000/en-US/v1/locations/by_postal_code/60047.
Methods inherited from BaseController
#catalog_for_request, #error!, #locale_for_request, #logger, #render_bad_request_response, #render_internal_server_error, #render_not_found_response, #render_result, #render_unprocessable_entity_response, #set_locale, #store_for_request, #underscore_params
Instance Method Details
#by_lat_lng ⇒ Object
Get location data by lat/lng
GET https://api.warmlyyours.me:3000/en-US/v1/locations/by_lat_lng?lat=42.1779737&lng=-88.06782100000001
16 17 18 19 20 21 |
# File 'app/controllers/api/v1/locations_controller.rb', line 16 def by_lat_lng lat = params[:lat].to_f lng = params[:lng].to_f electricity_res = ElectricityRate.get_by_lat_lng(lat, lng) render json: electricity_res, status: electricity_res[:status] end |
#by_postal_code ⇒ Object
Get location data by zip/postal code
GET https://api.warmlyyours.me:3000/en-US/v1/locations/by_postal_code/60047
6 7 8 9 10 11 12 |
# File 'app/controllers/api/v1/locations_controller.rb', line 6 def by_postal_code postal_code = params[:postal_code].presence electricity_res = ElectricityRate.get_from_postal_code(postal_code) # future # average_temperature_res = AverageMonthlyTemperature.get_from_postal_code(postal_code) render json: electricity_res, status: electricity_res[:status] end |