Class: Spree::Api::ReturnAuthorizationsController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Instance Method Details

#cancelObject



60
61
62
63
64
65
66
67
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 60

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



11
12
13
14
15
16
17
18
19
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 11

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



21
22
23
24
25
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 21

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



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 27

def index
  authorize! :admin, ReturnAuthorization

  @return_authorizations = @order.
    return_authorizations.
    accessible_by(current_ability).
    ransack(params[:q]).
    result

  @return_authorizations = paginate(@return_authorizations)

  respond_with(@return_authorizations)
end

#newObject



41
42
43
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 41

def new
  authorize! :admin, ReturnAuthorization
end

#showObject



45
46
47
48
49
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 45

def show
  authorize! :admin, ReturnAuthorization
  @return_authorization = @order.return_authorizations.accessible_by(current_ability, :show).find(params[:id])
  respond_with(@return_authorization)
end

#updateObject



51
52
53
54
55
56
57
58
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 51

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