class Multiwoven::Integrations::Destination::Mailchimp::Client

def process_records(records, stream)

def process_records(records, stream)
  log_message_array = []
  write_success = 0
  write_failure = 0
  properties = stream.json_schema[:properties]
  records.each do |record_object|
    record = extract_data(record_object, properties)
    args = [stream.name, "Id", record]
    begin
      response = send_to_mailchimp(record, stream.name)
      write_success += 1
      log_message_array << log_request_response("info", args, response)
    rescue StandardError => e
      handle_exception(e, {
                         context: "MAILCHIMP:WRITE:EXCEPTION",
                         type: "error",
                         sync_id: @sync_config.sync_id,
                         sync_run_id: @sync_config.sync_run_id
                       })
      write_failure += 1
      log_message_array << log_request_response("error", args, e.message)
    end
  end
  tracking_message(write_success, write_failure, log_message_array)
end