Class: Spree::Api::V3::Admin::CustomFieldsController
- Inherits:
-
ResourceController
- Object
- ActionController::API
- BaseController
- ResourceController
- ResourceController
- Spree::Api::V3::Admin::CustomFieldsController
- Defined in:
- app/controllers/spree/api/v3/admin/custom_fields_controller.rb
Overview
Custom field values for any parent that includes the custom-fields concern. Mounted via the ‘:custom_fieldable` route concern; the parent class is inferred from whichever `<segment>_id` route param matches a registered owner.
Defined Under Namespace
Classes: ParentLookup
Constant Summary
Constants included from ScopedAuthorization
ScopedAuthorization::READ_ACTIONS
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
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
-
#create ⇒ Object
POST /api/v3/admin/<parent>/<parent_id>/custom_fields.
-
#update ⇒ Object
PATCH /api/v3/admin/<parent>/<parent_id>/custom_fields/:id Only ‘value` is mutable.
Methods inherited from ResourceController
Methods included from Spree::Api::V3::ApiKeyAuthentication
#authenticate_api_key!, #authenticate_secret_key!
Methods included from JwtAuthentication
#authenticate_user, #require_authentication!
Instance Method Details
#create ⇒ Object
POST /api/v3/admin/<parent>/<parent_id>/custom_fields
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/spree/api/v3/admin/custom_fields_controller.rb', line 11 def create @resource = @parent..new(permitted_params) (@resource, :create) if @resource.save render json: serialize_resource(@resource), status: :created else render_validation_error(@resource.errors) end end |
#update ⇒ Object
PATCH /api/v3/admin/<parent>/<parent_id>/custom_fields/:id Only ‘value` is mutable. Switching the linked definition is a delete-and-create — the model rejects it (definition + resource uniqueness) and the type wouldn’t match.
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/spree/api/v3/admin/custom_fields_controller.rb', line 26 def update (@resource) if @resource.update(update_permitted_params) render json: serialize_resource(@resource) else render_validation_error(@resource.errors) end end |