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

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

Instance Method Summary collapse

Methods inherited from BaseController

#subscription_guest_token

Instance Method Details

#destroyObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb', line 21

def destroy
  load_line_item

  @line_item.destroy!

  if @line_item.order && !@line_item.order.complete?
    @line_item.order.recalculate
  end

  render json: @line_item.to_json
end

#updateObject



11
12
13
14
15
16
17
18
19
# File 'app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb', line 11

def update
  load_line_item

  if @line_item.update(line_item_params)
    render json: @line_item.to_json
  else
    render json: @line_item.errors.to_json, status: :unprocessable_entity
  end
end