define(['angular'], function(angular) {
	angular.module("powerQueryModule",[])
	.service("pqService",function($http, $q){
		
		//query - the name of the PowerQuery
		//data - JavaScript Object including any parameters that must be passed to the query
		this.getPQResults = function(query, data){
			var deferredResponse = $q.defer();
			 $http({
				url: '/ws/schema/query/' + query,
				method:'POST',
				data: data || {},
				params: {"pagesize":0},
				headers: {
					'Accept': 'application/json', 
					"Content-Type": "application/json"
				}
			})
			.then(function(response){
				deferredResponse.resolve(response.data.record || []);
			});
			return deferredResponse.promise;
		};
	});
});