Class: Cdek::CitySuggestionsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Cdek::CitySuggestionsController
- Defined in:
- app/controllers/cdek/city_suggestions_controller.rb
Overview
Public read-only endpoint for city autocomplete in host applications.
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/cdek/city_suggestions_controller.rb', line 6 def index render json: Cdek.city_suggestions( params[:q], country_code: params[:country_code].presence || Cdek::CitySuggestions::DEFAULT_COUNTRY_CODE ) rescue Cdek::ConfigurationError => e render json: { message: e. }, status: :service_unavailable rescue Cdek::ApiError => e status = e.status.to_i.positive? ? e.status : 502 render json: { message: e., errors: e.errors, body: e.body }, status: status rescue Cdek::Error => e render json: { message: e. }, status: :bad_gateway end |