Class: SolidusSubscriptions::Api::V1::LineItemsController

Inherits:
Spree::Api::BaseController
  • Object
show all
Defined in:
app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject


14
15
16
17
18
19
20
21
22
# File 'app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb', line 14

def destroy
  authorize! :crud, @line_item, @order
  return render json: {}, status: 400 if @line_item.order.complete?

  @line_item.destroy!
  @line_item.order.recalculate

  render json: @line_item.to_json
end

#updateObject


5
6
7
8
9
10
11
12
# File 'app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb', line 5

def update
  authorize! :crud, @line_item, @order
  if @line_item.update(line_item_params)
    render json: @line_item.to_json
  else
    render json: @line_item.errors.to_json, status: 422
  end
end