Class: Spree::Api::CheckoutsController
- Inherits:
-
BaseController
- Object
- ActionController::Metal
- BaseController
- Spree::Api::CheckoutsController
show all
- Includes:
- Core::ControllerHelpers::Auth, Core::ControllerHelpers::Order
- Defined in:
- app/controllers/spree/api/checkouts_controller.rb
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
12
13
14
15
|
# File 'app/controllers/spree/api/checkouts_controller.rb', line 12
def create
@order = Order.build_from_api(current_api_user, nested_params)
respond_with(@order, :default_template => 'spree/api/orders/show', :status => 201)
end
|
#next ⇒ Object
33
34
35
36
37
38
|
# File 'app/controllers/spree/api/checkouts_controller.rb', line 33
def next
@order.next!
respond_with(@order, :default_template => 'spree/api/orders/show', :status => 200)
rescue StateMachine::InvalidTransition
respond_with(@order, :default_template => 'spree/api/orders/could_not_transition', :status => 422)
end
|
#update ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/spree/api/checkouts_controller.rb', line 17
def update
user_id = object_params.delete(:user_id)
if @order.update_attributes(object_params)
if current_api_user.has_spree_role?("admin") && user_id.present?
@order.associate_user!(Spree.user_class.find(user_id))
end
return if after_update_attributes
state_callback(:after) if @order.next
respond_with(@order, :default_template => 'spree/api/orders/show')
else
invalid_resource!(@order)
end
end
|