Class: Spree::Api::V3::Admin::Orders::GiftCardsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- ResourceController
- ResourceController
- BaseController
- Spree::Api::V3::Admin::Orders::GiftCardsController
- Defined in:
- app/controllers/spree/api/v3/admin/orders/gift_cards_controller.rb
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/orders/:order_id/gift_cards.
-
#destroy ⇒ Object
DELETE /api/v3/admin/orders/:order_id/gift_cards/:id.
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/orders/:order_id/gift_cards
Body: { code: String }
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/spree/api/v3/admin/orders/gift_cards_controller.rb', line 14 def create with_order_lock do gift_card = find_gift_card! return unless gift_card result = @parent.apply_gift_card(gift_card) if result.success? render json: serializer_class.new(gift_card).to_h, status: :created else render_service_error(result.error) end end end |
#destroy ⇒ Object
DELETE /api/v3/admin/orders/:order_id/gift_cards/:id
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/spree/api/v3/admin/orders/gift_cards_controller.rb', line 30 def destroy with_order_lock do result = @parent.remove_gift_card if result.success? head :no_content else render_service_error(result.error) end end end |