Class: Workarea::Api::Admin::FulfillmentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/api/admin/fulfillments_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #sort_direction, #sort_field

Instance Method Details

#cancel_itemsObject



245
246
247
248
249
250
251
252
253
254
# File 'app/controllers/workarea/api/admin/fulfillments_controller.rb', line 245

def cancel_items
  if @fulfillment.cancel_items(items)
    respond_with(
      { fulfillment: @fulfillment },
      { location: fulfillment_path(@fulfillment) }
    )
  else
    raise Mongoid::Errors::Validations.new(@fulfillment)
  end
end

#indexObject



54
55
56
57
58
59
60
61
# File 'app/controllers/workarea/api/admin/fulfillments_controller.rb', line 54

def index
  @fulfillments = Fulfillment
                    .all
                    .order_by(sort_field => sort_direction)
                    .page(params[:page])

  respond_with fulfillments: @fulfillments
end

#ship_itemsObject



171
172
173
174
175
176
177
178
179
180
# File 'app/controllers/workarea/api/admin/fulfillments_controller.rb', line 171

def ship_items
  if @fulfillment.ship_items(params[:tracking_number], items)
    respond_with(
      { fulfillment: @fulfillment },
      { location: fulfillment_path(@fulfillment) }
    )
  else
    raise Mongoid::Errors::Validations.new(@fulfillment)
  end
end

#showObject



100
101
102
# File 'app/controllers/workarea/api/admin/fulfillments_controller.rb', line 100

def show
  respond_with fulfillment: @fulfillment
end