Class: Spree::Api::V3::Store::MarketsController
- Inherits:
-
Store::BaseController
- Object
- Store::BaseController
- Spree::Api::V3::Store::MarketsController
- Includes:
- HttpCaching
- Defined in:
- app/controllers/spree/api/v3/store/markets_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
GET /api/v3/store/markets.
-
#resolve ⇒ Object
GET /api/v3/store/markets/resolve?country=DE.
-
#show ⇒ Object
GET /api/v3/store/markets/:id.
Instance Method Details
#index ⇒ Object
GET /api/v3/store/markets
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/spree/api/v3/store/markets_controller.rb', line 9 def index markets = current_store.markets.includes(:countries).order(:position) return unless cache_collection(markets) render json: { data: markets.map { |market| serialize_market(market) } } end |
#resolve ⇒ Object
GET /api/v3/store/markets/resolve?country=DE
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/spree/api/v3/store/markets_controller.rb', line 29 def resolve country_iso = params[:country]&.upcase country = Spree::Country.find_by!(iso: country_iso) market = current_store.market_for_country(country) raise ActiveRecord::RecordNotFound unless market return unless cache_resource(market) render json: serialize_market(market) end |
#show ⇒ Object
GET /api/v3/store/markets/:id
20 21 22 23 24 25 26 |
# File 'app/controllers/spree/api/v3/store/markets_controller.rb', line 20 def show market = current_store.markets.includes(:countries).find_by_prefix_id!(params[:id]) return unless cache_resource(market) render json: serialize_market(market) end |