From 8adefffac78a3170df8b8e9a3e9d785b8d5ec007 Mon Sep 17 00:00:00 2001 From: Jonathan Hornung Date: Fri, 23 Dec 2016 09:45:08 +0100 Subject: [PATCH] new version (v0.2.4) --- bower.json | 2 +- demo/js/app.js | 1 + dist/angular-footballdata-api-factory.js | 42 ++++++++++---------- dist/angular-footballdata-api-factory.min.js | 4 +- package.json | 2 +- src/angular-footballdata-api-factory.js | 40 +++++++++---------- 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/bower.json b/bower.json index 0d3ade0..7310a18 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "authors": [ "Jonathan Hornung " ], - "version": "0.2.2", + "version": "0.2.4", "description": "angular factory for the football-data.org rest api", "main": "dist/angular-footballdata-api-factory.min.js", "moduleType": [], diff --git a/demo/js/app.js b/demo/js/app.js index 4f8f29e..7403caf 100644 --- a/demo/js/app.js +++ b/demo/js/app.js @@ -10,6 +10,7 @@ app.controller('controller', ['$scope', 'footballdataFactory', function($scope, console.info("getSeasons", _data); }); + footballdataFactory.getSeason({ id: '426', apiKey: apiKey, diff --git a/dist/angular-footballdata-api-factory.js b/dist/angular-footballdata-api-factory.js index 49f2b33..259461e 100644 --- a/dist/angular-footballdata-api-factory.js +++ b/dist/angular-footballdata-api-factory.js @@ -1,6 +1,6 @@ /** @name: angular-footballdata-api-factory - @version: 0.2.2 (23-12-2016) + @version: 0.2.4 (23-12-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-footballdata-api-factory#readme @license: MIT @@ -191,72 +191,72 @@ angular.module("jtt_footballdata", []) switch (_type) { case "getSeasons": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'season', + 'apiKey', 'season', ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/'; break; case "getSeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', + 'apiKey', ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id; break; case "getTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey' + 'apiKey' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'teams/' + _params.id; break; case "getPlayersByTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey' + 'apiKey' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id + '/players'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'teams/' + _params.id + '/players'; break; case "getFixtures": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'league', 'timeFrame' + 'apiKey', 'league', 'timeFrame' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'fixtures'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'fixtures'; break; case "getFixture": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'head2head' + 'apiKey', 'head2head' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'fixtures/' + _params.id; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'fixtures/' + _params.id; break; case "getTeamsBySeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', + 'apiKey', ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/teams'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id + '/teams'; break; case "getLeagueTableBySeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'matchday' + 'apiKey', 'matchday' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/leagueTable'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id + '/leagueTable'; break; case "getFixturesBySeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'matchday', 'timeFrame' + 'apiKey', 'matchday', 'timeFrame' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/fixtures'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id + '/fixtures'; break; case "getFixturesByTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'season', 'timeFrame', 'venue' + 'apiKey', 'season', 'timeFrame', 'venue' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id + '/fixtures'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'teams/' + _params.id + '/fixtures'; break; } diff --git a/dist/angular-footballdata-api-factory.min.js b/dist/angular-footballdata-api-factory.min.js index 4dbcc0e..3a1bd23 100644 --- a/dist/angular-footballdata-api-factory.min.js +++ b/dist/angular-footballdata-api-factory.min.js @@ -1,8 +1,8 @@ /** @name: angular-footballdata-api-factory - @version: 0.2.2 (23-12-2016) + @version: 0.2.4 (23-12-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-footballdata-api-factory#readme @license: MIT */ -"use strict";angular.module("jtt_footballdata",[]).factory("footballdataFactory",["$http","footballdataSearchDataService",function(a,b){var c={};return c.getSeasons=function(c){var d=b.getNew("getSeasons",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey}})},c.getSeason=function(c){var d=b.getNew("getSeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey}})},c.getTeam=function(c){var d=b.getNew("getTeam",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getPlayersByTeam=function(c){var d=b.getNew("getPlayersByTeam",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixtures=function(c){var d=b.getNew("getFixtures",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixture=function(c){var d=b.getNew("getFixture",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixturesByTeam=function(c){var d=b.getNew("getFixturesByTeam",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getTeamsBySeason=function(c){var d=b.getNew("getTeamsBySeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getLeagueTableBySeason=function(c){var d=b.getNew("getLeagueTableBySeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixturesBySeason=function(c){var d=b.getNew("getFixturesBySeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c}]).service("footballdataSearchDataService",function(){this.getApiBaseUrl=function(a){switch(a){case"http":case"https":a+=":";break;default:a=""}return a+"//api.football-data.org/v1/"},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(a){case"getSeasons":c=this.fillDataInObjectByList(c,b,["protocol","apiKey","season"]),c.url=this.getApiBaseUrl(c.object.protocol)+"soccerseasons/";break;case"getSeason":c=this.fillDataInObjectByList(c,b,["protocol","apiKey"]),c.url=this.getApiBaseUrl(c.object.protocol)+"soccerseasons/"+b.id;break;case"getTeam":c=this.fillDataInObjectByList(c,b,["protocol","apiKey"]),c.url=this.getApiBaseUrl(c.object.protocol)+"teams/"+b.id;break;case"getPlayersByTeam":c=this.fillDataInObjectByList(c,b,["protocol","apiKey"]),c.url=this.getApiBaseUrl(c.object.protocol)+"teams/"+b.id+"/players";break;case"getFixtures":c=this.fillDataInObjectByList(c,b,["protocol","apiKey","league","timeFrame"]),c.url=this.getApiBaseUrl(c.object.protocol)+"fixtures";break;case"getFixture":c=this.fillDataInObjectByList(c,b,["protocol","apiKey","head2head"]),c.url=this.getApiBaseUrl(c.object.protocol)+"fixtures/"+b.id;break;case"getTeamsBySeason":c=this.fillDataInObjectByList(c,b,["protocol","apiKey"]),c.url=this.getApiBaseUrl(c.object.protocol)+"soccerseasons/"+b.id+"/teams";break;case"getLeagueTableBySeason":c=this.fillDataInObjectByList(c,b,["protocol","apiKey","matchday"]),c.url=this.getApiBaseUrl(c.object.protocol)+"soccerseasons/"+b.id+"/leagueTable";break;case"getFixturesBySeason":c=this.fillDataInObjectByList(c,b,["protocol","apiKey","matchday","timeFrame"]),c.url=this.getApiBaseUrl(c.object.protocol)+"soccerseasons/"+b.id+"/fixtures";break;case"getFixturesByTeam":c=this.fillDataInObjectByList(c,b,["protocol","apiKey","season","timeFrame","venue"]),c.url=this.getApiBaseUrl(c.object.protocol)+"teams/"+b.id+"/fixtures"}return c}}); \ No newline at end of file +"use strict";angular.module("jtt_footballdata",[]).factory("footballdataFactory",["$http","footballdataSearchDataService",function(a,b){var c={};return c.getSeasons=function(c){var d=b.getNew("getSeasons",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey}})},c.getSeason=function(c){var d=b.getNew("getSeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey}})},c.getTeam=function(c){var d=b.getNew("getTeam",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getPlayersByTeam=function(c){var d=b.getNew("getPlayersByTeam",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixtures=function(c){var d=b.getNew("getFixtures",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixture=function(c){var d=b.getNew("getFixture",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixturesByTeam=function(c){var d=b.getNew("getFixturesByTeam",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getTeamsBySeason=function(c){var d=b.getNew("getTeamsBySeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getLeagueTableBySeason=function(c){var d=b.getNew("getLeagueTableBySeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c.getFixturesBySeason=function(c){var d=b.getNew("getFixturesBySeason",c);return a({method:"GET",url:d.url,params:d.object,headers:{"X-Auth-Token":c.apiKey?c.apiKey:apiKey}})},c}]).service("footballdataSearchDataService",function(){this.getApiBaseUrl=function(a){switch(a){case"http":case"https":a+=":";break;default:a=""}return a+"//api.football-data.org/v1/"},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(a){case"getSeasons":c=this.fillDataInObjectByList(c,b,["apiKey","season"]),c.url=this.getApiBaseUrl(b.protocol)+"soccerseasons/";break;case"getSeason":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl(b.protocol)+"soccerseasons/"+b.id;break;case"getTeam":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl(b.protocol)+"teams/"+b.id;break;case"getPlayersByTeam":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl(b.protocol)+"teams/"+b.id+"/players";break;case"getFixtures":c=this.fillDataInObjectByList(c,b,["apiKey","league","timeFrame"]),c.url=this.getApiBaseUrl(b.protocol)+"fixtures";break;case"getFixture":c=this.fillDataInObjectByList(c,b,["apiKey","head2head"]),c.url=this.getApiBaseUrl(b.protocol)+"fixtures/"+b.id;break;case"getTeamsBySeason":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl(b.protocol)+"soccerseasons/"+b.id+"/teams";break;case"getLeagueTableBySeason":c=this.fillDataInObjectByList(c,b,["apiKey","matchday"]),c.url=this.getApiBaseUrl(b.protocol)+"soccerseasons/"+b.id+"/leagueTable";break;case"getFixturesBySeason":c=this.fillDataInObjectByList(c,b,["apiKey","matchday","timeFrame"]),c.url=this.getApiBaseUrl(b.protocol)+"soccerseasons/"+b.id+"/fixtures";break;case"getFixturesByTeam":c=this.fillDataInObjectByList(c,b,["apiKey","season","timeFrame","venue"]),c.url=this.getApiBaseUrl(b.protocol)+"teams/"+b.id+"/fixtures"}return c}}); \ No newline at end of file diff --git a/package.json b/package.json index 398f6d7..499a41a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-footballdata-api-factory", - "version": "0.2.2", + "version": "0.2.4", "description": "angularjs factory for footballdata jsonp rest api requests", "main": "dist/angular-footballdata-api-factory.min.js", "scripts": { diff --git a/src/angular-footballdata-api-factory.js b/src/angular-footballdata-api-factory.js index 6e130c8..be066ba 100644 --- a/src/angular-footballdata-api-factory.js +++ b/src/angular-footballdata-api-factory.js @@ -184,72 +184,72 @@ angular.module("jtt_footballdata", []) switch (_type) { case "getSeasons": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'season', + 'apiKey', 'season', ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/'; break; case "getSeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', + 'apiKey', ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id; break; case "getTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey' + 'apiKey' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'teams/' + _params.id; break; case "getPlayersByTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey' + 'apiKey' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id + '/players'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'teams/' + _params.id + '/players'; break; case "getFixtures": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'league', 'timeFrame' + 'apiKey', 'league', 'timeFrame' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'fixtures'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'fixtures'; break; case "getFixture": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'head2head' + 'apiKey', 'head2head' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'fixtures/' + _params.id; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'fixtures/' + _params.id; break; case "getTeamsBySeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', + 'apiKey', ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/teams'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id + '/teams'; break; case "getLeagueTableBySeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'matchday' + 'apiKey', 'matchday' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/leagueTable'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id + '/leagueTable'; break; case "getFixturesBySeason": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'matchday', 'timeFrame' + 'apiKey', 'matchday', 'timeFrame' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/fixtures'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'soccerseasons/' + _params.id + '/fixtures'; break; case "getFixturesByTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ - 'protocol', 'apiKey', 'season', 'timeFrame', 'venue' + 'apiKey', 'season', 'timeFrame', 'venue' ]); - footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id + '/fixtures'; + footballdataSearchData.url = this.getApiBaseUrl(_params.protocol) + 'teams/' + _params.id + '/fixtures'; break; }