diff --git a/dist/angular-github-api-factory.js b/dist/angular-github-api-factory.js index 14eedf0..3ea2981 100644 --- a/dist/angular-github-api-factory.js +++ b/dist/angular-github-api-factory.js @@ -1,6 +1,6 @@ /** @name: angular-github-api-factory - @version: 0.5.0 (06-01-2016) + @version: 0.5.0 (17-02-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-github-api-factory#readme @license: MIT @@ -76,7 +76,7 @@ angular.module("jtt_github", []) this.fillDataInObjectByList = function (_object, _params, _list) { angular.forEach(_list, function (value, key) { - if (typeof _params[value] !== "undefined") { + if (angular.isDefined(_params[value])) { _object.object[value] = _params[value]; } }); @@ -92,7 +92,7 @@ angular.module("jtt_github", []) url: "", }; - if (typeof _params.per_page !== "undefined") { + if (angular.isDefined(_params.per_page)) { githubSearchData.object.per_page = _params.per_page; } @@ -141,7 +141,6 @@ angular.module("jtt_github", []) githubSearchData.url = this.getApiBaseUrl() + "repos/" + _params.user + "/" + _params.repo + "/events"; break; } - return githubSearchData; }; }); \ No newline at end of file diff --git a/dist/angular-github-api-factory.min.js b/dist/angular-github-api-factory.min.js index 891feda..187032c 100644 --- a/dist/angular-github-api-factory.min.js +++ b/dist/angular-github-api-factory.min.js @@ -1,8 +1,8 @@ /** @name: angular-github-api-factory - @version: 0.5.0 (06-01-2016) + @version: 0.5.0 (17-02-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-github-api-factory#readme @license: MIT */ -"use strict";angular.module("jtt_github",[]).factory("githubFactory",["$http","githubSearchDataService",function(a,b){var c={};return c.getUser=function(c){var d=b.getNew("user",c);return a({method:"GET",url:d.url,params:d.object})},c.getReposByUser=function(c){var d=b.getNew("reposByUser",c);return a({method:"GET",url:d.url,params:d.object})},c.getReposByName=function(c){var d=b.getNew("reposByName",c);return a({method:"GET",url:d.url,params:d.object})},c.getRepoByUserAndName=function(c){var d=b.getNew("repoByUserAndName",c);return a({method:"GET",url:d.url,params:d.object})},c.getEventsByUser=function(c){var d=b.getNew("eventsByUser",c);return a({method:"GET",url:d.url,params:d.object})},c.getEventsFromRepoByUserAndName=function(c){var d=b.getNew("eventsFromRepoByUserAndName",c);return a({method:"GET",url:d.url,params:d.object})},c}]).service("githubSearchDataService",function(){this.getApiBaseUrl=function(a){return"https://api.github.com/"},this.fillDataInObjectByList=function(a,b,c){return angular.forEach(c,function(c,d){"undefined"!=typeof b[c]&&(a.object[c]=b[c])}),a},this.getNew=function(a,b){var c={object:{access_token:b.access_token},url:""};switch("undefined"!=typeof b.per_page&&(c.object.per_page=b.per_page),a){case"user":c.object.per_page=void 0,c=this.fillDataInObjectByList(c,b,[]),c.url=this.getApiBaseUrl()+"users/"+b.user;break;case"reposByUser":c=this.fillDataInObjectByList(c,b,["q","sort","order","page"]),c.url=this.getApiBaseUrl()+"users/"+b.user+"/repos";break;case"reposByName":c=this.fillDataInObjectByList(c,b,["sort","order","page"]),c.url=this.getApiBaseUrl()+"search/repositories?q="+b.q;break;case"repoByUserAndName":c.object={access_token:b.access_token},c=this.fillDataInObjectByList(c,b,[]),c.url=this.getApiBaseUrl()+"repos/"+b.user+"/"+b.repo;break;case"eventsByUser":c=this.fillDataInObjectByList(c,b,["q","sort","order","page"]),c.url=this.getApiBaseUrl()+"users/"+b.user+"/events";break;case"eventsFromRepoByUserAndName":c=this.fillDataInObjectByList(c,b,["q","sort","order","page"]),c.url=this.getApiBaseUrl()+"repos/"+b.user+"/"+b.repo+"/events"}return c}}); \ No newline at end of file +"use strict";angular.module("jtt_github",[]).factory("githubFactory",["$http","githubSearchDataService",function(a,b){var c={};return c.getUser=function(c){var d=b.getNew("user",c);return a({method:"GET",url:d.url,params:d.object})},c.getReposByUser=function(c){var d=b.getNew("reposByUser",c);return a({method:"GET",url:d.url,params:d.object})},c.getReposByName=function(c){var d=b.getNew("reposByName",c);return a({method:"GET",url:d.url,params:d.object})},c.getRepoByUserAndName=function(c){var d=b.getNew("repoByUserAndName",c);return a({method:"GET",url:d.url,params:d.object})},c.getEventsByUser=function(c){var d=b.getNew("eventsByUser",c);return a({method:"GET",url:d.url,params:d.object})},c.getEventsFromRepoByUserAndName=function(c){var d=b.getNew("eventsFromRepoByUserAndName",c);return a({method:"GET",url:d.url,params:d.object})},c}]).service("githubSearchDataService",function(){this.getApiBaseUrl=function(a){return"https://api.github.com/"},this.fillDataInObjectByList=function(a,b,c){return angular.forEach(c,function(c,d){angular.isDefined(b[c])&&(a.object[c]=b[c])}),a},this.getNew=function(a,b){var c={object:{access_token:b.access_token},url:""};switch(angular.isDefined(b.per_page)&&(c.object.per_page=b.per_page),a){case"user":c.object.per_page=void 0,c=this.fillDataInObjectByList(c,b,[]),c.url=this.getApiBaseUrl()+"users/"+b.user;break;case"reposByUser":c=this.fillDataInObjectByList(c,b,["q","sort","order","page"]),c.url=this.getApiBaseUrl()+"users/"+b.user+"/repos";break;case"reposByName":c=this.fillDataInObjectByList(c,b,["sort","order","page"]),c.url=this.getApiBaseUrl()+"search/repositories?q="+b.q;break;case"repoByUserAndName":c.object={access_token:b.access_token},c=this.fillDataInObjectByList(c,b,[]),c.url=this.getApiBaseUrl()+"repos/"+b.user+"/"+b.repo;break;case"eventsByUser":c=this.fillDataInObjectByList(c,b,["q","sort","order","page"]),c.url=this.getApiBaseUrl()+"users/"+b.user+"/events";break;case"eventsFromRepoByUserAndName":c=this.fillDataInObjectByList(c,b,["q","sort","order","page"]),c.url=this.getApiBaseUrl()+"repos/"+b.user+"/"+b.repo+"/events"}return c}}); \ No newline at end of file diff --git a/src/angular-github-api-factory.js b/src/angular-github-api-factory.js index f370de1..fee88ee 100644 --- a/src/angular-github-api-factory.js +++ b/src/angular-github-api-factory.js @@ -69,7 +69,7 @@ angular.module("jtt_github", []) this.fillDataInObjectByList = function (_object, _params, _list) { angular.forEach(_list, function (value, key) { - if (typeof _params[value] !== "undefined") { + if (angular.isDefined(_params[value])) { _object.object[value] = _params[value]; } }); @@ -85,7 +85,7 @@ angular.module("jtt_github", []) url: "", }; - if (typeof _params.per_page !== "undefined") { + if (angular.isDefined(_params.per_page)) { githubSearchData.object.per_page = _params.per_page; } @@ -134,7 +134,6 @@ angular.module("jtt_github", []) githubSearchData.url = this.getApiBaseUrl() + "repos/" + _params.user + "/" + _params.repo + "/events"; break; } - return githubSearchData; }; }); \ No newline at end of file