text: "use strict";angular.module("azure-mobile-service.module",[]).service("Azureservice",function(e){var r="https://<AZURE_APP_NAME>.azure-mobile.net/",n="<AZURE_APP_API_KEY>",o=["google","twitter","facebook","windowsaccount","windowsazureactivedirectory"],t=WindowsAzure.MobileServiceClient,i=new t(r,n),u=function(){sessionStorage.loggedInUser&&(i.currentUser=JSON.parse(sessionStorage.loggedInUser))};u();var s=function(e){return i.getTable(e)},l=function(e){return"undefined"==typeof e||"object"!=typeof e&&"function"!=typeof e},c=function(e){return a(e)||"object"!=typeof e},a=function(e){return null===e||"undefined"==typeof e},f=function(e){return!a(e)},d=function(r){var n=e.defer();return r.done(function(e){n.resolve(e)},function(e){n.reject(e)}),n.promise};return{query:function(e,r){var n=null;if(a(e))return console.error("Azureservice.query: You must specify a table name"),null;if(angular.isDefined(r)&&angular.isObject(r)){if(l(r.criteria)&&(r.criteria={}),n=s(e).where(r.criteria,r.params),f(r.take)&&angular.isNumber(r.take)&&(n=n.take(r.take)),f(r.skip)&&angular.isNumber(r.take)&&(n=n.skip(r.skip)),angular.isDefined(r.orderBy)&&angular.isArray(r.orderBy))for(var o=r.orderBy,t=0;t<o.length;t++){var i=o[t].column,u=o[t].direction;angular.isDefined(i)&&(angular.isDefined(u)&&"desc"===u.toLowerCase()?n=n.orderByDescending(i):angular.isDefined(i)&&(n=n.orderBy(i)))}angular.isDefined(r.columns)&&angular.isArray(r.columns)&&(n=n.select(r.columns.join()))}else n=s(e).where({});return d(n.includeTotalCount().read())},getById:function(e,r){return a(e)?(console.error("Azureservice.getById: You must specify a table name"),null):a(r)?(console.error("Azureservice.getById: You must specify the id"),null):d(s(e).lookup(r))},getAll:function(e){return this.query(e)},insert:function(e,r){return a(e)?(console.error("Azureservice.insert: You must specify a table name"),null):c(r)?(console.error("Azureservice.insert: You must specify the insert object"),null):d(s(e).insert(r))},update:function(e,r){return a(e)?(console.error("Azureservice.update: You must specify a table name"),null):c(r)?(console.error("Azureservice.update: You must specify the insert object"),null):d(s(e).update(r))},del:function(e,r){return a(e)?(console.error("Azureservice.del: You must specify a table name"),null):c(r)?(console.error("Azureservice.del: You must specify the insert object"),null):d(s(e).del(r))},login:function(e){if(!angular.isDefined(e)||-1===o.indexOf(e))throw new Error("Azureservice.login Invalid or no oauth provider listed.");var r=i.login(e).then(function(){sessionStorage.loggedInUser=JSON.stringify(i.currentUser)});return d(r)},logout:function(){sessionStorage.loggedInUser=null,i.logout()},isLoggedIn:function(){return f(i.currentUser)&&f(sessionStorage.loggedInUser)},invokeApi:function(r,n){var o=e.defer(),t=["get","post","put","delete"];if(a(r))return console.error("Azureservice.invokeApi No custom api name specified"),null;if(c(n))n={method:"get"};else if(a(n.method))n.method="get";else if(-1===t.indexOf(n.method.toLowerCase()))return console.error("Azureservice.invokeApi Invalid method type"),null;return i.invokeApi(r,n).done(function(e){o.resolve(e.result)},function(e){o.reject(e)}),o.promise}}});