Class: EgovUtils::IszrController

Inherits:
ApplicationController show all
Defined in:
app/controllers/egov_utils/iszr_controller.rb

Instance Method Summary collapse

Instance Method Details

#searchObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/egov_utils/iszr_controller.rb', line 4

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