Class: Spree::Api::LineItemsController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#map_nested_attributes_keys, #set_jsonp_format

Methods included from ControllerSetup

included

Instance Method Details

#createObject



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

def create
  authorize! :update, order, order_token
  @line_item = order.line_items.build(params[:line_item], :as => :api)
  if @line_item.save
    @order.ensure_updated_shipments
    respond_with(@line_item, :status => 201, :default_template => :show)
  else
    invalid_resource!(@line_item)
  end
end

#destroyObject



28
29
30
31
32
33
# File 'app/controllers/spree/api/line_items_controller.rb', line 28

def destroy
  authorize! :update, order, order_token
  @line_item = order.line_items.find(params[:id])
  @line_item.destroy
  respond_with(@line_item, :status => 204)
end

#updateObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spree/api/line_items_controller.rb', line 17

def update
  authorize! :update, order, order_token
  @line_item = order.line_items.find(params[:id])
  if @line_item.update_attributes(params[:line_item], :as => :api)
    @order.ensure_updated_shipments
    respond_with(@line_item, :default_template => :show)
  else
    invalid_resource!(@line_item)
  end
end