Class: Spree::Api::V2::Tenant::LineItemsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/tenant/line_items_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#render_serialized_payload, #require_tenant, #scope

Instance Method Details

#collectionObject



8
9
10
11
12
13
14
# File 'app/controllers/spree/api/v2/tenant/line_items_controller.rb', line 8

def collection
  if spree_current_user.nil?
    line_items_by_order_tokens
  else
    spree_current_user.line_items.filter_by_event(params[:event])
  end
end

#mark_as_completedObject

TODO: refactor app to pass token here, it is not safe to pass id & update.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/spree/api/v2/tenant/line_items_controller.rb', line 22

def mark_as_completed
  line_item = Spree::LineItem.find(params[:id])
  step_position = params.fetch(:position, 1).to_i

  result = SpreeCmCommissioner::CompletionSteps::MarkLineItemAsCompleted.call(
    line_item: line_item,
    position: step_position
  )

  if result.success?
    render_serialized_payload { serialize_resource(result.value) }
  else
    render_error_payload(result.error)
  end
end

#showObject



16
17
18
19
# File 'app/controllers/spree/api/v2/tenant/line_items_controller.rb', line 16

def show
  line_item = Spree::LineItem.find(params[:id])
  render_serialized_payload { serialize_resource(line_item) }
end