diff --git a/plugins/FantasyPremierLeague/v1/configValidation.json b/plugins/FantasyPremierLeague/v1/configValidation.json new file mode 100644 index 0000000..b84ab41 --- /dev/null +++ b/plugins/FantasyPremierLeague/v1/configValidation.json @@ -0,0 +1,11 @@ +{ + "steps": [ + { + "displayName": "FPL Manager ID", + "dataStream": { "name": "managerInformation" }, + "success": "Successfully connected to FPL", + "error": "Can't find this FPL Manager ID — check the URL on the FPL website", + "required": true + } + ] +} diff --git a/plugins/FantasyPremierLeague/v1/cspell.json b/plugins/FantasyPremierLeague/v1/cspell.json index 831ea67..ff77acf 100644 --- a/plugins/FantasyPremierLeague/v1/cspell.json +++ b/plugins/FantasyPremierLeague/v1/cspell.json @@ -1,6 +1,8 @@ { "words": [ "FPL", - "Gameweek" + "Gameweek", + "bboost", + "freehit" ] } diff --git a/plugins/FantasyPremierLeague/v1/custom_types.json b/plugins/FantasyPremierLeague/v1/custom_types.json new file mode 100644 index 0000000..ec6bbfb --- /dev/null +++ b/plugins/FantasyPremierLeague/v1/custom_types.json @@ -0,0 +1,23 @@ +[ + { + "name": "FPL Gameweek", + "sourceType": "fpl-gameweek", + "icon": "calendar", + "singular": "Gameweek", + "plural": "Gameweeks" + }, + { + "name": "FPL Classic League", + "sourceType": "fpl-classic-league", + "icon": "trophy", + "singular": "Classic League", + "plural": "Classic Leagues" + }, + { + "name": "FPL H2H League", + "sourceType": "fpl-h2h-league", + "icon": "swords", + "singular": "H2H League", + "plural": "H2H Leagues" + } +] diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/classicLeagues.json b/plugins/FantasyPremierLeague/v1/dataStreams/classicLeagues.json new file mode 100644 index 0000000..9f02ad8 --- /dev/null +++ b/plugins/FantasyPremierLeague/v1/dataStreams/classicLeagues.json @@ -0,0 +1,64 @@ +{ + "name": "classicLeagues", + "displayName": "Classic Leagues", + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "expandInnerObjects": false, + "endpointPath": "entry/{{userID}}", + "pathToData": "leagues.classic", + "getArgs": [], + "headers": [] + }, + "manualConfigApply": true, + "rowPath": [], + "metadata": [ + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "id", + "displayName": "League ID", + "role": "value" + }, + { + "name": "name", + "displayName": "League Name", + "role": "label" + }, + { + "name": "short_name", + "displayName": "Short Name" + }, + { + "name": "league_type", + "displayName": "League Type" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "entry_rank", + "displayName": "Current Rank" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "entry_last_rank", + "displayName": "Last Rank" + } + ], + "timeframes": false, + "matches": "none", + "tags": ["Leagues"] +} diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/gameweekData.json b/plugins/FantasyPremierLeague/v1/dataStreams/gameweekData.json index 9955ff1..3af8eb5 100644 --- a/plugins/FantasyPremierLeague/v1/dataStreams/gameweekData.json +++ b/plugins/FantasyPremierLeague/v1/dataStreams/gameweekData.json @@ -5,7 +5,7 @@ "httpMethod": "get", "expandInnerObjects": true, "endpointPath": "bootstrap-static", - "pathToData": "events", + "postRequestScript": "gameweekData.js", "getArgs": [], "headers": [] }, @@ -53,44 +53,44 @@ "name": "average_entry_score" }, { - "displayName": "BB chip played", + "displayName": "BB Chip Played", "shape": [ "number", { "decimalPlaces": 0 } ], - "name": "chip_plays.0.num_played" + "name": "chip_plays.bboost" }, { - "displayName": "TC chip played", + "displayName": "TC Chip Played", "shape": [ "number", { - "decimalPlaces": 2 + "decimalPlaces": 0 } ], - "name": "chip_plays.1.num_played" + "name": "chip_plays.3xc" }, { - "displayName": "Free Hit played", + "displayName": "Wildcard Chip Played", "shape": [ "number", { "decimalPlaces": 0 } ], - "name": "chip_plays.3.num_played" + "name": "chip_plays.wildcard" }, { - "displayName": "Wildcard chip played", + "displayName": "Free Hit Chip Played", "shape": [ "number", { "decimalPlaces": 0 } ], - "name": "chip_plays.2.num_played" + "name": "chip_plays.freehit" }, { "shape": [ @@ -119,10 +119,6 @@ ], "name": "most_vice_captained" }, - { - "displayName": "TC chip played", - "name": "chip_plays.3.chip_name" - }, { "shape": [ "number", @@ -135,5 +131,6 @@ ], "displayName": "Gameweek Data", "baseDataSourceName": "httpRequestUnscoped", - "matches": "none" + "matches": "none", + "tags": ["Game info"] } \ No newline at end of file diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/h2hLeagueSummary.json b/plugins/FantasyPremierLeague/v1/dataStreams/h2hLeagueSummary.json new file mode 100644 index 0000000..6d07bde --- /dev/null +++ b/plugins/FantasyPremierLeague/v1/dataStreams/h2hLeagueSummary.json @@ -0,0 +1,134 @@ +{ + "timeframes": false, + "name": "h2hLeagueSummary", + "config": { + "httpMethod": "get", + "expandInnerObjects": true, + "endpointPath": "leagues-h2h/{{leagueID}}/standings/", + "pathToData": "standings.results", + "getArgs": [], + "headers": [] + }, + "baseDataSourceName": "httpRequestUnscoped", + "manualConfigApply": true, + "rowPath": [], + "metadata": [ + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "points_for", + "displayName": "Points For" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "rank", + "expand": [ + { + "compareTo": "last_rank", + "shape": "number", + "comparisonName": "compare1", + "comparisonType": "absolute", + "displayName": "Rank Change" + } + ] + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "last_rank" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "matches_won", + "displayName": "Won" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "matches_drawn", + "displayName": "Drawn" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "matches_lost", + "displayName": "Lost" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "total", + "displayName": "Total Points" + }, + { + "displayName": "Team Name", + "name": "entry_name" + }, + { + "displayName": "Player Name", + "name": "player_name" + } + ], + "defaultShaping": { + "sort": { + "by": [ + [ + "rank", + "asc" + ] + ] + } + }, + "displayName": "H2H League Summary", + "matches": "none", + "tags": ["Leagues"], + "ui": [ + { + "name": "leagueID", + "label": "H2H League", + "placeholder": "Select an H2H league", + "type": "autocomplete", + "allowCustomValues": false, + "isMulti": false, + "validation": { + "required": true, + "message": "You must select an H2H league" + }, + "data": { + "source": "dataStream", + "dataStreamName": "h2hLeagues", + "dataSourceConfig": {} + } + } + ] +} diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/h2hLeagues.json b/plugins/FantasyPremierLeague/v1/dataStreams/h2hLeagues.json new file mode 100644 index 0000000..4992e69 --- /dev/null +++ b/plugins/FantasyPremierLeague/v1/dataStreams/h2hLeagues.json @@ -0,0 +1,60 @@ +{ + "name": "h2hLeagues", + "displayName": "H2H Leagues", + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "expandInnerObjects": false, + "endpointPath": "entry/{{userID}}", + "pathToData": "leagues.h2h", + "getArgs": [], + "headers": [] + }, + "manualConfigApply": true, + "rowPath": [], + "metadata": [ + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "id", + "displayName": "League ID", + "role": "value" + }, + { + "name": "name", + "displayName": "League Name", + "role": "label" + }, + { + "name": "short_name", + "displayName": "Short Name" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "entry_rank", + "displayName": "Current Rank" + }, + { + "shape": [ + "number", + { + "decimalPlaces": 0 + } + ], + "name": "entry_last_rank", + "displayName": "Last Rank" + } + ], + "timeframes": false, + "matches": "none", + "tags": ["Leagues"] +} diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/leagueSummary.json b/plugins/FantasyPremierLeague/v1/dataStreams/leagueSummary.json index 1329c0a..0a57f6b 100644 --- a/plugins/FantasyPremierLeague/v1/dataStreams/leagueSummary.json +++ b/plugins/FantasyPremierLeague/v1/dataStreams/leagueSummary.json @@ -81,15 +81,23 @@ }, "displayName": "League Summary", "matches": "none", + "tags": ["Leagues"], "ui": [ { "name": "leagueID", - "label": "League ID", - "placeholder": "123456", - "title": "League ID", - "type": "text", + "label": "Classic League", + "placeholder": "Select a classic league", + "type": "autocomplete", + "allowCustomValues": false, + "isMulti": false, "validation": { - "required": true + "required": true, + "message": "You must select a classic league" + }, + "data": { + "source": "dataStream", + "dataStreamName": "classicLeagues", + "dataSourceConfig": {} } } ] diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/managerHistory.json b/plugins/FantasyPremierLeague/v1/dataStreams/managerHistory.json index 5a34150..b3ccb67 100644 --- a/plugins/FantasyPremierLeague/v1/dataStreams/managerHistory.json +++ b/plugins/FantasyPremierLeague/v1/dataStreams/managerHistory.json @@ -47,16 +47,5 @@ "displayName": "Manager History", "baseDataSourceName": "httpRequestUnscoped", "matches": "none", - "ui": [ - { - "name": "userID", - "label": "Manager ID", - "placeholder": "123456", - "title": "Manager ID", - "type": "text", - "validation": { - "required": true - } - } - ] + "tags": ["Manager"] } \ No newline at end of file diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/managerInformation.json b/plugins/FantasyPremierLeague/v1/dataStreams/managerInformation.json index 79ff644..393bba9 100644 --- a/plugins/FantasyPremierLeague/v1/dataStreams/managerInformation.json +++ b/plugins/FantasyPremierLeague/v1/dataStreams/managerInformation.json @@ -105,7 +105,7 @@ "shape": [ "number", { - "decimalPlaces": 2 + "decimalPlaces": 0 } ], "name": "leagues.classic.0.id", @@ -123,16 +123,5 @@ "displayName": "Manager Information", "baseDataSourceName": "httpRequestUnscoped", "matches": "none", - "ui": [ - { - "name": "userID", - "label": "Manager ID", - "placeholder": "123456", - "title": "Manager ID", - "type": "text", - "validation": { - "required": true - } - } - ] + "tags": ["Manager"] } \ No newline at end of file diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/managerSummary.json b/plugins/FantasyPremierLeague/v1/dataStreams/managerSummary.json index cafdc5c..733e70d 100644 --- a/plugins/FantasyPremierLeague/v1/dataStreams/managerSummary.json +++ b/plugins/FantasyPremierLeague/v1/dataStreams/managerSummary.json @@ -100,15 +100,5 @@ "displayName": "Manager Summary", "baseDataSourceName": "httpRequestUnscoped", "matches": "none", - "ui": [ - { - "name": "userID", - "label": "Manager ID", - "placeholder": "123456", - "type": "text", - "validation": { - "required": true - } - } - ] + "tags": ["Manager"] } diff --git a/plugins/FantasyPremierLeague/v1/dataStreams/scripts/gameweekData.js b/plugins/FantasyPremierLeague/v1/dataStreams/scripts/gameweekData.js new file mode 100644 index 0000000..83bef53 --- /dev/null +++ b/plugins/FantasyPremierLeague/v1/dataStreams/scripts/gameweekData.js @@ -0,0 +1,7 @@ +result = data.events.map(function (event) { + var chipMap = {}; + (event.chip_plays || []).forEach(function (chip) { + chipMap[chip.chip_name] = chip.num_played; + }); + return Object.assign({}, event, { chip_plays: chipMap }); +}); diff --git a/plugins/FantasyPremierLeague/v1/indexDefinitions/default.json b/plugins/FantasyPremierLeague/v1/indexDefinitions/default.json new file mode 100644 index 0000000..ea02b0e --- /dev/null +++ b/plugins/FantasyPremierLeague/v1/indexDefinitions/default.json @@ -0,0 +1,59 @@ +{ + "steps": [ + { + "name": "Gameweeks", + "dataStream": { + "name": "gameweekData" + }, + "timeframe": "none", + "objectMapping": { + "id": "id", + "name": "name", + "type": { "value": "fpl-gameweek" }, + "properties": [ + "deadline_time", + "highest_score", + "average_entry_score", + "transfers_made" + ] + } + }, + { + "name": "Classic Leagues", + "dataStream": { + "name": "classicLeagues" + }, + "timeframe": "none", + "objectMapping": { + "id": "id", + "name": "name", + "type": { "value": "fpl-classic-league" }, + "properties": [ + { "leagueId": "id" }, + "short_name", + "league_type", + { "currentRank": "entry_rank" }, + { "lastRank": "entry_last_rank" } + ] + } + }, + { + "name": "H2H Leagues", + "dataStream": { + "name": "h2hLeagues" + }, + "timeframe": "none", + "objectMapping": { + "id": "id", + "name": "name", + "type": { "value": "fpl-h2h-league" }, + "properties": [ + { "leagueId": "id" }, + "short_name", + { "currentRank": "entry_rank" }, + { "lastRank": "entry_last_rank" } + ] + } + } + ] +} diff --git a/plugins/FantasyPremierLeague/v1/metadata.json b/plugins/FantasyPremierLeague/v1/metadata.json index 4f2031c..1d7c37c 100644 --- a/plugins/FantasyPremierLeague/v1/metadata.json +++ b/plugins/FantasyPremierLeague/v1/metadata.json @@ -1,7 +1,7 @@ { "name": "fantasy-premier-league", "displayName": "Fantasy Premier League", - "version": "1.0.2", + "version": "1.0.3", "author": { "name": "@TimWheeler-SQUP", "type": "community" @@ -10,7 +10,7 @@ "category": "Fun", "type": "cloud", "restrictedToPlatforms": [], - "importNotSupported": true, + "importNotSupported": false, "schemaVersion": "2.0", "base": { "plugin": "WebAPI", @@ -20,6 +20,7 @@ "baseUrl": "https://fantasy.premierleague.com/api" } }, + "keywords": ["FPL", "Fantasy", "Premier League", "Football"], "links": [ { "category": "source", diff --git a/plugins/FantasyPremierLeague/v1/ui.json b/plugins/FantasyPremierLeague/v1/ui.json index 0637a08..c754759 100644 --- a/plugins/FantasyPremierLeague/v1/ui.json +++ b/plugins/FantasyPremierLeague/v1/ui.json @@ -1 +1,12 @@ -[] \ No newline at end of file +[ + { + "type": "text", + "name": "userID", + "label": "FPL Manager ID", + "help": "Your FPL Manager ID — found in the URL when viewing your team on the FPL website (e.g. https://fantasy.premierleague.com/entry/**123456**/event/1)", + "validation": { + "required": true + }, + "placeholder": "Enter manager ID e.g. 1234567" + } +]