move curl code into request class