Class: Spree::Api::V1::ReturnAuthorizationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v1/return_authorizations_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#content_type, #permitted_line_item_attributes

Methods included from ControllerSetup

included

Instance Method Details

#cancelObject



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

#createObject



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

#destroyObject



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

#indexObject



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, :read).
                           ransack(params[:q]).result.
                           page(params[:page]).per(params[:per_page])
  respond_with(@return_authorizations)
end

#newObject



29
30
31
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 29

def new
  authorize! :admin, ReturnAuthorization
end

#showObject



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, :read).find(params[:id])
  respond_with(@return_authorization)
end

#updateObject



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_attributes(return_authorization_params)
    respond_with(@return_authorization, default_template: :show)
  else
    invalid_resource!(@return_authorization)
  end
end