poconsole.factory('FluidShot',function($q, $http, $log){
	var service = {};
	service.getFluidShotPage = function(page_number) {
        var deferred = $q.defer();
        $http.get('/api/fluid_shots?q={"order_by":[{"field":"created_on","direction":"desc"}]}&page=' + page_number).success(function(data) {
        	deferred.resolve(data);
        });
        return deferred.promise;
    };

    service.getFluidShot = function(id){
        var deferred = $q.defer();
        $http.get('/api/fluid_shots/' + id).success(function(data) {
        	deferred.resolve(data);
        });
        return deferred.promise;
    };

    service.createFluidShot = function(t){
        var deferred = $q.defer();
        var well_test = {
            'pump_intake_pressure': t.pump_intake_pressure,
            'created_on': t.created_on
        };
        $http.post('/api/fluid_shots', well_test).success(function(data){
            deferred.resolve(data);
        });
        return deferred.promise;
    };

    service.updateFluidShot = function(t){
        var deferred = $q.defer();
        var well_test = {
            'pump_intake_pressure': t.duration_hours,
            'created_on': t.created_on
        };
        $http.put('/api/fluid_shots/'+ t._id, data=well_test).success(function(data){
            deferred.resolve(data);
        });
        return deferred.promise;
    };

    service.deleteFluidShot = function(id){
        var deferred = $q.defer();
        var url = '/api/fluid_shots/' + id;
        $http.delete(url).success(function(data) {
            deferred.resolve({
                data: data
            });
        });
        return deferred.promise;
    };



    return service;
});
