Sha256: 98611e0b750631792f76a99c81b783c2ff224c1fb85f1c37d584166921215fde

Contents?: true

Size: 1.59 KB

Versions: 14

Compression:

Stored size: 1.59 KB

Contents

module Comee
  module Core
    class CustomerOrdersController < ApplicationController
      include Common

      before_action :set_service, only: %i[submit submit_for_confirmation accept cancel]

      def submit
        order = @service.submit(params[:id])
        render json: {success: true, data: serialize(order)}
      rescue StandardError => e
        render json: {success: false, error: e.message}
      end

      def submit_for_confirmation
        order = @service.submit_for_confirmation(params[:id])
        render json: {success: true, data: serialize(order)}
      rescue StandardError => e
        render json: {success: false, error: e.message}
      end

      def accept
        order = @service.accept(params[:id])
        render json: {success: true, data: serialize(order)}
      rescue StandardError => e
        render json: {success: false, error: e.message}
      end

      def cancel
        order = @service.cancel(params[:id])
        render json: {success: true, data: serialize(order)}
      rescue StandardError => e
        render json: {success: false, error: e.message}
      end

      def filter
        @customer_orders = Comee::Core::CustomerOrder.ransack(params[:q]).result
        render json: {success: true, data: serialize(@customer_orders)}
      end

      private

      def model_params
        params.require(:payload).permit(:order_number, :order_date, :order_terms, :delivery_address, :invoice_address, :status, :client_id,
                                        :file)
      end

      def set_service
        @service = CustomerOrderService.new
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
comee_core-0.1.82 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.81 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.80 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.79 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.78 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.77 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.76 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.75 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.74 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.73 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.72 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.71 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.70 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.69 app/controllers/comee/core/customer_orders_controller.rb