Polish superstar Iga Swiatek has beaten Paula Badosa in three sets to lead her side to victory over hosts Spain in the Billie Jean King Cup Finals in Malaga.