Class: Spree::Api::LineItemsController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#update ⇒ Object
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
|