Sha256: 8c10f0821043e61f352e20f99c3c6f62f519543537f48c100285c16bc7994e36

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

module Workarea
  if Plugin.installed?("Workarea::Api")
    module Api
      module Admin
        class LegacyOrdersController < Workarea::Api::Admin::ApplicationController
          def index
            @orders = LegacyOrder
              .all
              .order_by(sort_field => sort_direction)
              .page(params[:page])

            respond_with orders: @orders
          end

          def create
            @order = LegacyOrder.create!(params[:order])
            respond_with(
              { order: @order },
              status: :created,
              location: legacy_order_path(@order.id)
            )
          end

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

          def update
            @order = LegacyOrder.find(params[:id])
            @order.update_attributes!(params[:order])
            respond_with order: @order
          end

          private

            def sort_field
              params[:sort_by].presence || :placed_at
            end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-legacy_orders-2.0.3 app/controllers/workarea/api/admin/legacy_orders_controller.rb
workarea-legacy_orders-2.0.2 app/controllers/workarea/api/admin/legacy_orders_controller.rb
workarea-legacy_orders-2.0.1 app/controllers/workarea/api/admin/legacy_orders_controller.rb
workarea-legacy_orders-2.0.0 app/controllers/workarea/api/admin/legacy_orders_controller.rb