module EgovUtils module Iszr module LegalPeople class ProdSearch < ActiveInteraction::Base string :ico validates :ico, presence: true MAPPING_CLASS = EgovUtils::Services::Iszr::LegalPeople def execute find_person end private def request result = EgovUtils::Iszr::LegalPeople::CreateRequest.run(ico:) # make some call to API with result end def find_person # Request will contain provided ICO on which the response will be based response = File.read(sample_results) body = Nokogiri::XML(response) person = MAPPING_CLASS.new( ico: body.at('//dot:Ico').text, name: body.at('//dot:NazevOsoby').text, remote_id: body.at('//ros:Aifo').text ) if person.nil? errors.add(:base, I18n.t('errors.messages.legal_person.not_found')) else person end end def sample_results 'lib/egov_utils/iszr/e20_ico_response.xml' end end end end end