Skip to content

Commit

Permalink
new version (v0.2.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Dec 23, 2016
1 parent 3b1ccf9 commit 87bbf58
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 55 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
//Show one Season
footballdataFactory.getSeason({
id: '<SEASON_ID>',
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand All @@ -50,6 +51,7 @@ footballdataFactory.getSeason({
//List all available soccer seasons
footballdataFactory.getSeasons({
season: '<SEASON>', // (optional) Default is the current year (4 digit), e.g: '2015'
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand All @@ -64,6 +66,7 @@ footballdataFactory.getSeasons({
//Show one team.
footballdataFactory.getTeam({
id: '<TEAM_ID>',
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand All @@ -78,6 +81,7 @@ footballdataFactory.getTeam({
//List all teams for a certain soccerseason
footballdataFactory.getTeamsBySeason({
id: '<SEASON_ID>',
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand All @@ -92,6 +96,7 @@ footballdataFactory.getTeamsBySeason({
//Show all players for a certain team.
footballdataFactory.getPlayersByTeam({
id: '<TEAM_ID>',
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand All @@ -107,6 +112,7 @@ footballdataFactory.getPlayersByTeam({
footballdataFactory.getLeagueTableBySeason({
id: '<SEASON_ID>',
matchday: '<MATCHDAY>', // (optional) The current/last matchday is taken per default
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand Down Expand Up @@ -137,6 +143,7 @@ footballdataFactory.getFixture({
footballdataFactory.getFixtures({
timeFrame: '<TIMEFRAME>', // (optional) The value of the timeFrame argument must start with either 'p' for past or 'n' for next. It is followed by a number in the range 1-99.
league: '<LEAGUE_CODE>', // (optional) A (list of, comma separated) league-code(s). Default is unset. Get all league codes at http://api.football-data.org/docs/latest/index.html
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand All @@ -151,6 +158,7 @@ footballdataFactory.getFixturesBySeason({
id: '<SEASON_ID>',
timeFrame: '<TIMEFRAME>', // (optional) The value of the timeFrame argument must start with either 'p' for past or 'n' for next. It is followed by a number in the range 1-99.
matchday: '<MATCHDAY>', // (optional) The current/last matchday is taken per default
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand All @@ -166,6 +174,7 @@ footballdataFactory.getFixturesByTeam({
season: '<SEASON>', // (optional) Defaults to the current year, given as 4 digit like '2015'
timeFrame: '<TIMEFRAME>', // (optional) The value of the timeFrame argument must start with either 'p' for past or 'n' for next. It is followed by a number in the range 1-99.
venue: '<VENUE>', // (optional) Valid values: `home` and `away`. Default is unset.
protocol: '<PROTOCOL>', // (optional) 'http', 'https', 'auto'
apiKey: '<YOUR_API_KEY>', // Register for a free api key: http://api.football-data.org/register
}).then(function (_data) {
//on success
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Jonathan Hornung <[email protected]>"
],
"version": "0.2.1",
"version": "0.2.2",
"description": "angular factory for the football-data.org rest api",
"main": "dist/angular-footballdata-api-factory.min.js",
"moduleType": [],
Expand Down
12 changes: 6 additions & 6 deletions demo/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ app.controller('controller', ['$scope', 'footballdataFactory', function($scope,
var apiKey = 'e42cb6a6ecc949c8897e06d284a55e05';

footballdataFactory.getSeasons({
season: '2014',
season: '2015',
apiKey: apiKey,
}).then(function(_data){
console.info("getSeasons", _data);
});

footballdataFactory.getSeason({
id: '424',
id: '426',
apiKey: apiKey,
}).then(function(_data){
console.info("getSeason", _data);
Expand All @@ -24,7 +24,7 @@ app.controller('controller', ['$scope', 'footballdataFactory', function($scope,
});

footballdataFactory.getFixture({
id: 149461,
id: 155048,
apiKey: apiKey,
}).then(function(_data){
console.info("getFixture", _data);
Expand Down Expand Up @@ -52,22 +52,22 @@ app.controller('controller', ['$scope', 'footballdataFactory', function($scope,
});

footballdataFactory.getTeamsBySeason({
id: 351,
id: 424,
apiKey: apiKey,
}).then(function(_data){
console.info("getTeamsBySeason", _data);
});

footballdataFactory.getLeagueTableBySeason({
id: 351,
id: 426,
matchday: 10,
apiKey: apiKey,
}).then(function(_data){
console.info("getLeagueTableBySeason", _data);
});

footballdataFactory.getFixturesBySeason({
id: 351,
id: 426,
matchday: 10,
apiKey: apiKey,
}).then(function(_data){
Expand Down
57 changes: 34 additions & 23 deletions dist/angular-footballdata-api-factory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
@name: angular-footballdata-api-factory
@version: 0.2.1 (20-12-2016)
@version: 0.2.2 (23-12-2016)
@author: Jonathan Hornung
@url: https://github.com/JohnnyTheTank/angular-footballdata-api-factory#readme
@license: MIT
Expand Down Expand Up @@ -155,8 +155,19 @@ angular.module("jtt_footballdata", [])
return footballdataFactory;
}])
.service('footballdataSearchDataService', function () {
this.getApiBaseUrl = function () {
return 'https://api.football-data.org/v1/';
this.getApiBaseUrl = function (protocol) {

switch (protocol) {
case 'http':
case 'https':
protocol += ':';
break;

default:
protocol = '';
}

return protocol + '//api.football-data.org/v1/';
};

this.fillDataInObjectByList = function (_object, _params, _list) {
Expand All @@ -180,72 +191,72 @@ angular.module("jtt_footballdata", [])
switch (_type) {
case "getSeasons":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey', 'season',
'protocol', 'apiKey', 'season',
]);
footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/';
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/';
break;

case "getSeason":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey',
'protocol', 'apiKey',
]);
footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/' + _params.id;
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id;
break;

case "getTeam":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey'
'protocol', 'apiKey'
]);
footballdataSearchData.url = this.getApiBaseUrl() + 'teams/' + _params.id;
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id;
break;

case "getPlayersByTeam":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey'
'protocol', 'apiKey'
]);
footballdataSearchData.url = this.getApiBaseUrl() + 'teams/' + _params.id + '/players';
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id + '/players';
break;

case "getFixtures":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey', 'league', 'timeFrame'
'protocol', 'apiKey', 'league', 'timeFrame'
]);
footballdataSearchData.url = this.getApiBaseUrl() + '/fixtures';
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'fixtures';
break;

case "getFixture":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey', 'head2head'
'protocol', 'apiKey', 'head2head'
]);
footballdataSearchData.url = this.getApiBaseUrl() + '/fixtures/' + _params.id;
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'fixtures/' + _params.id;
break;

case "getTeamsBySeason":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [

'protocol', 'apiKey',
]);
footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/' + _params.id + '/teams';
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/teams';
break;

case "getLeagueTableBySeason":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey', 'matchday'
'protocol', 'apiKey', 'matchday'
]);
footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/' + _params.id + '/leagueTable';
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/leagueTable';
break;

case "getFixturesBySeason":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey', 'matchday', 'timeFrame'
'protocol', 'apiKey', 'matchday', 'timeFrame'
]);
footballdataSearchData.url = this.getApiBaseUrl() + 'soccerseasons/' + _params.id + '/fixtures';
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'soccerseasons/' + _params.id + '/fixtures';
break;

case "getFixturesByTeam":
footballdataSearchData = this.fillDataInObjectByList(footballdataSearchData, _params, [
'apiKey', 'season', 'timeFrame', 'venue'
'protocol', 'apiKey', 'season', 'timeFrame', 'venue'
]);
footballdataSearchData.url = this.getApiBaseUrl() + '/teams/' + _params.id + '/fixtures';
footballdataSearchData.url = this.getApiBaseUrl(footballdataSearchData.object.protocol) + 'teams/' + _params.id + '/fixtures';
break;

}
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-footballdata-api-factory.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-footballdata-api-factory",
"version": "0.2.1",
"version": "0.2.2",
"description": "angularjs factory for footballdata jsonp rest api requests",
"main": "dist/angular-footballdata-api-factory.min.js",
"scripts": {
Expand Down
Loading

0 comments on commit 87bbf58

Please sign in to comment.