Use $resource to make RESTful API call to reduce code
Extract them into service