Class: Spree::Api::ReturnAuthorizationsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- 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, #permitted_line_item_attributes, #set_jsonp_format
included
Instance Method Details
#add ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 48
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
67
68
69
70
71
72
73
74
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 67
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
5
6
7
8
9
10
11
12
13
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 5
def create
authorize! :create, ReturnAuthorization
@return_authorization = order.return_authorizations.build(return_authorization_params)
if @return_authorization.save
respond_with(@return_authorization, status: 201, default_template: :show)
else
invalid_resource!(@return_authorization)
end
end
|
#destroy ⇒ Object
15
16
17
18
19
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 15
def destroy
@return_authorization = order.return_authorizations.accessible_by(current_ability, :destroy).find(params[:id])
@return_authorization.destroy
respond_with(@return_authorization, status: 204)
end
|
#index ⇒ Object
21
22
23
24
25
26
27
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 21
def index
authorize! :admin, ReturnAuthorization
@return_authorizations = order.return_authorizations.accessible_by(current_ability, :read).
ransack(params[:q]).result.
page(params[:page]).per(params[:per_page])
respond_with(@return_authorizations)
end
|
#new ⇒ Object
29
30
31
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 29
def new
authorize! :admin, ReturnAuthorization
end
|
#receive ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 58
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
33
34
35
36
37
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 33
def show
authorize! :admin, ReturnAuthorization
@return_authorization = order.return_authorizations.accessible_by(current_ability, :read).find(params[:id])
respond_with(@return_authorization)
end
|
#update ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 39
def update
@return_authorization = order.return_authorizations.accessible_by(current_ability, :update).find(params[:id])
if @return_authorization.update_attributes(return_authorization_params)
respond_with(@return_authorization, default_template: :show)
else
invalid_resource!(@return_authorization)
end
end
|