Refactored API out into Repository classes