Skip to content

Commit

Permalink
ap-5097: create shared CHARACTERS hash in CCMS::Requestors::BaseReque…
Browse files Browse the repository at this point in the history
…stor

that can also be used for applicant matching
  • Loading branch information
kmahern committed Jul 2, 2024
1 parent 5708388 commit e5d9bca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
11 changes: 3 additions & 8 deletions app/services/ccms/parsers/applicant_search_response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,10 @@ def build_client_result_array
end

def parse_client(client_struct)
characters = {
"’" => "'",
"‘" => "'",
}.freeze

client_struct.match = [
@applicant.first_name.first.casecmp?(client_struct.first_initial),
@applicant.last_name.gsub(/[’‘]/, characters).casecmp?(client_struct.last_name),
@applicant.surname_at_birth.gsub(/[’‘]/, characters).casecmp?(client_struct.last_name_at_birth),
@applicant.first_name.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::CHARACTERS).first.casecmp?(client_struct.first_initial),
@applicant.last_name.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::CHARACTERS).casecmp?(client_struct.last_name),
@applicant.surname_at_birth.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::CHARACTERS).casecmp?(client_struct.last_name_at_birth),
@applicant.date_of_birth.strftime("%Y-%m-%d").eql?(client_struct.date_of_birth),
(@applicant.national_insurance_number || "").casecmp?(client_struct.national_insurance_number),
].all?
Expand Down
16 changes: 6 additions & 10 deletions app/services/ccms/requestors/base_requestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class BaseRequestor
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
}.freeze

CHARACTERS = {
"’" => "'",
"‘" => "'",
}.freeze

attr_reader :namespaces

def initialize
Expand All @@ -36,7 +41,7 @@ def formatted_xml
result = ""
formatter = REXML::Formatters::Pretty.new
formatter.compact = true
formatter.write(REXML::Document.new(replace_special_characters(request_xml)), result)
formatter.write(REXML::Document.new(request_xml.gsub(/[’‘]/, CHARACTERS)), result)
result
end

Expand Down Expand Up @@ -80,15 +85,6 @@ def wsdl_location
def config
Rails.configuration.x.ccms_soa
end

def replace_special_characters(xml)
characters = {
"’" => "'",
"‘" => "'",
}.freeze

xml.gsub(/[’‘]/, characters)
end
end
end
end

0 comments on commit e5d9bca

Please sign in to comment.