Sha256: 3c448d663eb3bd10beb89d0a2b3968aab4b3e0630db659a851202230e7fd0c9f

Contents?: true

Size: 889 Bytes

Versions: 16

Compression:

Stored size: 889 Bytes

Contents

module EgovUtils
  module Iszr
    module LegalPeople
      class DevSearch < ActiveInteraction::Base
        string :ico

        validates :ico, presence: true

        MAPPING_CLASS = EgovUtils::Services::Iszr::LegalPeople

        def execute
          legal_person = initialize_person.detect { |person| person.ico == ico }

          if legal_person.nil?
            errors.add(:base, I18n.t('errors.messages.legal_person.not_found'))
          else
            legal_person
          end
        end

        private

        def sample_results
          EgovUtils::Engine.root.join('lib/egov_utils/iszr/lp_results.json')
        end

        def initialize_person
          response = File.read(sample_results)

          body = JSON.parse(response)

          body.map do
            MAPPING_CLASS.new(_1.deep_symbolize_keys!)
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
egov_utils-1.5.0.alpha16 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha15 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha14 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha13 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha12 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha11 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha10 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha9 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha8 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha7 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha6 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha5 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha4 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha3 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha2 app/services/egov_utils/iszr/legal_people/dev_search.rb
egov_utils-1.5.0.alpha1 app/services/egov_utils/iszr/legal_people/dev_search.rb