Sha256: 1a60e024ab042ef2433d45d41546b5f6fbbf59c6d451d512d3c76f9bbec9c333

Contents?: true

Size: 1.42 KB

Versions: 27

Compression:

Stored size: 1.42 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

      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

27 entries across 27 versions & 1 rubygems

Version Path
comee_core-0.1.68 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.67 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.66 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.65 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.64 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.63 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.62 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.61 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.60 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.59 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.58 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.57 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.56 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.55 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.54 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.53 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.52 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.51 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.50 app/controllers/comee/core/customer_orders_controller.rb
comee_core-0.1.49 app/controllers/comee/core/customer_orders_controller.rb