Refactor RestApi