Refactored BaseAPIClass, extracted utility functions into its own class.