import base64


def clean_data(records):
    """
    Clean up records to be json.dump-able and sent to subscriber
    """
    for record in records:
        timestamp = record['ApproximateArrivalTimestamp'].timestamp()
        decoded_data = base64.b64encode(record['Data']).decode(
            'utf-8')  # Needs to be base64'd and decoded to match regular kinesis
        record['ApproximateArrivalTimestamp'] = timestamp
        record['Data'] = decoded_data
    return records