Hamas has released four Israeli soldiers in exchange for 200 Palestinian prisoners as part of a ceasefire agreement in Gaza.