Refactoring API server class