def batch_failures entries, response, include_batch_index=false
response[:failed].inject([]) do |failures, failure|
entry = entries.find{|e| e[:id] == failure[:id] }
details = {
:error_code => failure[:code],
:error_message => failure[:message],
:sender_fault => failure[:sender_fault],
}
if include_batch_index
details[:batch_index] = failure[:id].to_i
end
if message_body = entry[:message_body]
details[:message_body] = message_body
end
if handle = entry[:receipt_handle]
details[:receipt_handle] = handle
end
failures << details
end
end