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

Methods inherited from BaseController

#map_nested_attributes_keys, #set_jsonp_format

Methods included from ControllerSetup

included

Instance Method Details

#createObject



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

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

#destroyObject



38
39
40
41
42
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 38

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

#indexObject



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

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

#showObject



15
16
17
18
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 15

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

#updateObject



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

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