rest api refactoring