Class: Spree::Api::CouponCodesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::CouponCodesController
- Defined in:
- app/controllers/spree/api/coupon_codes_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/spree/api/coupon_codes_controller.rb', line 9 def create :update, @order, order_token @order.coupon_code = params[:coupon_code] @handler = Spree::Config.promotions.coupon_code_handler_class.new(@order).apply if @handler.successful? render 'spree/api/promotions/handler', status: 200 else logger.error("apply_coupon_code_error=#{@handler.error.inspect}") render 'spree/api/promotions/handler', status: 422 end end |
#destroy ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/spree/api/coupon_codes_controller.rb', line 23 def destroy :update, @order, order_token @order.coupon_code = params[:id] @handler = Spree::Config.promotions.coupon_code_handler_class.new(@order).remove if @handler.successful? render 'spree/api/promotions/handler', status: 200 else logger.error("remove_coupon_code_error=#{@handler.error.inspect}") render 'spree/api/promotions/handler', status: 422 end end |