Class: Spree::Api::V1::ReturnAuthorizationsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::V1::ReturnAuthorizationsController
show all
- Defined in:
- app/controllers/spree/api/v1/return_authorizations_controller.rb
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#content_type, #permitted_line_item_attributes
included
Instance Method Details
#cancel ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 48
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/v1/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/v1/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/v1/return_authorizations_controller.rb', line 21
def index
authorize! :admin, ReturnAuthorization
@return_authorizations = order.return_authorizations.accessible_by(current_ability).
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/v1/return_authorizations_controller.rb', line 29
def new
authorize! :admin, ReturnAuthorization
end
|
#show ⇒ Object
33
34
35
36
37
|
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 33
def show
authorize! :admin, ReturnAuthorization
@return_authorization = order.return_authorizations.accessible_by(current_ability, :show).find(params[:id])
respond_with(@return_authorization)
end
|
#update ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/controllers/spree/api/v1/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(return_authorization_params)
respond_with(@return_authorization, default_template: :show)
else
invalid_resource!(@return_authorization)
end
end
|