Handle QrMatching response - mock
This commit is contained in:
@@ -15,12 +15,17 @@ module BrayniacAI
|
||||
pdfs = []
|
||||
images = []
|
||||
matches = []
|
||||
errors = []
|
||||
|
||||
# Use first file for the error entry
|
||||
first_attachment = attachments.shift
|
||||
unless first_attachment.nil?
|
||||
errors << { file: first_attachment, error_code: 1 }
|
||||
|
||||
if first_attachment.present?
|
||||
matches << {
|
||||
headshots: [],
|
||||
contracts: [],
|
||||
unknowns: [first_attachment],
|
||||
identifier: ''
|
||||
}
|
||||
end
|
||||
|
||||
attachments.each do |attachment|
|
||||
@@ -45,18 +50,20 @@ module BrayniacAI
|
||||
pdf = pair_element2
|
||||
image = pair_element1
|
||||
end
|
||||
if pdf.nil? || image.nil?
|
||||
matches << { headshot: image } if pdf.nil?
|
||||
matches << { contract: pdf } if image.nil?
|
||||
else
|
||||
matches << { headshot: image, contract: pdf, identifier: '' }
|
||||
end
|
||||
headshots = image.present? ? [image] : []
|
||||
contracts = pdf.present? ? [pdf] : []
|
||||
|
||||
matches << {
|
||||
headshots: headshots,
|
||||
contracts: contracts,
|
||||
unknowns: [],
|
||||
identifier: ''
|
||||
}
|
||||
end
|
||||
|
||||
{
|
||||
request_id: request_data[:request_id],
|
||||
matches: matches,
|
||||
errors: errors
|
||||
request_id: request_data[:request_id],
|
||||
matches: matches
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user