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

#map_nested_attributes_keys

Methods included from ControllerSetup

included

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 17

def create
  @return_authorization = order.return_authorizations.build(params[:return_authorization], :as => :api)
  if @return_authorization.save
    render :show, :status => 201
  else
    invalid_resource!(@return_authorization)
  end
end

#destroyObject



35
36
37
38
39
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 35

def destroy
  @return_authorization = order.return_authorizations.find(params[:id])
  @return_authorization.destroy
  render :text => nil, :status => 204
end

#indexObject



7
8
9
10
11
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 7

def index
  @return_authorizations = order.return_authorizations.
                           ransack(params[:q]).result.
                           page(params[:page]).per(params[:per_page])
end

#showObject



13
14
15
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 13

def show
  @return_authorization = order.return_authorizations.find(params[:id])
end

#updateObject



26
27
28
29
30
31
32
33
# File 'app/controllers/spree/api/v1/return_authorizations_controller.rb', line 26

def update
  @return_authorization = order.return_authorizations.find(params[:id])
  if @return_authorization.update_attributes(params[:return_authorization])
    render :show
  else
    invalid_resource!(@return_authorization)
  end
end