Updated API to include separation of success and failure callbacks.