From 5e8ec22631a54157a48468a24fdcfaf6e3adbb56 Mon Sep 17 00:00:00 2001 From: Jonathan Hornung Date: Wed, 1 Jun 2016 19:44:35 +0200 Subject: [PATCH] removed unneeded access token --- README.md | 12 ++++++------ bower.json | 2 +- demo/js/app.js | 11 +++-------- dist/angular-github-api-factory.js | 10 ++++++---- dist/angular-github-api-factory.min.js | 4 ++-- package.json | 2 +- src/angular-github-api-factory.js | 8 +++++--- 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7fcc861..b028c26 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank)) ```js githubFactory.getUser({ user:"", - access_token:"" + access_token:"" // (optional) }).then(function(_data){ //on success }).catch(function (_data) { @@ -47,7 +47,7 @@ githubFactory.getUser({ githubFactory.getRepoByUserAndName({ user:"", repo:"", - access_token:"" + access_token:"" // (optional) }).then(function(_data){ //on success }).catch(function (_data) { @@ -63,7 +63,7 @@ githubFactory.getReposByName({ sort:"", // (optional) 'stars', 'forks', or 'updated' order:"", // (optional) 'desc', 'asc' per_page:"", // (optional) valid values: 1-100 | default: 30 - access_token:"" + access_token:"" // (optional) }).then(function(_data){ //on success }).catch(function (_data) { @@ -78,7 +78,7 @@ githubFactory.getReposByUser({ sort:"", // (optional) 'stars', 'forks', or 'updated' order:"", // (optional) 'desc', 'asc' per_page:"", // (optional) valid values: 1-100 | default: 30 - access_token:"" + access_token:"" // (optional) }).then(function(_data){ //on success }).catch(function (_data) { @@ -95,7 +95,7 @@ githubFactory.getEventsFromRepoByUserAndName({ sort:"", // (optional) order:"", // (optional) 'desc', 'asc' per_page:"", // (optional) valid values: 1-100 | default: 30 - access_token:"" + access_token:"" // (optional) }).then(function(_data){ //on success }).catch(function (_data) { @@ -110,7 +110,7 @@ githubFactory.getEventsByUser({ sort:"", // (optional) order:"", // (optional) 'desc', 'asc' per_page:"", // (optional) valid values: 1-100 | default: 30 - access_token:"" + access_token:"" // (optional) }).then(function(_data){ //on success }).catch(function (_data) { diff --git a/bower.json b/bower.json index 0bebda6..338b8c5 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "angular-github-api-factory", "description": "angularjs factory for github json rest api requests", - "version": "0.5.0", + "version": "0.5.1", "main": "dist/angular-github-api-factory.js", "authors": [ "Jonathan Hornung" diff --git a/demo/js/app.js b/demo/js/app.js index 71b8537..3a94a31 100644 --- a/demo/js/app.js +++ b/demo/js/app.js @@ -1,35 +1,32 @@ var app = angular.module("app", ['jtt_github']); app.controller('controller', ['$scope', 'githubFactory', function($scope, githubFactory) { - var _access_token = ''; - githubFactory.getUser({ user:"xremix", - access_token:_access_token }).then(function(_data){ console.info("user", _data); }); + githubFactory.getReposByUser({ user:"JohnnyTheTank", per_page: 100, - access_token:_access_token }).success(function(_data){ console.info("repos by user", _data); }); + githubFactory.getReposByName({ q:"apiNG-plugin", per_page: 20, - access_token:_access_token }).then(function(_data){ console.info("repos by name", _data); }); + githubFactory.getEventsByUser({ user:"xremix", per_page: 20, - access_token:_access_token }).then(function(_data){ console.info("events by user", _data); }); @@ -38,7 +35,6 @@ app.controller('controller', ['$scope', 'githubFactory', function($scope, github user:"JohnnyTheTank", repo:"apiNG", per_page: 100, - access_token:_access_token }).then(function(_data){ console.info("events from repo by user and name", _data); }); @@ -47,7 +43,6 @@ app.controller('controller', ['$scope', 'githubFactory', function($scope, github user:"xremix", repo:"xGallerify", per_page: 20, - access_token:_access_token }).then(function(_data){ console.info("repo by user and name", _data); }); diff --git a/dist/angular-github-api-factory.js b/dist/angular-github-api-factory.js index 3ea2981..d35a377 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 (17-02-2016) + @version: 0.5.1 (01-06-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-github-api-factory#readme @license: MIT @@ -86,9 +86,7 @@ angular.module("jtt_github", []) this.getNew = function (_type, _params) { var githubSearchData = { - object: { - access_token: _params.access_token, - }, + object: {}, url: "", }; @@ -96,6 +94,10 @@ angular.module("jtt_github", []) githubSearchData.object.per_page = _params.per_page; } + if (angular.isDefined(_params.access_token)) { + githubSearchData.object.access_token = _params.access_token; + } + switch (_type) { case "user": githubSearchData.object.per_page = undefined; diff --git a/dist/angular-github-api-factory.min.js b/dist/angular-github-api-factory.min.js index 187032c..126a9d0 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 (17-02-2016) + @version: 0.5.1 (01-06-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){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 +"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:{},url:""};switch(angular.isDefined(b.per_page)&&(c.object.per_page=b.per_page),angular.isDefined(b.access_token)&&(c.object.access_token=b.access_token),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/package.json b/package.json index d2d937b..ce871bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-github-api-factory", - "version": "0.5.0", + "version": "0.5.1", "description": "angularjs factory for github json rest api requests", "main": "dist/angular-github-api-factory.js", "scripts": { diff --git a/src/angular-github-api-factory.js b/src/angular-github-api-factory.js index fee88ee..fda336f 100644 --- a/src/angular-github-api-factory.js +++ b/src/angular-github-api-factory.js @@ -79,9 +79,7 @@ angular.module("jtt_github", []) this.getNew = function (_type, _params) { var githubSearchData = { - object: { - access_token: _params.access_token, - }, + object: {}, url: "", }; @@ -89,6 +87,10 @@ angular.module("jtt_github", []) githubSearchData.object.per_page = _params.per_page; } + if (angular.isDefined(_params.access_token)) { + githubSearchData.object.access_token = _params.access_token; + } + switch (_type) { case "user": githubSearchData.object.per_page = undefined;