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

Inherits:
BaseController show all
Includes:
HttpCaching
Defined in:
app/controllers/spree/api/v3/store/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/countries



9
10
11
12
13
14
15
16
17
# File 'app/controllers/spree/api/v3/store/countries_controller.rb', line 9

def index
  countries = current_store.countries_from_markets

  return unless cache_collection(countries)

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

#showObject

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



20
21
22
23
24
25
26
# File 'app/controllers/spree/api/v3/store/countries_controller.rb', line 20

def show
  country = current_store.countries_from_markets.find_by!(iso: params[:id].upcase)

  return unless cache_resource(country)

  render json: serialize_country(country)
end