Skip to content

Commit

Permalink
Merge pull request #231 from mkreiser/current-periods
Browse files Browse the repository at this point in the history
Update League object with current matchup and scoring period IDs
  • Loading branch information
mkreiser authored Oct 22, 2023
2 parents f8d037b + a4e37ca commit 4a0dbea
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44858,6 +44858,8 @@ exports[`2018 season client integration tests getFreeAgents returns a populated

exports[`2018 season client integration tests getLeagueInfo returns a populated League instance 1`] = `
League {
"currentMatchupPeriodId": 15,
"currentScoringPeriodId": 18,
"draftSettings": {
"canTradeDraftPicks": false,
"date": 2018-08-28T17:15:00.000Z,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49605,6 +49605,8 @@ exports[`2022 season client integration tests getFreeAgents returns a populated

exports[`2022 season client integration tests getLeagueInfo returns a populated League instance 1`] = `
League {
"currentMatchupPeriodId": 17,
"currentScoringPeriodId": 19,
"draftSettings": {
"canTradeDraftPicks": true,
"date": 2022-08-27T01:00:00.000Z,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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": "espn-fantasy-football-api",
"version": "1.2.0",
"version": "1.3.0",
"description": "A Javascript API to connect to ESPN's fantasy football API",
"main": "web.js",
"files": [
Expand Down
9 changes: 8 additions & 1 deletion src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,14 @@ class Client {
});

return axios.get(route, this._buildAxiosConfig()).then((response) => {
const data = _.get(response.data, 'settings');
const settingsData = _.get(response.data, 'settings');
const statusData = _.get(response.data, 'status');
const data = {
currentMatchupPeriodId: statusData.currentMatchupPeriod,
currentScoringPeriodId: statusData.latestScoringPeriod,
...settingsData
};

return League.buildFromServer(data, { leagueId: this.leagueId, seasonId });
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/client/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,10 @@ describe('Client', () => {
draftSettings: {},
rosterSettings: {},
scheduleSettings: {}
},
status: {
currentMatchupPeriod: 7,
latestScoringPeriod: 7
}
}
};
Expand Down
7 changes: 7 additions & 0 deletions src/league/league.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class League extends BaseObject {
* @property {DRAFT_TYPE} type The type of draft.
* @property {number} timePerPick The amount of time to make a selection.
* @property {boolean} canTradeDraftPicks Whether or not draft picks can be traded.
* @property {number} currentMatchupPeriodId The current matchup period id (see README.md for
* matchupPeriod v. scoringPeriod)
* @property {number} currentScoringPeriodId The current scoring period id (see README.md for
* matchupPeriod v. scoringPeriod)
*/

/**
Expand Down Expand Up @@ -65,6 +69,9 @@ class League extends BaseObject {
size: 'size',
isPublic: 'isPublic',

currentMatchupPeriodId: 'currentMatchupPeriodId',
currentScoringPeriodId: 'currentScoringPeriodId',

draftSettings: {
key: 'draftSettings',
manualParse: (responseData) => ({
Expand Down

0 comments on commit 4a0dbea

Please sign in to comment.