Class based REST API interaction for AngularJS