refactor api_get and api_post to private methods