Class: Spree::Api::V3::Store::Markets::CountriesController

Inherits:
BaseController show all
Includes:
HttpCaching
Defined in:
app/controllers/spree/api/v3/store/markets/countries_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::RATE_LIMIT_RESPONSE

Constants included from Idempotent

Idempotent::IDEMPOTENCY_HEADER, Idempotent::IDEMPOTENCY_TTL, Idempotent::MAX_KEY_LENGTH, Idempotent::MUTATING_METHODS

Constants included from ErrorHandler

ErrorHandler::ERROR_CODES

Constants included from JwtAuthentication

JwtAuthentication::JWT_AUDIENCE_ADMIN, JwtAuthentication::JWT_AUDIENCE_STORE, JwtAuthentication::JWT_ISSUER, JwtAuthentication::USER_TYPE_ADMIN, JwtAuthentication::USER_TYPE_CUSTOMER

Instance Method Summary collapse

Methods included from ApiKeyAuthentication

#authenticate_api_key!, #authenticate_secret_key!

Methods included from JwtAuthentication

#authenticate_user, #require_authentication!

Instance Method Details

#indexObject

GET /api/v3/store/markets/:market_id/countries



12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/api/v3/store/markets/countries_controller.rb', line 12

def index
  countries = @market.countries.order(:name)

  return unless cache_collection(countries)

  render json: {
    data: countries.map { |country| serialize_country(country) }
  }
end

#showObject

GET /api/v3/store/markets/:market_id/countries/:id



23
24
25
26
27
28
29
# File 'app/controllers/spree/api/v3/store/markets/countries_controller.rb', line 23

def show
  country = @market.countries.find_by!(iso: params[:id].upcase)

  return unless cache_resource(country)

  render json: serialize_country(country)
end