Class: Spree::Api::ReturnAuthorizationsController
- Inherits:
-
BaseController
- Object
- ActionController::Metal
- BaseController
- Spree::Api::ReturnAuthorizationsController
show all
- Defined in:
- app/controllers/spree/api/return_authorizations_controller.rb
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#add ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 44
def add
@return_authorization = order.return_authorizations.accessible_by(current_ability, :update).find(params[:id])
@return_authorization.add_variant params[:variant_id].to_i, params[:quantity].to_i
if @return_authorization.valid?
respond_with @return_authorization, default_template: :show
else
invalid_resource!(@return_authorization)
end
end
|
#cancel ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 63
def cancel
@return_authorization = order.return_authorizations.accessible_by(current_ability, :update).find(params[:id])
if @return_authorization.cancel
respond_with @return_authorization, default_template: :show
else
invalid_resource!(@return_authorization)
end
end
|
#create ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 20
def create
@return_authorization = order.return_authorizations.build(params[:return_authorization], :as => :api)
if @return_authorization.save
respond_with(@return_authorization, :status => 201, :default_template => :show)
else
invalid_resource!(@return_authorization)
end
end
|
#destroy ⇒ Object
38
39
40
41
42
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 38
def destroy
@return_authorization = order.return_authorizations.find(params[:id])
@return_authorization.destroy
respond_with(@return_authorization, :status => 204)
end
|
#index ⇒ Object
8
9
10
11
12
13
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 8
def index
@return_authorizations = order.return_authorizations.
ransack(params[:q]).result.
page(params[:page]).per(params[:per_page])
respond_with(@return_authorizations)
end
|
#receive ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 54
def receive
@return_authorization = order.return_authorizations.accessible_by(current_ability, :update).find(params[:id])
if @return_authorization.receive
respond_with @return_authorization, default_template: :show
else
invalid_resource!(@return_authorization)
end
end
|
#show ⇒ Object
15
16
17
18
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 15
def show
@return_authorization = order.return_authorizations.find(params[:id])
respond_with(@return_authorization)
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 29
def update
@return_authorization = order.return_authorizations.find(params[:id])
if @return_authorization.update_attributes(params[:return_authorization])
respond_with(@return_authorization, :default_template => :show)
else
invalid_resource!(@return_authorization)
end
end
|