Class: Spree::Api::LegacyReturnAuthorizationsController

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

Instance Method Summary collapse

Instance Method Details

#addObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/spree/api/legacy_return_authorizations_controller.rb', line 34

def add
  @legacy_return_authorization = order.legacy_return_authorizations.accessible_by(current_ability, :update).find(params[:id])
  @legacy_return_authorization.add_variant params[:variant_id].to_i, params[:quantity].to_i
  if @legacy_return_authorization.valid?
    respond_with @legacy_return_authorization, default_template: :show
  else
    invalid_resource!(@legacy_return_authorization)
  end
end

#cancelObject



53
54
55
56
57
58
59
60
# File 'app/controllers/spree/api/legacy_return_authorizations_controller.rb', line 53

def cancel
  @legacy_return_authorization = order.legacy_return_authorizations.accessible_by(current_ability, :update).find(params[:id])
  if @legacy_return_authorization.cancel
    respond_with @legacy_return_authorization, default_template: :show
  else
    invalid_resource!(@legacy_return_authorization)
  end
end

#destroyObject



5
6
7
8
9
# File 'app/controllers/spree/api/legacy_return_authorizations_controller.rb', line 5

def destroy
  @legacy_return_authorization = order.legacy_return_authorizations.accessible_by(current_ability, :destroy).find(params[:id])
  @legacy_return_authorization.destroy
  respond_with(@legacy_return_authorization, status: 204)
end

#indexObject



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

def index
  authorize! :admin, LegacyReturnAuthorization
  @legacy_return_authorizations = order.legacy_return_authorizations.accessible_by(current_ability, :read).
                           ransack(params[:q]).result.
                           page(params[:page]).per(params[:per_page])
  respond_with(@legacy_return_authorizations)
end

#receiveObject



44
45
46
47
48
49
50
51
# File 'app/controllers/spree/api/legacy_return_authorizations_controller.rb', line 44

def receive
  @legacy_return_authorization = order.legacy_return_authorizations.accessible_by(current_ability, :update).find(params[:id])
  if @legacy_return_authorization.receive
    respond_with @legacy_return_authorization, default_template: :show
  else
    invalid_resource!(@legacy_return_authorization)
  end
end

#showObject



19
20
21
22
23
# File 'app/controllers/spree/api/legacy_return_authorizations_controller.rb', line 19

def show
  authorize! :admin, LegacyReturnAuthorization
  @legacy_return_authorization = order.legacy_return_authorizations.accessible_by(current_ability, :read).find(params[:id])
  respond_with(@legacy_return_authorization)
end

#updateObject



25
26
27
28
29
30
31
32
# File 'app/controllers/spree/api/legacy_return_authorizations_controller.rb', line 25

def update
  @legacy_return_authorization = order.legacy_return_authorizations.accessible_by(current_ability, :update).find(params[:id])
  if @legacy_return_authorization.update_attributes(legacy_return_authorization_params)
    respond_with(@legacy_return_authorization, default_template: :show)
  else
    invalid_resource!(@legacy_return_authorization)
  end
end