Sha256: cfa051ac236780bba60f3cc8b90dca8f1d2ec7cd9fbcf49a24146a56e765bea3

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

module Logistics
  module Core
    class AdditionalDocumentsController < ApplicationController
      before_action :set_service

      def get_lookup_values
        values = @service.get_lookup_values(params[:entity])
        response = Mks::Common::MethodResponse.new(true, nil, values, nil, nil)
        render json: response
      end

      def get_document_types
        documents = @service.get_additional_documents(params[:entity], params[:rec_id])
        data = ActiveModelSerializers::SerializableResource.new(documents).as_json
        response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil)
        render json: response
      end

      def bulk_save
        success, error = @service.bulk_save(additional_document_params[:payload])
        response = Mks::Common::MethodResponse.new(success, nil, nil, [error], nil)
        render json: response
      end

      def bulk_update
        success, error = @service.bulk_update(additional_document_params[:payload])
        response = Mks::Common::MethodResponse.new(success, nil, nil, [error], nil)
        render json: response
      end

      def bulk_delete
        success, error = @service.bulk_delete(params[:ids])
        response = Mks::Common::MethodResponse.new(success, nil, nil, [error], nil)
        render json: response
      end

      private

      def set_service
        @service = AdditionalDocumentService.new
      end

      def additional_document_params
        params.permit(:payload => [:id, :documentable_id, :documentable_type, :document_type_id, :original, :copy,
                                   :certified, :is_endorsed, :is_mandatory, :transaction_type_id])
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-21.11.1 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-21.08.1 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-21.03.1 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-20.10.3 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-20.10.2 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-20.10.1 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-20.9.1 app/controllers/logistics/core/additional_documents_controller.rb
logistics_core-20.8.1 app/controllers/logistics/core/additional_documents_controller.rb