Sha256: fe2a8165b5e8b6b56b1ec6e09f91194abb770614f1bf7cdba21500e36ea8e7bc

Contents?: true

Size: 907 Bytes

Versions: 15

Compression:

Stored size: 907 Bytes

Contents

module EgovUtils
  class IszrController < ApplicationController

    def search
      if params.dig(:search, :ico).present?
        @legal_person = EgovUtils::Iszr::LegalPeople::Search.run(search_params)

        if @legal_person.valid?
          render json: @legal_person.result
        else
          render json: @legal_person.errors.details, status: :unprocessable_entity
        end
      else
        @natural_person = EgovUtils::Iszr::NaturalPeople::Search.run(
          search_params
        )
        if @natural_person.valid?
          render json: @natural_person.result
        else
          render json: @natural_person.errors.details, status: :unprocessable_entity
        end
      end
    end

    private

    def search_params
      params.require(:search).permit(
        :ico,
        :firstname,
        :lastname,
        :birth_date,
        :birth_place
      )
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
egov_utils-1.5.0.alpha15 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha14 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha13 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha12 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha11 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha10 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha9 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha8 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha7 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha6 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha5 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha4 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha3 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha2 app/controllers/egov_utils/iszr_controller.rb
egov_utils-1.5.0.alpha1 app/controllers/egov_utils/iszr_controller.rb