Magnetic refrigeration and slow magnetic relaxation in tetranuclear lanthanide cages (Ln = Gd, Dy) with in situ ligand transformation