From 76d3da7c79016a01bfe75993360c611e968fd945 Mon Sep 17 00:00:00 2001 From: Jonathan Hornung Date: Fri, 24 Jun 2016 21:25:05 +0200 Subject: [PATCH] added new method and bump version --- bower.json | 2 +- demo/js/app.js | 7 ++++++ dist/angular-footballdata-api-factory.js | 23 +++++++++++++++++++- dist/angular-footballdata-api-factory.min.js | 4 ++-- package.json | 2 +- src/angular-footballdata-api-factory.js | 21 ++++++++++++++++++ 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 7970826..db8288a 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "authors": [ "Jonathan Hornung " ], - "version": "0.1.0", + "version": "0.2.0", "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 4c94365..158667a 100644 --- a/demo/js/app.js +++ b/demo/js/app.js @@ -10,6 +10,13 @@ app.controller('controller', ['$scope', 'footballdataFactory', function($scope, console.info("getSeasons", _data); }); + footballdataFactory.getSeason({ + id: '424', + apiKey: apiKey, + }).then(function(_data){ + console.info("getSeason", _data); + }); + footballdataFactory.getFixtures({ apiKey: apiKey, }).then(function(_data){ diff --git a/dist/angular-footballdata-api-factory.js b/dist/angular-footballdata-api-factory.js index 90ce189..18eb862 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.1.0 (21-06-2016) + @version: 0.2.0 (24-06-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-footballdata-api-factory#readme @license: MIT @@ -26,6 +26,20 @@ angular.module("jtt_footballdata", []) }); }; + footballdataFactory.getSeason = function (_params) { + + var searchData = footballdataSearchDataService.getNew("getSeason", _params); + + return $http({ + method: 'GET', + url: searchData.url, + params: searchData.object, + headers: { + 'X-Auth-Token': _params.apiKey, + } + }); + }; + footballdataFactory.getTeam = function (_params) { var searchData = footballdataSearchDataService.getNew("getTeam", _params); @@ -171,6 +185,13 @@ angular.module("jtt_footballdata", []) footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/'; break; + case "getSeason": + footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ + 'apiKey', + ]); + footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/' + _params.id; + break; + case "getTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ 'apiKey' diff --git a/dist/angular-footballdata-api-factory.min.js b/dist/angular-footballdata-api-factory.min.js index 78b4a0b..d765937 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.1.0 (21-06-2016) + @version: 0.2.0 (24-06-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.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(){return"http://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()+"soccerseasons/";break;case"getTeam":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl()+"teams/"+b.id;break;case"getPlayersByTeam":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl()+"teams/"+b.id+"/players";break;case"getFixtures":c=this.fillDataInObjectByList(c,b,["apiKey","league","timeFrame"]),c.url=this.getApiBaseUrl()+"/fixtures";break;case"getFixture":c=this.fillDataInObjectByList(c,b,["apiKey","head2head"]),c.url=this.getApiBaseUrl()+"/fixtures/"+b.id;break;case"getTeamsBySeason":c=this.fillDataInObjectByList(c,b,[]),c.url=this.getApiBaseUrl()+"soccerseasons/"+b.id+"/teams";break;case"getLeagueTableBySeason":c=this.fillDataInObjectByList(c,b,["apiKey","matchday"]),c.url=this.getApiBaseUrl()+"soccerseasons/"+b.id+"/leagueTable";break;case"getFixturesBySeason":c=this.fillDataInObjectByList(c,b,["apiKey","matchday","timeFrame"]),c.url=this.getApiBaseUrl()+"soccerseasons/"+b.id+"/fixtures";break;case"getFixturesByTeam":c=this.fillDataInObjectByList(c,b,["apiKey","season","timeFrame","venue"]),c.url=this.getApiBaseUrl()+"/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(){return"http://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()+"soccerseasons/";break;case"getSeason":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl()+"soccerseasons/"+b.id;break;case"getTeam":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl()+"teams/"+b.id;break;case"getPlayersByTeam":c=this.fillDataInObjectByList(c,b,["apiKey"]),c.url=this.getApiBaseUrl()+"teams/"+b.id+"/players";break;case"getFixtures":c=this.fillDataInObjectByList(c,b,["apiKey","league","timeFrame"]),c.url=this.getApiBaseUrl()+"/fixtures";break;case"getFixture":c=this.fillDataInObjectByList(c,b,["apiKey","head2head"]),c.url=this.getApiBaseUrl()+"/fixtures/"+b.id;break;case"getTeamsBySeason":c=this.fillDataInObjectByList(c,b,[]),c.url=this.getApiBaseUrl()+"soccerseasons/"+b.id+"/teams";break;case"getLeagueTableBySeason":c=this.fillDataInObjectByList(c,b,["apiKey","matchday"]),c.url=this.getApiBaseUrl()+"soccerseasons/"+b.id+"/leagueTable";break;case"getFixturesBySeason":c=this.fillDataInObjectByList(c,b,["apiKey","matchday","timeFrame"]),c.url=this.getApiBaseUrl()+"soccerseasons/"+b.id+"/fixtures";break;case"getFixturesByTeam":c=this.fillDataInObjectByList(c,b,["apiKey","season","timeFrame","venue"]),c.url=this.getApiBaseUrl()+"/teams/"+b.id+"/fixtures"}return c}}); \ No newline at end of file diff --git a/package.json b/package.json index 30fb489..609a367 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-footballdata-api-factory", - "version": "0.1.0", + "version": "0.2.0", "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 2047c70..459540e 100644 --- a/src/angular-footballdata-api-factory.js +++ b/src/angular-footballdata-api-factory.js @@ -19,6 +19,20 @@ angular.module("jtt_footballdata", []) }); }; + footballdataFactory.getSeason = function (_params) { + + var searchData = footballdataSearchDataService.getNew("getSeason", _params); + + return $http({ + method: 'GET', + url: searchData.url, + params: searchData.object, + headers: { + 'X-Auth-Token': _params.apiKey, + } + }); + }; + footballdataFactory.getTeam = function (_params) { var searchData = footballdataSearchDataService.getNew("getTeam", _params); @@ -164,6 +178,13 @@ angular.module("jtt_footballdata", []) footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/'; break; + case "getSeason": + footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ + 'apiKey', + ]); + footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/' + _params.id; + break; + case "getTeam": footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [ 'apiKey'